generated from Arquisoft/wiq_0
-
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 #99 from Arquisoft/dev
Dev
- Loading branch information
Showing
35 changed files
with
791 additions
and
180 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
teamname="wiq_en2a" | ||
teamname="wiq_en2a" | ||
WIQ_EXTERNAL_DNS_NAME_OR_IP=$DOCKER_HOST_IP |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from 'react'; | ||
import { render, fireEvent, getByTestId } from '@testing-library/react'; | ||
import { MemoryRouter } from 'react-router-dom'; // Importa MemoryRouter | ||
import NavBar from './Nav'; | ||
|
||
describe('NavBar Component', () => { | ||
it('should render without crashing', () => { | ||
const { getByTestId } = render( | ||
<MemoryRouter> {/* Envuelve el componente en MemoryRouter */} | ||
<NavBar /> | ||
</MemoryRouter> | ||
); | ||
const appName = getByTestId('app_name'); // Reemplaza 'app_name' con el texto real del nombre de la aplicación | ||
expect(appName).toBeInTheDocument(); | ||
}); | ||
/** | ||
it('should navigate to "/game" when "Game" button is clicked', () => { | ||
const { getByTestId } = render( | ||
<MemoryRouter> | ||
<NavBar /> | ||
</MemoryRouter> | ||
); | ||
const gameButton = getByTestId('nav_game'); // Reemplaza 'nav_game' con el botón de juego | ||
fireEvent.click(gameButton); | ||
expect(window.location.pathname).toBe('/game'); | ||
}); | ||
it('should navigate to "/groups" when "Groups" button is clicked', () => { | ||
const { getByTestId } = render( | ||
<MemoryRouter> | ||
<NavBar /> | ||
</MemoryRouter> | ||
); | ||
const groupsButton = getByTestId('nav_groups'); // Reemplaza 'nav_groups' con el botón de grupos | ||
fireEvent.click(groupsButton); | ||
expect(window.location.pathname).toBe('/groups'); | ||
}); | ||
it('should navigate to "/scoreboard" when "Scoreboard" button is clicked', () => { | ||
const { getByTestId: getByTestId } = render( | ||
<MemoryRouter> | ||
<NavBar /> | ||
</MemoryRouter> | ||
); | ||
const scoreboardButton = getByTestId('nav_scoreboard'); // Reemplaza 'nav_scoreboard' con el botón de marcador | ||
fireEvent.click(scoreboardButton); | ||
expect(window.location.pathname).toBe('/scoreboard'); | ||
}); | ||
**/ | ||
// Agrega más pruebas similares para los otros botones y funcionalidades del componente NavBar | ||
}); |
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,17 @@ | ||
import React from 'react'; | ||
import { render, fireEvent } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import GLoginButton from './GLoginButton'; | ||
import { GoogleOAuthProvider } from '@react-oauth/google'; | ||
|
||
describe('GLoginButton Component', () => { | ||
it('should render without crashing', () => { | ||
render( | ||
<GoogleOAuthProvider> | ||
<GLoginButton /> | ||
</GoogleOAuthProvider> | ||
); | ||
}); | ||
|
||
}); | ||
|
Empty file.
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,50 @@ | ||
import React from 'react'; | ||
import { render, screen, fireEvent, waitFor } from '@testing-library/react'; | ||
import GameLayout from './GameLayout'; | ||
import { MemoryRouter } from 'react-router-dom'; // Importa MemoryRouter | ||
|
||
describe('GameLayout component', () => { | ||
it('renders Game by default', () => { | ||
render( | ||
<MemoryRouter> | ||
<GameLayout /> | ||
</MemoryRouter> | ||
); | ||
expect(screen.getByTestId('game-header')).toBeInTheDocument(); | ||
expect(screen.getByTestId('game-link')).toBeInTheDocument(); | ||
expect(screen.getByTestId('groups-link')).toBeInTheDocument(); | ||
expect(screen.getByTestId('scoreboard-link')).toBeInTheDocument(); | ||
|
||
}); | ||
|
||
it('renders GroupsPage when Groups link is clicked', () => { | ||
render( | ||
<MemoryRouter> | ||
<GameLayout /> | ||
</MemoryRouter> | ||
); | ||
waitFor(() => { | ||
fireEvent.click(screen.getByTestId('groups-link')); | ||
expect(screen.queryByTestId('game-component')).toBeNull(); | ||
expect(screen.getByTestId('groups-page-component')).toBeInTheDocument(); | ||
expect(screen.queryByTestId('scoreboard-component')).toBeNull(); | ||
}); | ||
|
||
}); | ||
|
||
it('renders Scoreboard when Scoreboard link is clicked', () => { | ||
|
||
render( | ||
<MemoryRouter> | ||
<GameLayout /> | ||
</MemoryRouter> | ||
); | ||
waitFor(() => { | ||
fireEvent.click(screen.getByTestId('scoreboard-link')); | ||
expect(screen.queryByTestId('game-component')).toBeNull(); | ||
expect(screen.queryByTestId('groups-page-component')).toBeNull(); | ||
expect(screen.getByTestId('scoreboard-component')).toBeInTheDocument(); | ||
}); | ||
|
||
}); | ||
}); |
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,41 +1,44 @@ | ||
import { useState } from "react"; | ||
import Game from "../game/singleplayer/GameSinglePlayer"; | ||
import {GroupsPage} from "../../pages/groups/index"; | ||
import { GroupsPage } from "../../pages/groups/index"; | ||
import Scoreboard from "../scoreboard/Scoreboard"; | ||
|
||
|
||
const GameLayout = () => { | ||
const [currentView, setCurrentView] = useState("Game"); | ||
|
||
const [currentView, setCurrentView] = useState("Game"); | ||
|
||
return( | ||
<head className="GameHead"> | ||
<nav className="GameNav"> | ||
<ul> | ||
return ( | ||
<div> | ||
<header className="GameHead"> | ||
<nav className="GameNav"> | ||
<ul> | ||
<li> | ||
<p>Game</p> | ||
<p data-testid="game-header">Game</p> | ||
</li> | ||
<li> | ||
<a onClick={()=>setCurrentView("Game")}>Game</a> | ||
<a data-testid="game-link" onClick={() => setCurrentView("Game")}> | ||
Game | ||
</a> | ||
</li> | ||
<li> | ||
<a onClick={()=>setCurrentView("Group")} >Groups</a> | ||
<a data-testid="groups-link" onClick={() => setCurrentView("Group")}> | ||
Groups | ||
</a> | ||
</li> | ||
<li> | ||
<a onClick={()=>setCurrentView("Scoreboard")}>Scoreboard</a> | ||
<a data-testid="scoreboard-link" onClick={() => setCurrentView("Scoreboard")}> | ||
Scoreboard | ||
</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
|
||
import Game from "./Game"; // Import the 'Game' component | ||
|
||
<body> | ||
{currentView === "Game" ? <Game /> : | ||
currentView === "Group" ? <GroupsPage /> : | ||
<Scoreboard />} | ||
</body> | ||
</head> | ||
</ul> | ||
</nav> | ||
</header> | ||
<main> | ||
{currentView === "Game" ? <Game /> : currentView === "Group" ? <GroupsPage data-testid="groups-page-component" /> : | ||
<Scoreboard data-testid="scoreboard-component"/>} | ||
</main> | ||
</div> | ||
); | ||
}; | ||
|
||
) | ||
export default GameLayout; | ||
|
||
}; export default GameLayout; // Export the 'GameLayout' component |
Empty file.
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,29 @@ | ||
import { render,screen,within } from '@testing-library/react'; | ||
import ScoreboardGame from './ScoreboardGame'; | ||
|
||
describe('ScoreboardGame component', () => { | ||
it('renders correctly with single player scores', () => { | ||
const mockUserScoresSinglePlayer = [ | ||
{ username: 'Player 1', points: 100 }, | ||
{ username: 'Player 2', points: 80 }, | ||
{ username: 'Player 3', points: 120 }, | ||
]; | ||
|
||
const { getByTestId, getAllByTestId } = render( | ||
<ScoreboardGame userScoresSinglePlayer={mockUserScoresSinglePlayer} /> | ||
); | ||
|
||
// Verificar que el caption está presente | ||
expect(getByTestId('scoreboard-caption')).toBeInTheDocument(); | ||
|
||
// Verificar que todas las filas de la tabla están presentes | ||
const tableRows = getAllByTestId(/position-\d+/); | ||
expect(tableRows.length).toBe(mockUserScoresSinglePlayer.length); // No hay fila de encabezado en este caso | ||
|
||
// Verificar que los tres nombres de usuario estén presentes en la vista | ||
mockUserScoresSinglePlayer.forEach((score) => { | ||
const usernameCell = screen.getByText(score.username); | ||
expect(usernameCell).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
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.