Files
Magent/scripts/review_welcome.cjs
Assclaw 4034a8f72a
Magent CI/CD / verify (push) Successful in 10m26s
Magent CI/CD / deploy-prod (push) Skipped
Magent CI/CD / deploy-beta (push) Skipped
Add post-login welcome and friendly how-it-works guide
2026-09-07 16:08:37 +12:00

35 lines
2.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { chromium } = require(process.env.REVIEW_PLAYWRIGHT);
const assert = require('node:assert/strict');
(async () => {
const browser = await chromium.launch({ headless: true });
try {
const page = await browser.newPage();
let mode = 'ready';
await page.route('**/api/**', route => {
if (route.request().url().endsWith('/auth/me')) return route.fulfill({ json: { username: 'Tester', role: 'user' } });
if (route.request().url().endsWith('/site/info')) return route.fulfill({ status: mode === 'unauthorized' ? 401 : 200, json: { mediaServerUrl: mode === 'missing' ? null : 'https://watch.example.com/' } });
return route.fulfill({ json: {} });
});
for (const width of [1440, 390]) {
await page.setViewportSize({ width, height: 900 });
await page.goto('http://127.0.0.1:3103/welcome');
await page.getByRole('link', { name: /Go to GrizzlyFlix/ }).waitFor();
assert.equal(await page.getByRole('link', { name: /Go to GrizzlyFlix/ }).getAttribute('href'), 'https://watch.example.com/');
assert.equal(await page.getByRole('link', { name: /Manage your account/ }).getAttribute('href'), '/');
assert.equal(await page.locator('.header').count(), 0);
assert(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
await page.goto('http://127.0.0.1:3103/how-it-works');
await page.getByText('Understand the six progress steps').click();
await page.getByText('Your request has been received.').waitFor();
assert(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
}
mode = 'missing';
await page.goto('http://127.0.0.1:3103/welcome');
await page.getByText(/watch link hasnt been set up/).waitFor();
mode = 'unauthorized';
await page.goto('http://127.0.0.1:3103/welcome');
await page.waitForURL('**/login');
console.log('Welcome and guide checks passed: desktop, mobile, links, disclosure, missing URL, auth redirect.');
} finally { await browser.close(); }
})().catch(error => { console.error(error); process.exit(1); });