From 91f21a3c3c2391a099a8c8676f63422de1e1aa5e Mon Sep 17 00:00:00 2001 From: eric2788 Date: Tue, 15 Oct 2024 22:00:34 +0800 Subject: [PATCH] added e2e test --- tests/content.spec.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/content.spec.ts b/tests/content.spec.ts index 4d87b8bc..8af566f0 100644 --- a/tests/content.spec.ts +++ b/tests/content.spec.ts @@ -451,3 +451,31 @@ test('測試导航', async ({ room, content, serviceWorker }) => { }) +test('測試 强制啓動 模式', { tag: '@scoped' }, async ({ context, optionPageUrl, page, content }) => { + + logger.info('進入離綫的直播間...') + // this room is always offline (guess what) + await page.goto('https://live.bilibili.com/21849412', { waitUntil: 'domcontentloaded' }) + await page.waitForTimeout(3000) + logger.info('測試主元素是否不存在...') + await expect(content.getByText('功能菜单')).toBeHidden() + await expect(content.locator('section#bjf-feature-jimaku')).not.toBeAttached() + await expect(content.locator('section#bjf-feature-superchat')).not.toBeAttached() + + logger.info('正在修改設定...') + const settingsPage = await context.newPage() + await settingsPage.goto(optionPageUrl, { waitUntil: 'domcontentloaded' }) + await settingsPage.getByText('开发者相关').click() + await settingsPage.getByText('在直播间下线时依然强制启动').check() + await settingsPage.getByText('保存设定').click() + await settingsPage.close() + + logger.info('正在刷新頁面...') + await page.reload({ waitUntil: 'domcontentloaded' }) + await page.waitForTimeout(3000) + logger.info('測試主元素是否存在...') + await expect(content.getByText('功能菜单')).toBeVisible() + await expect(content.locator('section#bjf-feature-jimaku')).toBeAttached() + await expect(content.locator('section#bjf-feature-superchat')).toBeAttached() + +}) \ No newline at end of file