Files
hanzo.ai/e2e/unit/link.spec.ts
zeekay 2e6b0f5b3c auth: email first, the link by default; /beta applies before the account
The first screen asks for the address alone. Every address is sent its link and code at once; a known account's password is a press away, a new one's is optional and typed twice. The emailed link lands on /auth/callback and hands its code to the waiting tab, signs in the browser that asked, or shows the code elsewhere. Apple leads the providers when IAM offers it. /beta asks its questions signed out and makes the account on /signup at the end, then goes on to the plan.
2026-10-21 22:02:11 -07:00

21 lines
1.1 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { test, expect } from '@playwright/test'
import { names, read } from '../../lib/auth/link'
test('a link’s fragment gives its address and code, in either order, and nothing else does', () => {
expect(read('#code=123456&email=ada%40example.com')).toEqual({ email: '[email protected]', code: '123456' })
expect(read('email=ada%40example.com&code=123456')).toEqual({ email: '[email protected]', code: '123456' })
expect(read('#code=123456')).toBeNull()
expect(read('#email=ada%40example.com')).toBeNull()
expect(read('#email=&code=123456')).toBeNull()
expect(read('')).toBeNull()
})
test('a tab takes a link for its own address only, whatever its case', () => {
expect(names({ email: '[email protected]', code: '123456' }, '[email protected] ')).toBe(true)
expect(names({ email: '[email protected]', code: '123456' }, '[email protected]')).toBe(false)
expect(names({ email: '[email protected]' }, '[email protected]')).toBe(false)
expect(names({ taken: '123456' }, '[email protected]')).toBe(false)
expect(names(null, '[email protected]')).toBe(false)
expect(names('[email protected]', '[email protected]')).toBe(false)
})