This commit is contained in:
pro.boooooo 2024-05-12 16:08:44 +02:00
parent 002dce7084
commit 0c860ac593
15 changed files with 564 additions and 1563 deletions

View File

@ -1,9 +1,3 @@
# Projet BUT 3
## Acces en ligne
(ici)[https://www.google.com]
## Demarrer en local ## Demarrer en local
### Cloner le projet git ### Cloner le projet git
@ -16,21 +10,18 @@
### Installation des dependences ### Installation des dependences
```bash ```bash
pnpm install npm install
``` ```
### Demarrer le front-end ### Demarrer le front-end
Alors ici il y a un petit soucis que j'arrive pas a localiser, quand le front se demarre, une requete /authenticated doit etre faite.
Quand le projet se demarre et que je tente d'acceder au site, la requete ne s'envoie pas. M'obligeant donc a refresh la page puis me diriger vers /login manuellement.
```bash ```bash
pnpm run dev npm run dev
```
### Test
```
``` ```
## Membre ## Membre
Bilal Boudjemline Bilal Boudjemline (solo)

1256
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -8,10 +8,6 @@
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"test": "vitest",
"test-e2e": "npx playwright test",
"show-e2e": "npx playwright show-report",
"ui-test": "npx playwright test --ui",
"preview": "vite preview", "preview": "vite preview",
"format": "prettier --write 'src/**/*.{js,jsx}'", "format": "prettier --write 'src/**/*.{js,jsx}'",
"prepare": "husky install" "prepare": "husky install"
@ -29,8 +25,6 @@
"sass": "^1.72.0" "sass": "^1.72.0"
}, },
"devDependencies": { "devDependencies": {
"@playwright/test": "^1.42.1",
"@testing-library/react": "^14.1.2",
"@types/node": "^20.11.9", "@types/node": "^20.11.9",
"@types/react": "^18.2.43", "@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17", "@types/react-dom": "^18.2.17",

View File

@ -1,50 +0,0 @@
// @ts-check
import { defineConfig, devices } from "@playwright/test";
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
/**
* @see https://playwright.dev/docs/test-configuration
*/
export default defineConfig({
testDir: "./tests",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: "http://127.0.0.1:3000",
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
},
outputDir: "./tests/traces",
/* Configure projects for major browsers */
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
],
//Run your local dev server before starting the tests /
webServer: {
command: "npm run dev",
url: "http://127.0.0.1:3000",
reuseExistingServer: !process.env.CI,
},
});

706
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
import { MagnifyingGlass } from "react-loader-spinner"; import { MagnifyingGlass } from "react-loader-spinner";
import "./LoaderSpace.scss"; import "./LoaderSpace.scss";
import React from "react";
export default function LoaderSpace({ isVisible, isCenterLoader }) { export default function LoaderSpace({ isVisible, isCenterLoader }) {
return ( return (

View File

@ -35,8 +35,10 @@ export const AuthenticationProvider = ({ children }) => {
const login = async (email, password) => { const login = async (email, password) => {
try { try {
const user = await loginApi(email, password); const user = await loginApi(email, password);
if (typeof user !== "string") {
setAuthState({ user }); setAuthState({ user });
redirect(); redirect();
}
} catch (error) { } catch (error) {
console.error("Erreur lors de la connexion :", error); console.error("Erreur lors de la connexion :", error);
setAuthState({ user: undefined }); setAuthState({ user: undefined });

View File

@ -20,6 +20,7 @@ export const Home = () => {
getState().then((res) => { getState().then((res) => {
try { try {
console.log(res);
setIsLoad(false); setIsLoad(false);
setDataset(res); setDataset(res);
setupRoomsStats(res.rooms); setupRoomsStats(res.rooms);

View File

@ -31,7 +31,7 @@ export default function Rooms() {
createRoom(name).then((res) => { createRoom(name).then((res) => {
setIsErr(false); setIsErr(false);
const values = [...rooms]; let values = rooms ? [...rooms] : [];
values.push(res); values.push(res);
setRooms(values); setRooms(values);
alert(`Creation de la piece ${name} reussite !`); alert(`Creation de la piece ${name} reussite !`);

View File

@ -1,32 +0,0 @@
// @ts-check
import { test, expect } from "@playwright/test";
test("Test de connexion", async ({ page }) => {
const account = "Bilouuuuuuu94!@@";
await page.goto("/login");
await page.waitForURL("/login");
await page
.locator(
"#layout-container > main > div > form > input[type=text]:nth-child(1)",
)
.fill(account);
await page
.locator(
"#layout-container > main > div > form > input[type=password]:nth-child(2)",
)
.fill(account);
await page.locator("#layout-container > main > div > form > button").click({
button: "left",
});
await page.waitForURL("/");
expect(await page.title()).toBe("Accueil");
expect(await page.locator("#title").innerText()).toBe(`Bonjour ${account} !`);
test.setTimeout(10000);
await page.waitForURL("/");
});

View File

@ -1,33 +0,0 @@
// @ts-check
import { test, expect } from "@playwright/test";
test("Test de connexion", async ({ page }) => {
const account = "Eheheh9400$$!@@";
await page.goto("/register");
await page.waitForURL("/register");
await page
.locator(
"#layout-container > main > div > form > input[type=text]:nth-child(1)",
)
.fill(account);
await page
.locator(
"#layout-container > main > div > form > input[type=password]:nth-child(2)",
)
.fill(account);
await page
.locator(
"#layout-container > main > div > form > input[type=password]:nth-child(3)",
)
.fill(account);
await page
.locator("#layout-container > main > div > form > button")
.click({ button: "left" });
await page.waitForURL("/");
expect(await page.title()).toBe("Accueil");
expect(await page.locator("#title").innerText()).toBe(`Bonjour ${account} !`);
});

View File

@ -1,9 +0,0 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
export default defineConfig({
server: {
port: 3001,
},
plugins: [react()],
});