Skip to content

Commit

Permalink
chore: Add e2e test for errors on Neuroglancer site (#1027)
Browse files Browse the repository at this point in the history
#1025

Had to add some startup flags to chromium so that WebGL is enabled (and
the Neuroglancer site actually loads).

Tried with firefox and webkit as well and both worked without any extra
flags.
  • Loading branch information
bchu1 authored Aug 13, 2024
1 parent 1e4a081 commit 572972d
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
14 changes: 14 additions & 0 deletions frontend/packages/data-portal/e2e/pageObjects/neuroglancerPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Locator } from '@playwright/test'

import { BasePage } from './basePage'

/** neuroglancer-demo.appspot.com */
export class NeuroglancerPage extends BasePage {
findViewer(): Locator {
return this.page.locator('.neuroglancer-viewer')
}

findErrorText(): Locator {
return this.page.getByText('Error')
}
}
15 changes: 15 additions & 0 deletions frontend/packages/data-portal/e2e/pageObjects/singleRunPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Locator } from '@playwright/test'
import { SINGLE_RUN_URL } from 'e2e/constants'

import { BasePage } from './basePage'

/** /runs/$id */
export class SingleRunPage extends BasePage {
async goToPage() {
await this.goTo(SINGLE_RUN_URL)
}

getPrimaryViewTomogramButton(): Locator {
return this.page.locator('a:has-text("View Tomogram")')
}
}
36 changes: 36 additions & 0 deletions frontend/packages/data-portal/e2e/singleRun.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { expect, test } from '@playwright/test'

import { NeuroglancerPage } from './pageObjects/neuroglancerPage'
import { SingleRunPage } from './pageObjects/singleRunPage'

test.describe('Single run page: ', () => {
let page: SingleRunPage
let neuroglancerPage: NeuroglancerPage
test.beforeEach(async ({ page: playwrightPage }) => {
page = new SingleRunPage(playwrightPage)
neuroglancerPage = new NeuroglancerPage(playwrightPage)
await page.goToPage()
})

/** This test ensures that the test after it is not a false negative. */
test('Invalid Neuroglancer URL results in error on Neuroglancer page', async () => {
await page.goTo(
(await page.getPrimaryViewTomogramButton().getAttribute('href'))!.replace(
'#!',
"#!'",
),
)

await expect(neuroglancerPage.findViewer()).toBeVisible()
await expect(neuroglancerPage.findErrorText()).toHaveCount(1)
})

test('Neuroglancer URL does not result in error on Neuroglancer page', async () => {
await page.goTo(
(await page.getPrimaryViewTomogramButton().getAttribute('href'))!,
)

await expect(neuroglancerPage.findViewer()).toBeVisible()
await expect(neuroglancerPage.findErrorText()).toHaveCount(0)
})
})
3 changes: 3 additions & 0 deletions frontend/packages/data-portal/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export default defineConfig({
name: 'chromium',
use: {
...devices['Desktop Chrome'],
launchOptions: {
args: ['--ignore-gpu-blocklist', '--use-gl=angle'],
},

contextOptions: {
permissions: ['clipboard-read', 'clipboard-write'],
Expand Down

0 comments on commit 572972d

Please sign in to comment.