Skip to content

Commit

Permalink
use local fetch in e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr0nox committed Jan 24, 2025
1 parent 7dd9125 commit 364f403
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 19 deletions.
2 changes: 0 additions & 2 deletions report-viewer/tests/e2e/Cluster.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { test, expect } from '@playwright/test'
import { uploadFile } from './TestUtils'

test('Test cluster view', async ({ page }) => {
await page.goto('/')

await uploadFile('result_small_cluster.zip', page)

// check for all clusters being shown
Expand Down
2 changes: 0 additions & 2 deletions report-viewer/tests/e2e/Comparison.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { test, expect, Page } from '@playwright/test'
import { uploadFile } from './TestUtils'

test('Test comparison table and comparsion view', async ({ page }) => {
await page.goto('/')

await uploadFile('progpedia-report.zip', page)

const comparisonContainer = page.getByText('Hide AllSort By')
Expand Down
2 changes: 0 additions & 2 deletions report-viewer/tests/e2e/Distribution.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { uploadFile } from './TestUtils'

test('Test distribution diagram', async ({ page }) => {
test.slow()
await page.goto('/')

await uploadFile('progpedia-report.zip', page)

const options = getTestCombinations()
Expand Down
1 change: 0 additions & 1 deletion report-viewer/tests/e2e/Information.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { expect, test } from '@playwright/test'
import { uploadFile } from './TestUtils'

test('Test information page', async ({ page }) => {
await page.goto('/')
await uploadFile('progpedia-report.zip', page)

// check displayed information on overview page
Expand Down
2 changes: 0 additions & 2 deletions report-viewer/tests/e2e/OpenComparisonTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ const testSets: DataSet[] = [

for (const testSet of testSets) {
test(`Can open ${testSet.datasetName}`, async ({ page }) => {
await page.goto('/')

await uploadFile(testSet.datasetName, page)

const comparisonTable = await page.getByText('Cluster1').textContent()
Expand Down
2 changes: 0 additions & 2 deletions report-viewer/tests/e2e/OpenOldReport.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const oldVersionZips = [

for (const oldVersion of oldVersionZips) {
test(`Test old version redirect for v${oldVersion.version}`, async ({ page }) => {
await page.goto('/')
await uploadFile(oldVersion.zipName, page, '/old/' + oldVersion.version)

const bodyContent = await page.locator('body').textContent()
Expand All @@ -34,7 +33,6 @@ for (const oldVersion of oldVersionZips) {
}

test('Test unsupported old version', async ({ page }) => {
await page.goto('/')
await uploadFile('progpedia-report-v4_0_0.zip', page, '/old/4.0.0')

const bodyContent = await page.locator('body').textContent()
Expand Down
1 change: 0 additions & 1 deletion report-viewer/tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ If you want to add new tests we suggest doing the following tests:
- The test should start like this
```typescript
test('Name of the test', async ({ page }) => {
await page.goto('/')
await uploadFile('YOUR_DATASET_NAME-report.zip', page)
// Your test code
});
Expand Down
18 changes: 11 additions & 7 deletions report-viewer/tests/e2e/TestUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Page, expect } from '@playwright/test'
import { Page } from '@playwright/test'

/**
* Selects a file in the file chooser and uploads it.
Expand All @@ -7,13 +7,17 @@ import { Page, expect } from '@playwright/test'
* @param fileName
*/
export async function uploadFile(fileName: string, page: Page, expectedURL: string = '/overview') {
expect(page).toHaveURL('/')
page.route('**/results.zip', async (route) => {
await route.fulfill({
// fullfill with the file
path: `./tests/e2e/assets/${fileName}`,
headers: {
'Content-Type': 'application/zip'
}
})
})

// upload file through file chooser
const fileChooserPromise = page.waitForEvent('filechooser')
await page.getByText('Drag and Drop zip/Json file on this page').click()
const fileChooser = await fileChooserPromise
await fileChooser.setFiles(`tests/e2e/assets/${fileName}`)
await page.goto('/')

await page.waitForURL(expectedURL)
}

0 comments on commit 364f403

Please sign in to comment.