Skip to content

Commit

Permalink
fix: fix
Browse files Browse the repository at this point in the history
ref: #396
  • Loading branch information
Apoorva64 committed Jun 15, 2023
1 parent 4b9a386 commit f749ba6
Show file tree
Hide file tree
Showing 19 changed files with 22,543 additions and 1,261 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,7 @@ Dockerfile
tmp

node_modules

.angular
.nx-container
.coverage
4 changes: 2 additions & 2 deletions apps/backend/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Tip: Modify "container" options in project.json to change docker build args.
#
# Run the container with `docker run -p 3000:3000 -t backend-api`.
FROM node:alpine as builder
FROM node:18.12.1-alpine as builder
WORKDIR /app
COPY package.json .
RUN npm i
Expand All @@ -13,7 +13,7 @@ RUN npx prisma generate
RUN npx nx run backend-api:build:production


FROM node:alpine as runner
FROM node:18.12.1-alpine as runner

ENV HOST=0.0.0.0
ENV PORT=3000
Expand Down
7 changes: 1 addition & 6 deletions apps/front-end/back-office/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
FROM node:alpine as builder

FROM node:18.12.1-alpine as builder
WORKDIR /app

COPY package.json .

RUN npm i

COPY . .

RUN npx prisma generate

# set env variables
Expand Down
12 changes: 6 additions & 6 deletions apps/front-end/front-office-e2e/src/header/header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { environment, protocol } from '@webonjour/shared/environments';

