fix frontend wechat oauth capability recovery
This commit is contained in:
@@ -201,6 +201,61 @@ describe('WechatCallbackView', () => {
|
||||
expect(locationState.current.href).not.toContain('mode=mp')
|
||||
})
|
||||
|
||||
it('falls back to the query mode when capability settings cannot be confirmed', async () => {
|
||||
routeState.query = {
|
||||
wechat_bind_existing: '1',
|
||||
mode: 'mp',
|
||||
redirect: '/profile',
|
||||
}
|
||||
fetchPublicSettingsMock.mockResolvedValue(null)
|
||||
getAuthTokenMock.mockReturnValue('current-auth-token')
|
||||
|
||||
mount(WechatCallbackView, {
|
||||
global: {
|
||||
stubs: {
|
||||
AuthLayout: { template: '<div><slot /></div>' },
|
||||
Icon: true,
|
||||
RouterLink: { template: '<a><slot /></a>' },
|
||||
transition: false,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
await flushPromises()
|
||||
|
||||
expect(prepareOAuthBindAccessTokenCookieMock).toHaveBeenCalledTimes(1)
|
||||
expect(locationState.current.href).toContain('mode=mp')
|
||||
})
|
||||
|
||||
it('ignores legacy aggregate wechat settings and reuses the query mode during bind recovery', async () => {
|
||||
routeState.query = {
|
||||
wechat_bind_existing: '1',
|
||||
mode: 'open',
|
||||
redirect: '/profile',
|
||||
}
|
||||
appStoreState.cachedPublicSettings = {
|
||||
wechat_oauth_enabled: true,
|
||||
}
|
||||
appStoreState.publicSettingsLoaded = true
|
||||
getAuthTokenMock.mockReturnValue('current-auth-token')
|
||||
|
||||
mount(WechatCallbackView, {
|
||||
global: {
|
||||
stubs: {
|
||||
AuthLayout: { template: '<div><slot /></div>' },
|
||||
Icon: true,
|
||||
RouterLink: { template: '<a><slot /></a>' },
|
||||
transition: false,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
await flushPromises()
|
||||
|
||||
expect(prepareOAuthBindAccessTokenCookieMock).toHaveBeenCalledTimes(1)
|
||||
expect(locationState.current.href).toContain('mode=open')
|
||||
})
|
||||
|
||||
it('does not send adoption decisions during the initial exchange', async () => {
|
||||
exchangePendingOAuthCompletionMock.mockResolvedValue({
|
||||
access_token: 'access-token',
|
||||
|
||||
Reference in New Issue
Block a user