Files
return-youtube-dislike/Extensions/e2e/playwright-extension-global-setup.spec.js
Anarios e500088e65 Prepare 4.0.5 Firefox update and Shorts fixes
Add Firefox data consent, repair contributor sign-in, and introduce optional Hide clutter buttons. Harden video navigation, voting, and action layouts with shared browser regression coverage and reproducible release packaging.
2026-09-06 12:51:12 +02:00

70 lines
2.4 KiB
JavaScript

/**
* @jest-environment node
*/
const path = require("node:path");
const extensionPlaywrightConfig = require("../../playwright.extension.config");
const {
ALLOW_CUSTOM_ARTIFACT_ENV,
REPOSITORY_EXTENSION_ARTIFACT,
selectedArtifact,
verifyPlaywrightExtensionArtifact,
} = require("./playwright-extension-global-setup");
test("the extension Playwright config always runs the artifact freshness gate", () => {
expect(extensionPlaywrightConfig.globalSetup).toBe(require.resolve("./playwright-extension-global-setup"));
});
test("the default Playwright target receives full repository artifact verification", () => {
const verifyArtifact = jest.fn(() => ({ kind: "repository" }));
expect(verifyPlaywrightExtensionArtifact({ env: {}, verifyArtifact })).toEqual({ kind: "repository" });
expect(selectedArtifact({})).toBe(REPOSITORY_EXTENSION_ARTIFACT);
expect(verifyArtifact).toHaveBeenCalledWith(undefined);
});
test("a custom artifact cannot silently bypass the repository build receipt", () => {
const customArtifact = path.resolve("test-results", "intentional-broken-extension");
const verifyArtifact = jest.fn();
expect(() =>
verifyPlaywrightExtensionArtifact({
env: { RYD_EXTENSION_ARTIFACT: customArtifact },
verifyArtifact,
}),
).toThrow(new RegExp(`${ALLOW_CUSTOM_ARTIFACT_ENV}=1`));
expect(verifyArtifact).not.toHaveBeenCalled();
});
test("an explicit custom-fixture opt-in still runs standalone artifact validation", () => {
const customArtifact = path.resolve("test-results", "intentional-broken-extension");
const verifyArtifact = jest.fn(() => ({ kind: "custom" }));
expect(
verifyPlaywrightExtensionArtifact({
env: {
[ALLOW_CUSTOM_ARTIFACT_ENV]: "1",
RYD_EXTENSION_ARTIFACT: customArtifact,
},
verifyArtifact,
}),
).toEqual({ kind: "custom" });
expect(verifyArtifact).toHaveBeenCalledWith(customArtifact);
});
test("truthy-looking custom-fixture values do not weaken the explicit gate", () => {
const customArtifact = path.resolve("test-results", "intentional-broken-extension");
for (const value of ["true", "yes", "0"]) {
expect(() =>
verifyPlaywrightExtensionArtifact({
env: {
[ALLOW_CUSTOM_ARTIFACT_ENV]: value,
RYD_EXTENSION_ARTIFACT: customArtifact,
},
verifyArtifact: jest.fn(),
}),
).toThrow(new RegExp(`${ALLOW_CUSTOM_ARTIFACT_ENV}=1`));
}
});