仰望星辰工作室

miaopanel

miaopanel/ scripts/ui-shot-create.mjs 1.9 KB · 47 行 原始文件
1// Exercise the redesigned "create site" dialog and capture each type.
2import { chromium } from 'playwright'
3
4const base = process.argv[2]
5const password = process.argv[3]
6const out = process.argv[4] || '.'
7
8const browser = await chromium.launch()
9const page = await browser.newPage({ viewport: { width: 1440, height: 1000 }, deviceScaleFactor: 2 })
10
11await page.goto(base + '/', { waitUntil: 'networkidle' })
12await page.fill('input[autocomplete="username"]', 'admin')
13await page.fill('input[type="password"]', password)
14await page.click('button[type="submit"]')
15await page.waitForTimeout(2000)
16await page.getByRole('button', { name: '网站' }).click()
17await page.waitForTimeout(500)
18await page.getByRole('button', { name: '新建站点' }).click()
19await page.waitForTimeout(600)
20await page.screenshot({ path: `${out}/ui-create-static.png` })
21
22await page.getByRole('button', { name: 'PHP', exact: true }).click()
23await page.waitForTimeout(300)
24await page.screenshot({ path: `${out}/ui-create-php.png` })
25
26await page.getByRole('button', { name: 'Node 应用' }).click()
27await page.waitForTimeout(500)
28await page.screenshot({ path: `${out}/ui-create-node.png` })
29
30await page.getByRole('button', { name: /更多配置/ }).click()
31await page.waitForTimeout(400)
32await page.screenshot({ path: `${out}/ui-create-more.png` })
33
34await page.getByRole('button', { name: 'Go 应用' }).click()
35await page.waitForTimeout(300)
36await page.screenshot({ path: `${out}/ui-create-go.png` })
37
38// End-to-end: create a static site through the dialog.
39await page.getByRole('button', { name: '静态站点' }).click()
40await page.fill('textarea', 'ui-create.test')
41await page.getByRole('button', { name: '创建站点' }).click()
42await page.waitForTimeout(2500)
43const created = await page.getByText('ui-create', { exact: false }).count()
44console.log('created row visible:', created > 0)
45
46await browser.close()
47console.log('create screenshots written to', out)