mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-02 10:52:27 +00:00
Fix npm ci failure by resolving dependency conflicts and updating lockfile
- Explicitly add `@noble/hashes@^2.0.1` to `devDependencies` to satisfy `jsdom`'s peer dependency requirement, resolving the version conflict with `nostr-tools`. - Update `package-lock.json` to reflect the new dependency resolution. - Fix `UploadModal` integration tests (`tests/ui/uploadModal-integration.test.mjs`) to robustly handle JSDOM container reuse and `fetch` mocking, preventing false positives in CI. - Improve `UploadModal.load` robustness by falling back to `lastElementChild` if `querySelector` fails (defensive coding against DOM quirks). Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
607fbb814e
commit
6e1a0d637d
4 files changed
+476
-482
No files matched your search
@@ -162,6 +162,9 @@ export class UploadModal {
|
||||
|
||||
targetContainer.appendChild(wrapper.firstElementChild);
|
||||
this.root = targetContainer.querySelector("#uploadModal");
|
||||
if (!this.root && targetContainer.lastElementChild && targetContainer.lastElementChild.id === "uploadModal") {
|
||||
this.root = targetContainer.lastElementChild;
|
||||
}
|
||||
this.container = targetContainer;
|
||||
|
||||
this.cacheElements();
|
||||
|
||||
Generated
+395
-408
File diff suppressed because it is too large.
Load diff
@@ -32,6 +32,7 @@
|
||||
"telemetry:aggregate": "node scripts/agent/telemetry-aggregator.mjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@noble/hashes": "^2.0.1",
|
||||
"@playwright/test": "^1.58.0",
|
||||
"@tailwindcss/typography": "^0.5.15",
|
||||
"autoprefixer": "^10.4.23",
|
||||
|
||||
@@ -16,6 +16,66 @@ describe("UploadModal Integration", () => {
|
||||
isMock: true
|
||||
};
|
||||
|
||||
// Updated Mock HTML matching refactored component
|
||||
const mockHtml = `
|
||||
<div id="uploadModal" class="hidden">
|
||||
<form id="unifiedUploadForm">
|
||||
<button id="btn-mode-upload"></button>
|
||||
<button id="btn-mode-external"></button>
|
||||
<div id="section-source-upload">
|
||||
<button id="btn-storage-settings"></button>
|
||||
|
||||
<!-- Storage Settings Container -->
|
||||
<div id="section-storage-settings" class="hidden">
|
||||
<!-- Summary View -->
|
||||
<div id="storage-summary-view" class="hidden">
|
||||
<span id="storage-lock-status">Locked 🔒</span>
|
||||
<button id="btn-storage-unlock" class="hidden">Unlock</button>
|
||||
<button id="btn-manage-storage">Manage</button>
|
||||
<span id="summary-provider">--</span>
|
||||
<span id="summary-bucket">--</span>
|
||||
<span id="summary-url-style">--</span>
|
||||
<span id="summary-copy"></span>
|
||||
</div>
|
||||
|
||||
<!-- Empty View -->
|
||||
<div id="storage-empty-view" class="hidden">
|
||||
<button id="btn-configure-storage">Configure Storage</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="upload-status-text"></div>
|
||||
<div id="upload-percent-text"></div>
|
||||
<progress id="input-progress"></progress>
|
||||
</div>
|
||||
<div id="section-source-external"></div>
|
||||
|
||||
<!-- Inputs -->
|
||||
<input id="input-title" />
|
||||
<textarea id="input-description"></textarea>
|
||||
<input id="input-thumbnail" />
|
||||
<input id="input-thumbnail-file" />
|
||||
<input id="input-file" />
|
||||
<input id="input-url" />
|
||||
<input id="input-magnet" />
|
||||
|
||||
<input id="check-nsfw" type="checkbox" />
|
||||
<input id="check-kids" type="checkbox" />
|
||||
<input id="check-comments" type="checkbox" />
|
||||
<input id="check-summary-unlock" type="checkbox" />
|
||||
|
||||
<button id="btn-advanced-toggle"></button>
|
||||
<button id="btn-thumbnail-file"></button>
|
||||
|
||||
<div id="section-advanced"></div>
|
||||
|
||||
<button id="btn-submit"></button>
|
||||
<div id="submit-status"></div>
|
||||
</form>
|
||||
<button id="closeUploadModal"></button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
before(async () => {
|
||||
dom = createUiDom();
|
||||
global.window = dom.window;
|
||||
@@ -29,6 +89,16 @@ describe("UploadModal Integration", () => {
|
||||
global.HTMLButtonElement = dom.window.HTMLButtonElement;
|
||||
global.HTMLDivElement = dom.window.HTMLDivElement;
|
||||
|
||||
global.fetch = async (url) => {
|
||||
if (url.includes("upload-modal.html")) {
|
||||
return {
|
||||
ok: true,
|
||||
text: async () => mockHtml
|
||||
};
|
||||
}
|
||||
return { ok: false };
|
||||
};
|
||||
|
||||
// Load UploadModal class
|
||||
const module = await import("../../js/ui/components/UploadModal.js");
|
||||
UploadModal = module.UploadModal;
|
||||
@@ -67,76 +137,6 @@ describe("UploadModal Integration", () => {
|
||||
setGlobalModalState: () => {},
|
||||
});
|
||||
|
||||
// Updated Mock HTML matching refactored component
|
||||
const mockHtml = `
|
||||
<div id="uploadModal" class="hidden">
|
||||
<form id="unifiedUploadForm">
|
||||
<button id="btn-mode-upload"></button>
|
||||
<button id="btn-mode-external"></button>
|
||||
<div id="section-source-upload">
|
||||
<button id="btn-storage-settings"></button>
|
||||
|
||||
<!-- Storage Settings Container -->
|
||||
<div id="section-storage-settings" class="hidden">
|
||||
<!-- Summary View -->
|
||||
<div id="storage-summary-view" class="hidden">
|
||||
<span id="storage-lock-status">Locked 🔒</span>
|
||||
<button id="btn-storage-unlock" class="hidden">Unlock</button>
|
||||
<button id="btn-manage-storage">Manage</button>
|
||||
<span id="summary-provider">--</span>
|
||||
<span id="summary-bucket">--</span>
|
||||
<span id="summary-url-style">--</span>
|
||||
<span id="summary-copy"></span>
|
||||
</div>
|
||||
|
||||
<!-- Empty View -->
|
||||
<div id="storage-empty-view" class="hidden">
|
||||
<button id="btn-configure-storage">Configure Storage</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="upload-status-text"></div>
|
||||
<div id="upload-percent-text"></div>
|
||||
<progress id="input-progress"></progress>
|
||||
</div>
|
||||
<div id="section-source-external"></div>
|
||||
|
||||
<!-- Inputs -->
|
||||
<input id="input-title" />
|
||||
<textarea id="input-description"></textarea>
|
||||
<input id="input-thumbnail" />
|
||||
<input id="input-thumbnail-file" />
|
||||
<input id="input-file" />
|
||||
<input id="input-url" />
|
||||
<input id="input-magnet" />
|
||||
|
||||
<input id="check-nsfw" type="checkbox" />
|
||||
<input id="check-kids" type="checkbox" />
|
||||
<input id="check-comments" type="checkbox" />
|
||||
<input id="check-summary-unlock" type="checkbox" />
|
||||
|
||||
<button id="btn-advanced-toggle"></button>
|
||||
<button id="btn-thumbnail-file"></button>
|
||||
|
||||
<div id="section-advanced"></div>
|
||||
|
||||
<button id="btn-submit"></button>
|
||||
<div id="submit-status"></div>
|
||||
</form>
|
||||
<button id="closeUploadModal"></button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
global.fetch = async (url) => {
|
||||
if (url.includes("upload-modal.html")) {
|
||||
return {
|
||||
ok: true,
|
||||
text: async () => mockHtml
|
||||
};
|
||||
}
|
||||
return { ok: false };
|
||||
};
|
||||
|
||||
await modal.load({ container });
|
||||
|
||||
// Verify State
|
||||
@@ -170,10 +170,13 @@ describe("UploadModal Integration", () => {
|
||||
meta: { bucket: "locked-bucket" }
|
||||
}];
|
||||
|
||||
// Setup DOM
|
||||
const container = document.createElement("div");
|
||||
container.id = "modalContainer2"; // Different ID to avoid collision if DOM persists
|
||||
document.body.appendChild(container);
|
||||
// Setup DOM - Reuse existing container or create if missing (cleaned by load)
|
||||
let container = document.getElementById("modalContainer");
|
||||
if (!container) {
|
||||
container = document.createElement("div");
|
||||
container.id = "modalContainer";
|
||||
document.body.appendChild(container);
|
||||
}
|
||||
|
||||
// Re-instantiate
|
||||
const modal = new UploadModal({
|
||||
|
||||
Reference in new issue
Block a user