feat: enhance build process and add readiness checks for components
Some checks failed
docker-images / resolve-build-targets (push) Successful in 6s
ui-regression / playwright-regression (push) Failing after 13m44s
docker-images / build-and-push (admin) (push) Successful in 1m13s
docker-images / build-and-push (backend) (push) Successful in 45m36s
docker-images / build-and-push (frontend) (push) Successful in 1m29s
docker-images / submit-indexnow (push) Successful in 18s

This commit is contained in:
2026-04-02 14:57:01 +08:00
parent 3628a46ed1
commit ebfb9c7838
6 changed files with 137 additions and 40 deletions

View File

@@ -1,6 +1,13 @@
import { expect, test } from '@playwright/test'
import { getDebugState, patchAdminSiteSettings, resetMockState } from './helpers'
import {
getDebugState,
patchAdminSiteSettings,
resetMockState,
waitForCommentsReady,
waitForHomeInteractive,
waitForSubscriptionPopupReady,
} from './helpers'
test.beforeEach(async ({ request }) => {
await resetMockState(request)
@@ -8,6 +15,7 @@ test.beforeEach(async ({ request }) => {
test('首页过滤、热门区和文章详情链路可用', async ({ page }) => {
await page.goto('/')
await waitForHomeInteractive(page)
await expect(page.locator('#home-results-count')).toContainText(/条结果/)
@@ -58,8 +66,10 @@ test('首页过滤、热门区和文章详情链路可用', async ({ page }) =>
test('文章评论、搜索和 AI 问答链路可用', async ({ page, request }) => {
await page.goto('/articles/astro-terminal-blog')
await waitForCommentsReady(page)
await page.locator('#toggle-comment-form').click()
await expect(page.locator('#comment-form input[name="nickname"]')).toBeVisible()
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('这是一条来自回归测试的新评论。')
@@ -94,11 +104,13 @@ test('友链申请与订阅确认/偏好/退订链路可用', async ({ page, req
expect(friendState.friend_links.some((item: { site_name: string }) => item.site_name === 'Playwright Friend')).toBeTruthy()
await page.goto('/')
await waitForHomeInteractive(page)
await page.locator('[data-subscribe-form] input[name="displayName"]').fill('首页订阅用户')
await page.locator('[data-subscribe-form] input[name="email"]').fill('inline-subscriber@example.com')
await page.locator('[data-subscribe-form] button[type="submit"]').click()
await expect(page.locator('[data-subscribe-status]')).toContainText('订阅')
await waitForSubscriptionPopupReady(page)
await page.locator('[data-subscription-popup-open]').click()
await expect(page.locator('[data-subscription-popup-panel]')).toBeVisible()
await page.locator('[data-subscription-popup-form] input[name="displayName"]').fill('弹窗订阅用户')
@@ -136,6 +148,8 @@ test('GEO 分享面板、AI 摘要块与 llms 入口可用', async ({ page, requ
})
await page.goto('/')
await waitForHomeInteractive(page)
await waitForSubscriptionPopupReady(page)
await expect(page.locator('head link[rel="alternate"][href$="/llms.txt"]')).toHaveCount(1)
await expect(page.locator('head link[rel="alternate"][href$="/llms-full.txt"]')).toHaveCount(1)
await expect(page.getByRole('heading', { name: '给 AI 看的站点摘要' })).toBeVisible()

View File

@@ -33,6 +33,26 @@ export async function patchAdminSiteSettings(
return response.json()
}
export async function waitForHomeInteractive(page: Page) {
await page.waitForFunction(
() => (window as Window & { __termiHomeReady?: boolean }).__termiHomeReady === true,
)
}
export async function waitForCommentsReady(page: Page) {
await page.waitForFunction(
() => (window as Window & { __termiCommentsReady?: boolean }).__termiCommentsReady === true,
)
}
export async function waitForSubscriptionPopupReady(page: Page) {
await page.waitForFunction(
() =>
(window as Window & { __termiSubscriptionPopupReady?: boolean })
.__termiSubscriptionPopupReady === true,
)
}
export async function loginAdmin(page: Page) {
await page.goto('/login')
await page.getByLabel('用户名').fill('admin')