Skip to content

Commit 4b8ff4e

Browse files
fix: flaky MM-T5521-8 (mattermost#35385)
1 parent 8fd7aea commit 4b8ff4e

File tree

2 files changed

+42
-12
lines changed
  • e2e-tests/playwright

2 files changed

+42
-12
lines changed

e2e-tests/playwright/lib/src/ui/components/system_console/sections/user_management/users/menus.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ export class ColumnToggleMenu {
5050
}
5151
}
5252

53+
type RoleFilter = 'Any' | 'System Admin' | 'Member' | 'Guest';
54+
type StatusFilter = 'Any' | 'Activated users' | 'Deactivated users';
55+
5356
/**
5457
* Filter popover that appears when clicking the Filters button
5558
*/
@@ -92,6 +95,22 @@ export class FilterPopover {
9295
await this.container.page().waitForTimeout(500);
9396
}
9497

98+
/**
99+
* Select a team from the dropdown. For "All teams" and "No teams", opens the
100+
* dropdown directly. For specific team names, searches first then selects.
101+
*/
102+
async filterByTeam(team: 'All teams' | 'No teams' | (string & {})) {
103+
if (team === 'All teams' || team === 'No teams') {
104+
await expect(this.teamMenuInput).toBeVisible();
105+
await this.teamMenuInput.click();
106+
} else {
107+
await this.searchInTeamMenu(team);
108+
}
109+
const option = this.container.getByRole('option', {name: team});
110+
await option.waitFor();
111+
await option.click();
112+
}
113+
95114
/**
96115
* Open the role filter menu
97116
*/
@@ -100,6 +119,16 @@ export class FilterPopover {
100119
await this.roleMenuButton.click();
101120
}
102121

122+
/**
123+
* Open the role filter menu and select a role option
124+
*/
125+
async filterByRole(role: RoleFilter) {
126+
await this.openRoleMenu();
127+
const option = this.container.getByRole('option', {name: role});
128+
await option.waitFor();
129+
await option.click();
130+
}
131+
103132
/**
104133
* Open the status filter menu
105134
*/
@@ -108,6 +137,16 @@ export class FilterPopover {
108137
await this.statusMenuButton.click();
109138
}
110139

140+
/**
141+
* Open the status filter menu and select a status option
142+
*/
143+
async filterByStatus(status: StatusFilter) {
144+
await this.openStatusMenu();
145+
const option = this.container.getByRole('option', {name: status});
146+
await option.waitFor();
147+
await option.click();
148+
}
149+
111150
/**
112151
* Close the popover (if still open)
113152
*/

e2e-tests/playwright/specs/functional/system_console/system_users/filter_popover.spec.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ test('MM-T5521-7 Should be able to filter users with team filter', async ({pw})
3535
const filterPopover = await systemConsolePage.users.openFilterPopover();
3636

3737
// # Enter the team name of the first user and select it
38-
await filterPopover.searchInTeamMenu(team1.display_name);
39-
await filterPopover.teamMenuInput.press('Enter');
38+
await filterPopover.filterByTeam(team1.display_name);
4039

4140
// # Save the filter and close the popover
4241
await filterPopover.save();
@@ -79,11 +78,7 @@ test('MM-T5521-8 Should be able to filter users with role filter', async ({pw})
7978
const filterPopover = await systemConsolePage.users.openFilterPopover();
8079

8180
// # Open the role filter in the popover and select Guest
82-
await filterPopover.openRoleMenu();
83-
// Wait for dropdown options and click on Guest
84-
const guestOption = systemConsolePage.page.getByText('Guest', {exact: true});
85-
await guestOption.waitFor();
86-
await guestOption.click();
81+
await filterPopover.filterByRole('Guest');
8782

8883
// # Save the filter and close the popover
8984
await filterPopover.save();
@@ -132,11 +127,7 @@ test('MM-T5521-9 Should be able to filter users with status filter', async ({pw}
132127
const filterPopover = await systemConsolePage.users.openFilterPopover();
133128

134129
// # Open the status filter in the popover and select Deactivated users
135-
await filterPopover.openStatusMenu();
136-
// Wait for dropdown options and click on Deactivated users
137-
const deactivatedOption = systemConsolePage.page.getByText('Deactivated users', {exact: true});
138-
await deactivatedOption.waitFor();
139-
await deactivatedOption.click();
130+
await filterPopover.filterByStatus('Deactivated users');
140131

141132
// # Save the filter and close the popover
142133
await filterPopover.save();

0 commit comments

Comments
 (0)