fix(frontend): preserve callback recovery state

This commit is contained in:
IanShaw027
2026-04-22 13:19:41 +08:00
parent 81c827ee51
commit 6696e61c7b
10 changed files with 229 additions and 23 deletions

View File

@ -517,6 +517,50 @@ describe('WechatCallbackView', () => {
expect(replaceMock).toHaveBeenCalledWith('/subscriptions')
})
it('keeps the oauth flow active when complete-registration returns another pending step', async () => {
exchangePendingOAuthCompletionMock.mockResolvedValue({
error: 'invitation_required',
redirect: '/dashboard',
adoption_required: true,
suggested_display_name: 'WeChat Nick',
suggested_avatar_url: 'https://cdn.example/wechat.png',
})
completeWeChatOAuthRegistrationMock.mockResolvedValue({
auth_result: 'pending_session',
step: 'choose_account_action_required',
redirect: '/dashboard',
email: 'fresh@example.com',
resolved_email: 'fresh@example.com',
force_email_on_signup: true,
adoption_required: true,
})
const wrapper = mount(WechatCallbackView, {
global: {
stubs: {
AuthLayout: { template: '<div><slot /></div>' },
Icon: true,
RouterLink: { template: '<a><slot /></a>' },
transition: false,
},
},
})
await flushPromises()
await wrapper.find('input[type="text"]').setValue('invite-code')
await wrapper.find('button').trigger('click')
await flushPromises()
expect(completeWeChatOAuthRegistrationMock).toHaveBeenCalledWith('invite-code', {
adoptDisplayName: true,
adoptAvatar: true,
})
expect(setTokenMock).not.toHaveBeenCalled()
expect(replaceMock).not.toHaveBeenCalled()
expect(wrapper.get('[data-testid="wechat-choice-bind-existing"]').exists()).toBe(true)
expect(wrapper.get('[data-testid="wechat-choice-create-account"]').exists()).toBe(true)
})
it('offers existing-account email collection during invitation flow', async () => {
exchangePendingOAuthCompletionMock.mockResolvedValue({
error: 'invitation_required',