功能:补充固定场景助手与GPU健康诊断能力
This commit is contained in:
1 parent
9f05aa20ea
commit
b6026f9759
29 files changed
+1333
-22
No files matched your search
@@ -1,9 +1,9 @@
|
||||
import { test, expect, type Page } from '@playwright/test'
|
||||
|
||||
async function fixture(page: Page, options: { role?: string; empty?: boolean; fail?: string; id?: string; saved?: string; timeout?: boolean } = {}) {
|
||||
async function fixture(page: Page, options: { role?: string; empty?: boolean; ambiguous?: boolean; fail?: string; id?: string; saved?: string; timeout?: boolean } = {}) {
|
||||
const writes: { path: string; body: Record<string, unknown> }[] = [], reads: string[] = []
|
||||
let users = options.empty ? [] : [{ id: 'u1', username: 'zhang', displayName: '张三', enabled: true, terminalId: 't1', desktopIds: ['d1'] }, { id: 'u2', username: 'li', displayName: '李四', enabled: false, terminalId: null, desktopIds: [] as string[] }]
|
||||
const desktops = options.empty ? [] : ['d1', 'd2'].map((id, i) => ({ id, name: i ? '备用桌面' : '办公桌面', os: 'Windows', node: 'pve', vmid: 100 + i, powerState: i ? 'stopped' : 'running', serviceState: i ? 'unknown' : 'ready', setupRequired: false, updatedAt: new Date().toISOString() }))
|
||||
const desktops = options.empty ? [] : ['d1', 'd2', ...(options.ambiguous ? ['d3'] : [])].map((id, i) => ({ id, name: options.ambiguous && i === 2 ? '备用桌面' : i ? '备用桌面' : '办公桌面', os: 'Windows', node: 'pve', vmid: 100 + i, powerState: i ? 'stopped' : 'running', serviceState: i ? 'unknown' : 'ready', setupRequired: false, updatedAt: new Date().toISOString() }))
|
||||
const terminals = options.empty ? [] : [{ id: 't1', sn: 'SN-01', name: '前台盒子', enabled: true, status: 'offline', sessionDesktopId: null, lastSeen: new Date().toISOString() }, { id: 't2', sn: 'SN-02', name: '新盒子', enabled: true, status: 'unregistered', sessionDesktopId: null, lastSeen: null }]
|
||||
const task = { id: 'k1', targetId: 'd2', targetName: '备用桌面', kind: 'desktop', action: 'start', status: options.timeout ? 'timeout' : 'success', message: '等待核对', actor: 'admin', createdAt: new Date().toISOString(), updatedAt: new Date().toISOString() }
|
||||
await page.addInitScript(({ id, saved }) => { sessionStorage.setItem('vdi.accessToken', 'editions-fixture'); if (saved) localStorage.setItem(`vdi.console-mode:${id}`, saved) }, { id: options.id || 'admin', saved: options.saved })
|
||||
@@ -129,3 +129,38 @@ test('通用工作台深浅主题与窄屏导航无溢出', async ({ page }, inf
|
||||
await page.getByRole('button', { name: '关闭导航', exact: true }).click(); expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true)
|
||||
await page.screenshot({ path: info.outputPath('workbench-mobile.png'), fullPage: true })
|
||||
})
|
||||
|
||||
test('通用工作台固定场景助手生成方案,确认后复用真实授权接口', async ({ page }) => {
|
||||
const calls = await fixture(page); await page.goto('/workbench')
|
||||
await page.getByRole('textbox', { name: '描述需求', exact: true }).fill('给张三分配备用桌面')
|
||||
await page.getByRole('button', { name: '生成方案', exact: true }).click()
|
||||
await expect(page.getByText('可执行方案', { exact: true })).toBeVisible()
|
||||
await expect(page.getByRole('heading', { name: '分配已有桌面', exact: true })).toBeVisible()
|
||||
await expect(page.locator('.assistant-plan').getByText('备用桌面', { exact: false }).first()).toBeVisible()
|
||||
await page.getByRole('button', { name: '执行方案', exact: true }).click()
|
||||
await page.getByRole('button', { name: '确认提交', exact: true }).click()
|
||||
await expect(page.getByRole('button', { name: '已执行', exact: true })).toBeVisible()
|
||||
expect(calls.writes.filter(w => w.path === '/users/batch-bindings')).toHaveLength(1)
|
||||
expect(calls.writes.find(w => w.path === '/users/batch-bindings')?.body).toEqual({ userIds: ['u1'], desktopIds: ['d2'], action: 'grant' })
|
||||
})
|
||||
|
||||
test('通用工作台助手对未知或重复授权给出阻止方案,不发写请求', async ({ page }) => {
|
||||
const calls = await fixture(page); await page.goto('/workbench')
|
||||
await page.getByRole('textbox', { name: '描述需求', exact: true }).fill('给不存在的人分配一台桌面')
|
||||
await page.getByRole('button', { name: '生成方案', exact: true }).click()
|
||||
await expect(page.getByText('需要补充信息', { exact: true })).toBeVisible()
|
||||
await expect(page.getByText('没有匹配到员工', { exact: false })).toBeVisible()
|
||||
await page.getByRole('textbox', { name: '描述需求', exact: true }).fill('给张三分配办公桌面')
|
||||
await page.getByRole('button', { name: '生成方案', exact: true }).click()
|
||||
await expect(page.getByText('授权已存在', { exact: false })).toBeVisible()
|
||||
expect(calls.writes).toHaveLength(0)
|
||||
})
|
||||
|
||||
test('通用工作台助手不会在多个同名桌面之间自动选择', async ({ page }) => {
|
||||
const calls = await fixture(page, { ambiguous: true }); await page.goto('/workbench')
|
||||
await page.getByRole('textbox', { name: '描述需求', exact: true }).fill('给张三分配备用桌面')
|
||||
await page.getByRole('button', { name: '生成方案', exact: true }).click()
|
||||
await expect(page.getByText('需要补充信息', { exact: true })).toBeVisible()
|
||||
await expect(page.getByText('匹配到多个桌面', { exact: false })).toBeVisible()
|
||||
expect(calls.writes).toHaveLength(0)
|
||||
})
|
||||
Reference in new issue
Block a user