优化:提升小程序全链路性能
This commit is contained in:
@@ -27,15 +27,19 @@ function reset(preference) {
|
||||
navigations.length = 0
|
||||
appDefinition.globalData.userInfo = null
|
||||
appDefinition.globalData.wechatLoginState = null
|
||||
codeSequence = 0
|
||||
}
|
||||
|
||||
async function run() {
|
||||
reset({ rememberMe: true, agreementVersions: { USER_TERMS: '1', PRIVACY_POLICY: '1' } })
|
||||
authApi.wechatStatus = async () => ({ status: 'READY' })
|
||||
let statusCalled = false
|
||||
authApi.wechatStatus = async () => { statusCalled = true; return { status: 'READY' } }
|
||||
authApi.wechatQuickLogin = async () => ({ status: 'SUCCESS', accessToken: 'token', userInfo: { id: 1 } })
|
||||
await appDefinition.runWechatBootstrap()
|
||||
assert.deepStrictEqual(navigations, ['/pages/planning/index'])
|
||||
assert.strictEqual(appDefinition.globalData.userInfo.id, 1)
|
||||
assert.strictEqual(statusCalled, false)
|
||||
assert.strictEqual(codeSequence, 1)
|
||||
|
||||
reset({ rememberMe: false })
|
||||
let quickLoginCalled = false
|
||||
@@ -44,9 +48,9 @@ async function run() {
|
||||
await appDefinition.runWechatBootstrap()
|
||||
assert.deepStrictEqual(navigations, ['/pages/login/index'])
|
||||
assert.strictEqual(quickLoginCalled, false)
|
||||
assert.strictEqual(codeSequence, 1)
|
||||
|
||||
reset({ rememberMe: true, agreementVersions: { USER_TERMS: '1', PRIVACY_POLICY: '1' } })
|
||||
authApi.wechatStatus = async () => ({ status: 'READY' })
|
||||
authApi.wechatQuickLogin = async () => { throw new Error('网络异常') }
|
||||
await appDefinition.runWechatBootstrap()
|
||||
assert.deepStrictEqual(navigations, ['/pages/login/index'])
|
||||
@@ -54,7 +58,6 @@ async function run() {
|
||||
assert.strictEqual(appDefinition.globalData.wechatLoginState.status, 'ERROR')
|
||||
|
||||
reset({ rememberMe: true, agreementVersions: { USER_TERMS: '1', PRIVACY_POLICY: '1' } })
|
||||
authApi.wechatStatus = async () => ({ status: 'READY' })
|
||||
authApi.wechatQuickLogin = async () => ({ status: 'SELECT_SHOP', ticket: 'ticket', shops: [{ id: 2 }] })
|
||||
await appDefinition.runWechatBootstrap()
|
||||
assert.deepStrictEqual(navigations, ['/pages/login/index'])
|
||||
|
||||
Reference in New Issue
Block a user