Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Add base e2e test for global audio
Browse files Browse the repository at this point in the history
  • Loading branch information
krysal committed Aug 26, 2022
1 parent 03cbb6d commit 84268f8
Show file tree
Hide file tree
Showing 2 changed files with 7,035 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/playwright/e2e/global-audio.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { test, expect, Page, Locator } from '@playwright/test'

import { sleep } from '~~/test/playwright/utils/navigation'

const getNthAudioRow = async (page: Page, num: number) => {
const rowSelector = `[aria-label*="Audio Player"] >> nth=${num}`
const nthAudioRow = await page.locator(rowSelector).locator('article')
expect(nthAudioRow).toHaveAttribute('status', 'paused')
return nthAudioRow
}

const play = async (audioRow: Locator) => {
await audioRow.locator('button[aria-label="Play"] >> visible=true').click()
expect(audioRow).toHaveAttribute('status', /(loading|playing)/)
}

test.describe('global audio', () => {
test('track continues to play when navigating from audio search to its details page', async ({
page,
}) => {
await page.goto('/search/audio?q=honey')

// Find and play the first audio result
const firstAudioRow = await getNthAudioRow(page, 0)
await play(firstAudioRow)
// Navigate to the details page of the playing audio track
await firstAudioRow.locator('a').click()
// and confirm is still playing (or loading to play)
const mainPlayerButton = await page.locator('.main-track >> button')
sleep(600) // Doesn't seem to make a difference here
expect(mainPlayerButton).toHaveAttribute('aria-label', /(Loading|Pause)/)
})
})

0 comments on commit 84268f8

Please sign in to comment.