Skip to content

Commit

Permalink
feat: edit playwright config && fix test on quiz
Browse files Browse the repository at this point in the history
Ref. #383
  • Loading branch information
ozeliurs committed Jun 13, 2023
1 parent 199fd63 commit 2e41acd
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 13 deletions.
7 changes: 4 additions & 3 deletions apps/front-end/back-office-e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { PlaywrightTestConfig } from '@playwright/test';

import { baseConfig } from '../../../playwright.config.base';
import { environment, protocol } from '@webonjour/shared/environments';

const config: PlaywrightTestConfig = {
...baseConfig,
Expand All @@ -12,9 +13,9 @@ const config: PlaywrightTestConfig = {
),
use: {
...baseConfig.use,
ignoreHTTPSErrors: true,
video: 'on-first-retry',
screenshot: 'only-on-failure',
baseURL: `${protocol(environment.back_office.secure)}://${
environment.back_office.domain
}`,
},
};

Expand Down
31 changes: 31 additions & 0 deletions apps/front-end/back-office-e2e/src/quiz/quiz.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ test.describe('Quiz', () => {
test('should edit quiz', async ({ fixtures }) => {
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.updateQuiz(QUIZ_UPDATED_NAME);

await fixtures.quizPage.goto();
Expand All @@ -45,6 +46,7 @@ test.describe('Quiz', () => {
DEFAULT_QUIZ_COUNT + 1
);
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await expect(
await fixtures.quizEditPage.quizGeneralTitle.inputValue()
).toBe(QUIZ_UPDATED_NAME);
Expand All @@ -53,9 +55,11 @@ test.describe('Quiz', () => {
test('should add question to quiz', async ({ fixtures }) => {
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.questionAddPage.addQuestion('Question 1', 'CHOICE');
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.questions.last().waitFor({
state: 'visible',
});
Expand All @@ -65,12 +69,15 @@ test.describe('Quiz', () => {
test('should edit question', async ({ fixtures }) => {
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.questions.last().click();
await fixtures.questionEditPage.page.waitForLoadState('networkidle');
await fixtures.questionEditPage.updateQuestion('Question 2');
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.questions.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await expect(
await fixtures.questionEditPage.questionGeneralTitle.inputValue()
).toBe('Question 2');
Expand All @@ -79,7 +86,9 @@ test.describe('Quiz', () => {
test('should add answer to question', async ({ fixtures }) => {
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.questions.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.answerPage.addAnswer('Answer 1', true);
// wait for answer to be visible
await fixtures.answerPage.answers.last().waitFor({
Expand All @@ -92,11 +101,15 @@ test.describe('Quiz', () => {
test('should edit answer', async ({ fixtures }) => {
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.questions.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.answerPage.updateAnswer(0, 'Answer 2', false);
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.questions.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await expect(
await fixtures.answerPage.answers
.first()
Expand All @@ -109,18 +122,24 @@ test.describe('Quiz', () => {
test('should delete answer', async ({ fixtures }) => {
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.questions.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.answerPage.deleteAnswer(0);
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.questions.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
expect(await fixtures.answerPage.answers.count()).toBe(0);
});

test('should add clue to question', async ({ fixtures }) => {
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.questions.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.cluePage.addClue('Clue 1');
// wait for clue to be visible
await fixtures.cluePage.clues.last().waitFor({
Expand All @@ -132,11 +151,15 @@ test.describe('Quiz', () => {
test('should edit clue', async ({ fixtures }) => {
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.questions.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.cluePage.updateClue(0, 'Clue 2');
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.questions.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await expect(
await fixtures.cluePage.clues.first().locator('td').first().innerText()
).toBe('Clue 2');
Expand All @@ -145,27 +168,35 @@ test.describe('Quiz', () => {
test('should delete clue', async ({ fixtures }) => {
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.questions.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.cluePage.deleteClue(0);
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.questions.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
expect(await fixtures.cluePage.clues.count()).toBe(0);
});

test('should delete question', async ({ fixtures }) => {
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.questions.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.questionEditPage.deleteQuestion();
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
expect(await fixtures.quizEditPage.questions.count()).toBe(0);
});

test('should delete quiz', async ({ fixtures }) => {
await fixtures.quizPage.goto();
await fixtures.quizPage.quizzes.last().click();
await fixtures.quizPage.page.waitForLoadState('networkidle');
await fixtures.quizEditPage.deleteQuiz();
expect(await fixtures.quizPage.quizzes.count()).toBe(DEFAULT_QUIZ_COUNT);
});
Expand Down
3 changes: 0 additions & 3 deletions apps/front-end/cross-office-e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ const config: PlaywrightTestConfig = {
),
use: {
...baseConfig.use,
ignoreHTTPSErrors: true,
video: 'on-first-retry',
screenshot: 'only-on-failure',
},
};

Expand Down
7 changes: 7 additions & 0 deletions apps/front-end/front-office-e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { PlaywrightTestConfig } from '@playwright/test';

import { baseConfig } from '../../../playwright.config.base';
import { environment, protocol } from '@webonjour/shared/environments';

const config: PlaywrightTestConfig = {
...baseConfig,
Expand All @@ -10,6 +11,12 @@ const config: PlaywrightTestConfig = {
globalTeardown: require.resolve(
'apps/front-end/front-office-e2e/src/support/global-teardown.ts'
),
use: {
...baseConfig.use,
baseURL: `${protocol(environment.front_office.secure)}://${
environment.front_office.domain
}`,
},
};

export default config;
8 changes: 4 additions & 4 deletions libs/shared/environments/src/lib/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
export const environment = {
production: false,
front_office: {
port: 4200,
port: 4201,
host: '0.0.0.0',
domain: '127.0.0.1:4200',
domain: '127.0.0.1:4201',
secure: false,
},
back_office: {
port: 4201,
port: 4200,
host: '0.0.0.0',
domain: '127.0.0.1:4201',
domain: '127.0.0.1:4200',
secure: false,
},
api: {
Expand Down
6 changes: 3 additions & 3 deletions playwright.config.base.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { PlaywrightTestConfig } from '@playwright/test';

const baseURL = process.env.E2E_BASE_URL || 'http://127.0.0.1:4200/';

export const baseConfig: PlaywrightTestConfig = {
retries: 3,
maxFailures: 2,
timeout: 120000,
workers: 1,
use: {
baseURL,
ignoreHTTPSErrors: true,
video: 'on-first-retry',
screenshot: 'only-on-failure',
},
};

0 comments on commit 2e41acd

Please sign in to comment.