diff --git a/api/numberGame/Pokemon.js b/api/numberGame/Pokemon.js index 168e2e7..a448046 100644 --- a/api/numberGame/Pokemon.js +++ b/api/numberGame/Pokemon.js @@ -26,4 +26,4 @@ class Pokemon { } } -module.exports = Pokemon \ No newline at end of file +module.exports = Pokemon diff --git a/frontend/src/components/GuessForm.jsx b/frontend/src/components/GuessForm.jsx index 3062128..db23c4e 100644 --- a/frontend/src/components/GuessForm.jsx +++ b/frontend/src/components/GuessForm.jsx @@ -6,7 +6,6 @@ export function GuessForm(props) {

- props.setInput(e.target.value)} id="website-admin" className="rounded-lg bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 block flex-1 min-w-0 w-full text-sm p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Your guess">
diff --git a/tests/inGame.spec.js b/tests/inGame.spec.js new file mode 100644 index 0000000..bded082 --- /dev/null +++ b/tests/inGame.spec.js @@ -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!!!!!!")) +}); +}) \ No newline at end of file diff --git a/tests/playerLobby.spec.js b/tests/playerLobby.spec.js index 007382b..40c8221 100644 --- a/tests/playerLobby.spec.js +++ b/tests/playerLobby.spec.js @@ -33,4 +33,10 @@ test.describe("Player Lobby Page", () => { await expect(page.getByText("Simon")).toBeVisible(); await expect(page.getByText("Joe (Host)")).toBeVisible(); }); + test("when a host starts a game, the player is directed to in-game", async ({page}) => { + await utils.newPlayerJoinGame(page, playerPage, "Simon"); + await utils.hostStartsGame(page) + await expect(playerPage).toHaveURL("/in-game"); + + }) }); diff --git a/tests/utils.js b/tests/utils.js index 8172512..3c52b30 100644 --- a/tests/utils.js +++ b/tests/utils.js @@ -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 \ No newline at end of file +module.exports = Utils;