Skip to content

Commit 2f2a5dc

Browse files
committed
Decrease flakyness when switching account
1 parent 26448fc commit 2f2a5dc

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

integration/tests/session-tasks-multi-session.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
8080
await u.po.userButton.waitForMounted();
8181
await u.po.userButton.toggleTrigger();
8282
await u.po.userButton.waitForPopover();
83-
await u.po.userButton.switchAccount(user2.firstName);
83+
await u.po.userButton.toHaveVisibleMenuItems([/Manage account/i, /Sign out$/i]);
84+
await u.po.userButton.switchAccount(user2.email);
8485

8586
// Resolve task
8687
await u.page.waitForAppUrl('/sign-in/tasks/add-organization');

packages/testing/src/playwright/unstable/page-objects/userButton.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ export const createUserButtonPageObject = (testArgs: { page: EnhancedPage }) =>
3232
triggerManageAccount: () => {
3333
return page.getByRole('menuitem', { name: /Manage account/i }).click();
3434
},
35-
switchAccount: (username: string) => {
36-
return page
35+
switchAccount: async (emailAddress: string) => {
36+
const menuItem = page
3737
.getByRole('menuitem')
38-
.filter({ has: page.locator('span', { hasText: username }) })
39-
.click();
38+
.filter({ has: page.locator('span', { hasText: new RegExp(emailAddress) }) });
39+
await menuItem.waitFor({ state: 'attached' });
40+
return menuItem.click();
4041
},
4142
};
4243

0 commit comments

Comments
 (0)