mirror of
https://github.com/iflytek/skillhub.git
synced 2026-10-07 02:57:51 +00:00
test(auth): cover registration and runtime return navigation
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
This commit is contained in:
parent
1aa8d7bc85
commit
5aea7345b8
1 changed files with 50 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { randomBytes } from 'node:crypto'
|
||||
import { expect, test } from '@playwright/test'
|
||||
import { setEnglishLocale } from './helpers/auth-fixtures'
|
||||
|
||||
|
|
@ -17,6 +18,15 @@ test.describe('Auth Entry', () => {
|
|||
|
||||
await page.getByRole('link', { name: 'Sign up now' }).click()
|
||||
await expect(page).toHaveURL('/register?returnTo=%2Fdashboard%2Ftokens')
|
||||
|
||||
await page.getByLabel('Email').fill('test@example.com')
|
||||
await page.getByRole('button', { name: 'Register & Login' }).click()
|
||||
await expect(page.getByText('Username is required')).toBeVisible()
|
||||
await expect(page.getByText('Password is required')).toBeVisible()
|
||||
|
||||
await page.getByLabel('Email').fill('')
|
||||
await page.getByLabel('Email').blur()
|
||||
await expect(page.getByText('Email is required')).toBeVisible()
|
||||
})
|
||||
|
||||
test('shows configured OAuth methods without exposing unsupported organization discovery', async ({ page }) => {
|
||||
|
|
@ -82,5 +92,45 @@ test.describe('Auth Entry', () => {
|
|||
|
||||
await expect(page.getByRole('button', { name: 'Log in with work account' })).toBeVisible()
|
||||
await expect(page.getByLabel('Password', { exact: true })).toBeHidden()
|
||||
|
||||
await page.getByRole('button', { name: 'Personal login' }).click()
|
||||
await expect(page.getByLabel('Password', { exact: true })).toBeVisible()
|
||||
})
|
||||
|
||||
test('logs in to an explicit local destination on the isolated runtime', async ({ browser, page }) => {
|
||||
test.skip(process.env.SKILLHUB_RUNTIME_E2E !== '1', 'Requires an isolated runtime with local registration enabled')
|
||||
test.setTimeout(90_000)
|
||||
|
||||
const suffix = randomBytes(6).toString('hex')
|
||||
const username = `pr901_${suffix}`
|
||||
const password = `${randomBytes(18).toString('base64url')}Aa1!`
|
||||
|
||||
await page.goto('/register')
|
||||
await page.getByLabel('Username').fill(username)
|
||||
await page.getByLabel('Email').fill(`${username}@example.com`)
|
||||
await page.getByLabel('Password').fill(password)
|
||||
await page.getByRole('button', { name: 'Register & Login' }).click()
|
||||
await expect(page).toHaveURL('/')
|
||||
|
||||
const loginPage = await browser.newPage()
|
||||
await setEnglishLocale(loginPage)
|
||||
await loginPage.goto('/login?returnTo=%2Fdashboard%2Ftokens')
|
||||
await expect.poll(() => loginPage.evaluate(async () => (await fetch('/api/v1/auth/me')).status)).toBe(401)
|
||||
|
||||
await loginPage.getByLabel('Username').fill(username)
|
||||
await loginPage.getByLabel('Password').fill(password)
|
||||
await loginPage.getByRole('button', { name: 'Login' }).click()
|
||||
await expect(loginPage).toHaveURL('/dashboard/tokens')
|
||||
await expect.poll(() => loginPage.evaluate(async () => (await fetch('/api/v1/auth/me')).status)).toBe(200)
|
||||
await loginPage.close()
|
||||
|
||||
const defaultLoginPage = await browser.newPage()
|
||||
await setEnglishLocale(defaultLoginPage)
|
||||
await defaultLoginPage.goto('/login')
|
||||
await defaultLoginPage.getByLabel('Username').fill(username)
|
||||
await defaultLoginPage.getByLabel('Password').fill(password)
|
||||
await defaultLoginPage.getByRole('button', { name: 'Login' }).click()
|
||||
await expect(defaultLoginPage).toHaveURL('/')
|
||||
await defaultLoginPage.close()
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue