- Introduced `auth.setup.js` to handle authentication against the live site and store the session state. - Created `live-race.spec.js` to test loading a live race page with an authenticated session, including cookie validation. - Added utility functions in `live-site-test-utils.js` for managing authentication, dismissing cookie banners, and checking UI states. - Included a temporary JSON file for live state inspection. - Updated deployment manifest to reflect new and modified files. - Implemented `_inc_faceai_identity.jsp` for managing FaceAI identity cookies and included it in relevant JSP files. - Added language management JavaScript in `lang.js`. - Adjusted `fotoCR-en.jsp` and `fotoCR.jsp` to include the FaceAI identity logic. - Created a tarball for staging deployment.
47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
const { chromium } = require('playwright');
|
|
const fs = require('fs');
|
|
|
|
async function run() {
|
|
const browser = await chromium.launch();
|
|
const context = await browser.newContext();
|
|
const page = await context.newPage();
|
|
|
|
try {
|
|
const loginUrl = process.env.LIVE_SITE_LOGIN_URL;
|
|
const raceUrl = process.env.LIVE_SITE_RACE_URL;
|
|
|
|
console.log('--- Step 1: Navigating to Login ---');
|
|
await page.goto(loginUrl, { waitUntil: 'load' });
|
|
|
|
console.log('--- Step 2: Filling credentials ---');
|
|
await page.type('#login', process.env.LIVE_SITE_USERNAME);
|
|
await page.type('#pwd', process.env.LIVE_SITE_PASSWORD);
|
|
|
|
console.log('--- Step 3: Clicking Accedi ---');
|
|
await page.click('button:has-text("Accedi")');
|
|
await page.waitForTimeout(5000); // Give it time to process and redirect
|
|
|
|
console.log('--- Step 4: Navigating to Race Page ---');
|
|
const response = await page.goto(raceUrl, { waitUntil: 'load' });
|
|
|
|
console.log('Race Page URL:', page.url());
|
|
console.log('HTTP Status:', response.status());
|
|
|
|
const cookies = await context.cookies();
|
|
const cookieNames = cookies.map(c => c.name);
|
|
console.log('Cookies:', cookieNames.join(', '));
|
|
console.log('rus_faceai_identity:', cookieNames.includes('rus_faceai_identity'));
|
|
console.log('JSESSIONID:', cookieNames.includes('JSESSIONID'));
|
|
|
|
const logoutCount = await page.locator('a[href*="logout"]').count();
|
|
const loginCount = await page.locator('a[href*="login"]').count();
|
|
console.log('Logout Link Count:', logoutCount);
|
|
console.log('Login Link Count:', loginCount);
|
|
|
|
} catch (err) {
|
|
console.error('Error occurred:', err.message);
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
}
|
|
run();
|