Some checks failed
App Prod-Parity E2E Dispatch / dispatch (push) Failing after 10s
CD Storybook UI / build (push) Failing after 3m25s
CD Storybook UI / dispatch (push) Has been skipped
CD deploy main / website-changed-files (push) Successful in 18m8s
CI Agent Skills / changed-files-check (push) Successful in 18m9s
CI Create App E2E minimal / changed-files-check (push) Successful in 24s
CI Create App / changed-files-check (push) Successful in 26s
CI Docs / changed-files-check (push) Successful in 26s
CI Emails / changed-files-check (push) Successful in 28s
CI Example App Hello World / changed-files-check (push) Successful in 23s
CI Front / changed-files-check (push) Has been skipped
CI Example App Postcard / changed-files-check (push) Successful in 27s
CI UI / changed-files-check (push) Has been skipped
CI Utils Test / changed-files-check (push) Successful in 45s
CI Twenty Apps / discover (push) Successful in 1m3s
CD deploy main / deploy-main (push) Failing after 3s
CI Agent Skills / agent-skills-validate (push) Has been skipped
CI Create App / create-app-test (lint) (push) Has been skipped
CI Emails / emails-test (push) Has been skipped
CI Front / front-task (lingui:compile) (push) Has been skipped
CI Front / front-task (lint) (push) Has been skipped
CI Example App Postcard / example-app-postcard (push) Has been skipped
CI UI / ui-task (lint) (push) Has been skipped
CI UI / ui-task (pack-size) (push) Has been skipped
CI UI / ui-task (size) (push) Has been skipped
CI UI / ui-task (test) (push) Has been skipped
CI UI / ui-task (typecheck) (push) Has been skipped
CI Utils Test / utils-test (push) Has been skipped
CI Twenty Apps / ${{ matrix.app.name }} (push) Has been skipped
CI Emails / ci-emails-status-check (push) Successful in 2s
CI Example App Hello World / ci-example-app-hello-world-status-check (push) Successful in 2s
CI Example App Postcard / ci-example-app-postcard-status-check (push) Successful in 3s
CI UI / ui-sb-test (push) Has been skipped
CI Utils Test / ci-utils-test-status-check (push) Successful in 2s
CI Twenty Apps / ci-twenty-apps-status-check (push) Successful in 2s
CI UI / ci-ui-status-check (push) Successful in 2s
CI Desktop / desktop (push) Failing after 1m8s
Push docs to Crowdin / Push documentation to Crowdin (push) Failing after 55s
Push translations to Crowdin / Extract and upload translations (push) Failing after 5s
Push website translations to Crowdin / Extract and upload website translations (push) Failing after 5s
CI Create App / create-app-test (test) (push) Has been skipped
CI Create App / create-app-test (typecheck) (push) Has been skipped
CI Docs / docs-lint (push) Has been skipped
CI Example App Hello World / example-app-hello-world (push) Has been skipped
CI Front / front-task (lingui:extract) (push) Has been skipped
CI Front / front-task (test) (push) Has been skipped
CI Front / front-task (typecheck) (push) Has been skipped
CI UI / ui-sb-build (push) Failing after 1m32s
CI Twenty Apps / ${{ matrix.app.name }} (${{ matrix.server-source }}) (push) Has been skipped
CI Agent Skills / agent-skills-publish (push) Has been skipped
CI Create App / ci-create-app-status-check (push) Successful in 2s
CI Agent Skills / agent-skills-remote-source (push) Has been skipped
CI Create App E2E minimal / create-app-e2e-minimal (push) Has been cancelled
CI E2E Main / e2e-test (push) Has been cancelled
CI Front / front-sb-build (push) Has been cancelled
CI Front / front-build (push) Has been cancelled
CI Create App E2E minimal / ci-create-app-e2e-minimal-status-check (push) Has been cancelled
CI E2E Main / ci-e2e-main-status-check (push) Has been cancelled
CI E2E Main / notify-main-ci-failure (push) Has been cancelled
CI E2E Main / qa-scout-comment (push) Has been cancelled
CI Front / front-sb-test (push) Has been cancelled
CI Front / front-sb-screenshots (push) Has been cancelled
CI Front / ci-front-status-check (push) Has been cancelled
DPA Sub-Processor Sync / sync-subprocessors (push) Failing after 3s
AI Catalog Sync / sync-catalog (push) Failing after 2s
105 lines
3.1 KiB
JavaScript
105 lines
3.1 KiB
JavaScript
import { readFileSync } from 'node:fs';
|
|
|
|
import {
|
|
createBattery,
|
|
launchBrowser,
|
|
NEW_BASE,
|
|
openPage,
|
|
} from './battery-kit.mjs';
|
|
|
|
// Decorative section backgrounds (gradients, halftones, notched cards,
|
|
// crosshairs) must never bleed past the content column — only the section's
|
|
// solid colour is full-bleed. The cap is read from the token itself, so this
|
|
// guard can never drift from it. Measured well past the cap so the centring is
|
|
// exercised: every [data-background-layer] must land <= the cap and centred.
|
|
const tokenSource = readFileSync(
|
|
new URL('../src/tokens/max-content-width.ts', import.meta.url),
|
|
'utf8',
|
|
);
|
|
const MAX_CONTENT_WIDTH_PX = Number(
|
|
/MAX_CONTENT_WIDTH_PX\s*=\s*(\d+)/.exec(tokenSource)?.[1],
|
|
);
|
|
const WIDE_VIEWPORT = { height: 1200, width: 2400 };
|
|
const PAGES = [
|
|
'/',
|
|
'/product',
|
|
'/pricing',
|
|
'/customers',
|
|
'/partners',
|
|
'/partners/become',
|
|
'/why-twenty',
|
|
'/releases',
|
|
];
|
|
|
|
const battery = createBattery('background-cap');
|
|
const browser = await launchBrowser();
|
|
|
|
for (const pagePath of PAGES) {
|
|
// eslint-disable-next-line no-await-in-loop
|
|
const page = await openPage(browser, `${NEW_BASE}${pagePath}`, {
|
|
settleMs: 1000,
|
|
viewport: WIDE_VIEWPORT,
|
|
});
|
|
|
|
// eslint-disable-next-line no-await-in-loop
|
|
const pageHeight = await page.evaluate(
|
|
() => document.documentElement.scrollHeight,
|
|
);
|
|
for (let y = 0; y <= pageHeight; y += 800) {
|
|
// eslint-disable-next-line no-await-in-loop
|
|
await page.evaluate((scrollY) => window.scrollTo(0, scrollY), y);
|
|
// eslint-disable-next-line no-await-in-loop
|
|
await page.waitForTimeout(150);
|
|
}
|
|
|
|
// eslint-disable-next-line no-await-in-loop
|
|
const layers = await page.evaluate(() =>
|
|
[...document.querySelectorAll('[data-background-layer]')]
|
|
.map((element) => element.getBoundingClientRect())
|
|
.filter((rect) => rect.width > 0)
|
|
.map((rect) => ({
|
|
leftMargin: Math.round(rect.left),
|
|
rightMargin: Math.round(window.innerWidth - rect.right),
|
|
width: Math.round(rect.width),
|
|
})),
|
|
);
|
|
// eslint-disable-next-line no-await-in-loop
|
|
await page.close();
|
|
|
|
if (layers.length === 0) {
|
|
battery.ok(`${pagePath} — no capped background layers rendered`, 'none');
|
|
continue;
|
|
}
|
|
|
|
const overflowing = layers.filter(
|
|
(layer) => layer.width > MAX_CONTENT_WIDTH_PX + 1,
|
|
);
|
|
const offCentre = layers.filter(
|
|
(layer) => Math.abs(layer.leftMargin - layer.rightMargin) > 2,
|
|
);
|
|
|
|
if (overflowing.length > 0) {
|
|
battery.fail(
|
|
`${pagePath} background layers exceed ${MAX_CONTENT_WIDTH_PX}px`,
|
|
JSON.stringify(overflowing),
|
|
);
|
|
}
|
|
if (offCentre.length > 0) {
|
|
battery.fail(
|
|
`${pagePath} background layers not centred`,
|
|
JSON.stringify(offCentre),
|
|
);
|
|
}
|
|
if (overflowing.length === 0 && offCentre.length === 0) {
|
|
const widths = [...new Set(layers.map((layer) => layer.width))].toSorted(
|
|
(first, second) => second - first,
|
|
);
|
|
battery.ok(
|
|
`${pagePath} — ${layers.length} background layers capped + centred`,
|
|
`widths ${widths.join(', ')}px <= ${MAX_CONTENT_WIDTH_PX}`,
|
|
);
|
|
}
|
|
}
|
|
|
|
await battery.finish(browser);
|