feat: Add FaceAI handoff URL builder and enhance race storage metadata handling
All checks were successful
Publish FaceAI Container / publish (push) Successful in 9m53s
All checks were successful
Publish FaceAI Container / publish (push) Successful in 9m53s
This commit is contained in:
parent
bba8026b7c
commit
4f003bb5a9
5 changed files with 214 additions and 37 deletions
|
|
@ -50,6 +50,15 @@ async function enterViaHandoff(page, options = {}) {
|
|||
await waitForFaceAiHome(page);
|
||||
}
|
||||
|
||||
async function readLaunchUrlFromLegacyPage(page) {
|
||||
const launchUrl = await page.evaluate(() => {
|
||||
return typeof buildFaceAiLaunchUrl === 'function' ? buildFaceAiLaunchUrl() : '';
|
||||
});
|
||||
|
||||
expect(launchUrl, 'Expected the simulator race page to expose a FaceAI handoff URL builder.').toBeTruthy();
|
||||
return new URL(launchUrl, 'http://127.0.0.1:8080');
|
||||
}
|
||||
|
||||
async function startSearch(page, selfieName) {
|
||||
const createResponsePromise = page.waitForResponse((response) => {
|
||||
return response.url().includes('/api/searches')
|
||||
|
|
@ -170,6 +179,27 @@ test('runs the simulator flow through FaceAI and returns to the filtered legacy
|
|||
});
|
||||
});
|
||||
|
||||
test('builds the simulator FaceAI handoff URL with the exact local race storage metadata', async ({ page }) => {
|
||||
await page.goto(buildSimulatorUrl({
|
||||
raceId: '202',
|
||||
raceSlug: 'mezza-di-pisa',
|
||||
raceName: 'Mezza di Pisa',
|
||||
raceYear: '2026',
|
||||
raceMonthFolder: '04.APRILE',
|
||||
raceFolder: 'PISA'
|
||||
}), { waitUntil: 'domcontentloaded' });
|
||||
|
||||
await expect(page.locator('#faceAiRaceYear')).toHaveValue('2026');
|
||||
await expect(page.locator('#faceAiRaceMonthFolder')).toHaveValue('04.APRILE');
|
||||
await expect(page.locator('#faceAiRaceFolder')).toHaveValue('PISA');
|
||||
|
||||
const launchUrl = await readLaunchUrlFromLegacyPage(page);
|
||||
expect(launchUrl.searchParams.get('raceYear')).toBe('2026');
|
||||
expect(launchUrl.searchParams.get('raceMonthFolder')).toBe('04.APRILE');
|
||||
expect(launchUrl.searchParams.get('raceFolder')).toBe('PISA');
|
||||
expect(launchUrl.searchParams.get('raceStorageRelativeDir')).toBe('2026/04.APRILE/PISA');
|
||||
});
|
||||
|
||||
test('shows the unsupported-race message when the current race has no PKL data and lets the user go back', async ({ page }) => {
|
||||
await launchFromSimulator(page, {
|
||||
raceId: '404',
|
||||
|
|
|
|||
|
|
@ -9,6 +9,13 @@ const {
|
|||
requirePortraitFixture
|
||||
} = require('./live-site-test-utils');
|
||||
|
||||
const LIVE_EXPECTED_RACE_STORAGE = {
|
||||
year: '2026',
|
||||
monthFolder: '04.APRILE',
|
||||
raceFolder: 'HMF_2026',
|
||||
relativeDir: '2026/04.APRILE/HMF_2026'
|
||||
};
|
||||
|
||||
function escapeRegExp(value) {
|
||||
return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
||||
|
|
@ -32,10 +39,10 @@ async function openLiveFaceAi(page) {
|
|||
expect(launchUrl, 'Expected the legacy race page script to expose a FaceAI handoff URL builder.').toBeTruthy();
|
||||
|
||||
const parsedLaunchUrl = new URL(launchUrl, LIVE_SITE_BASE_URL);
|
||||
expect(parsedLaunchUrl.searchParams.get('raceYear')).toBeTruthy();
|
||||
expect(parsedLaunchUrl.searchParams.get('raceMonthFolder')).toBeTruthy();
|
||||
expect(parsedLaunchUrl.searchParams.get('raceFolder')).toBeTruthy();
|
||||
expect(parsedLaunchUrl.searchParams.get('raceStorageRelativeDir')).toBeTruthy();
|
||||
expect(parsedLaunchUrl.searchParams.get('raceYear')).toBe(LIVE_EXPECTED_RACE_STORAGE.year);
|
||||
expect(parsedLaunchUrl.searchParams.get('raceMonthFolder')).toBe(LIVE_EXPECTED_RACE_STORAGE.monthFolder);
|
||||
expect(parsedLaunchUrl.searchParams.get('raceFolder')).toBe(LIVE_EXPECTED_RACE_STORAGE.raceFolder);
|
||||
expect(parsedLaunchUrl.searchParams.get('raceStorageRelativeDir')).toBe(LIVE_EXPECTED_RACE_STORAGE.relativeDir);
|
||||
|
||||
await expect(page.locator('#faceaiLaunchButton')).toBeVisible();
|
||||
await page.locator('#faceaiLaunchButton').click();
|
||||
|
|
@ -125,6 +132,37 @@ async function waitForLegacyFaceAiCount(page, expectedCount) {
|
|||
}).toBe(String(expectedCount));
|
||||
}
|
||||
|
||||
function basenameOfPhotoKey(photoKey) {
|
||||
return String(photoKey).replace(/\\/g, '/').split('/').pop();
|
||||
}
|
||||
|
||||
async function lookupLivePhoto(page, photoKey) {
|
||||
return page.evaluate(async (value) => {
|
||||
const lookupData = getFaceAiPhotoLookupData(value);
|
||||
const params = new URLSearchParams(lookupData.request);
|
||||
const response = await fetch(`${getFaceAiLookupEndpoint()}?${params.toString()}`, {
|
||||
credentials: 'include'
|
||||
});
|
||||
const text = await response.text();
|
||||
let payload = null;
|
||||
|
||||
try {
|
||||
payload = JSON.parse(text);
|
||||
} catch (error) {
|
||||
payload = {
|
||||
parseError: String(error),
|
||||
raw: text
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
status: response.status,
|
||||
request: lookupData.request,
|
||||
payload
|
||||
};
|
||||
}, photoKey);
|
||||
}
|
||||
|
||||
async function expectLegacyFaceAiGalleryToRemainStable(page, expectedPhotoIds, holdMs = 4000) {
|
||||
await page.waitForTimeout(holdMs);
|
||||
|
||||
|
|
@ -159,6 +197,44 @@ test('renders the exact live FaceAI filtered sample URL with visible thumbnails'
|
|||
await expectLegacyFaceAiGalleryToRemainStable(page, samplePhotoIds);
|
||||
});
|
||||
|
||||
test('keeps the live Firenze FaceAI race storage metadata pinned to April 2026', async ({ page }) => {
|
||||
await ensureLiveAuthenticatedRacePage(page);
|
||||
|
||||
await expect(page.locator('#faceAiRaceYear')).toHaveValue(LIVE_EXPECTED_RACE_STORAGE.year);
|
||||
await expect(page.locator('#faceAiRaceMonthFolder')).toHaveValue(LIVE_EXPECTED_RACE_STORAGE.monthFolder);
|
||||
await expect(page.locator('#faceAiRaceFolder')).toHaveValue(LIVE_EXPECTED_RACE_STORAGE.raceFolder);
|
||||
await expect(page.locator('#faceAiRaceStorageRelativeDir')).toHaveValue(LIVE_EXPECTED_RACE_STORAGE.relativeDir);
|
||||
|
||||
const launchUrl = await page.evaluate(() => {
|
||||
return typeof buildFaceAiLaunchUrl === 'function' ? buildFaceAiLaunchUrl() : '';
|
||||
});
|
||||
const parsedLaunchUrl = new URL(launchUrl, LIVE_SITE_BASE_URL);
|
||||
|
||||
expect(parsedLaunchUrl.searchParams.get('raceYear')).toBe(LIVE_EXPECTED_RACE_STORAGE.year);
|
||||
expect(parsedLaunchUrl.searchParams.get('raceMonthFolder')).toBe(LIVE_EXPECTED_RACE_STORAGE.monthFolder);
|
||||
expect(parsedLaunchUrl.searchParams.get('raceFolder')).toBe(LIVE_EXPECTED_RACE_STORAGE.raceFolder);
|
||||
expect(parsedLaunchUrl.searchParams.get('raceStorageRelativeDir')).toBe(LIVE_EXPECTED_RACE_STORAGE.relativeDir);
|
||||
});
|
||||
|
||||
test('resolves the live Firenze sample photo lookups inside the current race', async ({ page }) => {
|
||||
const samplePhotoIds = [
|
||||
'00.PANORAMICA\\GIC_7918.JPG',
|
||||
'02.PARTENZA\\GIC_7918.JPG'
|
||||
];
|
||||
|
||||
await ensureLiveAuthenticatedRacePage(page);
|
||||
|
||||
for (const photoKey of samplePhotoIds) {
|
||||
const lookup = await lookupLivePhoto(page, photoKey);
|
||||
expect(lookup.status, `Expected faceai_photo_lookup.jsp to resolve ${photoKey} on the live Firenze race page.`).toBe(200);
|
||||
expect(String(lookup.request.raceId || '')).toBe('1018545');
|
||||
expect(lookup.payload && lookup.payload.found, `Expected ${photoKey} to resolve within the current live race.`).toBe(true);
|
||||
expect(String(lookup.payload.photoId || '')).toBe(photoKey);
|
||||
expect(basenameOfPhotoKey(String(lookup.payload.resolvedFile || ''))).toBe(basenameOfPhotoKey(photoKey));
|
||||
expect(String(lookup.payload.thumbSrc || '')).toContain(`+tn-${lookup.payload.legacyId}.jpg`);
|
||||
}
|
||||
});
|
||||
|
||||
test('loads a live race page with an authenticated session', async ({ page }) => {
|
||||
await ensureLiveAuthenticatedRacePage(page);
|
||||
|
||||
|
|
@ -174,7 +250,7 @@ test('loads a live race page with an authenticated session', async ({ page }) =>
|
|||
test('launches the live FaceAI app with race storage metadata and a styled header', async ({ page }) => {
|
||||
const { consoleErrors, launchUrl } = await openLiveFaceAi(page);
|
||||
|
||||
expect(launchUrl.searchParams.get('raceStorageRelativeDir')).toContain('/');
|
||||
expect(launchUrl.searchParams.get('raceStorageRelativeDir')).toBe(LIVE_EXPECTED_RACE_STORAGE.relativeDir);
|
||||
await expect(page.locator('nav.navbar')).toBeVisible();
|
||||
await expect(page.locator('link[data-legacy-href*="bootstrap.min.css"]')).toHaveCount(1);
|
||||
await expect(page.locator('link[data-legacy-href*="custom-style.css"]')).toHaveCount(1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue