Merge branch 'unstable' into agents/daily/style-agent-2026-02-26-17149479282532484205

This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-03-02 21:41:14 -05:00
commit a41c78bc0f
99 files changed
+2163 -225

No files matched your search

+34 -36
View File
@@ -1,12 +1,13 @@
import { describe, it, beforeEach } from "node:test";
import assert from "node:assert";
import { describe, it, beforeEach } from 'node:test';
import assert from 'node:assert';
// Manual DOM Mocks
class MockElement {
constructor(tagName) {
this.tagName = tagName;
this.children = [];
this.textContent = "";
this.textContent = '';
this.dataset = {};
this.classList = {
add: () => {},
@@ -38,13 +39,14 @@ class MockElement {
getAttribute() {
return null;
}
querySelector() { return null; }
querySelectorAll() { return []; }
appendChild(child) { this.children.push(child); }
replaceChildren() { this.children = []; }
getAttribute() { return null; }
setAttribute() {}
get ownerDocument() {
return globalThis.document;
}
get nodeType() {
return 1;
} // ELEMENT_NODE
get ownerDocument() { return globalThis.document; }
get nodeType() { return 1; } // ELEMENT_NODE
addEventListener() {}
removeEventListener() {}
}
@@ -56,14 +58,12 @@ globalThis.EventTarget = class EventTarget {
};
globalThis.CustomEvent = class CustomEvent {};
globalThis.DOMParser = class DOMParser {
parseFromString() {
return { body: { children: [] } };
}
parseFromString() { return { body: { children: [] } }; }
};
globalThis.document = {
getElementById: () => null,
createElement: (tag) => new MockElement(tag),
body: new MockElement("BODY"),
body: new MockElement('BODY'),
activeElement: null,
addEventListener: () => {},
removeEventListener: () => {},
@@ -71,9 +71,9 @@ globalThis.document = {
};
// Dynamic import to ensure mocks are ready before module execution
const { DeleteModal } = await import("../../../js/ui/components/DeleteModal.js");
const { DeleteModal } = await import('../../../js/ui/components/DeleteModal.js');
describe("DeleteModal", () => {
describe('DeleteModal', () => {
let modal;
let mockModalElement;
let subtitle;
@@ -81,26 +81,26 @@ describe("DeleteModal", () => {
beforeEach(() => {
// Setup mock elements
mockModalElement = new MockElement("DIV");
subtitle = new MockElement("DIV");
subtitle.id = "deleteModalSubtitle";
metadataList = new MockElement("DL");
metadataList.id = "deleteModalMetadata";
mockModalElement = new MockElement('DIV');
subtitle = new MockElement('DIV');
subtitle.id = 'deleteModalSubtitle';
metadataList = new MockElement('DL');
metadataList.id = 'deleteModalMetadata';
// Mock querySelector for cacheElements
mockModalElement.querySelector = (selector) => {
if (selector === "#deleteModalSubtitle") return subtitle;
if (selector === "#deleteModalMetadata") return metadataList;
return new MockElement("DIV"); // Return generic element for others
if (selector === '#deleteModalSubtitle') return subtitle;
if (selector === '#deleteModalMetadata') return metadataList;
return new MockElement('DIV'); // Return generic element for others
};
modal = new DeleteModal({ container: new MockElement("DIV") });
modal = new DeleteModal({ container: new MockElement('DIV') });
modal.cacheElements(mockModalElement);
});
it("should extract d-tag and display it in subtitle", () => {
it('should extract d-tag and display it in subtitle', () => {
const video = {
tags: [["d", "test-d-tag"]],
tags: [['d', 'test-d-tag']]
};
modal.setVideo(video);
@@ -108,30 +108,28 @@ describe("DeleteModal", () => {
assert.match(subtitle.textContent, /d=test-d-tag/);
});
it("should extract d-tag and display it in metadata", () => {
it('should extract d-tag and display it in metadata', () => {
const video = {
tags: [["d", "test-d-tag"]],
tags: [['d', 'test-d-tag']]
};
modal.setVideo(video);
// Metadata list populates children
// We can check if any child (or grandchild) has the text
const hasDTag = metadataList.children.some((child) => {
const hasDTag = metadataList.children.some(child => {
// child is wrapper, wrapper has dt/dd
return child.children.some((grandchild) =>
grandchild.textContent.includes("test-d-tag"),
);
return child.children.some(grandchild => grandchild.textContent.includes('test-d-tag'));
});
assert.ok(hasDTag, "Metadata should contain d-tag");
assert.ok(hasDTag, 'Metadata should contain d-tag');
});
it("should handle missing d-tag", () => {
it('should handle missing d-tag', () => {
const video = {
tags: [["t", "hashtag"]],
tags: [['t', 'hashtag']]
};
modal.setVideo(video);
assert.ok(!subtitle.textContent.includes("d="));
assert.ok(!subtitle.textContent.includes('d='));
});
});