mirror of
https://github.com/hanzo-apps/hanzo.ai.git
synced 2026-10-29 07:20:43 +00:00
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.
21 lines
1.1 KiB
TypeScript
21 lines
1.1 KiB
TypeScript
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)
|
||
})
|