test(e2e): cover TOTP enrollment flow

This commit is contained in:
kolaente 2026-04-21 10:50:47 +02:00 committed by kolaente
parent 3b7c098c84
commit 5266392bb7
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
import {test, expect} from '../../../support/fixtures'
import {authenticator} from 'otplib'
import {gotoUserSettings} from '../../../support/userSettings'
test.describe('TOTP', () => {
test('enrolls TOTP and forces re-login', async ({authenticatedPage: page}) => {
await gotoUserSettings(page, 'totp')
await page.getByRole('button', {name: 'Enroll'}).click()
// Secret is rendered in <strong> after enroll()
const secret = await page.locator('.card strong').first().innerText()
expect(secret).toMatch(/^[A-Z2-7]+$/) // base32
const code = authenticator.generate(secret)
await page.locator('#totpConfirmPasscode').fill(code)
await page.getByRole('button', {name: 'Confirm'}).click()
// TOTP.vue:152 calls authStore.logout() on confirm success.
await expect(page).toHaveURL(/\/login/)
})
})