|
1 | 1 | // This file is copied from `atomic-data-browser` to `atomic-data-server` when `pnpm build-server` is run. |
2 | 2 | // This is why the `testConfig` is imported. |
3 | 3 |
|
4 | | -import { test, expect, Page, Browser } from '@playwright/test'; |
5 | | -import { testConfig } from './test-config'; |
| 4 | +import { test, expect } from '@playwright/test'; |
| 5 | +import type { Browser, Page } from '@playwright/test'; |
| 6 | +import { testConfig } from './test-config.js'; |
6 | 7 |
|
7 | 8 | export interface TestConfig { |
8 | 9 | demoFileName: string; |
@@ -42,13 +43,16 @@ test.describe('data-browser', async () => { |
42 | 43 | if (!serverUrl) { |
43 | 44 | throw new Error('serverUrl is not set'); |
44 | 45 | } |
| 46 | + |
45 | 47 | // Open the server |
46 | 48 | await page.goto(frontEndUrl); |
| 49 | + |
47 | 50 | // Sometimes we run the test server on a different port, but we should |
48 | 51 | // only change the drive if it is non-default. |
49 | 52 | if (serverUrl !== 'http://localhost:9883') { |
50 | 53 | await changeDrive(serverUrl, page); |
51 | 54 | } |
| 55 | + |
52 | 56 | await expect(page.locator(currentDriveTitle)).toBeVisible(); |
53 | 57 | }); |
54 | 58 |
|
@@ -107,10 +111,11 @@ test.describe('data-browser', async () => { |
107 | 111 | await editProfileAndCommit(page); |
108 | 112 | }); |
109 | 113 |
|
110 | | - test('search', async ({ page }) => { |
111 | | - await page.fill(addressBar, 'setup'); |
112 | | - await page.click('text=setup'); |
113 | | - await expect(page.locator('text=Use this Invite')).toBeVisible(); |
| 114 | + test('text search', async ({ page }) => { |
| 115 | + await page.fill(addressBar, 'welcome'); |
| 116 | + await expect(page.locator('text=Welcome to your')).toBeVisible(); |
| 117 | + await page.keyboard.press('Enter'); |
| 118 | + await expect(page.locator('text=resources:')).toBeVisible(); |
114 | 119 | }); |
115 | 120 |
|
116 | 121 | test('scoped search', async ({ page }) => { |
@@ -329,8 +334,8 @@ test.describe('data-browser', async () => { |
329 | 334 | page.click('button:has-text("Upload file")'), |
330 | 335 | ]); |
331 | 336 | await fileChooser.setFiles(demoFile); |
332 | | - await page.click(`[data-test]:has-text("${demoFileName}")`); |
333 | | - const image = await page.locator('[data-test="image-viewer"]'); |
| 337 | + await page.click(`[data-test="file-pill"]:has-text("${demoFileName}")`); |
| 338 | + const image = page.locator('[data-test="image-viewer"]'); |
334 | 339 | await expect(image).toBeVisible(); |
335 | 340 | await expect(image).toHaveScreenshot({ maxDiffPixelRatio: 0.1 }); |
336 | 341 | }); |
@@ -382,10 +387,10 @@ test.describe('data-browser', async () => { |
382 | 387 | // Fetch `example.com |
383 | 388 | const input = page.locator('[placeholder="https\\:\\/\\/example\\.com"]'); |
384 | 389 | await input.click(); |
385 | | - await input.fill('https://example.com'); |
| 390 | + await input.fill('https://ontola.io'); |
386 | 391 | await page.locator(currentDialogOkButton).click(); |
387 | 392 |
|
388 | | - await expect(page.locator('text=This domain is ')).toBeVisible(); |
| 393 | + await expect(page.locator(':text-is("Full-service")')).toBeVisible(); |
389 | 394 | }); |
390 | 395 |
|
391 | 396 | test('folder', async ({ page }) => { |
@@ -520,7 +525,6 @@ test.describe('data-browser', async () => { |
520 | 525 | const d1 = 'depth1'; |
521 | 526 | await setTitle(d1); |
522 | 527 |
|
523 | | - // Not sure why we need this, I'd prefer to wait for commits... |
524 | 528 | await expect( |
525 | 529 | page.locator(`[data-test="sidebar"] >> text=${d1}`), |
526 | 530 | ).toBeVisible(); |
@@ -658,10 +662,12 @@ async function openNewSubjectWindow(browser: Browser, url: string) { |
658 | 662 | const context2 = await browser.newContext(); |
659 | 663 | const page = await context2.newPage(); |
660 | 664 | await page.goto(frontEndUrl); |
| 665 | + |
661 | 666 | // Only when we run on `localhost` we don't need to change drive during tests |
662 | 667 | if (serverUrl !== defaultDevServer) { |
663 | 668 | await changeDrive(serverUrl, page); |
664 | 669 | } |
| 670 | + |
665 | 671 | await openSubject(page, url); |
666 | 672 | await page.setViewportSize({ width: 1000, height: 400 }); |
667 | 673 |
|
|
0 commit comments