Files
chorus/admin-ui/tests/e2e/generation-drawer.spec.ts
T

48 lines
2.0 KiB
TypeScript

import { expect, test } from '@playwright/test'
const BASE_URL = process.env.ADMIN_UI_URL || 'http://127.0.0.1:9528'
const ADMIN_TOKEN = process.env.ADMIN_TOKEN || ''
test.describe('Chorus generation detail drawer', () => {
test.skip(!ADMIN_TOKEN, 'ADMIN_TOKEN is required for the authenticated page')
test.beforeEach(async({ context, page }) => {
await context.addCookies([{
name: 'Admin-Token', value: ADMIN_TOKEN, url: BASE_URL, httpOnly: false, secure: false
}])
await page.goto(`${BASE_URL}/#/chorus/generations`, { waitUntil: 'networkidle' })
await expect(page).not.toHaveURL(/login/)
await expect(page.locator('.table-panel tbody tr').first()).toBeVisible()
})
test('keeps the list full width and opens details explicitly', async({ page }) => {
const errors: string[] = []
const detailDrawer = page.locator('.el-drawer').filter({ hasText: '生成任务详情' })
page.on('console', message => { if (message.type() === 'error') errors.push(message.text()) })
await expect(page.locator('.generation-grid')).toHaveCount(0)
await expect(detailDrawer).toBeHidden()
await page.locator('.table-panel tbody tr').first().dblclick()
await expect(detailDrawer).toBeVisible()
await expect(detailDrawer).toContainText('总耗时')
await detailDrawer.locator('.el-drawer__close-btn').click()
await expect(detailDrawer).toBeHidden()
await page.getByRole('button', { name: '查看' }).first().click()
await expect(detailDrawer).toBeVisible()
expect(errors).toEqual([])
})
test('uses a near-full-width drawer on a narrow viewport', async({ page }) => {
await page.setViewportSize({ width: 375, height: 812 })
await page.getByRole('button', { name: '查看' }).first().click()
const drawer = page.locator('.el-drawer').filter({ hasText: '生成任务详情' })
await expect(drawer).toBeVisible()
const box = await drawer.boundingBox()
expect(box).not.toBeNull()
expect(box!.width).toBeGreaterThanOrEqual(350)
expect(box!.width).toBeLessThanOrEqual(360)
})
})