Refactor FaceAI build process and update Docker configurations to include matcher binary
This commit is contained in:
parent
b13c306883
commit
d36b0f4e46
15 changed files with 177 additions and 30 deletions
|
|
@ -4,6 +4,7 @@ const {
|
|||
LIVE_SITE_BASE_URL,
|
||||
LIVE_SITE_PORTRAIT_PATH,
|
||||
LIVE_SITE_RACE_URL,
|
||||
LIVE_SITE_RESULT_URL_PATTERN,
|
||||
LIVE_SITE_RUN_UPLOAD_FLOW,
|
||||
ensureLiveAuthenticatedRacePage,
|
||||
requirePortraitFixture
|
||||
|
|
@ -51,6 +52,34 @@ async function openLiveFaceAi(page) {
|
|||
};
|
||||
}
|
||||
|
||||
async function waitForSearchCompletion(page, searchId) {
|
||||
return expect.poll(async () => {
|
||||
return page.evaluate(async (id) => {
|
||||
const response = await fetch(`/api/searches/${id}`, { credentials: 'include' });
|
||||
if (!response.ok) {
|
||||
return {
|
||||
status: 'poll-error',
|
||||
httpStatus: response.status
|
||||
};
|
||||
}
|
||||
|
||||
const payload = await response.json();
|
||||
return {
|
||||
status: payload.status,
|
||||
errorMessage: payload.errorMessage || null,
|
||||
completionCode: payload.completionCode || null,
|
||||
matchCount: payload.matchCount ?? null,
|
||||
resultId: payload.resultId || null
|
||||
};
|
||||
}, searchId);
|
||||
}, {
|
||||
timeout: 3 * 60 * 1000,
|
||||
message: `Expected FaceAI search ${searchId} to complete successfully.`
|
||||
}).toMatchObject({
|
||||
status: 'completed'
|
||||
});
|
||||
}
|
||||
|
||||
test('loads a live race page with an authenticated session', async ({ page }) => {
|
||||
await ensureLiveAuthenticatedRacePage(page);
|
||||
|
||||
|
|
@ -70,6 +99,7 @@ test('launches the live FaceAI app with race storage metadata and a styled heade
|
|||
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);
|
||||
await expect(page.locator('link[data-legacy-href*="font-awesome"]')).toHaveCount(0);
|
||||
|
||||
const legacyStylesheetHrefs = await page.locator('link[data-legacy-href]').evaluateAll((elements) => {
|
||||
return elements.map((element) => element.getAttribute('href') || '');
|
||||
|
|
@ -116,6 +146,32 @@ test('accepts the supplied portrait image for the live upload flow', async ({ pa
|
|||
expect(searchResponse.ok(), 'Expected the live upload flow to create a FaceAI search successfully.').toBe(true);
|
||||
|
||||
const searchPayload = await searchResponse.json();
|
||||
expect(searchPayload.id || searchPayload.searchId, 'Expected the search creation response to include a search identifier.').toBeTruthy();
|
||||
await expect(page.locator('.faceai-feedback')).not.toContainText(/Impossibile|Unable|Errore|Error/i);
|
||||
const searchId = searchPayload.id || searchPayload.searchId;
|
||||
expect(searchId, 'Expected the search creation response to include a search identifier.').toBeTruthy();
|
||||
|
||||
const completion = await page.evaluate(async (id) => {
|
||||
const response = await fetch(`/api/searches/${id}`, { credentials: 'include' });
|
||||
return response.json();
|
||||
}, searchId).catch(() => null);
|
||||
|
||||
if (completion?.status === 'failed') {
|
||||
throw new Error(`FaceAI search ${searchId} failed immediately: ${completion.errorMessage || 'unknown error'}`);
|
||||
}
|
||||
|
||||
await waitForSearchCompletion(page, searchId);
|
||||
|
||||
await page.waitForURL(new RegExp(`^${escapeRegExp(LIVE_SITE_RESULT_URL_PATTERN)}`), {
|
||||
timeout: 3 * 60 * 1000
|
||||
});
|
||||
|
||||
await expect.poll(async () => page.url(), {
|
||||
timeout: 15 * 1000,
|
||||
message: 'Expected the browser to land on the legacy result page after FaceAI completed.'
|
||||
}).toMatch(new RegExp(`^${escapeRegExp(LIVE_SITE_BASE_URL)}/`));
|
||||
|
||||
await expect(page.locator('body')).toContainText(/Vista filtrata da FaceAI|foto da FaceAI|ID foto:/i);
|
||||
await expect.poll(async () => page.locator('.gallery-card').count(), {
|
||||
timeout: 15 * 1000,
|
||||
message: 'Expected the legacy return page to render at least one FaceAI result card.'
|
||||
}).toBeGreaterThan(0);
|
||||
});
|
||||
|
|
@ -7,6 +7,7 @@ const LIVE_SITE_BASE_URL = process.env.LIVE_SITE_BASE_URL || 'https://www.regala
|
|||
const LIVE_SITE_LOGIN_URL = process.env.LIVE_SITE_LOGIN_URL || `${LIVE_SITE_BASE_URL}/login_clienti-it.html`;
|
||||
const LIVE_SITE_RACE_URL = process.env.LIVE_SITE_RACE_URL || `${LIVE_SITE_BASE_URL}/42%20HALF%20MARATHON%20FIRENZE_gara-1018545---96-1.html`;
|
||||
const LIVE_FACEAI_BASE_URL = process.env.LIVE_FACEAI_BASE_URL || 'https://ai.regalamiunsorriso.it';
|
||||
const LIVE_SITE_RESULT_URL_PATTERN = process.env.LIVE_SITE_RESULT_URL_PATTERN || `${LIVE_SITE_BASE_URL}/faceai_return.php`;
|
||||
const LIVE_SITE_USERNAME = process.env.LIVE_SITE_USERNAME || '';
|
||||
const LIVE_SITE_PASSWORD = process.env.LIVE_SITE_PASSWORD || '';
|
||||
const LIVE_SITE_PORTRAIT_PATH = process.env.LIVE_SITE_PORTRAIT_PATH || path.join(WORKSPACE_ROOT, 'test_pkl', 'live', 'test_portrait_1.png');
|
||||
|
|
@ -109,6 +110,7 @@ module.exports = {
|
|||
LIVE_SITE_PASSWORD,
|
||||
LIVE_SITE_PORTRAIT_PATH,
|
||||
LIVE_SITE_RACE_URL,
|
||||
LIVE_SITE_RESULT_URL_PATTERN,
|
||||
LIVE_SITE_RUN_UPLOAD_FLOW,
|
||||
LIVE_SITE_USERNAME,
|
||||
dismissCookieBanner,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue