fix: some

This commit is contained in:
luo
2026-10-14 09:56:09 +08:00
parent d672dec0d0
commit a7b1156ac1
11 changed files with 112 additions and 39 deletions

View File

@@ -225,11 +225,11 @@ test('shared asset-info receiver keeps a child-first reminder and rejects stale
assert.equal(asset.state.expiryReminder.identifier, 'B');
});
test('notification APIs use POST read-all and retain PUT single-read without new parameters', async () => {
test('notification APIs use PUT for read-all and single-read without new parameters', async () => {
const r = runtime();
const { notificationApi } = await r.load('api/modules/notification.js');
const all = notificationApi.markAllRead();
assert.equal(r.requests[0].method, 'POST');
assert.equal(r.requests[0].method, 'PUT');
assert.match(r.requests[0].url, /\/notifications\/read-all$/);
r.reply(r.requests[0]); await all;
const one = notificationApi.markRead(12);
@@ -398,6 +398,38 @@ test('expiry popup waits for an open notification and closing it does not mark e
assert.equal(page.visibleExpiryReminder.value, null);
});
test('expiry renewal reuses homepage renewal and keeps queued notifications behind payment', async () => {
const r = runtime();
r.api.assetApi = { getInfo: async () => ({ identifier: 'A', current_package_id: 12, current_package: '月套餐', renewal_price: 990 }) };
r.api.notificationApi = {
getList: async () => ({ items: [{ id: 2, category: 'approval', is_read: false }] }),
getUnreadCount: async () => ({ count: 1 }), markRead: async () => {}
};
const asset = (await r.load('store/asset.js')).useAssetStore();
asset.receiveExpiryReminder({ token: 'session-A', identifier: 'A' }, { remaining_days: 0, level: 'red' });
const page = await r.load('pages/index/index.vue', ['visibleExpiryReminder', 'notificationPopupShow', 'onPopupCandidateClose', 'loadUnreadNotifications', 'renewalPopupRef', 'onRenewalVisibilityChange', 'renewFromExpiryReminder', 'startHomepageRenewal']);
await r.shown[0](); page.onPopupCandidateClose('empty');
await page.loadUnreadNotifications();
assert.equal(page.visibleExpiryReminder.value.remaining_days, 0);
const opens = [];
page.renewalPopupRef.value = { open: async (...args) => {
assert.equal(page.visibleExpiryReminder.value, null);
assert.equal(page.notificationPopupShow.value, false);
opens.push(plain(args));
page.onRenewalVisibilityChange(true);
} };
await page.renewFromExpiryReminder();
assert.deepEqual(opens, [[[12], ['月套餐'], 990]]);
assert.equal(page.notificationPopupShow.value, false);
page.onRenewalVisibilityChange(false);
assert.equal(page.notificationPopupShow.value, true);
page.notificationPopupShow.value = false;
await page.startHomepageRenewal();
assert.deepEqual(opens[1], opens[0]);
const source = readFileSync(resolve(root, 'components/ExpiryReminderPopup.vue'), 'utf8');
assert.match(source, /@tap="\$emit\('renew'\)">立即续费/);
});
test('notification center refreshes server scope after read-all; failures keep unread items', async () => {
for (const fail of [false, true]) {
const r = runtime();