Files
return-youtube-dislike/Extensions/e2e/action-overflow-contract.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

51 lines
2.0 KiB
JavaScript

const assert = require("node:assert/strict");
const {
ACTION_OVERFLOW_SCENARIOS,
OPTIONAL_ACTIONS,
assertActionOverflowScenario,
requiredActionRowWidth,
} = require("./action-overflow-contract");
describe("action overflow E2E contract", () => {
test("locks explicit roomy, constrained, and opted-in clutter scenarios", () => {
expect(ACTION_OVERFLOW_SCENARIOS.map(({ id }) => id)).toEqual([
"roomy-keeps-every-optional-action",
"one-button-overflow-hides-one",
"two-button-overflow-hides-two",
"three-button-overflow-hides-three",
"narrow-action-allocation-overflows-every-optional-action",
"hide-clutter-keeps-only-reactions",
]);
});
test.each(ACTION_OVERFLOW_SCENARIOS.filter(({ hideClutterButtons }) => !hideClutterButtons))(
"$id is the maximal prefix that fits",
(scenario) => {
expect(requiredActionRowWidth(scenario.expectedTopLevel)).toBeLessThanOrEqual(scenario.availableWidth);
if (scenario.expectedOverflow.length > 0) {
expect(requiredActionRowWidth([...scenario.expectedTopLevel, scenario.expectedOverflow[0]])).toBeGreaterThan(
scenario.availableWidth,
);
}
},
);
test("the opt-in scenario moves every optional action under More", () => {
const scenario = ACTION_OVERFLOW_SCENARIOS.find(({ hideClutterButtons }) => hideClutterButtons);
expect(scenario.expectedTopLevel).toEqual([]);
expect(scenario.expectedOverflow).toEqual(OPTIONAL_ACTIONS.map(({ id }) => id));
});
test("the oracle rejects a false-green snapshot that hides every button at a constrained width", () => {
const scenario = ACTION_OVERFLOW_SCENARIOS.find(({ id }) => id === "one-button-overflow-hides-one");
const falseGreen = {
duplicateActionIds: [],
moreButtonCount: 1,
overflowActionIds: OPTIONAL_ACTIONS.map(({ id }) => id),
reactionGroupCount: 1,
topLevelActionIds: [],
};
expect(() => assertActionOverflowScenario(falseGreen, scenario, assert)).toThrow("wrong top-level actions");
});
});