mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 21:02:28 +00:00
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`.
37 lines
1.4 KiB
JavaScript
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);
|
|
}
|
|
}
|