fix: some
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 2m14s

This commit is contained in:
luo
2026-10-13 16:11:02 +08:00
parent da95a914e3
commit 97dec4dc65
9 changed files with 71 additions and 61 deletions

View File

@@ -261,7 +261,7 @@ test('1192 disables repeated submission, while 1184 keeps the backend error', as
}
});
test('asset-only binding accepts a different phone; mandatory binding does not consume asset info', async () => {
test('asset-only binding accepts a different phone; mandatory binding keeps the session and goes home', async () => {
const r = runtime();
const user = (await r.load('store/user.js')).useUserStore();
user.setLoginPhoneState({ asset_phone_bound: false, asset_phone_is_own: false, need_bind_phone: false });
@@ -277,23 +277,53 @@ test('asset-only binding accepts a different phone; mandatory binding does not c
assert.deepEqual(submitted, { phone: '13900000002', code: '123456' });
assert.equal(user.state.customerPhone, '13800000001');
assert.equal(user.state.assetPhoneBound, true);
r.timers[0]();
assert.equal(r.calls.find(call => call.kind === 'navigateBack').kind, 'navigateBack');
for (const assetBound of [true, false]) {
const mandatory = runtime();
const mandatory = runtime({ postBindReloginNotice: '1' });
mandatory.setOptions({ fromLogin: 'true' });
const mandatoryUser = (await mandatory.load('store/user.js')).useUserStore();
mandatoryUser.setLoginPhoneState({ asset_phone_bound: assetBound, asset_phone_is_own: false, need_bind_phone: true });
const mandatoryAsset = (await mandatory.load('store/asset.js')).useAssetStore();
mandatoryAsset.receiveExpiryReminder({ token: 'session-A', identifier: 'A' }, { remaining_days: 0, level: 'red' });
mandatoryUser.setUserInfo({ nickname: '测试客户' });
mandatory.api.authApi = { bindPhone: async () => {} };
mandatory.api.assetApi = { getInfo: async () => { throw new Error('Mandatory page must not consume expiry reminder'); } };
mandatory.api.assetApi = { getInfo: async () => ({ bound_phone: '' }) };
const mandatoryPage = await mandatory.load('pages/bind/bind.vue', ['bind', 'bindPhone']);
await mandatory.mounted[0]();
mandatoryPage.bind.phone = '13900000002'; mandatoryPage.bind.code = '123456';
await mandatoryPage.bindPhone();
assert.equal(mandatory.calls.find(call => call.kind === 'reLaunch').url, '/pages/login/login');
assert.equal(mandatory.calls.find(call => call.kind === 'reLaunch').url, '/pages/index/index');
assert.equal(mandatory.storage.get('identifier'), 'A');
assert.equal(mandatory.storage.has('token'), false);
assert.equal(mandatory.storage.get('token'), 'session-A');
assert.equal(mandatoryUser.state.token, 'session-A');
assert.equal(mandatoryUser.state.needBindPhone, false);
assert.equal(mandatoryUser.state.userInfo.nickname, '测试客户');
assert.equal(mandatoryAsset.state.expiryReminder.reminder.remaining_days, 0);
assert.equal(mandatory.storage.has('postBindReloginNotice'), false);
assert.equal(mandatory.calls.some(call => call.url === '/pages/login/login'), false);
}
});
test('binding still marks a previously unbound asset bound when prefill fails', async () => {
const r = runtime();
r.setOptions({ fromLogin: 'true' });
const user = (await r.load('store/user.js')).useUserStore();
user.setLoginPhoneState({ asset_phone_bound: false, asset_phone_is_own: false, need_bind_phone: true });
r.api.assetApi = { getInfo: async () => { throw new Error('offline'); } };
r.api.authApi = { bindPhone: async () => {} };
const page = await r.load('pages/bind/bind.vue', ['bind', 'bindPhone']);
await r.mounted[0]();
page.bind.phone = '13900000002'; page.bind.code = '123456';
await page.bindPhone();
assert.equal(user.state.assetPhoneBound, true);
assert.equal(user.state.assetPhoneIsOwn, null);
assert.equal(user.state.customerPhone, null);
assert.equal(user.state.needBindPhone, false);
assert.equal(r.storage.get('token'), 'session-A');
assert.equal(r.calls.find(call => call.kind === 'reLaunch').url, '/pages/index/index');
});
test('change-phone page updates only the confirmed customer phone', async () => {
const r = runtime();
const user = (await r.load('store/user.js')).useUserStore();