Skip to content

Commit 08322e7

Browse files
committed
add dir
1 parent c58f34c commit 08322e7

4 files changed

Lines changed: 58 additions & 39 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,5 @@ metafile-*.json
6262

6363
tsup.*.bundled_*.mjs
6464

65-
vite.client.dev.js
65+
vite.client.dev.js
66+
/videos

e2e/docPIP.spec.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,44 +22,44 @@ test('测试浮动按钮是否正常', async ({ page, browser }, testInfo) => {
2222
await expect(floatBtn).toBeVisible()
2323
})
2424

25-
for (const url of testUrls) {
26-
test(`docPIP能否打开 - ${new URL(url).hostname}`, async ({
27-
page,
28-
browser,
29-
}) => {
30-
await page.goto(url)
31-
await onPageAndExtensionLoaded(page)
25+
// for (const url of testUrls) {
26+
// test(`docPIP能否打开 - ${new URL(url).hostname}`, async ({
27+
// page,
28+
// browser,
29+
// }) => {
30+
// await page.goto(url)
31+
// await onPageAndExtensionLoaded(page)
3232

33-
const videoEl = await page.waitForSelector('video')
34-
const timer = setInterval(async () => {
35-
try {
36-
if (!videoEl || page.isClosed()) {
37-
clearInterval(timer)
38-
return
39-
}
40-
await videoEl.dispatchEvent('mousemove', {
41-
bubbles: true,
42-
})
43-
} catch (error) {
44-
clearInterval(timer)
45-
}
46-
}, 500)
47-
browser.on('disconnected', () => {
48-
clearInterval(timer)
49-
})
33+
// const videoEl = await page.waitForSelector('video')
34+
// const timer = setInterval(async () => {
35+
// try {
36+
// if (!videoEl || page.isClosed()) {
37+
// clearInterval(timer)
38+
// return
39+
// }
40+
// await videoEl.dispatchEvent('mousemove', {
41+
// bubbles: true,
42+
// })
43+
// } catch (error) {
44+
// clearInterval(timer)
45+
// }
46+
// }, 500)
47+
// browser.on('disconnected', () => {
48+
// clearInterval(timer)
49+
// })
5050

51-
// 点击float按钮
52-
const startPipBtn = page.locator('.start-pip-btn')
53-
await startPipBtn.click()
51+
// // 点击float按钮
52+
// const startPipBtn = page.locator('.start-pip-btn')
53+
// await startPipBtn.click()
5454

55-
await wait(1000)
55+
// await wait(1000)
5656

57-
const pipWindow = await page.evaluate('documentPictureInPicture.window')
57+
// const pipWindow = await page.evaluate('documentPictureInPicture.window')
5858

59-
await expect(pipWindow).not.toBeNull()
59+
// await expect(pipWindow).not.toBeNull()
6060

61-
clearInterval(timer)
62-
})
63-
}
61+
// clearInterval(timer)
62+
// })
63+
// }
6464

6565
// test('bilibili大功能测试', () => {})

e2e/fixtures.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,30 @@ import packageJson from '../package.json' with { type: 'json' }
88

99
export const { name } = packageJson
1010

11-
export const extensionPath = path.resolve(
12-
path.dirname(fileURLToPath(import.meta.url)),
13-
'../dist',
14-
)
11+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
12+
export const extensionPath = path.resolve(__dirname, '../dist')
1513

1614
const chromeExePath = 'C:/Program Files/Google/Chrome/Application/chrome.exe'
1715
export const test = base.extend<{
1816
context: BrowserContext
1917
extensionId: string
2018
}>({
21-
context: async ({ headless, browser }, use) => {
19+
context: async ({ headless, browser }, use, testInfo) => {
2220
// workaround for the Vite server has started but contentScript is not yet.
2321
await sleep(1000)
22+
23+
// Create a sanitized folder name from test title
24+
const sanitizeTitle = (title: string) => {
25+
return title
26+
.replace(/[<>:"/\\|?*]/g, '_')
27+
.replace(/\s+/g, '_')
28+
.replace(/_+/g, '_')
29+
.replace(/^_|_$/g, '')
30+
}
31+
32+
const testDirName = sanitizeTitle(testInfo.title)
33+
const videoDir = path.resolve(__dirname, '../videos', testDirName)
34+
2435
const context = await chromium.launchPersistentContext('', {
2536
headless: false,
2637
args: [
@@ -36,6 +47,9 @@ export const test = base.extend<{
3647
'--disable-software-rasterizer',
3748
'--disable-features=VaapiVideoDecoder',
3849
],
50+
recordVideo: {
51+
dir: videoDir,
52+
},
3953
// executablePath: chromeExePath,
4054
})
4155
await use(context)

test-results/.last-run.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"status": "passed",
3+
"failedTests": []
4+
}

0 commit comments

Comments
 (0)