Skip to content

Commit

Permalink
test: use PLAYWRIGHT_APP_BACKEND
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraS committed Aug 15, 2024
1 parent a726779 commit 77de588
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Install all Playwright dependencies and chromium to run tests.
npm run test:e2e:install
```

Run tests. If `PLAYWRIGHT_BASE_URL` is provided, tests run on this url, otherwise Playwright `webServer` is started with `npm run dev` on `http://localhost:3000` and all tests run there.
Run tests. If `PLAYWRIGHT_BASE_URL` is provided, tests run on this url, otherwise Playwright `webServer` is started with `npm run dev` on `http://localhost:3000` and all tests run there. If `PLAYWRIGHT_APP_BACKEND` is provided, tests will be use this url as backend, otherwise `http://localhost:8765` will be used.

```
npm run test:e2e
Expand Down
10 changes: 5 additions & 5 deletions tests/suites/tenant/initialLoad.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {expect, test} from '@playwright/test';

import {tenantName} from '../../utils/constants';
import {backend, tenantName} from '../../utils/constants';

import {TenantPage} from './TenantPage';

Expand All @@ -10,7 +10,7 @@ const pageQueryParams = {
tenantPage: 'diagnostics',
};

test.describe('Tenant initial load', () => {
test.describe.only('Tenant initial load', () => {
test('Tenant diagnostics page is visible', async ({page}) => {
const tenantPage = new TenantPage(page);
await tenantPage.goto(pageQueryParams);
Expand All @@ -19,7 +19,7 @@ test.describe('Tenant initial load', () => {
});

test('Tenant diagnostics page is visible when describe returns no data', async ({page}) => {
await page.route('http://localhost:8765/viewer/json/describe?*', async (route) => {
await page.route(`${backend}/viewer/json/describe?*`, async (route) => {
await route.fulfill({json: ''});
});

Expand All @@ -30,7 +30,7 @@ test.describe('Tenant initial load', () => {
});

test('Tenant page shows error message when describe returns 401', async ({page}) => {
await page.route('http://localhost:8765/viewer/json/describe?*', async (route) => {
await page.route(`${backend}/viewer/json/describe?*`, async (route) => {
await route.fulfill({status: 401});
});

Expand All @@ -42,7 +42,7 @@ test.describe('Tenant initial load', () => {
});

test('Tenant page shows error message when describe returns 403', async ({page}) => {
await page.route('http://localhost:8765/viewer/json/describe?*', async (route) => {
await page.route(`${backend}/viewer/json/describe?*`, async (route) => {
await route.fulfill({status: 403});
});

Expand Down
3 changes: 3 additions & 0 deletions tests/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ export const tenantPage = 'tenant';

// Entities
export const tenantName = '/local';

// URLs
export const backend = process.env.PLAYWRIGHT_APP_BACKEND || 'http://localhost:8765';

0 comments on commit 77de588

Please sign in to comment.