-
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.
Merge pull request #103 from shammy642/more-e2e
e2e
- Loading branch information
Showing
5 changed files
with
46 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,4 @@ class Pokemon { | |
} | ||
} | ||
|
||
module.exports = Pokemon | ||
module.exports = Pokemon |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const { test, expect, chromium } = require("@playwright/test"); | ||
const Utils = require("./utils") | ||
|
||
const utils = new Utils() | ||
|
||
test.describe("In game page", () => { | ||
let playerPage; | ||
let context; | ||
let browser; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto("/"); | ||
|
||
await page.getByPlaceholder("Username").fill("Joe"); | ||
await page.locator("button").click(); | ||
|
||
browser = await chromium.launch(); | ||
context = await browser.newContext(); | ||
playerPage = await context.newPage(); | ||
}); | ||
|
||
test.afterEach(async () => { | ||
await context.close(); | ||
await browser.close(); | ||
}); | ||
|
||
test("mocks a pokemon and doesnt call api", async ({page}) => { | ||
|
||
expect(screen.getByText("Hello Please Work!!!!!!")) | ||
}); | ||
}) |
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,17 +1,20 @@ | ||
const { expect} = require("@playwright/test"); | ||
const { expect } = require("@playwright/test"); | ||
|
||
class Utils { | ||
|
||
async newPlayerJoinGame(page, newPage, name) { | ||
// host shares link | ||
const gameLink = await page.getByTestId("game-link").textContent(); | ||
// player goes to host's link | ||
await newPage.goto(gameLink) | ||
await expect(newPage).toHaveURL(gameLink) | ||
await newPage.goto(gameLink); | ||
await expect(newPage).toHaveURL(gameLink); | ||
// player enters name and clicks join room | ||
await newPage.getByPlaceholder("Username").fill(name); | ||
await newPage.locator("button").click(); | ||
} | ||
|
||
async hostStartsGame(page) { | ||
await page.getByRole("button", { name: "Start Game" }).click(); | ||
} | ||
} | ||
|
||
module.exports = Utils | ||
module.exports = Utils; |