Files
computer-playbook/roles/test-e2e-playwright/files/addon-gating.js
kevinveenbirkenbachandClaude Opus 4.8 8e92f15f6a test(addons): require a Playwright spec for every addon; add 87 per-addon specs
Add tests/lint/ansible/services/test_addons_playwright_spec.py requiring roles/<role>/files/playwright/addons/<id>.spec.js for EVERY addon of EVERY role — no mechanism auto-exempt and no # nocheck escape. Ship the 87 per-addon specs (gated via skipUnlessAddonEnabled so they skip cleanly when the addon is disabled in the current variant), the test-e2e-playwright addon-gating harness (addon-gating.js, playwright.config.js, recursive 02_run_one.yml), the shared odoo helper, and the ADDON_<ID>_ENABLED flags in the six playwright.env.j2 templates. Relax test_env_file_schema to skip Jinja-templated keys in the ADDON loop. Doc updates (suppression.md, requirements/026) follow in a separate commit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 00:16:54 +02:00

28 lines
717 B
JavaScript

const { test } = require("@playwright/test");
const SUFFIX = "_ADDON_ENABLED";
function envKey(id) {
return id.toUpperCase().replace(/[^A-Z0-9]+/g, "_") + SUFFIX;
}
function isAddonEnabled(id) {
const raw = process.env[envKey(id)];
if (raw === undefined) return false;
return String(raw).toLowerCase() === "true";
}
function addonDisabledReason(id) {
if (isAddonEnabled(id)) return null;
return `${envKey(id)} is not "true" (addon "${id}" disabled or not deployed)`;
}
function skipUnlessAddonEnabled(id) {
const reason = addonDisabledReason(id);
if (reason !== null) {
test.skip(true, reason);
}
}
module.exports = { envKey, isAddonEnabled, addonDisabledReason, skipUnlessAddonEnabled };