Skip to content

Commit 25ef288

Browse files
authored
[Playwright] Update tests to have more verifications (#2259)
* update playwright tests
1 parent 39668d5 commit 25ef288

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

playwright-e2e/tests/dsm/participant-list/filter-empty-fields.spec.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,16 @@ test.describe('Participants List', () => {
1212
const participantListPage = await ParticipantListPage.goto(page, study, request);
1313
const participantsTable = participantListPage.participantListTable;
1414

15-
const numParticipants = await participantsTable.numOfParticipants();
15+
// Change numbers of rows displayed
16+
await participantsTable.changeRowCount(50);
17+
18+
const rowsCount = await participantsTable.getRowsCount(); // number of table rows displayd
19+
const numParticipants = await participantsTable.numOfParticipants(); // number of participants
20+
if (numParticipants >= 50) {
21+
expect(rowsCount).toStrictEqual(50);
22+
} else {
23+
expect(rowsCount).toStrictEqual(numParticipants);
24+
}
1625

1726
const customizeViewPanel = participantListPage.filters.customizeViewPanel;
1827
await customizeViewPanel.open();
@@ -37,7 +46,12 @@ test.describe('Participants List', () => {
3746
const searchPanel = participantListPage.filters.searchPanel;
3847
await searchPanel.open();
3948
await searchPanel.clear();
40-
// Clearing the search does not change the amount of participants seen in participant list
49+
50+
// Clearing manual search does not change rows per page
51+
const rowsCountAfterClear = await participantsTable.getRowsCount();
52+
expect(rowsCountAfterClear).toBe(rowsCount);
53+
54+
// Clearing manual search does not change the amount of participants seen in participant list
4155
const numParticipantsAfterClear = await participantsTable.numOfParticipants();
4256
expect(numParticipantsAfterClear).toBe(numParticipants);
4357
await searchPanel.search({ uri: '/ui/applyFilter?' });

playwright-e2e/tests/dsm/participant-list/filter-registration-date.spec.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,31 @@ test.describe('Participants Search', () => {
6464
await searchPanel.dates(MainInfoEnum.REGISTRATION_DATE, { additionalFilters: [AdditionalFilter.RANGE], from: yearAgo, to: today});
6565
await searchPanel.search();
6666

67+
const rowsCount = await participantsTable.getRowsCount();
6768
const numParticipants2 = await participantsTable.numOfParticipants();
6869
logInfo(`Search by Registration Date Range (from: ${yearAgo}, to: ${today}) returns ${numParticipants2} participants`);
6970
expect(numParticipants2).toBeGreaterThan(1);
7071
expect(numParticipants2).not.toBe(numParticipants1); // Expect Participants list table has reloaded and changed
7172

72-
// Use Registration Date column filter to verify date range in table
73+
// Sort Registration Date column filter to verify date range in table
7374
await participantsTable.sort(MainInfoEnum.REGISTRATION_DATE, SortOrder.DESC);
74-
const date1 = await participantsTable.cell(0, headerIndex).innerText();
75-
75+
const descFirstRowDate = await participantsTable.cell(0, headerIndex).innerText();
76+
const descLastRowDate = await participantsTable.cell(rowsCount - 1, headerIndex).innerText();
77+
// ascending
78+
expect(new Date(descFirstRowDate) < new Date(descLastRowDate),
79+
`descFirstRowDate: ${descFirstRowDate}, descLastRowDate: ${descLastRowDate}`)
80+
.toBeTruthy();
81+
82+
// Sort in opposite order
7683
await participantsTable.sort(MainInfoEnum.REGISTRATION_DATE, SortOrder.ASC);
77-
const date2 = await participantsTable.cell(0, headerIndex).innerText();
78-
79-
expect(getDate(new Date(date1))).not.toEqual(date2);
84+
const ascFirstRowDate = await participantsTable.cell(0, headerIndex).innerText();
85+
const ascLastRowDate = await participantsTable.cell(rowsCount - 1, headerIndex).innerText();
86+
// descending
87+
expect(new Date(ascFirstRowDate) > new Date(ascLastRowDate),
88+
`ascFirstRowDate: ${ascFirstRowDate}, ascLastRowDate: ${ascLastRowDate}`)
89+
.toBeTruthy();
90+
91+
expect(getDate(new Date(descFirstRowDate))).not.toEqual(ascFirstRowDate);
8092
});
8193
}
8294
});

0 commit comments

Comments
 (0)