mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-12 07:42:32 +00:00
Prevent zap popover for logged-out viewers
This commit is contained in:
1 parent
ed1166c16e
commit
24cedbd5ac
3 files changed
+76
-8
No files matched your search
@@ -358,6 +358,56 @@ await (async () => {
|
||||
app.destroy();
|
||||
})();
|
||||
|
||||
await (async () => {
|
||||
// Test: preventDefault is called when zap opening is rejected post-dispatch
|
||||
const { app, modalStub } = await createApp({
|
||||
splitAndZap: async () => ({ receipts: [] }),
|
||||
});
|
||||
|
||||
let loginNotificationCount = 0;
|
||||
app.zapController.notifyLoginRequired = () => {
|
||||
loginNotificationCount += 1;
|
||||
};
|
||||
|
||||
app.zapController.isUserLoggedIn = () => false;
|
||||
|
||||
modalStub.closeZapDialogCalls = [];
|
||||
|
||||
const preventCalls = [];
|
||||
const event = {
|
||||
detail: { requiresLogin: false },
|
||||
preventDefault: () => {
|
||||
preventCalls.push(true);
|
||||
},
|
||||
};
|
||||
|
||||
app.pendingModalZapOpen = true;
|
||||
|
||||
app.boundVideoModalZapOpenHandler(event);
|
||||
|
||||
assert.equal(
|
||||
loginNotificationCount,
|
||||
1,
|
||||
"should notify login requirement when zap open is rejected",
|
||||
);
|
||||
assert.equal(
|
||||
preventCalls.length,
|
||||
1,
|
||||
"should prevent default zap opening when controller rejects it",
|
||||
);
|
||||
assert.equal(
|
||||
app.pendingModalZapOpen,
|
||||
false,
|
||||
"pending zap reopen flag should clear when rejection wasn't login-gated",
|
||||
);
|
||||
assert.deepEqual(modalStub.closeZapDialogCalls[0], {
|
||||
silent: true,
|
||||
restoreFocus: false,
|
||||
});
|
||||
|
||||
app.destroy();
|
||||
})();
|
||||
|
||||
await (async () => {
|
||||
// Test: session actors should not be treated as logged-in users for zaps
|
||||
const { app, modalStub } = await createApp({
|
||||
|
||||
Reference in new issue
Block a user