Some checks failed
docker-images / build-and-push (admin, admin, termi-astro-admin, admin/Dockerfile) (push) Successful in 52s
docker-images / build-and-push (backend, backend, termi-astro-backend, backend/Dockerfile) (push) Failing after 13s
docker-images / build-and-push (frontend, frontend, termi-astro-frontend, frontend/Dockerfile) (push) Successful in 32s
ui-regression / playwright-regression (push) Failing after 14m24s
90 lines
4.4 KiB
TypeScript
90 lines
4.4 KiB
TypeScript
import { expect, test } from '@playwright/test'
|
|
|
|
import { getDebugState, resetMockState } from './helpers'
|
|
|
|
test.beforeEach(async ({ request }) => {
|
|
await resetMockState(request)
|
|
})
|
|
|
|
test('首页过滤、热门区和文章详情链路可用', async ({ page }) => {
|
|
await page.goto('/')
|
|
|
|
await expect(page.locator('#home-results-count')).toContainText(/条结果/)
|
|
|
|
await page.locator('[data-home-category-filter="测试体系"]').click()
|
|
await expect(page.locator('#home-active-category-text')).toHaveText('测试体系')
|
|
|
|
await page.locator('[data-home-tag-filter="Playwright"]').click()
|
|
await expect(page.locator('#home-active-tag-text')).toHaveText('Playwright')
|
|
|
|
await page.locator('[data-home-popular-range="30d"]').click()
|
|
await expect(page.locator('#home-stats-window-pill')).toHaveText('30d')
|
|
|
|
await page.locator('a[href="/articles/playwright-regression-workflow"]').first().click()
|
|
await expect(page).toHaveURL(/\/articles\/playwright-regression-workflow$/)
|
|
await expect(page.getByRole('heading', { name: 'Playwright 回归工作流设计' })).toBeVisible()
|
|
await expect(page.locator('.paragraph-comment-marker').first()).toBeVisible()
|
|
})
|
|
|
|
test('文章评论、搜索和 AI 问答链路可用', async ({ page, request }) => {
|
|
await page.goto('/articles/astro-terminal-blog')
|
|
|
|
await page.locator('#toggle-comment-form').click()
|
|
await page.locator('#comment-form input[name="nickname"]').fill('Playwright Visitor')
|
|
await page.locator('#comment-form input[name="email"]').fill('visitor@example.com')
|
|
await page.locator('#comment-form textarea[name="content"]').fill('这是一条来自回归测试的新评论。')
|
|
await page.locator('#comment-form input[name="captchaAnswer"]').fill('7')
|
|
await page.getByRole('button', { name: '提交' }).click()
|
|
await expect(page.locator('#comment-message')).toContainText('提交')
|
|
|
|
const commentState = await getDebugState(request)
|
|
expect(commentState.comments.some((item: { author: string }) => item.author === 'Playwright Visitor')).toBeTruthy()
|
|
|
|
await page.goto('/search?q=playwright')
|
|
await expect(page.getByText('Playwright 回归工作流设计')).toBeVisible()
|
|
|
|
await page.goto('/ask')
|
|
await page.locator('#ai-question').fill('这个博客主要写什么内容?')
|
|
await page.locator('#ai-submit').click()
|
|
await expect(page.locator('#ai-answer')).toContainText('Playwright 回归工作流')
|
|
})
|
|
|
|
test('友链申请与订阅确认/偏好/退订链路可用', async ({ page, request }) => {
|
|
await page.goto('/friends')
|
|
|
|
await page.locator('input[name="siteName"]').fill('Playwright Friend')
|
|
await page.locator('input[name="siteUrl"]').fill('https://playwright-friend.example')
|
|
await page.locator('textarea[name="description"]').fill('回归测试用的友链申请。')
|
|
await page.locator('label', { hasText: '[其他]' }).click()
|
|
await page.locator('#has-reciprocal').check()
|
|
await page.getByRole('button', { name: '提交申请' }).click()
|
|
await expect(page.locator('#form-message')).toContainText('提交')
|
|
|
|
const friendState = await getDebugState(request)
|
|
expect(friendState.friend_links.some((item: { site_name: string }) => item.site_name === 'Playwright Friend')).toBeTruthy()
|
|
|
|
await page.goto('/')
|
|
await page.locator('[data-subscription-popup-open]').click()
|
|
await page.locator('[data-subscription-popup-email]').fill('playwright-subscriber@example.com')
|
|
await page.locator('[data-subscription-popup-form] button[type="submit"]').click()
|
|
await expect(page.locator('[data-subscription-popup-status]')).toContainText('订阅')
|
|
|
|
const subscriptionState = await getDebugState(request)
|
|
const latest = subscriptionState.subscriptions.find(
|
|
(item: { target: string }) => item.target === 'playwright-subscriber@example.com',
|
|
)
|
|
expect(latest).toBeTruthy()
|
|
|
|
await page.goto(`/subscriptions/confirm?token=${encodeURIComponent(latest.confirm_token)}`)
|
|
await expect(page.getByText('订阅已确认')).toBeVisible()
|
|
|
|
await page.goto(`/subscriptions/manage?token=${encodeURIComponent(latest.manage_token)}`)
|
|
await page.getByRole('textbox', { name: '称呼' }).fill('回归通知')
|
|
await page.getByRole('button', { name: '保存偏好' }).click()
|
|
await expect(page.locator('[data-manage-status]')).toContainText('偏好已保存')
|
|
|
|
await page.goto(`/subscriptions/unsubscribe?token=${encodeURIComponent(latest.manage_token)}`)
|
|
await page.getByRole('button', { name: '确认退订' }).click()
|
|
await expect(page.locator('[data-unsubscribe-status]')).toContainText('成功退订')
|
|
})
|