Files
pleno-vue/tests/unit/playwright-full-workflow.spec.js
T
2026-07-06 19:31:21 +02:00

86 lines
3.9 KiB
JavaScript

import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
const root = process.cwd();
const workflowSource = () => readFileSync(join(root, ".github/workflows/tests.yml"), "utf8");
const networkFixtureSource = () => readFileSync(join(root, "tests/e2e/support/network.js"), "utf8");
describe("Playwright full E2E workflow grouping", () => {
it("orders full-suite matrix dimensions by browser, device, then role", () => {
const source = workflowSource();
expect(source).toContain("name: E2E-full-${{ matrix.browser_label }}-${{ matrix.device }}-${{ matrix.role }}");
expect(source).toContain("browser: [chromium, webkit, firefox]");
expect(source).toContain("device: [mobile, desktop, tablet]");
expect(source).toContain("role: [superuser, admin, customer, subuser]");
});
it("uses browser-device-role artifact namespaces and generated test lists", () => {
const source = workflowSource();
expect(source).toContain(
"PLAYWRIGHT_ARTIFACT_NAMESPACE: e2e-full-${{ matrix.browser }}-${{ matrix.device }}-${{ matrix.role }}"
);
expect(source).toContain(
"name: playwright-report-full-${{ matrix.browser }}-${{ matrix.device }}-${{ matrix.role }}"
);
expect(source).toContain(
"output/playwright/test-lists/${{ matrix.browser }}-${{ matrix.device }}-${{ matrix.role }}.txt"
);
});
it("keeps full-suite runner pressure bounded and diagnosable", () => {
const source = workflowSource();
expect(source).toContain(
"max-parallel: ${{ github.event_name == 'workflow_dispatch' && inputs.runner_pool == 'github-hosted' && 6 || 2 }}"
);
expect(source).toContain(
'runs-on: ${{ fromJSON(github.event_name == \'workflow_dispatch\' && inputs.runner_pool == \'github-hosted\' && \'["ubuntu-latest"]\' || \'["self-hosted","Linux","X64","pleno","frontend","docker"]\') }}'
);
expect(source).toMatch(/e2e-full:[\s\S]*?PLAYWRIGHT_WORKERS: 1/u);
expect(source).toMatch(/e2e-full:[\s\S]*?PLAYWRIGHT_VIDEO_MODE: off/u);
expect(source).toContain("scripts/ci/with-systemd-inhibit.sh");
expect(source).toContain("scripts/ci/runner-diagnostics.sh");
});
it("keeps PR E2E runner pressure bounded and diagnosable", () => {
const source = workflowSource();
expect(source).toMatch(/e2e-pr:[\s\S]*?runs-on: ubuntu-latest/u);
expect(source).toMatch(/e2e-pr:[\s\S]*?max-parallel: 4/u);
expect(source).toMatch(/e2e-pr:[\s\S]*?PLAYWRIGHT_WORKERS: 1/u);
expect(source).toMatch(/e2e-pr:[\s\S]*?PLAYWRIGHT_VIDEO_MODE: on-first-retry/u);
expect(source).toMatch(/e2e-pr:[\s\S]*?--env PLAYWRIGHT_WORKERS="\$PLAYWRIGHT_WORKERS"/u);
expect(source).toMatch(/e2e-pr:[\s\S]*?--env PLAYWRIGHT_VIDEO_MODE="\$PLAYWRIGHT_VIDEO_MODE"/u);
});
it("uses a machine-wide Playwright port lock across self-hosted runner processes", () => {
const source = workflowSource();
expect(source.match(/PLAYWRIGHT_PORT_LOCK_ROOT:-\/tmp\/pleno-playwright-port-locks/gu)).toHaveLength(2);
expect(source.match(/chmod 1777 "\$lock_root"/gu)).toHaveLength(2);
expect(source).not.toContain("${RUNNER_TEMP:-/tmp}/pleno-playwright-port-locks");
});
it("allows CI to reduce Playwright video artifact pressure", () => {
const source = readFileSync(join(root, "playwright.config.ts"), "utf8");
expect(source).toContain("PLAYWRIGHT_VIDEO_MODE");
expect(source).toContain('"retain-on-failure"');
expect(source).toContain('"on-first-retry"');
});
it("serves Font Awesome from local fixtures so external stylesheets cannot block page load", () => {
const source = networkFixtureSource();
expect(source).toContain("fixtures/fontawesome/6.7.1");
expect(source).toContain("FONT_AWESOME_CSS");
expect(source).toContain("FONT_AWESOME_WEBFONTS");
expect(source).toContain('contentType: "text/css"');
expect(source).toContain('contentType: "font/woff2"');
expect(source).toContain("body: FONT_AWESOME_CSS");
});
});