mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-29 17:02:28 +00:00
Fix edit modal error after successful submit
This commit is contained in:
1 parent
4e401b1f5a
commit
cf1f966f60
2 files changed
+46
-3
No files matched your search
@@ -791,12 +791,16 @@ export class EditModal {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.activeVideo || !this.root) {
|
||||
this.showError("No video selected for editing.");
|
||||
const contextVideo = this.activeVideo || this.pendingSubmitVideo || null;
|
||||
|
||||
if (!contextVideo || !this.root) {
|
||||
if (this.isVisible) {
|
||||
this.showError("No video selected for editing.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.setSubmitState({ pending: true, video: this.activeVideo });
|
||||
this.setSubmitState({ pending: true, video: contextVideo });
|
||||
|
||||
const fieldValue = (key) => {
|
||||
const input = this.fields[key];
|
||||
|
||||
@@ -191,3 +191,42 @@ test('ignores additional submissions while pending without spurious errors', asy
|
||||
|
||||
modal.setSubmitState({ pending: false });
|
||||
});
|
||||
|
||||
test('does not show missing video error after modal closes', async () => {
|
||||
const errorMessages = [];
|
||||
const modal = createModal({
|
||||
showError: (message) => {
|
||||
if (message) {
|
||||
errorMessages.push(message);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
await modal.load({ container });
|
||||
|
||||
const video = {
|
||||
id: 'video2',
|
||||
pubkey: 'pubkey2',
|
||||
title: 'Another video',
|
||||
url: 'https://example.com/another.mp4',
|
||||
};
|
||||
|
||||
await modal.open(video);
|
||||
|
||||
modal.submit();
|
||||
|
||||
assert.equal(errorMessages.includes('No video selected for editing.'), false);
|
||||
|
||||
modal.setSubmitState({ pending: false });
|
||||
modal.close();
|
||||
|
||||
assert.equal(modal.isVisible, false, 'modal should be hidden after close');
|
||||
|
||||
modal.submit();
|
||||
|
||||
assert.equal(
|
||||
errorMessages.includes('No video selected for editing.'),
|
||||
false,
|
||||
'should not surface missing video error when closed',
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user