Skip to content

Commit

Permalink
fixup! finished recorder feature and test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
eric2788 committed Apr 6, 2024
1 parent 525fe7d commit 3a7365e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
8 changes: 4 additions & 4 deletions tests/content.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ test('測試导航', async ({ room, content, serviceWorker }) => {

logger.info('正在測試導航前向...')

const next = content.getByRole('button', { name: '下一步' })
const previous = content.getByRole('button', { name: '上一步' })
const skip = content.getByRole('button', { name: '跳过' })
const finish = content.getByRole('button', { name: '完成' })
const next = content.locator('[data-test-id=button-primary]').filter({ hasText: '下一步' })
const previous = content.locator('[data-test-id=button-back]')
const skip = content.locator('[data-test-id=button-skip]')
const finish = content.locator('[data-test-id=button-primary]').filter({ hasText: '完成' })

while (await next.isVisible()) {
await next.click()
Expand Down
4 changes: 2 additions & 2 deletions tests/features/jimaku.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ test('測試離線記錄彈幕', async ({ room, content: p, context, tabUrl, pag
expect(subtitleList.length).toBe(0)
})

test('測試房間名單列表(黑名單/白名單)',
test('測試房間名單列表(黑名單/白名單)', { tag: "@scoped"},
testFeatureRoomList(
'jimaku',
expect,
(content) => content.getByTestId('subtitle-list')
(content) => content.locator('#subtitle-list')
)
)

Expand Down
10 changes: 5 additions & 5 deletions tests/pages/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ test('測試設定數據從MV2遷移', async ({ serviceWorker, page }) => {
})


test('測試导航', async ({ page, serviceWorker }) => {
test('測試导航', { tag: "@scoped" }, async ({ page, serviceWorker }) => {

const overlay = page.locator('.react-joyride__overlay')

Expand All @@ -435,10 +435,10 @@ test('測試导航', async ({ page, serviceWorker }) => {

logger.info('正在測試導航前向...')

const next = page.getByText('下一步')
const previous = page.getByText('上一步')
const skip = page.getByText('跳过')
const finish = page.getByText('完成')
const next = page.locator('[data-test-id=button-primary]').filter({ hasText: '下一步' })
const previous = page.locator('[data-test-id=button-back]')
const skip = page.locator('[data-test-id=button-skip]')
const finish = page.locator('[data-test-id=button-primary]').filter({ hasText: '完成' })

while (await next.isVisible()) {
await next.click()
Expand Down
20 changes: 20 additions & 0 deletions tests/utils/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ export async function getSuperChatList(section: Locator, options?: {
return section.getByRole('menu').locator('section.bjf-scrollbar > div').filter(options).all()
}

/**
* A utility function that tests a feature in a room list.
*
* @param feature - The feature to test.
* @param expect - The expect function from the testing framework.
* @param locate - A function that locates the content on the page.
* @returns A pre-configured test function that tests the feature in a room list.
*
* @example
*
* ```ts
* test('測試房間名單列表(黑名單/白名單)',
* testFeatureRoomList(
* 'jimaku',
* expect,
* (content) => content.locator('#subtitle-list')
* )
* )
* ```
*/
export function testFeatureRoomList(feature: string, expect: Expect<Locator>, locate: (content: PageFrame) => Locator): (args: any) => Promise<void> {

return async ({ room, content, context, tabUrl }) => {
Expand Down

0 comments on commit 3a7365e

Please sign in to comment.