Skip to content

Commit

Permalink
Merge pull request #46 from WildCodeSchool/41_landing_testing
Browse files Browse the repository at this point in the history
41 landing testing
  • Loading branch information
MaximeG971 authored Jul 12, 2024
2 parents 6ede830 + 687e296 commit 3d6068c
Show file tree
Hide file tree
Showing 11 changed files with 8,793 additions and 11,919 deletions.
4 changes: 3 additions & 1 deletion docker-compose.e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
db:
image: postgres
healthcheck:
test: [ "CMD-SHELL", "pg_isready -d postgres -U postgres" ]
test: ["CMD-SHELL", "pg_isready -d postgres -U postgres"]
interval: 1s
timeout: 2s
retries: 100
Expand All @@ -38,6 +38,8 @@ services:

files:
build: ./files
volumes:
- ./files/src:/app/src
healthcheck:
test: "curl --fail --request GET --url 'http://localhost:3000' || exit 1"
interval: 1s
Expand Down
133 changes: 67 additions & 66 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,68 @@
services:
backend:
build: ./backend
volumes:
- ./backend/src:/app/src
env_file:
- ./backend/.env
healthcheck:
test: 'curl --fail --request POST --header ''content-type: application/json'' --url ''http://localhost:4000/graphql'' --data ''{"query":"query { __typename }"}'' || exit 1'
interval: 1s
timeout: 2s
retries: 100
depends_on:
db:
condition: service_healthy
frontend:
build: ./frontend
volumes:
- ./frontend/src:/app/src
depends_on:
backend:
condition: service_healthy
healthcheck:
test: "curl --fail --request GET --url 'http://localhost:5173' || exit 1"
interval: 1s
timeout: 2s
retries: 100
db:
image: postgres
healthcheck:
test: [ "CMD-SHELL", "pg_isready -d postgres -U postgres" ]
interval: 1s
timeout: 2s
retries: 100
environment:
POSTGRES_PASSWORD: postgres
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
- ./postgres-data/data:/var/lib/postgresql/data
adminer:
image: adminer
ports:
- "8080:8080"
files:
build: ./files
volumes:
- ./files/src:/app/src
healthcheck:
test: "curl --fail --request GET --url 'http://localhost:3000' || exit 1"
interval: 1s
timeout: 2s
retries: 100
env_file:
- ./files/.env
apigateway:
image: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
depends_on:
backend:
condition: service_healthy
frontend:
condition: service_healthy
files:
condition: service_healthy
ports:
- "7002:80"
backend:
build: ./backend
volumes:
- ./backend/src:/app/src
env_file:
- ./backend/.env
healthcheck:
test: 'curl --fail --request POST --header ''content-type: application/json'' --url ''http://localhost:4000/graphql'' --data ''{"query":"query { __typename }"}'' || exit 1'
interval: 1s
timeout: 2s
retries: 100
depends_on:
db:
condition: service_healthy
frontend:
build: ./frontend
volumes:
- ./frontend/src:/app/src
depends_on:
backend:
condition: service_healthy
healthcheck:
test: "curl --fail --request GET --url 'http://localhost:5173' || exit 1"
interval: 1s
timeout: 2s
retries: 100
db:
image: postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready -d postgres -U postgres"]
interval: 1s
timeout: 2s
retries: 100
environment:
POSTGRES_PASSWORD: postgres
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
- ./postgres-data/data:/var/lib/postgresql/data
adminer:
image: adminer
ports:
- "8080:8080"
files:
build: ./files
volumes:
- ./files/src:/app/src
- ./files/uploads:/app/uploads
healthcheck:
test: "curl --fail --request GET --url 'http://localhost:3000' || exit 1"
interval: 1s
timeout: 2s
retries: 100
env_file:
- ./files/.env
apigateway:
image: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
depends_on:
backend:
condition: service_healthy
frontend:
condition: service_healthy
files:
condition: service_healthy
ports:
- "7002:80"
38 changes: 38 additions & 0 deletions e2e/tests/LandingPage.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { test, expect } from "@playwright/test";
import path from "path";
import fs from "fs";

test("Landing page", async ({ page }) => {
await page.goto("http://apigateway/");
await page.waitForLoadState("networkidle");

const emailInput = page.getByPlaceholder("Your email");
const emailToInput = await page.isVisible('text="Receivers emails"');
const titleInput = page.getByPlaceholder("Title");
const messageInput = page.getByPlaceholder("Message");
const uploadDragger = page.locator(".ant-upload-drag");
const transferButton = page.locator('button:has-text("Transfer")');

await expect(emailInput).toBeVisible();
await expect(emailToInput).toBe(true);
await expect(titleInput).toBeVisible();
await expect(messageInput).toBeVisible();
await expect(uploadDragger).toBeVisible();
await expect(transferButton).toBeVisible();

await emailInput.fill("[email protected]");
await titleInput.fill("Ton document");
await messageInput.fill("Hello, voici ton document");

const filePath = path.dirname("/app/tests/testFile.txt");
console.log("Chemin du fichier", filePath);

if (!fs.existsSync(filePath)) {
console.error(`Le fichier n'existe pas: ${filePath}`);
throw new Error(`Le fichier n'existe pas: ${filePath}`);
} else {
console.log(`Le fichier existe: ${filePath}`);
}

await transferButton.click();
});
1 change: 1 addition & 0 deletions e2e/tests/testFile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fichier de test pour upload
1 change: 1 addition & 0 deletions files/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uploads/
Loading

0 comments on commit 3d6068c

Please sign in to comment.