Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr0nox committed Nov 30, 2024
1 parent e6b12f7 commit 34dcbbe
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
5 changes: 4 additions & 1 deletion report-viewer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ coverage

test-results/
playwright-report/
tests/e2e/assets
tests/e2e/assets/*
!tests/e2e/assets/progpedia-report-v5_1_0.zip
!tests/e2e/assets/progpedia-report-v4_2_0.zip
!tests/e2e/assets/result_small_cluster.zip
32 changes: 32 additions & 0 deletions report-viewer/tests/e2e/OpenOldReport.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { expect, test } from '@playwright/test'
import { uploadFile } from './TestUtils'

const oldVersionZips = [
{
zipName: 'progpedia-report-v5_1_0.zip',
version: '5.1.0',
urlPostfix: 'v5'
},
{
zipName: 'progpedia-report-v4_2_0.zip',
version: '4.2.0',
urlPostfix: 'v5'
}
]

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()
expect(bodyContent).toContain('You are trying to open a report from an older version of JPlag')
expect(bodyContent).toContain(oldVersion.version)
expect(bodyContent).toContain('You can access the old report viewer here:')
expect(bodyContent).toContain('Open old report viewer')

const oldVersionLinkElement = await page.locator('a').first()
const oldVersionURL = await oldVersionLinkElement.getAttribute('href')
expect(oldVersionURL.endsWith('/v5/')).toBeTruthy()
})
}
4 changes: 2 additions & 2 deletions report-viewer/tests/e2e/TestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Page, expect } from '@playwright/test'
* Expects to be on the file upload page.
* @param fileName
*/
export async function uploadFile(fileName: string, page: Page) {
export async function uploadFile(fileName: string, page: Page, expectedURL: string = '/overview') {
expect(page).toHaveURL('/')

// upload file through file chooser
Expand All @@ -15,5 +15,5 @@ export async function uploadFile(fileName: string, page: Page) {
const fileChooser = await fileChooserPromise
await fileChooser.setFiles(`tests/e2e/assets/${fileName}`)

await page.waitForURL('/overview')
await page.waitForURL(expectedURL)
}
Binary file not shown.
Binary file not shown.

0 comments on commit 34dcbbe

Please sign in to comment.