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 branch 'develop' into Fernando-Monitorización
- Loading branch information
Showing
18 changed files
with
185 additions
and
73 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -30,18 +30,18 @@ defineFeature(feature, test => { | |
|
||
given('An unregistered user', async () => { | ||
username = "[email protected]" | ||
password = "pabloasw" | ||
password = "pabloasw1" | ||
await expect(page).toClick("button", { text: "REGÍSTRATE" }); | ||
}); | ||
|
||
when('I fill the data in the form and press submit', async () => { | ||
await expect(page).toFill('input[name="username"]', username); | ||
await expect(page).toFill('input[name="password"]', password); | ||
await expect(page).toClick('button', { text: 'Add User' }) | ||
await expect(page).toClick('button', { text: 'Crear' }) | ||
}); | ||
|
||
then('A confirmation message should be shown in the screen', async () => { | ||
await expect(page).toMatchElement("div", { text: "User added successfully" }); | ||
await expect(page).toMatchElement("div", { text: "Usuario creado correctamente" }); | ||
}); | ||
}) | ||
|
||
|
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 |
---|---|---|
|
@@ -30,18 +30,18 @@ defineFeature(feature, test => { | |
|
||
given('A user that is logged in the application', async () => { | ||
username = "[email protected]" | ||
password = "pabloasw" | ||
password = "pabloasw1" | ||
await expect(page).toClick("button", { text: "INICIA SESIÓN" }); | ||
}); | ||
|
||
when('I enter valid username and password', async () => { | ||
await expect(page).toFill('input[name="username"]', username); | ||
await expect(page).toFill('input[name="password"]', password); | ||
await expect(page).toClick('button', { text: 'Login' }) | ||
await expect(page).toClick('button', { text: 'Iniciar Sesión' }) | ||
}); | ||
|
||
then('A confirmation message should be shown in the screen', async () => { | ||
await expect(page).toMatchElement("div", { text: "Hello "+username+"!" }); | ||
await expect(page).toMatchElement("div", { text: "¡Buenas, "+username+"!" }); | ||
}); | ||
}) | ||
|
||
|
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 |
---|---|---|
|
@@ -30,14 +30,14 @@ defineFeature(feature, test => { | |
|
||
given('A user that is logged in the application', async () => { | ||
username = "[email protected]" | ||
password = "pabloasw" | ||
password = "pabloasw1" | ||
await expect(page).toClick("button", { text: "INICIA SESIÓN" }); | ||
}); | ||
|
||
when('I navigate to the Home page', async () => { | ||
await expect(page).toFill('input[name="username"]', username); | ||
await expect(page).toFill('input[name="password"]', password); | ||
await expect(page).toClick('button', { text: 'Login' }) | ||
await expect(page).toClick('button', { text: 'Iniciar Sesión' }) | ||
|
||
await expect(page).toClick('a[href="/"]', { text: 'WIQ 5A' }); | ||
await page.waitForNavigation(); | ||
|
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,68 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import App from './App'; | ||
|
||
/*test('renders learn react link', () => { | ||
render(<App />); | ||
const linkElement = screen.getByText(/Welcome to the 2024 edition of the Software Architecture course/i); | ||
expect(linkElement).toBeInTheDocument(); | ||
}); | ||
*/ | ||
|
||
describe('App', () => { | ||
|
||
it('renders login page when not logged in', () => { | ||
render( | ||
<MemoryRouter> | ||
<App /> | ||
</MemoryRouter> | ||
); | ||
|
||
expect(screen.getByText(/Login/i)).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders home page when logged in', () => { | ||
// Mock local storage to simulate being logged in | ||
const mockLocalStorage = { | ||
getItem: jest.fn(() => 'true'), | ||
setItem: jest.fn(), | ||
clear: jest.fn() | ||
}; | ||
global.localStorage = mockLocalStorage; | ||
|
||
render( | ||
<MemoryRouter> | ||
<App /> | ||
</MemoryRouter> | ||
); | ||
|
||
expect(screen.getByText(/Home/i)).toBeInTheDocument(); | ||
}); | ||
|
||
it('redirects to login when trying to access stats page without logging in', () => { | ||
render( | ||
<MemoryRouter initialEntries={['/stats']}> | ||
<App /> | ||
</MemoryRouter> | ||
); | ||
|
||
expect(screen.getByText(/Login/i)).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders stats page when logged in and trying to access stats page', () => { | ||
// Mock local storage to simulate being logged in | ||
const mockLocalStorage = { | ||
getItem: jest.fn(() => 'true'), | ||
setItem: jest.fn(), | ||
clear: jest.fn() | ||
}; | ||
global.localStorage = mockLocalStorage; | ||
|
||
render( | ||
<MemoryRouter initialEntries={['/stats']}> | ||
<App /> | ||
</MemoryRouter> | ||
); | ||
|
||
expect(screen.getByText(/Estadisticas/i)).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
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.