feat: register T1 (pending, verify)
This commit is contained in:
1 parent
3c3f7c6194
commit
4e41d60142
29 files changed
+2162
-42
No files matched your search
+1
-1
@@ -302,7 +302,7 @@ async function captureApp(
|
||||
})
|
||||
const page = await context.newPage()
|
||||
await page.goto(`${origin}${setup.path}`)
|
||||
await page.waitForLoadState('networkidle')
|
||||
await Promise.race([page.waitForLoadState('networkidle'), page.waitForTimeout(2000)])
|
||||
await setup.steps?.(page)
|
||||
await page.evaluate(() => document.fonts.ready)
|
||||
await page.waitForTimeout(settleMs)
|
||||
|
||||
@@ -63,6 +63,23 @@ function submitRegister(username: string, email: string, password: string) {
|
||||
}
|
||||
}
|
||||
|
||||
async function setPendingEmail(page: Page, email: string) {
|
||||
await page.evaluate((value) => sessionStorage.setItem('renewcms:pendingEmail', value), email)
|
||||
await page.reload()
|
||||
await page.waitForLoadState('networkidle')
|
||||
}
|
||||
|
||||
async function openCancelDialog(page: Page) {
|
||||
await page.getByRole('button', { name: 'Cancel registration', exact: true }).click()
|
||||
}
|
||||
|
||||
async function confirmCancelDialog(page: Page) {
|
||||
await page
|
||||
.getByRole('alertdialog')
|
||||
.getByRole('button', { name: 'Cancel registration', exact: true })
|
||||
.click()
|
||||
}
|
||||
|
||||
export const visualStates: Record<string, Record<string, VisualState>> = {
|
||||
'log-in': {
|
||||
Default: { path: '/login', api: { 'GET /v1/auth/registration': registrationClosed } },
|
||||
@@ -127,4 +144,91 @@ export const visualStates: Record<string, Record<string, VisualState>> = {
|
||||
steps: submitRegister('marta', 'marta@renew.example', 'limewash2026'),
|
||||
},
|
||||
},
|
||||
pending: {
|
||||
Default: {
|
||||
path: '/register/pending',
|
||||
api: { 'GET /v1/auth/me': { status: 200, body: { is_verified: false } } },
|
||||
steps: async (page) => {
|
||||
await setPendingEmail(page, 'marta@renew.example')
|
||||
},
|
||||
},
|
||||
'Email unknown': {
|
||||
path: '/register/pending',
|
||||
api: { 'GET /v1/auth/me': { status: 200, body: { is_verified: false } } },
|
||||
},
|
||||
'Confirm cancel': {
|
||||
path: '/register/pending',
|
||||
api: { 'GET /v1/auth/me': { status: 200, body: { is_verified: false } } },
|
||||
steps: async (page) => {
|
||||
await setPendingEmail(page, 'marta@renew.example')
|
||||
await openCancelDialog(page)
|
||||
},
|
||||
},
|
||||
Cancelling: {
|
||||
path: '/register/pending',
|
||||
api: {
|
||||
'GET /v1/auth/me': { status: 200, body: { is_verified: false } },
|
||||
'DELETE /v1/auth/register': { status: 200, hang: true },
|
||||
},
|
||||
steps: async (page) => {
|
||||
await setPendingEmail(page, 'marta@renew.example')
|
||||
await openCancelDialog(page)
|
||||
await confirmCancelDialog(page)
|
||||
},
|
||||
},
|
||||
Cancelled: {
|
||||
path: '/register/pending',
|
||||
api: {
|
||||
'GET /v1/auth/me': { status: 200, body: { is_verified: false } },
|
||||
'DELETE /v1/auth/register': { status: 200, body: { message: 'ok' } },
|
||||
},
|
||||
steps: async (page) => {
|
||||
await setPendingEmail(page, 'marta@renew.example')
|
||||
await openCancelDialog(page)
|
||||
await confirmCancelDialog(page)
|
||||
await page.waitForURL('**/register')
|
||||
},
|
||||
},
|
||||
'Already verified (403)': {
|
||||
path: '/register/pending',
|
||||
api: {
|
||||
'DELETE /v1/auth/register': { status: 403 },
|
||||
'GET /v1/auth/me': { status: 200, body: { is_verified: true } },
|
||||
},
|
||||
steps: async (page) => {
|
||||
await setPendingEmail(page, 'marta@renew.example')
|
||||
await openCancelDialog(page)
|
||||
await confirmCancelDialog(page)
|
||||
await page.waitForURL('**/home')
|
||||
},
|
||||
},
|
||||
},
|
||||
verify: {
|
||||
Verifying: {
|
||||
path: '/register/validate?c=abc123',
|
||||
api: { 'POST /v1/auth/verify': { status: 200, hang: true } },
|
||||
},
|
||||
Success: {
|
||||
path: '/register/validate?c=abc123',
|
||||
api: {
|
||||
'POST /v1/auth/verify': { status: 200, body: { message: 'ok' } },
|
||||
'GET /v1/auth/me': { status: 200, body: { is_verified: true } },
|
||||
},
|
||||
},
|
||||
'Invalid or expired (403)': {
|
||||
path: '/register/validate?c=abc123',
|
||||
api: { 'POST /v1/auth/verify': { status: 403 } },
|
||||
},
|
||||
'No session (401)': {
|
||||
path: '/register/validate?c=abc123',
|
||||
api: { 'POST /v1/auth/verify': { status: 401 } },
|
||||
},
|
||||
'No session, retrying': {
|
||||
path: '/register/validate?c=abc123',
|
||||
api: { 'POST /v1/auth/verify': { status: 200, hang: true } },
|
||||
},
|
||||
'Missing code': {
|
||||
path: '/register/validate',
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user