-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7678813
commit c501973
Showing
5 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
import { QueryParams } from 'app/constants/query' | ||
|
||
import { | ||
BROWSE_DATASETS_URL, | ||
E2E_CONFIG, | ||
SINGLE_DATASET_URL, | ||
translations, | ||
} from './constants' | ||
import { BreadcrumbsPage } from './pageObjects/breadcrumbsPage' | ||
import { FiltersActor } from './pageObjects/filters/filtersActor' | ||
import { FiltersPage } from './pageObjects/filters/filtersPage' | ||
import { TableActor } from './pageObjects/table/tableActor' | ||
import { TablePage } from './pageObjects/table/tablePage' | ||
|
||
let filtersPage: FiltersPage | ||
let filtersActor: FiltersActor | ||
let tablePage: TablePage | ||
let tableActor: TableActor | ||
let breadcrumbsPage: BreadcrumbsPage | ||
|
||
test.beforeEach(({ page }) => { | ||
filtersPage = new FiltersPage(page) | ||
filtersActor = new FiltersActor(filtersPage) | ||
tablePage = new TablePage(page) | ||
tableActor = new TableActor(tablePage) | ||
breadcrumbsPage = new BreadcrumbsPage(page) | ||
}) | ||
|
||
const TEST_PARAM = QueryParams.ObjectName | ||
const TEST_VALUE = E2E_CONFIG.objectName | ||
|
||
test.describe('Carry over filters', () => { | ||
test('should carry over datasets filter into single dataset page', async () => { | ||
await filtersPage.goTo(BROWSE_DATASETS_URL) | ||
await filtersActor.addSingleSelectFilter({ | ||
label: translations.objectName, | ||
value: TEST_VALUE, | ||
}) | ||
|
||
await tableActor.expectResultWithUrlParam(TEST_PARAM, TEST_VALUE) | ||
}) | ||
|
||
test('should carry over single dataset filter into single run page', async () => { | ||
await filtersPage.goTo(SINGLE_DATASET_URL) | ||
await filtersActor.addSingleSelectFilter({ | ||
label: translations.objectName, | ||
value: TEST_VALUE, | ||
}) | ||
|
||
await tableActor.expectResultWithUrlParam(TEST_PARAM, TEST_VALUE) | ||
}) | ||
test('should have filter in browse dataset breadcrumb url', async () => { | ||
await filtersPage.goTo(BROWSE_DATASETS_URL) | ||
await filtersActor.addSingleSelectFilter({ | ||
label: translations.objectName, | ||
value: TEST_VALUE, | ||
}) | ||
|
||
// Check links at single dataset level | ||
await tableActor.openFirstResult(TEST_PARAM, TEST_VALUE) | ||
|
||
await expect( | ||
breadcrumbsPage.getBreadcrumb({ | ||
index: 0, | ||
param: TEST_PARAM, | ||
value: TEST_VALUE, | ||
}), | ||
).toBeVisible() | ||
|
||
// Check links at single run level | ||
await tableActor.openFirstResult(TEST_PARAM, TEST_VALUE) | ||
|
||
await expect( | ||
breadcrumbsPage.getBreadcrumb({ | ||
index: 0, | ||
param: TEST_PARAM, | ||
value: TEST_VALUE, | ||
}), | ||
).toBeVisible() | ||
}) | ||
|
||
test('should have filter in single dataset breadcrumb url', async () => { | ||
await filtersPage.goTo(SINGLE_DATASET_URL) | ||
await filtersActor.addSingleSelectFilter({ | ||
label: translations.objectName, | ||
value: TEST_VALUE, | ||
}) | ||
|
||
await tableActor.openFirstResult(TEST_PARAM, TEST_VALUE) | ||
|
||
await expect( | ||
breadcrumbsPage.getBreadcrumb({ | ||
index: 0, | ||
param: TEST_PARAM, | ||
value: TEST_VALUE, | ||
}), | ||
).toBeVisible() | ||
}) | ||
|
||
// TODO When we have more data to test with | ||
// eslint-disable-next-line playwright/no-skipped-test | ||
test.skip('should carry over single deposition filter into single dataset page', async () => {}) | ||
|
||
// TODO When we have more data to test with | ||
// eslint-disable-next-line playwright/no-skipped-test | ||
test.skip('should carry over single deposition filter into single run page', async () => {}) | ||
|
||
// TODO When we have more data to test with | ||
// eslint-disable-next-line playwright/no-skipped-test | ||
test.skip('should remove deposition id filter when click on remove filter button', async () => {}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
frontend/packages/data-portal/e2e/pageObjects/breadcrumbsPage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { QueryParams } from 'app/constants/query' | ||
import { TestIds } from 'app/constants/testIds' | ||
|
||
import { BasePage } from './basePage' | ||
|
||
export class BreadcrumbsPage extends BasePage { | ||
getBreadcrumb({ | ||
index, | ||
param, | ||
value, | ||
}: { | ||
index: number | ||
param?: QueryParams | ||
value?: string | ||
}) { | ||
return this.page | ||
.getByTestId(TestIds.Breadcrumbs) | ||
.locator(this.getUrlWithParamSelector(param, value)) | ||
.nth(index) | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
frontend/packages/data-portal/e2e/pageObjects/table/tableActor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { expect } from '@playwright/test' | ||
|
||
import { QueryParams } from 'app/constants/query' | ||
|
||
import { TablePage } from './tablePage' | ||
|
||
export class TableActor { | ||
constructor(private tablePage: TablePage) {} | ||
|
||
async expectResultWithUrlParam(param: QueryParams, value: string) { | ||
await expect( | ||
this.tablePage.getResultLink({ param, value, index: 0 }), | ||
).toBeVisible() | ||
} | ||
|
||
async openFirstResult(param?: QueryParams, value?: string) { | ||
await this.tablePage.getResultLink({ index: 0, param, value }).click() | ||
await this.tablePage.waitForInteractive() | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
frontend/packages/data-portal/e2e/pageObjects/table/tablePage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { QueryParams } from 'app/constants/query' | ||
|
||
import { BasePage } from '../basePage' | ||
|
||
export class TablePage extends BasePage { | ||
getNthRow(index: number) { | ||
return this.page.locator('tbody').locator('tr').nth(index) | ||
} | ||
|
||
getResultLink({ | ||
index, | ||
param, | ||
value, | ||
}: { | ||
index: number | ||
param?: QueryParams | ||
value?: string | ||
}) { | ||
return this.getNthRow(index) | ||
.locator(this.getUrlWithParamSelector(param, value)) | ||
.first() | ||
} | ||
} |