Subscribe to zap receipt when zapping, show success for external

payment
This commit is contained in:
2026-08-20 12:24:54 -06:00
parent 644d6a2856
commit 2869ed6677
4 changed files with 138 additions and 1 deletions
+22
View File
@@ -37,9 +37,20 @@ export class MockNostrDataService extends Service {
@tracked blossomServers = [];
@tracked placePhotos = [];
@tracked profiles = {};
@tracked zapReceipts = {};
store = {
add: () => {},
timeline: () => ({
subscribe: () => ({
unsubscribe: () => {},
}),
}),
replaceable: () => ({
subscribe: () => ({
unsubscribe: () => {},
}),
}),
};
getProfile(pubkey) {
@@ -152,6 +163,17 @@ export class MockNostrZapService extends Service {
return this._webLNAvailable;
}
subscribeForZapReceipt(zapRequest, photo, onReceipt) {
this._receiptCallback = onReceipt;
this._receiptZapRequest = zapRequest;
return {
unsubscribe: () => {
this._receiptCallback = null;
this._receiptZapRequest = null;
},
};
}
async zap() {
return this._zapResult;
}
@@ -185,6 +185,35 @@ module('Integration | Component | zap-photo-modal', function (hooks) {
assert.dom('.zap-success h4').hasText('Zap Sent!', 'success title');
});
test('it shows success when a matching zap receipt is received', async function (assert) {
await render(
<template>
<div id="modal-portal"></div>
<ZapPhotoModal @photo={{this.photo}} />
</template>
);
await click('.zap-modal-actions .btn-primary');
await waitFor('.zap-qr-container');
assert.dom('.zap-qr-container').exists('QR code is shown');
assert.ok(
this.nostrZap._receiptCallback,
'receipt subscription was started'
);
this.nostrZap._receiptCallback();
await waitFor('.zap-success');
assert.dom('.zap-success').exists('success state is shown after receipt');
assert.notOk(
this.nostrZap._receiptCallback,
'receipt subscription was cleaned up'
);
});
test('it calls onClose when close button is clicked', async function (assert) {
let closed = false;
this.handleClose = () => {