-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f4758d
commit 104751e
Showing
20 changed files
with
223 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,73 @@ | ||
import { expect } from '@playwright/test' | ||
import { waitABit } from '../utils/wait-a-bit' | ||
import { secondsToMilliseconds } from 'date-fns' | ||
import { launchGameAndInitialize } from '../fixtures/launch-game-and-initialize' | ||
import { launchGame } from '../fixtures/launch-game' | ||
|
||
launchGameAndInitialize( | ||
'free players when the game ends', | ||
async ({ players, gameServer, gameNumber }) => { | ||
await Promise.all( | ||
players.map(async player => { | ||
const page = await player.queuePage() | ||
await page.goto() | ||
await expect(page.goBackToGameLink()).toBeVisible() | ||
for (let i = 0; i < 12; ++i) { | ||
await expect(page.slot(i).joinButton()).toBeDisabled() | ||
} | ||
}), | ||
) | ||
launchGame.use({ waitForStage: 'launching' }) | ||
launchGame('free players when the game ends', async ({ players, gameServer, gameNumber }) => { | ||
await Promise.all( | ||
players.map(async player => { | ||
const page = await player.queuePage() | ||
await page.goto() | ||
await expect(page.goBackToGameLink()).toBeVisible() | ||
for (let i = 0; i < 12; ++i) { | ||
await expect(page.slot(i).joinButton()).toBeDisabled() | ||
} | ||
}), | ||
) | ||
|
||
await gameServer.connectAllPlayers() | ||
await gameServer.matchStarts() | ||
await waitABit(secondsToMilliseconds(3)) | ||
await gameServer.matchEnds() | ||
await gameServer.connectAllPlayers() | ||
await gameServer.matchStarts() | ||
await waitABit(secondsToMilliseconds(3)) | ||
await gameServer.matchEnds() | ||
|
||
const medics = ['AstraGirl', 'BellBoy'] | ||
const medics = ['AstraGirl', 'BellBoy'] | ||
|
||
// medics are freed before other players | ||
await Promise.all([ | ||
...medics | ||
.map(playerName => players.find(p => p.playerName === playerName)!) | ||
.map(async player => { | ||
const page = await player.queuePage() | ||
await page.goto() | ||
await Promise.all([ | ||
expect(page.goBackToGameLink()).not.toBeVisible({ | ||
timeout: secondsToMilliseconds(1), | ||
}), | ||
...Array.from(Array(12).keys()).map( | ||
async i => await expect(page.slot(i).joinButton()).toBeEnabled(), | ||
), | ||
]) | ||
}), | ||
...players | ||
.filter(p => !medics.includes(p.playerName)) | ||
.map(async player => { | ||
const page = await player.queuePage() | ||
await page.goto() | ||
await Promise.all([ | ||
expect(page.goBackToGameLink()).toBeVisible(), | ||
...Array.from(Array(12).keys()).map( | ||
async i => await expect(page.slot(i).joinButton()).toBeDisabled(), | ||
), | ||
]) | ||
}), | ||
]) | ||
// medics are freed before other players | ||
await Promise.all([ | ||
...medics | ||
.map(playerName => players.find(p => p.playerName === playerName)!) | ||
.map(async player => { | ||
const page = await player.queuePage() | ||
await page.goto() | ||
await Promise.all([ | ||
expect(page.goBackToGameLink()).not.toBeVisible({ | ||
timeout: secondsToMilliseconds(1), | ||
}), | ||
...Array.from(Array(12).keys()).map( | ||
async i => await expect(page.slot(i).joinButton()).toBeEnabled(), | ||
), | ||
]) | ||
}), | ||
...players | ||
.filter(p => !medics.includes(p.playerName)) | ||
.map(async player => { | ||
const page = await player.queuePage() | ||
await page.goto() | ||
await Promise.all([ | ||
expect(page.goBackToGameLink()).toBeVisible(), | ||
...Array.from(Array(12).keys()).map( | ||
async i => await expect(page.slot(i).joinButton()).toBeDisabled(), | ||
), | ||
]) | ||
}), | ||
]) | ||
|
||
// other players are freed after 5 seconds | ||
await Promise.all( | ||
players | ||
.filter(p => !medics.includes(p.playerName)) | ||
.map(async player => { | ||
const page = await player.queuePage() | ||
await page.goto() | ||
await Promise.all([ | ||
expect(page.goBackToGameLink()).not.toBeVisible({ | ||
timeout: secondsToMilliseconds(5), | ||
}), | ||
...Array.from(Array(12).keys()).map( | ||
async i => await expect(page.slot(i).joinButton()).toBeEnabled(), | ||
), | ||
]) | ||
}), | ||
) | ||
}, | ||
) | ||
// other players are freed after 5 seconds | ||
await Promise.all( | ||
players | ||
.filter(p => !medics.includes(p.playerName)) | ||
.map(async player => { | ||
const page = await player.queuePage() | ||
await page.goto() | ||
await Promise.all([ | ||
expect(page.goBackToGameLink()).not.toBeVisible({ | ||
timeout: secondsToMilliseconds(5), | ||
}), | ||
...Array.from(Array(12).keys()).map( | ||
async i => await expect(page.slot(i).joinButton()).toBeEnabled(), | ||
), | ||
]) | ||
}), | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.