Skip to content

Commit

Permalink
test; commented clipboard test + add wait time to some test
Browse files Browse the repository at this point in the history
  • Loading branch information
prisca-c committed Nov 1, 2024
1 parent c0cc75b commit fb32cc4
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions tests/browser/game_session.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,35 +67,35 @@ test.group('game_session_page', (group) => {
await page.assertExists(giveHintButton)
})

// Need to find a way to fix flacky test
test('copy session id button should copy the session id to the clipboard (can be flacky)', async ({
visit,
browserContext,
assert,
}) => {
const player1 = await setupPlayer('[email protected]', 'test')
const player2 = await setupPlayer('[email protected]', 'test2')

await setupSession(player1, player2)

await browserContext.loginAs(player1)

await browserContext.grantPermissions(['clipboard-write', 'clipboard-read'])

const base = await visit(BaseGameSessionPage)
const { page } = base

const copySessionIdButton = page.getByRole('img', { name: 'Copy icon' })

await copySessionIdButton.click()

const clipboardText = await page.evaluate(async () => {
// @ts-ignore - TS doesn't know about clipboard API
return await navigator.clipboard.readText()
})

assert.equal(clipboardText, '9bb9871e-9da7-4193-a63c-66ef21687699')
})
// FIXME: Need to find a way to fix this flacky test
// test('copy session id button should copy the session id to the clipboard', async ({
// visit,
// browserContext,
// assert,
// }) => {
// const player1 = await setupPlayer('[email protected]', 'test')
// const player2 = await setupPlayer('[email protected]', 'test2')
//
// await setupSession(player1, player2)
//
// await browserContext.loginAs(player1)
//
// await browserContext.grantPermissions(['clipboard-write', 'clipboard-read'])
//
// const base = await visit(BaseGameSessionPage)
// const { page } = base
//
// const copySessionIdButton = page.getByRole('img', { name: 'Copy icon' })
//
// await copySessionIdButton.click()
//
// const clipboardText = await page.evaluate(async () => {
// // @ts-ignore - TS doesn't know about clipboard API
// return await navigator.clipboard.readText()
// })
//
// assert.equal(clipboardText, '9bb9871e-9da7-4193-a63c-66ef21687699')
// })

test('check if guesser page content is correct and guesser can submit a word', async ({ visit, browserContext }) => {
const player1 = await setupPlayer('[email protected]', 'test')
Expand Down Expand Up @@ -227,7 +227,7 @@ test.group('game_session_page', (group) => {
await page.assertExists(page.getByText('Invalid word'))

// Using 'pressSequentially' because first fill doesn't set value to the input correctly
await wordInput.pressSequentially('WordTest', { delay: 100 })
await wordInput.pressSequentially('WordTest', { delay: 200 })
await page.assertNotExists(page.getByText('Invalid word'))
await page.assertNotDisabled(page.getByRole('button', { name: 'Give a hint' }))

Expand Down Expand Up @@ -261,8 +261,8 @@ test.group('game_session_page', (group) => {
const backToMenuButton = page.locator('a', { hasText: 'Back to menu' })

await page.assertNotExists(backToMenuButton)
// Wait 6 seconds to make sure the game is over
await page.waitForTimeout(6000)
// Wait 7 seconds to make sure the game is over
await page.waitForTimeout(7000)

/**
* This part is commented out because SSE events with current package are not
Expand Down

0 comments on commit fb32cc4

Please sign in to comment.