Skip to content

Commit

Permalink
test: add api/config/proxy mock
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalinDe committed Dec 12, 2023
1 parent 7a27a9f commit 90c78a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
15 changes: 15 additions & 0 deletions web/frontend/tests/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,18 @@ export async function mockLogout (page: any) {
async route => {await route.fulfill({});}
);
}

export async function mockProxy (page: any) {
await page.route(
'/api/config/proxy',
async route => {
await route.fulfill(
{
status: 200,
contentType: 'text/html',
body: `${process.env.DELA_PROXY_URL}`,
headers: {'set-cookie': 'connect.sid=s%3A5srES5h7hQ2fN5T71W59qh3cUSQL3Mix.fPoO3rOxui8yfTG7tFd7RPyasaU5VTkhxgdzVRWJyNk'},
});
}
)
}
10 changes: 9 additions & 1 deletion web/frontend/tests/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import { test, expect } from '@playwright/test';
import en from './../src/language/en.json';
import fr from './../src/language/fr.json';
import de from './../src/language/de.json';
import { SCIPER_ADMIN, SCIPER_USER, mockPersonalInfo, mockGetDevLogin, mockLogout } from './mocks';
import {
SCIPER_ADMIN,
SCIPER_USER,
mockProxy,
mockPersonalInfo,
mockGetDevLogin,
mockLogout,
} from './mocks';

export function initI18n () {
i18n.init({
Expand All @@ -13,6 +20,7 @@ export function initI18n () {
}

export async function setUp(page: any, url: string) {
await mockProxy(page);
await mockGetDevLogin(page);
await mockLogout(page);
await page.goto(url);
Expand Down

0 comments on commit 90c78a6

Please sign in to comment.