Skip to content

Commit 9328f42

Browse files
Fran McDadeFran McDade
Fran McDade
authored and
Fran McDade
committed
fix: anvil cmg tab tests (#4453)
1 parent abd3b3e commit 9328f42

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

e2e/features/common/constants.ts

+2
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ export const MUI_CLASSES = {
1616
TABLE_CELL: ".MuiTableCell-root",
1717
TABLE_CONTAINER: ".MuiTableContainer-root",
1818
TABLE_ROW: ".MuiTableRow-root",
19+
TABLE_SORT_LABEL: ".MuiTableSortLabel-root",
20+
TABLE_SORT_LABEL_ICON: ".MuiTableSortLabel-icon",
1921
};

e2e/testFunctions.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export async function testTab(
118118
): Promise<void> {
119119
// Run the "Expect each tab to become selected, to go to the correct url, and to show all of its columns when selected" test
120120
await page.goto(startTab.url);
121+
await page.getByTestId(TEST_IDS.TABLE_FIRST_CELL).waitFor();
121122
await expect(getFirstRowNthColumnCellLocator(page, 1)).toBeVisible();
122123
await getTabByText(page, endTab.tabName).click();
123124
await expect(page).toHaveURL(endTab.url);
@@ -183,13 +184,12 @@ export async function testSortAzul(
183184
}
184185
if (columnObject?.sortable) {
185186
// Locator that can be clicked to sort the column
186-
const columnSortLocator = page.getByRole("button", {
187-
exact: true,
188-
name: columnObject.name,
189-
});
187+
const columnSortLocator = page
188+
.locator(MUI_CLASSES.TABLE_SORT_LABEL)
189+
.filter({ hasText: columnObject.name });
190190
// Locator for the column sort icon
191191
const sortIconLocator = columnSortLocator.locator(
192-
".MuiTableSortLabel-icon"
192+
MUI_CLASSES.TABLE_SORT_LABEL_ICON
193193
);
194194
// If on the first cell, expect the sort icon to be visible. Otherwise, expect it not to be
195195
if (columnPosition === 0) {
@@ -1245,9 +1245,7 @@ export async function testPaginationContent(
12451245
* @returns - a Playwright locator object for the tab with the specified text.
12461246
*/
12471247
export const getTabByText = (page: Page, tabText: string): Locator => {
1248-
return page.locator("[role='tab']", {
1249-
has: page.locator(`text="${tabText}"`),
1250-
});
1248+
return page.locator("[role='tab']").filter({ hasText: tabText });
12511249
};
12521250

12531251
/* eslint-enable sonarjs/no-duplicate-string -- Checking duplicate strings again*/

0 commit comments

Comments
 (0)