mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Fix nostr-tools bootstrapping, UploadModal zombie callbacks, and service error handling
- Add fallback mock to `js/nostrToolsBootstrap.js` for test environments. - Add guards to `js/ui/components/UploadModal.js` to prevent stale state updates. - Ensure service calls are awaited in `js/ui/tagPreferenceMenuController.js`. - Fix `tests/ui/uploadModal-reset.test.mjs` setup and environment. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
91b45abf9a
commit
3aafcf93d5
4 files changed
+72
-15
No files matched your search
@@ -29,8 +29,10 @@ describe("UploadModal Reset Logic", () => {
|
||||
};
|
||||
|
||||
before(async () => {
|
||||
process.env.NODE_ENV = 'test';
|
||||
dom = createUiDom();
|
||||
global.window = dom.window;
|
||||
global.self = dom.window;
|
||||
global.document = dom.document;
|
||||
global.EventTarget = dom.window.EventTarget;
|
||||
global.alert = (msg) => { console.log("ALERT CALLED:", msg); };
|
||||
@@ -167,6 +169,10 @@ describe("UploadModal Reset Logic", () => {
|
||||
modal.activeProvider = "cloudflare_r2";
|
||||
modal.activeCredentials = { accountId: 'acc', accessKeyId: 'key', secretAccessKey: 'sec' };
|
||||
|
||||
// Mock generateTorrentMetadata BEFORE calling handleVideoSelection
|
||||
modal.generateTorrentMetadata = async () => ({ hasValidInfoHash: false });
|
||||
modal.resolveUploadIdentifier = async () => "mock-identifier";
|
||||
|
||||
// Start upload
|
||||
const file = { name: "video.mp4" };
|
||||
const event = { target: { files: [file], value: "video.mp4" } };
|
||||
@@ -186,12 +192,6 @@ describe("UploadModal Reset Logic", () => {
|
||||
// Now let the upload promise resolve
|
||||
resolveUpload({ bucket: 'b', key: 'k' });
|
||||
|
||||
// Also need to handle generateTorrentMetadata which might be awaited
|
||||
// Assuming it resolves quickly or we mock it too.
|
||||
// UploadModal mocks `generateTorrentMetadata` internally? No, it's a method on instance or imported.
|
||||
// It calls `this.generateTorrentMetadata`. We can spy/mock it.
|
||||
modal.generateTorrentMetadata = async () => ({ hasValidInfoHash: false });
|
||||
|
||||
await uploadPromise;
|
||||
|
||||
// Assert that state remains 'idle' and wasn't overwritten by 'complete'
|
||||
|
||||
Reference in new issue
Block a user