mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-25 07:43:01 +01:00
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.
This commit is contained in:
1 parent
3657de9b2c
commit
e500088e65
196 files changed
+39706
-2694
No files matched your search
@@ -5,6 +5,8 @@ const {
|
||||
DEFAULT_LIVE_NAV_CHANNEL_URL,
|
||||
DEFAULT_LIVE_NAV_SHORT,
|
||||
DEFAULT_LIVE_SIDEBAR_HOPS,
|
||||
DEFAULT_LIVE_SHORTS_NEXT_HOPS,
|
||||
DEFAULT_LIVE_CDP_CONNECT_TIMEOUT_MILLISECONDS,
|
||||
LIVE_VOTE_APPROVALS_DIRECTORY,
|
||||
LIVE_VOTE_APPROVAL_WINDOW_SECONDS,
|
||||
consumeLiveVoteApproval,
|
||||
@@ -24,6 +26,7 @@ const VALID_ENVIRONMENT = {
|
||||
RYD_LIVE_WATCH_A: "abcdefghijk",
|
||||
RYD_LIVE_WATCH_B: "zyxwvutsrqp",
|
||||
RYD_LIVE_SHORT: "shortsabcde",
|
||||
RYD_LIVE_NAV_WATCH: "navwatch001",
|
||||
RYD_LIVE_PLAYLIST_URL: "https://www.youtube.com/watch?v=abcdefghijk&list=PL-test",
|
||||
RYD_LIVE_EXPECTED_CHANNEL: "@ryd-test",
|
||||
};
|
||||
@@ -31,20 +34,24 @@ const VALID_ENVIRONMENT = {
|
||||
function readLiveOptions(environment, nowMilliseconds = NOW) {
|
||||
return readLiveOptionsFromEnvironment(environment, nowMilliseconds, {
|
||||
readBuildId: () => EXPECTED_BUILD_ID,
|
||||
resolveEndpoint: (value) => value,
|
||||
});
|
||||
}
|
||||
|
||||
describe("live YouTube options", () => {
|
||||
test("reads the exact generated build ID from the selected runtime marker", () => {
|
||||
const readFileSync = jest.fn(() => JSON.stringify({ buildId: EXPECTED_BUILD_ID }));
|
||||
const assertArtifactCurrent = jest.fn();
|
||||
|
||||
expect(
|
||||
readExpectedBuildId("userscript", {
|
||||
assertArtifactCurrent,
|
||||
markerPaths: { userscript: "owned-live-build.json" },
|
||||
readFileSync,
|
||||
}),
|
||||
).toBe(EXPECTED_BUILD_ID);
|
||||
expect(readFileSync).toHaveBeenCalledWith("owned-live-build.json", "utf8");
|
||||
expect(assertArtifactCurrent).toHaveBeenCalledWith("userscript", EXPECTED_BUILD_ID);
|
||||
});
|
||||
|
||||
test.each([
|
||||
@@ -60,12 +67,29 @@ describe("live YouTube options", () => {
|
||||
])("rejects a %s generated live-build marker", (_label, readFileSync, expectedMessage) => {
|
||||
expect(() =>
|
||||
readExpectedBuildId("extension", {
|
||||
assertArtifactCurrent: jest.fn(),
|
||||
markerPaths: { extension: "owned-live-build.json" },
|
||||
readFileSync,
|
||||
}),
|
||||
).toThrow(expectedMessage);
|
||||
});
|
||||
|
||||
test("rejects a live marker when the corresponding artifact receipt is stale", () => {
|
||||
const staleArtifact = new Error("Userscript build inputs changed after the artifact was generated.");
|
||||
const assertArtifactCurrent = jest.fn(() => {
|
||||
throw staleArtifact;
|
||||
});
|
||||
|
||||
expect(() =>
|
||||
readExpectedBuildId("userscript", {
|
||||
assertArtifactCurrent,
|
||||
markerPaths: { userscript: "owned-live-build.json" },
|
||||
readFileSync: () => JSON.stringify({ buildId: EXPECTED_BUILD_ID }),
|
||||
}),
|
||||
).toThrow(staleArtifact);
|
||||
expect(assertArtifactCurrent).toHaveBeenCalledWith("userscript", EXPECTED_BUILD_ID);
|
||||
});
|
||||
|
||||
test("stores consumed vote approvals outside Playwright's cleaned output directory", () => {
|
||||
const playwrightOutputDirectory = path.resolve(__dirname, "../../../test-results/live-youtube");
|
||||
expect(LIVE_VOTE_APPROVALS_DIRECTORY).not.toBe(playwrightOutputDirectory);
|
||||
@@ -76,6 +100,11 @@ describe("live YouTube options", () => {
|
||||
expect(readLiveOptions({})).toBeNull();
|
||||
});
|
||||
|
||||
test("defaults to the currently verified high-volume channel navigation fixture", () => {
|
||||
expect(DEFAULT_LIVE_NAV_CHANNEL_URL).toBe("https://www.youtube.com/@MrBeast");
|
||||
expect(DEFAULT_LIVE_NAV_SHORT).toBe("5mU6SRS2Bxo");
|
||||
});
|
||||
|
||||
test("requires production API acknowledgement", () => {
|
||||
expect(() => readLiveOptions({ ...VALID_ENVIRONMENT, RYD_LIVE_PRODUCTION_API: undefined })).toThrow(
|
||||
"RYD_LIVE_PRODUCTION_API=1",
|
||||
@@ -116,12 +145,15 @@ describe("live YouTube options", () => {
|
||||
test.each(["userscript", "extension"])("accepts the %s runtime", (runtime) => {
|
||||
expect(readLiveOptions({ ...VALID_ENVIRONMENT, RYD_LIVE_RUNTIME: runtime })).toMatchObject({
|
||||
cdpEndpoint: "chrome",
|
||||
cdpConnectTimeoutMilliseconds: DEFAULT_LIVE_CDP_CONNECT_TIMEOUT_MILLISECONDS,
|
||||
expectedBuildId: EXPECTED_BUILD_ID,
|
||||
navigation: {
|
||||
channelUrl: DEFAULT_LIVE_NAV_CHANNEL_URL,
|
||||
short: DEFAULT_LIVE_NAV_SHORT,
|
||||
watch: null,
|
||||
shortsNextHops: DEFAULT_LIVE_SHORTS_NEXT_HOPS,
|
||||
watch: "navwatch001",
|
||||
},
|
||||
reactionShort: "shortsabcde",
|
||||
runtime,
|
||||
sidebar: { hopCount: DEFAULT_LIVE_SIDEBAR_HOPS },
|
||||
short: "shortsabcde",
|
||||
@@ -135,19 +167,68 @@ describe("live YouTube options", () => {
|
||||
const result = readLiveOptionsFromEnvironment(
|
||||
{ ...VALID_ENVIRONMENT, RYD_LIVE_EXPECTED_BUILD_ID: "f".repeat(32) },
|
||||
NOW,
|
||||
{ readBuildId },
|
||||
{ readBuildId, resolveEndpoint: (value) => value },
|
||||
);
|
||||
|
||||
expect(readBuildId).toHaveBeenCalledWith("userscript");
|
||||
expect(result.expectedBuildId).toBe(EXPECTED_BUILD_ID);
|
||||
});
|
||||
|
||||
test("resolves the configured browser endpoint with the same environment used for live options", () => {
|
||||
const resolveEndpoint = jest.fn(() => "ws://127.0.0.1:60011/devtools/browser/session");
|
||||
const environment = { ...VALID_ENVIRONMENT, RYD_CDP_ENDPOINT: " 127.0.0.1:60011 " };
|
||||
|
||||
const result = readLiveOptionsFromEnvironment(environment, NOW, {
|
||||
readBuildId: () => EXPECTED_BUILD_ID,
|
||||
resolveEndpoint,
|
||||
});
|
||||
|
||||
expect(resolveEndpoint).toHaveBeenCalledWith("127.0.0.1:60011", { environment });
|
||||
expect(result.cdpEndpoint).toBe("ws://127.0.0.1:60011/devtools/browser/session");
|
||||
});
|
||||
|
||||
test("accepts a bounded remote-debugging approval timeout", () => {
|
||||
expect(readLiveOptions({ ...VALID_ENVIRONMENT, RYD_CDP_CONNECT_TIMEOUT_MS: "180000" })).toMatchObject({
|
||||
cdpConnectTimeoutMilliseconds: 180_000,
|
||||
});
|
||||
});
|
||||
|
||||
test.each(["0", "14999", "300001", "1.5", "two minutes", "-1"])(
|
||||
"rejects invalid remote-debugging approval timeout %p",
|
||||
(timeout) => {
|
||||
expect(() => readLiveOptions({ ...VALID_ENVIRONMENT, RYD_CDP_CONNECT_TIMEOUT_MS: timeout })).toThrow(
|
||||
/RYD_CDP_CONNECT_TIMEOUT_MS.*whole number from 15000 to 300000/,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test("accepts a bounded sidebar stress hop count", () => {
|
||||
expect(readLiveOptions({ ...VALID_ENVIRONMENT, RYD_LIVE_SIDEBAR_HOPS: "5" })).toMatchObject({
|
||||
sidebar: { hopCount: 5 },
|
||||
});
|
||||
});
|
||||
|
||||
test("defaults the live Shorts stress to ten successful Next samples", () => {
|
||||
expect(readLiveOptions(VALID_ENVIRONMENT)).toMatchObject({
|
||||
navigation: { shortsNextHops: 10 },
|
||||
});
|
||||
});
|
||||
|
||||
test("accepts a larger bounded successful live Shorts Next count", () => {
|
||||
expect(readLiveOptions({ ...VALID_ENVIRONMENT, RYD_LIVE_SHORTS_NEXT_HOPS: "15" })).toMatchObject({
|
||||
navigation: { shortsNextHops: 15 },
|
||||
});
|
||||
});
|
||||
|
||||
test.each(["0", "1", "9", "26", "10.5", "three", "-1"])(
|
||||
"rejects live Shorts Next count below ten or outside the bound: %p",
|
||||
(hopCount) => {
|
||||
expect(() => readLiveOptions({ ...VALID_ENVIRONMENT, RYD_LIVE_SHORTS_NEXT_HOPS: hopCount })).toThrow(
|
||||
/RYD_LIVE_SHORTS_NEXT_HOPS.*whole number from 10 to 25/,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test.each(["0", "11", "1.5", "three", "-1"])("rejects invalid sidebar stress hop count %p", (hopCount) => {
|
||||
expect(() => readLiveOptions({ ...VALID_ENVIRONMENT, RYD_LIVE_SIDEBAR_HOPS: hopCount })).toThrow(
|
||||
/RYD_LIVE_SIDEBAR_HOPS.*whole number from 1 to 10/,
|
||||
@@ -171,6 +252,19 @@ describe("live YouTube options", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("accepts a dedicated reaction Short without changing the read-only Short", () => {
|
||||
expect(readLiveOptions({ ...VALID_ENVIRONMENT, RYD_LIVE_REACTION_SHORT: "reactshort1" })).toMatchObject({
|
||||
reactionShort: "reactshort1",
|
||||
short: "shortsabcde",
|
||||
});
|
||||
});
|
||||
|
||||
test.each(["invalid", "abcdefghij!", "abcdefghijkl"])("rejects malformed reaction Short ID %p", (videoId) => {
|
||||
expect(() => readLiveOptions({ ...VALID_ENVIRONMENT, RYD_LIVE_REACTION_SHORT: videoId })).toThrow(
|
||||
"RYD_LIVE_REACTION_SHORT must be an 11-character YouTube video ID",
|
||||
);
|
||||
});
|
||||
|
||||
test.each([
|
||||
"http://www.youtube.com/@SmashTrash",
|
||||
"https://example.com/@SmashTrash",
|
||||
@@ -184,7 +278,13 @@ describe("live YouTube options", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test.each(["RYD_LIVE_NAV_SHORT", "RYD_LIVE_NAV_WATCH"])("validates optional navigation ID %s", (name) => {
|
||||
test("requires an exact channel Watch target", () => {
|
||||
expect(() => readLiveOptions({ ...VALID_ENVIRONMENT, RYD_LIVE_NAV_WATCH: undefined })).toThrow(
|
||||
"RYD_LIVE_NAV_WATCH is required",
|
||||
);
|
||||
});
|
||||
|
||||
test.each(["RYD_LIVE_NAV_SHORT", "RYD_LIVE_NAV_WATCH"])("validates navigation ID %s", (name) => {
|
||||
expect(() => readLiveOptions({ ...VALID_ENVIRONMENT, [name]: "invalid" })).toThrow("11-character YouTube video ID");
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user