- Add e2e job (needs deploy, main/master only) that installs the Playwright browser and smoke-tests the live container on :3002 - Keep deploy-job contract slice from bleeding into the e2e job - Cover the e2e job in the CI workflow contract test - Ignore Playwright output dirs (test-results, playwright-report, blob-report)
68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
const workflow = readFileSync(
|
|
resolve(process.cwd(), ".gitea/workflows/ci.yaml"),
|
|
"utf8",
|
|
);
|
|
|
|
describe("CI workflow", () => {
|
|
it("has check and deploy jobs", () => {
|
|
expect(workflow).toContain("check:");
|
|
expect(workflow).toContain("deploy:");
|
|
});
|
|
|
|
it("deploy depends on check", () => {
|
|
expect(workflow).toContain("needs: check");
|
|
});
|
|
|
|
it("deploy only runs on push to main/master", () => {
|
|
expect(workflow).toContain("gitea.event_name == 'push'");
|
|
expect(workflow).toContain("gitea.ref_name == 'main'");
|
|
});
|
|
|
|
it("check runs lint, typecheck, and test", () => {
|
|
expect(workflow).toContain("pnpm biome:lint");
|
|
expect(workflow).toContain("pnpm typecheck");
|
|
expect(workflow).toContain("pnpm test");
|
|
});
|
|
|
|
it("check job runs on self-hosted runner", () => {
|
|
const checkJob = workflow.slice(
|
|
workflow.indexOf("check:"),
|
|
workflow.indexOf("\n deploy:"),
|
|
);
|
|
expect(checkJob).toContain("runs-on: self-hosted");
|
|
});
|
|
|
|
it("deploy job runs on self-hosted runner", () => {
|
|
const deployJob = workflow.slice(workflow.indexOf("\n deploy:"));
|
|
expect(deployJob).toContain("runs-on: self-hosted");
|
|
});
|
|
|
|
it("check includes toolchain check", () => {
|
|
expect(workflow).toContain("scripts/check-node-toolchain.mjs");
|
|
});
|
|
|
|
it("uses only valid pnpm install flags (no --jobs)", () => {
|
|
expect(workflow).toContain("pnpm install --frozen-lockfile");
|
|
expect(workflow).not.toContain("--jobs");
|
|
});
|
|
|
|
it("does not use github context", () => {
|
|
expect(workflow).not.toContain("github.ref");
|
|
});
|
|
|
|
it("has tag trigger", () => {
|
|
expect(workflow).toContain('tags: ["v*"]');
|
|
});
|
|
|
|
it("has e2e job that smoke-tests the deployed app", () => {
|
|
expect(workflow).toContain("e2e:");
|
|
expect(workflow).toContain("needs: deploy");
|
|
expect(workflow).toContain("pnpm test:e2e");
|
|
expect(workflow).toContain("PLAYWRIGHT_BASE_URL");
|
|
});
|
|
});
|