Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test for 'about' youtube modal #990

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions tests/about.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,15 @@ test.describe('About Page Tests', () => {
)
})

test('About YouTube modal plays video', async ({ page }) => {
test('the YouTube modal in "about" is visible and have the correct src', async ({ page }) => {
await page.goto('/about')
const videoFrame = page.frameLocator('iframe[title="YouTube video player"]')
const playButton = videoFrame.getByLabel('Play', { exact: true })
await playButton.click()
await playButton.waitFor({ state: 'hidden' })
const video = videoFrame.locator('video')
await video.hover()
await expect(videoFrame.getByLabel('Pause')).toBeVisible()
const iframeElement = await page.waitForSelector('iframe')
const Visible = await iframeElement.isVisible()
expect(Visible).toBe(true)
Comment on lines +113 to +114
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the toBeVisible assertion can be a better fit for this use case - if the element is not visible (for example because it's loading or has entrance animation) it will wait for it to appear

https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-visible

//const iframe = await iframeElement.contentFrame
const videoSrc = await iframeElement.getAttribute('src')
expect(videoSrc).toBe(
'https://www.youtube.com/embed/videoseries?si=oTULlxq8Is188hPu&list=PL6Rh06rT7uiX1AQE-lm55hy-seL3idx3T',
)
Comment on lines +117 to +119
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toHaveAttribute could also be a better choice here - up to you :)

})
})
Loading