fix: 沉默期提醒每次登录都弹,有未支付延期订单时提示去支付或作废
Some checks failed
构建并部署前端到测试环境 / build-and-deploy (push) Has been cancelled
Some checks failed
构建并部署前端到测试环境 / build-and-deploy (push) Has been cancelled
- 频率从每天一次改为每次登录一次:重新登录后会再次提醒,同一次登录内回首页不重复 - 已过期套餐有未支付延期订单时,弹窗提示继续支付或作废
This commit is contained in:
@@ -94,7 +94,7 @@ function runtime(initial = {}) {
|
||||
onLoad() {}, onReachBottom() {}
|
||||
});
|
||||
if (specifier === '@/api/index.js') return synthetic('api-index', {
|
||||
...api, deviceApi: {}, hasActiveOrPendingPackage: async () => true
|
||||
packageSilenceApi: {}, ...api, deviceApi: {}, hasActiveOrPendingPackage: async () => true
|
||||
});
|
||||
if (specifier === '@/utils/payment.js') return synthetic('payment', {
|
||||
...payment, consumePendingPaymentRefresh: (...args) => payment.consumePendingPaymentRefresh(...args)
|
||||
@@ -934,7 +934,7 @@ test('order completion and payment return reread actual asset state, not a presu
|
||||
assert.equal(reads, 4);
|
||||
});
|
||||
|
||||
test('home shows the silence reminder after other popups, once per day, and opens the extension page', async () => {
|
||||
test('home shows the silence reminder after other popups, once per login, and opens the extension page', async () => {
|
||||
const r = runtime();
|
||||
r.api.assetApi = {
|
||||
getInfo: async () => ({ identifier: 'A' }),
|
||||
@@ -944,20 +944,31 @@ test('home shows the silence reminder after other popups, once per day, and open
|
||||
children: []
|
||||
}] })
|
||||
};
|
||||
let pendingOrderNo = '';
|
||||
r.api.packageSilenceApi = { getEligibility: async () => ({ can_extend: !pendingOrderNo, pending_order_no: pendingOrderNo }) };
|
||||
r.api.notificationApi = { getUnreadCount: async () => ({ count: 0 }), getList: async () => ({ items: [] }) };
|
||||
const page = await r.load('pages/index/index.vue', ['silenceReminder', 'silenceReminderShow', 'onPopupCandidateClose', 'openSilenceReminderAction', 'closeSilenceReminder']);
|
||||
await r.shown[0](); await r.tick(); await r.tick();
|
||||
const settle = async () => { for (let i = 0; i < 6; i++) await r.tick(); };
|
||||
await r.shown[0](); await settle();
|
||||
// 运营弹窗仍在时不弹沉默期提醒
|
||||
assert.equal(page.silenceReminderShow.value, false);
|
||||
page.onPopupCandidateClose('empty'); await r.tick();
|
||||
page.onPopupCandidateClose('empty'); await settle();
|
||||
assert.equal(page.silenceReminderShow.value, true);
|
||||
assert.equal(page.silenceReminder.value.kind, 'expired');
|
||||
assert.equal(page.silenceReminder.value.pendingOrderNo, undefined);
|
||||
page.openSilenceReminderAction();
|
||||
assert.equal(page.silenceReminderShow.value, false);
|
||||
assert.equal(r.calls.at(-1).kind, 'navigateTo');
|
||||
assert.equal(r.calls.at(-1).url, '/pages/silence-extension/silence-extension?package_usage_id=44961');
|
||||
// 同一天再次回到首页不再弹
|
||||
r.hidden[0](); await r.shown[0](); await r.tick(); await r.tick();
|
||||
page.onPopupCandidateClose('empty'); await r.tick();
|
||||
// 同一次登录内再回到首页不重复弹
|
||||
r.hidden[0](); await r.shown[0](); await settle();
|
||||
page.onPopupCandidateClose('empty'); await settle();
|
||||
assert.equal(page.silenceReminderShow.value, false);
|
||||
// 重新登录(凭证变化)后再次提醒;有未支付延期订单时提示去支付或作废
|
||||
pendingOrderNo = 'SE20261107200004975908';
|
||||
r.storage.set('token', 'session-B');
|
||||
r.hidden[0](); await r.shown[0](); await settle();
|
||||
page.onPopupCandidateClose('empty'); await settle();
|
||||
assert.equal(page.silenceReminderShow.value, true);
|
||||
assert.equal(page.silenceReminder.value.pendingOrderNo, 'SE20261107200004975908');
|
||||
});
|
||||
|
||||
@@ -90,5 +90,8 @@ test('首页沉默期提醒:优先已过期可延期,其次 7 天内到期
|
||||
assert.equal(waiting.remainingDays, 3);
|
||||
|
||||
assert.equal(pickSilenceReminder([node(7, { silence_status: 'ended' })], now), null);
|
||||
assert.equal(silenceReminderKey('A', { packageUsageId: 3, kind: 'expired' }, '2026-11-07'), 'silence_reminder:A:3:expired:2026-11-07');
|
||||
const keyA = silenceReminderKey('A', { packageUsageId: 3, kind: 'expired' }, 'token-1');
|
||||
assert.match(keyA, /^silence_reminder:A:3:expired:/);
|
||||
assert.equal(keyA, silenceReminderKey('A', { packageUsageId: 3, kind: 'expired' }, 'token-1'));
|
||||
assert.notEqual(keyA, silenceReminderKey('A', { packageUsageId: 3, kind: 'expired' }, 'token-2'));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user