diff --git a/report-viewer/.gitignore b/report-viewer/.gitignore index 9d1252439..31a363625 100644 --- a/report-viewer/.gitignore +++ b/report-viewer/.gitignore @@ -29,4 +29,7 @@ coverage test-results/ playwright-report/ -tests/e2e/assets \ No newline at end of file +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 \ No newline at end of file diff --git a/report-viewer/tests/e2e/OpenOldReport.spec.ts b/report-viewer/tests/e2e/OpenOldReport.spec.ts new file mode 100644 index 000000000..1aaf19ce2 --- /dev/null +++ b/report-viewer/tests/e2e/OpenOldReport.spec.ts @@ -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() + }) +} diff --git a/report-viewer/tests/e2e/TestUtils.ts b/report-viewer/tests/e2e/TestUtils.ts index 55a74b755..55f32e571 100644 --- a/report-viewer/tests/e2e/TestUtils.ts +++ b/report-viewer/tests/e2e/TestUtils.ts @@ -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 @@ -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) } diff --git a/report-viewer/tests/e2e/assets/progpedia-report-v4_2_0.zip b/report-viewer/tests/e2e/assets/progpedia-report-v4_2_0.zip new file mode 100644 index 000000000..d22e018a8 Binary files /dev/null and b/report-viewer/tests/e2e/assets/progpedia-report-v4_2_0.zip differ diff --git a/report-viewer/tests/e2e/assets/progpedia-report-v5_1_0.zip b/report-viewer/tests/e2e/assets/progpedia-report-v5_1_0.zip new file mode 100644 index 000000000..42e2fd914 Binary files /dev/null and b/report-viewer/tests/e2e/assets/progpedia-report-v5_1_0.zip differ