Files
hanzo.ai/playwright.config.ts

99 lines
4.2 KiB
TypeScript
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.
import { defineConfig, devices } from '@playwright/test';
/**
* A GATE'S READER HAS ANSWERED THE COOKIE QUESTION, all categories on, the way
* it has already seen every tour (e2e/session.ts). The banner is fixed over the
* page's foot and is a dialog, so an unanswered one takes the clicks and the
* dialog counts of every spec that is not about it. conversion.spec.ts, which is
* about it, starts from a browser that has answered nothing. A cookie, because
* @hanzo/event keeps the choice in one (`hz_consent`), and a cookie ignores the
* port each gate serves the export on.
*/
const ANSWERED = {
cookies: [
// A plain-http page keeps the choice under its bare names on the host.
...['127.0.0.1', 'localhost'].flatMap((domain) =>
[
['hz_consent', 'analytics,marketing,ads'],
['hz_consent_v', '2'],
].map(([name, value]) => ({ name, value, domain, path: '/', expires: -1, httpOnly: false, secure: false, sameSite: 'Lax' as const })),
),
// A secure one under __Host- names, which only the host itself may set, so
// each host a gate opens over https holds its own: hanzo.ai, and hanzo.chat
// and hanzo.app, whose roots are this export's /forward and /app.
...['hanzo.ai', 'hanzo.chat', 'hanzo.app'].flatMap((domain) =>
[
['__Host-hz_consent', 'analytics,marketing,ads'],
['__Host-hz_consent_v', '2'],
].map(([name, value]) => ({ name, value, domain, path: '/', expires: -1, httpOnly: false, secure: true, sameSite: 'Lax' as const })),
),
],
origins: [],
};
export default defineConfig({
testDir: './e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
// Five at a time on CI, an xl runner's 30 cores six to a browser, and the full
// run split over shards (gates.yml). The gates share no state, but browsers
// starve each other's hydration past the 5–15 s waits: pinned to 6 CPUs,
// catalog.spec and enso.spec failed at two workers and passed at one.
workers: process.env.CI ? 5 : undefined,
// On CI the log is the report: each test as it ends and every failure at the
// end (list), and the counts for the run's summary (json). A run cut by its
// time limit still leaves every finished test in the log, where `html` alone
// printed nothing until the end.
reporter: process.env.CI ? [['list'], ['json', { outputFile: 'playwright-report/gates.json' }]] : 'html',
timeout: 30000,
use: {
baseURL: process.env.BASE_URL || 'http://localhost:8084',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
},
// `gates` serves `out/` itself and `unit` reads source; both can fail a merge.
// `chromium` drives a dev server on :8084 or the live site and is run by hand.
projects: [
{
name: 'gates',
testDir: './e2e/gates',
// A GATE'S ENVELOPE, SAID ONCE.
//
// These drive a React app that has to boot, sign in and hydrate over a
// served export, and they wait for that in seconds: the channels gate
// alone declares a 20 s wait for the room and a 10 s poll for the send,
// which is the whole 30 s default before its first navigation. Tests
// written that way do not fail, they run out — and they do it only on a
// loaded runner, which is how four of them arrived as flakes that passed
// on retry and one arrived as a failure that did not. Raising the
// envelope changes no assertion; it stops the budget contradicting the
// waits the tests already state. A few ask for longer still and say so.
timeout: 90_000,
use: { ...devices['Desktop Chrome'], storageState: ANSWERED },
},
// The e2e/gates specs whose subject differs by engine, in WebKit, over the
// same `out/`. Run by hand: CI installs Chromium alone.
{
name: 'webkit',
testDir: './e2e/gates',
testMatch: ['picker.spec.ts', 'members.spec.ts', 'plans.spec.ts', 'fit.spec.ts', 'sales.spec.ts'],
timeout: 90_000,
use: { ...devices['Desktop Safari'], storageState: ANSWERED },
},
{
name: 'unit',
testDir: './e2e/unit',
},
{
name: 'chromium',
testDir: './e2e',
testIgnore: ['**/gates/**', '**/unit/**'],
use: { ...devices['Desktop Chrome'] },
},
],
});