Fix Shorts support and add userscript voting

Harden Shorts controls, reaction state, and navigation; share voting logic
with the extension; improve ratio-bar rendering; and add comprehensive Jest,
Playwright, artifact, and live-browser regression coverage.
This commit is contained in:
Anarios committed 2026-09-01 23:41:28 +02:00
1 parent 4e6dfd1977
commit 3657de9b2c
74 files changed
+23328 -588

No files matched your search

@@ -0,0 +1,92 @@
const { assertInvariantContinuously, waitForStableInvariant } = require("./continuous-invariants");
function createClock() {
let time = 0;
return {
now: () => time,
sleep: async (milliseconds) => {
time += milliseconds;
},
};
}
describe("continuous browser invariants", () => {
test("reports readiness latency and requires an uninterrupted stable window", async () => {
const clock = createClock();
const values = [false, false, true, true, false, true, true, true];
let index = 0;
const result = await waitForStableInvariant({
intervalMs: 100,
isValid: Boolean,
label: "ratio bar",
now: clock.now,
read: async () => values[Math.min(index++, values.length - 1)],
sleep: clock.sleep,
stableForMs: 200,
timeoutMs: 1_000,
});
expect(result).toMatchObject({
elapsedMs: 700,
firstValidMs: 200,
invalidSamples: 3,
sampleCount: 8,
stableForMs: 200,
value: true,
});
});
test("includes sampled phase evidence when stability never arrives", async () => {
const clock = createClock();
let phase = "missing";
await expect(
waitForStableInvariant({
intervalMs: 100,
isValid: (sample) => sample.phase === "ready",
label: "destination ownership",
now: clock.now,
read: async () => ({ phase: (phase = phase === "missing" ? "ready" : "missing") }),
sleep: clock.sleep,
stableForMs: 200,
timeoutMs: 400,
}),
).rejects.toThrow(/destination ownership.*Samples:.*phase/);
});
test("continuous assertion rejects an invalid first sample", async () => {
const clock = createClock();
let calls = 0;
await expect(
assertInvariantContinuously({
durationMs: 200,
intervalMs: 100,
isValid: Boolean,
label: "settled watch UI",
now: clock.now,
read: async () => calls++ > 0,
sleep: clock.sleep,
}),
).rejects.toThrow(/settled watch UI became invalid after 0ms/);
});
test.each([
["negative timeout", { timeoutMs: -1 }],
["zero interval", { intervalMs: 0 }],
["stable duration beyond timeout", { stableForMs: 101, timeoutMs: 100 }],
])("rejects %s", async (_name, timing) => {
await expect(
waitForStableInvariant({
intervalMs: 10,
isValid: Boolean,
label: "invalid timing",
read: async () => true,
stableForMs: 10,
timeoutMs: 100,
...timing,
}),
).rejects.toThrow();
});
});