mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-21 13:53:01 +01:00
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.
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
const assert = require("node:assert/strict");
|
|
|
|
const VISUAL_CAPTURE_ENVIRONMENT_VARIABLE = "RYD_CAPTURE_VISUALS";
|
|
|
|
function visualCaptureIsEnabled(environment = process.env) {
|
|
return environment?.[VISUAL_CAPTURE_ENVIRONMENT_VARIABLE] === "1";
|
|
}
|
|
|
|
async function captureOptionalVisualEvidence({ capture, environment = process.env, outputPath }) {
|
|
if (!visualCaptureIsEnabled(environment)) {
|
|
return Object.freeze({ captured: false, outputPath: null, reason: "capture-disabled" });
|
|
}
|
|
if (typeof capture !== "function") throw new TypeError("Visual evidence capture must be a function.");
|
|
if (typeof outputPath !== "string" || outputPath.length === 0) {
|
|
throw new TypeError("Visual evidence outputPath must be a non-empty string.");
|
|
}
|
|
|
|
await capture(outputPath);
|
|
return Object.freeze({ captured: true, outputPath, reason: null });
|
|
}
|
|
|
|
function annotateVisualEvidence(testInfo, evidence) {
|
|
testInfo.annotations.push({
|
|
description: evidence.captured ? `captured:${evidence.outputPath}` : `not-captured:${evidence.reason}`,
|
|
type: "visual-evidence",
|
|
});
|
|
return evidence;
|
|
}
|
|
|
|
function assertVisualEvidenceCaptured(evidence, label = "Visual evidence") {
|
|
assert.equal(
|
|
evidence?.captured,
|
|
true,
|
|
`${label} was not captured. Structural browser assertions alone are not inspected screenshot evidence.`,
|
|
);
|
|
assert.equal(typeof evidence.outputPath, "string", `${label} has no screenshot path.`);
|
|
return evidence;
|
|
}
|
|
|
|
module.exports = {
|
|
VISUAL_CAPTURE_ENVIRONMENT_VARIABLE,
|
|
annotateVisualEvidence,
|
|
assertVisualEvidenceCaptured,
|
|
captureOptionalVisualEvidence,
|
|
visualCaptureIsEnabled,
|
|
};
|