Files
bitvid/examples/reproducers/issue-channel-moderation-test-crash/repro.mjs
T
google-labs-jules[bot] d592299dd8 feat: add minimal reproducer for channel moderation test crash
Adds a standalone Node.js script that reproduces the TypeError seen in
`tests/app/channel-profile-moderation.test.mjs`. The crash occurs because
the test harness instantiates `Application` without running the constructor,
leaving `moderationDecorator` undefined.

The reproducer demonstrates this by using `Object.create(Application.prototype)`
and attempting to call `decorateVideoModeration`.
2026-01-21 12:14:21 +00:00

37 lines
1.4 KiB
JavaScript

import { JSDOM } from "jsdom";
import "../../../tests/test-helpers/setup-localstorage.mjs";
// Mock globals for Application load
const dom = new JSDOM("<!DOCTYPE html><html><body></body></html>", {
url: "https://example.com",
});
globalThis.window = dom.window;
globalThis.document = dom.window.document;
globalThis.HTMLElement = dom.window.HTMLElement;
// Override WebSocket if setup-localstorage didn't do it or if we need a close method
globalThis.WebSocket = class { close() {} };
// Import Application
const { Application } = await import("../../../js/app.js");
console.log("Creating Application instance bypassing constructor...");
// This replicates what createModerationAppHarness does in tests/helpers/moderation-test-helpers.mjs
const app = Object.create(Application.prototype);
// Attempt to call decorateVideoModeration which relies on this.moderationDecorator
// initialized in constructor.
try {
console.log("Attempting to call decorateVideoModeration...");
app.decorateVideoModeration({});
console.log("FAIL: decorateVideoModeration did not throw.");
process.exit(1);
} catch (error) {
if (error instanceof TypeError && error.message.includes("decorateVideo")) {
console.log("SUCCESS: Caught expected error:", error.message);
process.exit(0); // Exit success
} else {
console.log("FAIL: Caught unexpected error:", error);
process.exit(1);
}
}