Skip to content

Commit

Permalink
test_suite_initiation
Browse files Browse the repository at this point in the history
  • Loading branch information
JHLincoln committed Oct 15, 2024
1 parent ee8d88b commit 57254b1
Show file tree
Hide file tree
Showing 9 changed files with 1,658 additions and 26 deletions.
1,586 changes: 1,580 additions & 6 deletions frontend/package-lock.json

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,29 @@
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1"
"react-dom": "^18.3.1",
"react-router-dom": "^6.14.2"
},
"devDependencies": {
"@eslint/js": "^9.11.1",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/react": "^18.3.10",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.2",
"@vitejs/plugin-react-swc": "^3.3.2",
"autoprefixer": "^10.4.20",
"eslint": "^9.11.1",
"eslint-plugin-react": "^7.37.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.12",
"eslint-plugin-vitest": "^0.3.26",
"globals": "^15.9.0",
"jsdom": "^22.1.0",
"postcss": "^8.4.47",
"tailwindcss": "^3.4.13",
"vite": "^5.4.8",
"vitest": "^2.1.3"
"vitest": "^2.1.3",
"vitest-fetch-mock": "^0.2.2"
}
}
36 changes: 32 additions & 4 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
//imports needed
import "./App.css";
import { createBrowserRouter, RouterProvider } from "react-router-dom";// docs: https://reactrouter.com/en/main/start/overview

//imports of pages
import { HomePage } from "./pages/HomePage";
import { InGame } from "./pages/InGame";
import { Lobby } from "./pages/Lobby";
import { RoundEnd } from "./pages/RoundEnd";

// router
const router = createBrowserRouter([
{
path: "/",
element: <HomePage />,
},
{
path: "/in-game",
element: <InGame />,
},
{
path: "/lobby",
element: <Lobby />,
},
{
path: "/round-end",
element: <RoundEnd />,
}
]);


// the app with the above-defined routes
function App() {
return (
<>
<div>
<h1 className="text-6xl font-bold underline">Makers UI game group!</h1>
</div>
<RouterProvider router={router} />
</>
);
}

export default App;
export default App;
12 changes: 8 additions & 4 deletions frontend/src/pages/HomePage.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
// the landing page with the create a game option

//imports needed
import { Link } from "react-router-dom";
import { Button } from "../components/Button";
{/*import { Button } from "../components/Button"; */}

// page function
export function HomePage() {
return (
<>
<div className="home">
<h1>Guess the number!</h1>
<h1 data-testid="game-name">Guess the number!</h1>
<p>
Rules of the game:
<ul>
<li>Guess the number between 1 and 100</li>
<li>2 to 6 players</li>
</ul>
</p>

<Button onClick={handleClick}>Create game</Button>
<Link to="/lobby" className="lobby-link"></Link>
{/* <Button onClick={handleClick}>Create game</Button> */}

</div>
</>
);
}
9 changes: 5 additions & 4 deletions frontend/src/pages/InGame.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// The page where the game happens
import { Link } from "react-router-dom";

// import { Link } from "react-router-dom";
// import { Button } from "../components/Button";

// in game page function
export function InGame() {
return (
<div className="InGame">
Expand All @@ -20,12 +21,12 @@ export function InGame() {
<div className="guess">
<h1>Guess a number component placeholder</h1>
<form>
<label for="number_guess">Guess a number between 1 and 100!</label>
<label htmlFor="number_guess">Guess a number between 1 and 100!</label>
<input type="number" id="number_guess" name="number_guess"></input>
</form>
</div>

<Button onClick={handleClick}>Submit</Button>
{/* <Button onClick={handleClick}>Submit</Button> */}

</div>
);
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/pages/Lobby.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// For the host, this is the page with the 'start the game' button

import { Link } from "react-router-dom";
import { Button } from "../components/Button";
{/* import { Button } from "../components/Button"; */}

export function Lobby() {
return (
Expand All @@ -19,7 +19,8 @@ export function Lobby() {
</p>
</div>

<Button onClick={handleClick}>Start game</Button>
<Link to="/in-game" className="in-game-link"></Link>
{/* <Button onClick={handleClick}>Start game</Button> */}

<div className="share_link">
<h1>Share link component placeholder</h1>
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/pages/RoundEnd.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// this page has the score and the option to do another round or quit

import { Link } from "react-router-dom";
import { Button } from "../components/Button";
// import { Button } from "../components/Button";

export function RoundEnd() {
return (
Expand Down Expand Up @@ -38,10 +38,11 @@ export function RoundEnd() {
</div>


<Link to="/" className="homepage-link"></Link>
<Link to="/in-game" className="in-game-link"></Link>
{/* <Button onClick={handleClick}>Next round :D</Button>
<Button onClick={handleClick}>Next round :D</Button>

<Button onClick={handleClick}>Quit :'(</Button>
<Button onClick={handleClick}>Quit :'(</Button> */}

</div>
);
Expand Down
13 changes: 13 additions & 0 deletions frontend/tests/pages/HomePage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
import { render, screen } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";
import { HomePage } from "../../src/pages/HomePage";
import { describe, expect, test } from "vitest";


describe("Homepage tests", () => {
test("name of the game", () => {
render(
<BrowserRouter>
<HomePage />
</BrowserRouter>
);

const heading = screen.getByTestId("game-name");
expect(heading.textContent).toEqual("Guess the number!");
});
});

3 changes: 3 additions & 0 deletions frontend/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
test: {globals: true,
environment: "jsdom"
}
})

0 comments on commit 57254b1

Please sign in to comment.