|
|
|
@@ -18,7 +18,7 @@ test('登录页按行政、教员、学员、管理员展示真实身份控件', |
|
|
|
await expect(page.locator('.login-role-options > button')).toHaveCount(4) |
|
|
|
expect((await page.locator('.login-role-options > button').allTextContents()).map((item) => item.trim())) |
|
|
|
.toEqual(roleCases.map((item) => item.label)) |
|
|
|
await expect(page.getByRole('button', { name: /登录系统/ })).toBeDisabled() |
|
|
|
await expect(page.getByRole('button', { name: '登录', exact: true })).toBeDisabled() |
|
|
|
await expect(page.getByText('管理员输入账号登录,其他身份请选择对应账号后输入密码。')).toBeVisible() |
|
|
|
|
|
|
|
for (const role of roleCases) { |
|
|
|
@@ -47,14 +47,57 @@ test('登录页按行政、教员、学员、管理员展示真实身份控件', |
|
|
|
await expect(passwordToggle).toHaveCount(1) |
|
|
|
await expect(passwordToggle.locator('svg')).toHaveCount(1) |
|
|
|
await expect(password).toHaveAttribute('type', 'password') |
|
|
|
await expect(page.getByTestId('password-hidden-icon')).toBeVisible() |
|
|
|
await expect(page.getByTestId('password-visible-icon')).toHaveCount(0) |
|
|
|
await page.getByRole('button', { name: '显示密码' }).click() |
|
|
|
await expect(password).toHaveAttribute('type', 'text') |
|
|
|
await expect(page.getByTestId('password-visible-icon')).toBeVisible() |
|
|
|
await expect(page.getByTestId('password-hidden-icon')).toHaveCount(0) |
|
|
|
await page.getByRole('button', { name: '隐藏密码' }).click() |
|
|
|
await expect(password).toHaveAttribute('type', 'password') |
|
|
|
await expect(page.getByTestId('password-hidden-icon')).toBeVisible() |
|
|
|
|
|
|
|
await captureScreenshot(page, testInfo, 'login-four-identities') |
|
|
|
}) |
|
|
|
|
|
|
|
test('深色主题下浏览器自动填充保持深色输入样式', async ({ page }, testInfo) => { |
|
|
|
await page.addInitScript(() => { |
|
|
|
window.localStorage.setItem('digital-human-theme', 'dark') |
|
|
|
}) |
|
|
|
await page.goto('/login') |
|
|
|
await expect(page.locator('.login-shell')).toHaveAttribute('data-theme', 'dark') |
|
|
|
|
|
|
|
const username = page.locator('input[name="username"]') |
|
|
|
await username.fill('saved-admin-preview') |
|
|
|
const client = await page.context().newCDPSession(page) |
|
|
|
await client.send('DOM.enable') |
|
|
|
await client.send('CSS.enable') |
|
|
|
const documentNode = await client.send('DOM.getDocument') |
|
|
|
const usernameNode = await client.send('DOM.querySelector', { |
|
|
|
nodeId: documentNode.root.nodeId, |
|
|
|
selector: 'input[name="username"]', |
|
|
|
}) |
|
|
|
await client.send('CSS.forcePseudoState', { |
|
|
|
nodeId: usernameNode.nodeId, |
|
|
|
forcedPseudoClasses: ['autofill'], |
|
|
|
}) |
|
|
|
|
|
|
|
const autofillStyle = await username.evaluate((element) => { |
|
|
|
const style = window.getComputedStyle(element) |
|
|
|
return { |
|
|
|
background: style.getPropertyValue('--login-autofill-background').trim(), |
|
|
|
boxShadow: style.webkitBoxShadow, |
|
|
|
textFill: style.webkitTextFillColor, |
|
|
|
} |
|
|
|
}) |
|
|
|
expect(autofillStyle.background).toBe('rgb(9 42 34 / 96%)') |
|
|
|
expect(autofillStyle.textFill).toBe('rgb(223, 244, 238)') |
|
|
|
expect(autofillStyle.boxShadow).toContain('9, 42, 34') |
|
|
|
|
|
|
|
await username.fill('') |
|
|
|
await captureScreenshot(page, testInfo, 'login-dark-autofill-theme') |
|
|
|
}) |
|
|
|
|
|
|
|
test('错误密码被拒绝且不会建立登录会话', async ({ page }, testInfo) => { |
|
|
|
const credentials = readAdminCredentials() |
|
|
|
await page.goto('/login') |
|
|
|
|