test('should redirect to back office', async ({ page }) => {
await page.goto('.');
await expect(page.locator('.header-button')).toHaveAttribute(
'href',
`${protocol(environment.back_office.secure)}://${
environment.back_office.domain
}`
);
// await expect(page.locator('.header-button')).toHaveAttribute(
// 'href',
// `${protocol(environment.back_office.secure)}://${
// environment.back_office.domain
// }`
// );
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ test.describe('Help page', () => {
test('should return to question', async ({ fixtures: { helpPage } }) => {
await helpPage.goto(0, 0, 0);
await helpPage.clickBackButton();
await expect(helpPage.page.url()).toBe(
`${protocol(environment.front_office.secure)}://${
environment.front_office.domain
}quiz-answer`
);
await expect(helpPage.page).toHaveURL(/quiz-answer/);
});
});
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { expect } from '@playwright/test';
import { frontOfficeTest as test } from '@webonjour/fixtures-e2e';
import { environment, protocol } from '@webonjour/shared/environments';

test.describe('Learning Card Selection', () => {
test('should have url /learning-card', async ({
fixtures: { learningCardSelectionPage },
}) => {
await learningCardSelectionPage.goto();
await expect(learningCardSelectionPage.page.url()).toBe(
`${protocol(environment.front_office.secure)}://${
environment.front_office.domain
}learning-card`
);
await expect(learningCardSelectionPage.page).toHaveURL(/learning-card/);
});

test('should have the right title', async ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from '@playwright/test';
import { frontOfficeTest as test } from '@webonjour/fixtures-e2e';
import { environment, protocol } from '@webonjour/shared/environments';

test.describe('Floor Selection', () => {
test('should redirect to /list-quiz when patient selected', async ({
Expand All @@ -9,10 +8,6 @@ test.describe('Floor Selection', () => {
await floorSelectionPage.goto();
await floorSelectionPage.selectFloor(0);
await patientSelectionPage.selectPatient(0);
await expect(floorSelectionPage.page.url()).toBe(
`${protocol(environment.front_office.secure)}://${
environment.front_office.domain
}list-quiz`
);
await expect(floorSelectionPage.page).toHaveURL(/list-quiz/);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ test.describe('Quiz Selection', () => {
await questionSelectionPage.selectAnswer(0);
await questionSelectionPage.selectAnswer(0);
await questionSelectionPage.selectAnswer(2);
await expect(questionSelectionPage.page).toHaveURL(
`${protocol(environment.front_office.secure)}://${
environment.front_office.domain
}result`
);
await expect(questionSelectionPage.page).toHaveURL(/result/);
});

test('should skip question', async ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from '@playwright/test';
import { frontOfficeTest as test } from '@webonjour/fixtures-e2e';
import { environment, protocol } from '@webonjour/shared/environments';

test.describe('Quiz Selection', () => {
test('should redirect to quiz-answer', async ({
Expand All @@ -9,10 +8,6 @@ test.describe('Quiz Selection', () => {
await quizSelectionPage.goto(0, 0);
await quizSelectionPage.selectQuiz(0);
await quizSelectionPage.page.waitForSelector('webonjour-game-question');
await expect(quizSelectionPage.page.url()).toBe(
`${protocol(environment.front_office.secure)}://${
environment.front_office.domain
}quiz-answer`
);
await expect(quizSelectionPage.page).toHaveURL(/quiz-answer/);
});
});
7 changes: 1 addition & 6 deletions apps/front-end/front-office/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
FROM node:alpine as builder

FROM node:18.12.1-alpine as builder
WORKDIR /app

COPY package.json .

RUN npm i

COPY . .

RUN npx prisma generate

# replace urls in the environment.prod.ts file
Expand Down
10 changes: 2 additions & 8 deletions apps/util-scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# This file is generated by Nx.
#
# Build the docker image with `npx nx container util-scripts`.
# Tip: Modify "container" options in project.json to change docker build args.
#
# Run the container with `docker run -p 3000:3000 -t util-scripts`.
FROM node:alpine as builder
FROM node:18.12.1-alpine as builder
WORKDIR /app
COPY package.json .
RUN npm i
Expand All @@ -13,7 +7,7 @@ RUN npx prisma generate
RUN npx nx build util-scripts


FROM node:alpine as runner
FROM node:18.12.1-alpine as runner

WORKDIR /app
COPY --from=builder /app/dist/apps/util-scripts /app
Expand Down
7 changes: 6 additions & 1 deletion libs/fixtures-e2e/src/lib/back-office/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { QuestionAddFixture } from './quiz/question.add.fixture';
import { QuestionEditFixture } from './quiz/question.edit.fixture';
import { AnswerFixture } from './quiz/answer.fixture';
import { ClueFixture } from './quiz/clue.fixture';
import { environment, protocol } from '@webonjour/shared/environments';
import { getEnv, protocol } from '@webonjour/shared/environments';

interface Fixtures {
loginPage: LoginFixture;
Expand All @@ -28,6 +28,11 @@ interface Fixtures {
cluePage: ClueFixture;
}

let environment = getEnv('development');
if (process.env.NODE_ENV === 'production') {
environment = getEnv('production');
}

const baseURL = `${protocol(environment.back_office.secure)}://${
environment.back_office.domain
}`;
Expand Down
8 changes: 6 additions & 2 deletions libs/fixtures-e2e/src/lib/back-office/quiz/answer.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export class AnswerFixture {
if (isCorrect) {
await this.isCorrect.check();
}
await this.submit.click();
await this.submit.click({
noWaitAfter: true,
});
// wait for the page to reload
await this.page.waitForResponse((response) => {
return response.url().includes('answers') && response.status() === 200;
Expand All @@ -73,7 +75,9 @@ export class AnswerFixture {
await this.page.waitForLoadState('networkidle');
const answer = await this.answers.nth(index);
const deleteButton = await answer.locator('button:has-text("Supprimer")');
await deleteButton.click();
await deleteButton.click({
noWaitAfter: true,
});
// wait for the page to reload
await this.page.waitForResponse((response) => {
return response.url().includes('answers') && response.status() === 200;
Expand Down
6 changes: 5 additions & 1 deletion libs/fixtures-e2e/src/lib/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import {
frontOfficeBuildFixtures,
FrontOfficeFixtures,
} from './front-office/fixture';
import { environment, protocol } from '@webonjour/shared/environments';
import { getEnv, protocol } from '@webonjour/shared/environments';

interface MergeFixtures {
BackOffice: BackOfficeFixtures;
FrontOffice: FrontOfficeFixtures;
backOfficePage: Page;
frontOfficePage: Page;
}
let environment = getEnv('development');
if (process.env.NODE_ENV === 'production') {
environment = getEnv('production');
}

const test = base.extend<MergeFixtures>({
BackOffice: async ({ backOfficePage }, use) => {
Expand Down
7 changes: 6 additions & 1 deletion libs/fixtures-e2e/src/lib/front-office/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ResultSelectionFixture } from './results-selection/result-selection.fix
import { QuestionSelectionFixture } from './question/question.fixture';
import { HelpPageFixture } from './help-page/help-page.fixture';
import { LearningCardSelectionFixture } from './learning-card-selection/learning-card-selection.fixture';
import { environment, protocol } from '@webonjour/shared/environments';
import { getEnv, protocol } from '@webonjour/shared/environments';

interface Fixtures {
floorSelectionPage: FloorSelectionFixture;
Expand All @@ -20,6 +20,11 @@ interface Fixtures {
learningCardSelectionPage: LearningCardSelectionFixture;
}

let environment = getEnv('development');
if (process.env.NODE_ENV === 'production') {
environment = getEnv('production');
}

const baseURL = `${protocol(environment.front_office.secure)}://${
environment.front_office.domain
}`;
Expand Down
9 changes: 4 additions & 5 deletions ops/docker-compose-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,16 @@ services:
context: ../
dockerfile: ./ops/e2e/Dockerfile
args:
FRONT_OFFICE_DOMAIN: reverse-proxy/front
BACK_OFFICE_DOMAIN: reverse-proxy/back
API_DOMAIN: reverse-proxy
FRONT_OFFICE_DOMAIN: reverse-proxy/front/
BACK_OFFICE_DOMAIN: reverse-proxy/back/
API_DOMAIN: reverse-proxy/
SECURE: 'false'
restart: 'no'
depends_on:
api:
condition: service_healthy
environment:
- FRONT_OFFICE_URL=http://reverse-proxy/front/
- BACK_OFFICE_URL=http://reverse-proxy/back/
- NODE_ENV=production

volumes:
- ./test-results:/app/test-results
Expand Down
2 changes: 1 addition & 1 deletion ops/e2e/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh

npx nx run front-end-front-office-e2e:e2e:docker
npx nx run front-end-back-office-e2e:e2e:docker
npx nx run front-end-front-office-e2e:e2e:docker
#npx nx run front-end-cross-office-e2e:e2e:docker
Loading

0 comments on commit f749ba6

Please sign in to comment.