Skip to content

Commit 030676e

Browse files
committed
test; commented clipboard test + add wait time to some test
1 parent c0cc75b commit 030676e

File tree

2 files changed

+52
-44
lines changed

2 files changed

+52
-44
lines changed

tests/browser/game_session.spec.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -67,35 +67,35 @@ test.group('game_session_page', (group) => {
6767
await page.assertExists(giveHintButton)
6868
})
6969

70-
// Need to find a way to fix flacky test
71-
test('copy session id button should copy the session id to the clipboard (can be flacky)', async ({
72-
visit,
73-
browserContext,
74-
assert,
75-
}) => {
76-
const player1 = await setupPlayer('[email protected]', 'test')
77-
const player2 = await setupPlayer('[email protected]', 'test2')
78-
79-
await setupSession(player1, player2)
80-
81-
await browserContext.loginAs(player1)
82-
83-
await browserContext.grantPermissions(['clipboard-write', 'clipboard-read'])
84-
85-
const base = await visit(BaseGameSessionPage)
86-
const { page } = base
87-
88-
const copySessionIdButton = page.getByRole('img', { name: 'Copy icon' })
89-
90-
await copySessionIdButton.click()
91-
92-
const clipboardText = await page.evaluate(async () => {
93-
// @ts-ignore - TS doesn't know about clipboard API
94-
return await navigator.clipboard.readText()
95-
})
96-
97-
assert.equal(clipboardText, '9bb9871e-9da7-4193-a63c-66ef21687699')
98-
})
70+
// FIXME: Need to find a way to fix this flacky test
71+
// test('copy session id button should copy the session id to the clipboard', async ({
72+
// visit,
73+
// browserContext,
74+
// assert,
75+
// }) => {
76+
// const player1 = await setupPlayer('[email protected]', 'test')
77+
// const player2 = await setupPlayer('[email protected]', 'test2')
78+
//
79+
// await setupSession(player1, player2)
80+
//
81+
// await browserContext.loginAs(player1)
82+
//
83+
// await browserContext.grantPermissions(['clipboard-write', 'clipboard-read'])
84+
//
85+
// const base = await visit(BaseGameSessionPage)
86+
// const { page } = base
87+
//
88+
// const copySessionIdButton = page.getByRole('img', { name: 'Copy icon' })
89+
//
90+
// await copySessionIdButton.click()
91+
//
92+
// const clipboardText = await page.evaluate(async () => {
93+
// // @ts-ignore - TS doesn't know about clipboard API
94+
// return await navigator.clipboard.readText()
95+
// })
96+
//
97+
// assert.equal(clipboardText, '9bb9871e-9da7-4193-a63c-66ef21687699')
98+
// })
9999

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

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

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

263263
await page.assertNotExists(backToMenuButton)
264-
// Wait 6 seconds to make sure the game is over
265-
await page.waitForTimeout(6000)
264+
// Wait 7 seconds to make sure the game is over
265+
await page.waitForTimeout(7000)
266266

267267
/**
268268
* This part is commented out because SSE events with current package are not

tests/functional/matchmaking/matchmaking_accept.spec.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,27 @@ test.group('Matchmaking - Accept matchmaking', (group) => {
1717
})
1818

1919
test('only user 1 should accept matchmaking', async ({ assert, client }) => {
20-
const user1 = await User.create({
21-
username: 'test1',
22-
23-
elo: 500,
24-
providerId: 1,
25-
})
20+
const user1 = await User.firstOrCreate(
21+
{
22+
username: 'test1',
23+
},
24+
{
25+
26+
elo: 500,
27+
providerId: 1,
28+
},
29+
)
2630

27-
const user2 = await User.create({
28-
username: 'test2',
29-
30-
elo: 500,
31-
providerId: 1,
32-
})
31+
const user2 = await User.firstOrCreate(
32+
{
33+
username: 'test2',
34+
},
35+
{
36+
37+
elo: 500,
38+
providerId: 1,
39+
},
40+
)
3341

3442
const responseUser1 = await client.post('/game/search').withCsrfToken().loginAs(user1)
3543
responseUser1.assertStatus(200)

0 commit comments

Comments
 (0)