Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkim-det committed Oct 31, 2024
1 parent 0646084 commit 85728aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 31 deletions.
4 changes: 2 additions & 2 deletions webui/react/src/e2e/models/pages/Admin/UserManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BaseComponent } from 'playwright-page-model-base/BaseComponent';

import { expect } from 'e2e/fixtures/global-fixtures';
import { DropdownMenu } from 'e2e/models/common/hew/Dropdown';
import { Nameplate } from 'e2e/models/common/hew/Nameplate';
import { Select } from 'e2e/models/common/hew/Select';
import { Toast } from 'e2e/models/common/hew/Toast';
import { AddUsersToGroupsModal } from 'e2e/models/components/AddUsersToGroupsModal';
Expand Down Expand Up @@ -150,9 +151,8 @@ class UserRow extends Row {
parent: this,
selector: '[data-testid="user"]',
});
readonly username = new BaseComponent({
readonly nameplate = new Nameplate({
parent: this,
selector: '[class^="Nameplate_text"] div:last-child',
});
readonly status = new BaseComponent({
parent: this,
Expand Down
39 changes: 10 additions & 29 deletions webui/react/src/e2e/tests/userManagement.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ test.describe('User Management', () => {

const getTableUsernames = async (userManagementPage: UserManagement) => {
return await Promise.all(
(await userManagementPage.table.table.rows.username.pwLocator.all()).map(
(await userManagementPage.table.table.rows.nameplate.name.pwLocator.all()).map(
async (username) => {
return await username.textContent();
},
Expand Down Expand Up @@ -343,43 +343,24 @@ test.describe('User Management', () => {
order,
);

expect(await getTableUsernames(userManagementPage)).toEqual(
sortedListTestUsers.slice(0, 10).map((u) => u.username),
);
await expect(async () => {
expect(await getTableUsernames(userManagementPage)).toEqual(
sortedListTestUsers.slice(0, 10).map((u) => u.username),
);
}).toPass({ timeout: 10_000 });
};

const testSort = async (
columnId: 'user' | 'role' | 'status' | 'modified',
sortBy: 'name' | 'admin' | 'active' | 'modifiedAt',
) => {
await expect(
repeatWithFallback(
async () => {
await expect(
userManagementPage.table.table.headRow[columnId].pwLocator,
).toHaveAttribute('aria-sort', 'ascending');
},
async () => {
await userManagementPage.table.table.headRow[columnId].pwLocator.click();
},
),
).toPass();
const columnHeader = userManagementPage.table.table.headRow[columnId].pwLocator;
const columnSort = await columnHeader.getAttribute('aria-sort');

if (columnSort !== 'ascending') await columnHeader.click();
await validateSort(sortBy, 'asc');

await expect(
repeatWithFallback(
async () => {
await expect(
userManagementPage.table.table.headRow[columnId].pwLocator,
).toHaveAttribute('aria-sort', 'descending');
},
async () => {
await userManagementPage.table.table.headRow[columnId].pwLocator.click();
},
),
).toPass();

await columnHeader.click();
await validateSort(sortBy, 'desc');
};

Expand Down

0 comments on commit 85728aa

Please sign in to comment.