Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#270 fix playwright esm
  • Loading branch information
joepio committed Nov 28, 2022
commit 526357ec01f43d3f45a693ea1b18d60594cf7a28
2 changes: 1 addition & 1 deletion data-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"predeploy": "build && touch build/.nojekyll",
"preview": "vite preview",
"start": "vite",
"test": "playwright test",
"test": "playwright test --config=./tests/playwright.config.ts",
"test-debug": "PWDEBUG=1 playwright test",
"test-new": "playwright codegen http://localhost:5173",
"test-query": "PWDEBUG=1 npx playwright test \"e2e.spec.ts\" -g",
Expand Down
10 changes: 8 additions & 2 deletions data-browser/tests/e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// This file is copied from `atomic-data-browser` to `atomic-data-server` when `pnpm build-server` is run.
// This is why the `testConfig` is imported.

import { test, expect, Page, Browser } from '@playwright/test';
import { testConfig } from './test-config';
import { test, expect } from '@playwright/test';
import type { Browser, Page } from '@playwright/test';
import { testConfig } from './test-config.js';

export interface TestConfig {
demoFileName: string;
Expand Down Expand Up @@ -42,13 +43,16 @@ test.describe('data-browser', async () => {
if (!serverUrl) {
throw new Error('serverUrl is not set');
}

// Open the server
await page.goto(frontEndUrl);

// Sometimes we run the test server on a different port, but we should
// only change the drive if it is non-default.
if (serverUrl !== 'http://localhost:9883') {
await changeDrive(serverUrl, page);
}

await expect(page.locator(currentDriveTitle)).toBeVisible();
});

Expand Down Expand Up @@ -659,10 +663,12 @@ async function openNewSubjectWindow(browser: Browser, url: string) {
const context2 = await browser.newContext();
const page = await context2.newPage();
await page.goto(frontEndUrl);

// Only when we run on `localhost` we don't need to change drive during tests
if (serverUrl !== defaultDevServer) {
await changeDrive(serverUrl, page);
}

await openSubject(page, url);
await page.setViewportSize({ width: 1000, height: 400 });

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
use: {
Expand Down
2 changes: 1 addition & 1 deletion data-browser/tests/test-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TestConfig } from './e2e.spec';
import type { TestConfig } from './e2e.spec.js';
const demoFileName = 'testimage.svg';

export const testConfig: TestConfig = {
Expand Down
1 change: 1 addition & 0 deletions data-browser/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"include": [
"./src",
"./tests"
],
"references": [
{
Expand Down