46 lines
2.3 KiB
JavaScript
46 lines
2.3 KiB
JavaScript
import { chromium } from 'playwright';
|
|
import assert from 'node:assert/strict';
|
|
import { mkdir } from 'node:fs/promises';
|
|
|
|
await mkdir('artifacts', { recursive: true });
|
|
const browser = await chromium.launch({ headless: true });
|
|
const page = await browser.newPage({ viewport: { width: 390, height: 844 }, deviceScaleFactor: 2 });
|
|
const errors = [];
|
|
page.on('console', message => { if (message.type() === 'error') errors.push(message.text()); });
|
|
page.on('pageerror', error => errors.push(error.message));
|
|
await page.goto('http://127.0.0.1:4173', { waitUntil: 'networkidle' });
|
|
await page.evaluate(() => localStorage.clear());
|
|
await page.reload({ waitUntil: 'networkidle' });
|
|
|
|
assert.match(await page.locator('h1').innerText(), /Snap first/i);
|
|
assert.equal(await page.locator('[data-scan]').first().isVisible(), true);
|
|
assert.equal(await page.locator('[data-log]').first().isVisible(), true);
|
|
await page.screenshot({ path: 'artifacts/home-mobile.png', fullPage: false });
|
|
|
|
await page.locator('[data-log]').first().click();
|
|
await page.locator('[data-type="6"]').click();
|
|
await page.locator('#next').click();
|
|
await page.locator('#color').selectOption('brown');
|
|
await page.locator('#urgency').fill('3');
|
|
await page.locator('#note').fill('After lunch');
|
|
await page.locator('#next').click();
|
|
await page.locator('[data-symptom="blood"]').check();
|
|
assert.equal(await page.getByText('Pause and get medical help.').isVisible(), true);
|
|
await page.screenshot({ path: 'artifacts/red-flag-mobile.png', fullPage: true });
|
|
await page.locator('#save').click();
|
|
assert.equal(await page.getByText('1', { exact: true }).first().isVisible(), true);
|
|
await page.waitForTimeout(2600);
|
|
|
|
await page.locator('[data-view="timmy"]').last().click();
|
|
await page.locator('[data-prompt="food"]').click();
|
|
const chatText = await page.locator('#chat').innerText();
|
|
assert.match(chatText, /cannot clear a restaurant/i);
|
|
assert.doesNotMatch(chatText, /Taco Bell is safe/i);
|
|
await page.waitForTimeout(500);
|
|
assert.equal(await page.evaluate(() => window.scrollY), 0, 'reply should not push the page header/navigation out of frame');
|
|
await page.screenshot({ path: 'artifacts/timmy-chat-mobile.png', fullPage: false });
|
|
|
|
assert.deepEqual(errors, []);
|
|
await browser.close();
|
|
console.log('PASS mobile home → log → red-flag → save → Timmy boundary');
|