Files
return-youtube-dislike/Extensions/e2e/playwright-extension-global-setup.js
T
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

36 lines
1.4 KiB
JavaScript

const path = require("node:path");
const { verifyRequestedExtensionArtifact } = require("./verify-extension-artifact");
const ALLOW_CUSTOM_ARTIFACT_ENV = "RYD_E2E_ALLOW_CUSTOM_EXTENSION_ARTIFACT";
const REPOSITORY_EXTENSION_ARTIFACT = path.resolve(__dirname, "../combined/dist/chrome");
function selectedArtifact(env) {
const requested = env.RYD_EXTENSION_ARTIFACT?.trim();
return requested ? path.resolve(requested) : REPOSITORY_EXTENSION_ARTIFACT;
}
function verifyPlaywrightExtensionArtifact({
env = process.env,
verifyArtifact = verifyRequestedExtensionArtifact,
} = {}) {
const artifact = selectedArtifact(env);
const custom = artifact !== REPOSITORY_EXTENSION_ARTIFACT;
if (custom && env[ALLOW_CUSTOM_ARTIFACT_ENV] !== "1") {
throw new Error(
`Refusing to run extension Playwright against custom artifact ${artifact}. ` +
`Set ${ALLOW_CUSTOM_ARTIFACT_ENV}=1 only for an intentional custom or negative-control fixture.`,
);
}
return verifyArtifact(custom ? artifact : undefined);
}
async function playwrightExtensionGlobalSetup() {
verifyPlaywrightExtensionArtifact();
}
module.exports = playwrightExtensionGlobalSetup;
module.exports.ALLOW_CUSTOM_ARTIFACT_ENV = ALLOW_CUSTOM_ARTIFACT_ENV;
module.exports.REPOSITORY_EXTENSION_ARTIFACT = REPOSITORY_EXTENSION_ARTIFACT;
module.exports.selectedArtifact = selectedArtifact;
module.exports.verifyPlaywrightExtensionArtifact = verifyPlaywrightExtensionArtifact;