diff --git a/frontend/src/components/auth/PendingOAuthCreateAccountForm.vue b/frontend/src/components/auth/PendingOAuthCreateAccountForm.vue new file mode 100644 index 00000000..39588a86 --- /dev/null +++ b/frontend/src/components/auth/PendingOAuthCreateAccountForm.vue @@ -0,0 +1,212 @@ + + + + + diff --git a/frontend/src/components/auth/__tests__/PendingOAuthCreateAccountForm.spec.ts b/frontend/src/components/auth/__tests__/PendingOAuthCreateAccountForm.spec.ts new file mode 100644 index 00000000..63aeebc6 --- /dev/null +++ b/frontend/src/components/auth/__tests__/PendingOAuthCreateAccountForm.spec.ts @@ -0,0 +1,80 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest' +import { flushPromises, mount } from '@vue/test-utils' + +import PendingOAuthCreateAccountForm from '../PendingOAuthCreateAccountForm.vue' + +const sendVerifyCode = vi.fn() + +vi.mock('vue-i18n', async () => { + const actual = await vi.importActual('vue-i18n') + return { + ...actual, + useI18n: () => ({ + t: (key: string) => key + }) + } +}) + +vi.mock('@/api/auth', async () => { + const actual = await vi.importActual('@/api/auth') + return { + ...actual, + sendVerifyCode: (...args: any[]) => sendVerifyCode(...args) + } +}) + +describe('PendingOAuthCreateAccountForm', () => { + beforeEach(() => { + sendVerifyCode.mockReset() + }) + + it('emits trimmed email, password, and verify code on submit', async () => { + const wrapper = mount(PendingOAuthCreateAccountForm, { + props: { + providerName: 'LinuxDo', + testIdPrefix: 'linuxdo', + initialEmail: 'prefill@example.com', + isSubmitting: false + } + }) + + await wrapper.get('[data-testid="linuxdo-create-account-email"]').setValue(' user@example.com ') + await wrapper.get('[data-testid="linuxdo-create-account-password"]').setValue('secret-123') + await wrapper.get('[data-testid="linuxdo-create-account-verify-code"]').setValue(' 246810 ') + await wrapper.get('form').trigger('submit.prevent') + + expect(wrapper.emitted('submit')).toEqual([ + [ + { + email: 'user@example.com', + password: 'secret-123', + verifyCode: '246810' + } + ] + ]) + }) + + it('sends a verify code for the trimmed email value', async () => { + sendVerifyCode.mockResolvedValue({ + message: 'sent', + countdown: 60 + }) + + const wrapper = mount(PendingOAuthCreateAccountForm, { + props: { + providerName: 'LinuxDo', + testIdPrefix: 'linuxdo', + initialEmail: '', + isSubmitting: false + } + }) + + await wrapper.get('[data-testid="linuxdo-create-account-email"]').setValue(' user@example.com ') + await wrapper.get('[data-testid="linuxdo-create-account-send-code"]').trigger('click') + await flushPromises() + + expect(sendVerifyCode).toHaveBeenCalledWith({ + email: 'user@example.com' + }) + }) +}) diff --git a/frontend/src/views/auth/LinuxDoCallbackView.vue b/frontend/src/views/auth/LinuxDoCallbackView.vue index ce7f92ef..128410bc 100644 --- a/frontend/src/views/auth/LinuxDoCallbackView.vue +++ b/frontend/src/views/auth/LinuxDoCallbackView.vue @@ -113,37 +113,14 @@

Enter an email address to create your account and continue.

-
- - - -
- -

- {{ accountActionError }} -

-
+