-
Notifications
You must be signed in to change notification settings - Fork 4
PEPPER-587: RGP DSM playwright tests_assert creation of new participant by checking DSM #2048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
bbd993f
e14f1f2
8726024
3af6483
a5c04ad
384cba6
2caa969
f9dba01
426c4d9
5c6f7e7
39752e2
e48a821
a8239b2
d469d71
8867a4d
694159d
5f72c4c
be80184
1bd3cf1
1c5d304
5b984b4
a59a080
34c9344
d22331b
fa4cd15
cdb83e4
32cad26
7a44501
2d26c89
861cb6c
121cb9f
db2305e
ac2d1e3
f20dc8b
b1962b3
5ee26be
4ad5bd7
89beaed
ee60525
fe0d7a2
5a22e4f
0eb71e8
7cec3b9
7c84f34
4642393
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.eslintrc.js | ||
.eslintrc | ||
node_modules/ | ||
build/ | ||
playwright-report/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ junit/ | |
**/*.iml | ||
**/*.zip | ||
**/*.log | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,63 @@ | ||
import { expect, Locator, Page } from '@playwright/test'; | ||
import { HomePageInterface } from 'pages/page-interface'; | ||
import { DSMPageBase } from './page-base'; | ||
import * as auth from 'authentication/auth-dsm'; | ||
import Select from 'lib/widget/select'; | ||
import { Navigation } from 'lib/component/dsm/navigation/navigation'; | ||
import { StudyNav } from 'lib/component/dsm/navigation/enums/studyNav.enum'; | ||
import ParticipantListPage from 'pages/dsm/participantList-page'; | ||
import ParticipantPage from 'pages/dsm/participant-page'; | ||
|
||
enum Titles { | ||
WELCOME = 'Welcome to the DDP Study Management System', | ||
SELECTED_STUDY = 'You have selected the ', | ||
STUDY = ' study.' | ||
} | ||
|
||
export default class HomePage { | ||
constructor(private readonly page: Page) {} | ||
export default class HomePage extends DSMPageBase implements HomePageInterface { | ||
private readonly navigation: Navigation; | ||
private readonly participantList: ParticipantListPage; | ||
|
||
constructor(page: Page) { | ||
super(page); | ||
this.navigation = new Navigation(page); | ||
this.participantList = new ParticipantListPage(page); | ||
} | ||
|
||
/** | ||
* Log into DSM application | ||
* @param opts | ||
*/ | ||
async logIn(opts: { email?: string; password?: string; waitForNavigation?: boolean } = {}) { | ||
await auth.login(this.page); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think when you are on this page, you are already logged in, therefore I don't think this method is useful here. What do you think about removing it? Usually, we just call the |
||
} | ||
|
||
async selectStudy(study: string, page: Page) { | ||
const studySelector = await new Select(page, { label: 'Select study' }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead, you could use this way: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, anyway, this method is not used anywhere. Maybe remove it? |
||
await studySelector.click(); | ||
await studySelector.selectOption(study); | ||
} | ||
|
||
async selectStudyMenuOption(menuOption: string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not used as well |
||
if (menuOption === 'Participant List') { | ||
//Select the Participant List from the available Study menu options | ||
await this.navigation.selectFromStudy<ParticipantListPage>(StudyNav.PARTICIPANT_LIST); | ||
await this.participantList.waitForReady(); | ||
await this.participantList.assertPageTitle(); | ||
await this.participantList.waitForReady(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
} | ||
|
||
async selectCustomizeViewOption(columnGroup: string, columnName: string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not used as well. |
||
//Select column group e.g. Participant Columns | ||
await this.page.locator('text=Customize View >> button').click(); | ||
await this.page.locator(`text='${columnGroup}' >> button`).click(); | ||
await this.page.locator(`text='${columnName}' >> button`).click(); | ||
} | ||
|
||
async waitForReady(): Promise<void> { | ||
await this.page.waitForFunction(() => document.title === 'DDP Study Management'); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI, |
||
|
||
public get welcomeTitle(): Locator { | ||
return this.page.locator('h1'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Page } from '@playwright/test'; | ||
import PageBase from 'pages/page-base'; | ||
|
||
/** | ||
* Data Study Manager (DSM) page base | ||
*/ | ||
export abstract class DSMPageBase extends PageBase { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻👍🏻 |
||
protected constructor(page: Page) { | ||
const { DSM_BASE_URL } = process.env; | ||
if (DSM_BASE_URL == null) { | ||
throw Error(`Invalid DSM base URL: process.env.DSM_BASE_URL=${DSM_BASE_URL}`); | ||
} | ||
super(page, DSM_BASE_URL); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import { expect, Locator, Page } from '@playwright/test'; | ||
|
||
import { waitForNoSpinner } from 'utils/test-utils'; | ||
import { Filters } from 'lib/component/dsm/filters/filters'; | ||
import { ParticipantListTable } from 'lib/component/dsm/tables/participantListTable'; | ||
|
||
export enum SearchFieldLabel { | ||
ShortId = 'Short ID', | ||
ParticipantID = 'Participant ID' | ||
} | ||
|
||
export default class ParticipantListPage { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
private readonly PAGE_TITLE: string = 'Participant List'; | ||
|
||
|
@@ -20,6 +24,18 @@ export default class ParticipantListPage { | |
await waitForNoSpinner(this.page); | ||
} | ||
|
||
public async filterListByParticipantGUID(participantGUID: string): Promise<void> { | ||
await this.page.locator('text=Customize View >> button').click(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead, you could use customize view functionality, which is available from the
And later to make assertions. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good - will make the changes |
||
await this.page.locator('text=Participant Columns').click(); | ||
await this.page.locator(`//mat-checkbox/label[span[normalize-space(text()) = 'Participant ID']]`).check(); | ||
await this.page.locator('text=Search >> button').click(); | ||
await this.page.locator(`//input[@data-placeholder='Participant ID']`).fill(participantGUID); | ||
await this.page.locator("button:has-text('Search') >> nth=0").click(); | ||
await this.page.getByRole('cell', { name: participantGUID }).click(); | ||
await expect(this.page.getByRole('heading', { name: 'Participant Page' })).toBeVisible(); | ||
await expect(this.page.getByRole('cell', { name: participantGUID })).toBeVisible(); | ||
} | ||
|
||
public async addBulkCohortTags(): Promise<void> { | ||
await this.page.locator('//button[.//*[@tooltip="Bulk Cohort Tag"]]').click(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { PlaywrightTestConfig } from '@playwright/test'; | ||
import testConfig from 'playwright.config'; | ||
|
||
const rgpConfig: PlaywrightTestConfig = { | ||
...testConfig, | ||
testDir: './', | ||
use: { | ||
video: 'on' | ||
} | ||
}; | ||
|
||
export default rgpConfig; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import { faker } from '@faker-js/faker'; | ||
import { Page } from '@playwright/test'; | ||
import * as user from 'data/fake-user.json'; | ||
|
||
export const generateUserName = (namePrefix: string): string => { | ||
return `${namePrefix}-${faker.name.lastName()}${faker.random.word()}`; | ||
|
@@ -17,3 +19,13 @@ export const generateEmailAlias = (email: string | undefined): string => { | |
const domain = splintedEmail[1]; | ||
return `${name}+${Math.floor(Math.random() * 1000000000)}@${domain}`; | ||
}; | ||
|
||
export const setPatientParticipantGuid = async (page: Page) => { | ||
const [response] = await Promise.all([ | ||
page.waitForResponse((resp) => resp.url().includes('/participants') && resp.status() === 200) | ||
]); | ||
|
||
const participantResponse = response.url(); | ||
const urlArray = participantResponse.split('/'); | ||
user.patient.participantGuid = urlArray[6]; | ||
}; | ||
Comment on lines
+28
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Waiting and parsing a request in a separate function is going to make tests flaky because request could have been finished before this function starts to run. Best way to do this is, perform action and wait for response together a in Promise.all.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will do - thinking a bit more about this one - in terms of which action to use - will make the changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import:
import ParticipantPage from 'pages/dsm/participant-page';