-
Notifications
You must be signed in to change notification settings - Fork 335
/
Copy pathuserButtonPageObject.ts
35 lines (31 loc) · 1.12 KB
/
userButtonPageObject.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { expect } from '@playwright/test';
import type { TestArgs } from './signInPageObject';
export const createUserButtonPageObject = (testArgs: TestArgs) => {
const { page } = testArgs;
const self = {
waitForMounted: () => {
return page.waitForSelector('.cl-userButtonTrigger', { state: 'attached' });
},
toggleTrigger: () => {
return page.locator('.cl-userButtonTrigger').click();
},
waitForPopover: () => {
return page.waitForSelector('.cl-userButtonPopoverCard', { state: 'visible' });
},
toHaveVisibleMenuItems: async (menuItems: string | RegExp | Array<string | RegExp>) => {
if (typeof menuItems === 'string' || menuItems instanceof RegExp) {
menuItems = [menuItems];
}
for (const menuItem of menuItems) {
await expect(page.getByRole('menuitem', { name: menuItem })).toBeVisible();
}
},
triggerSignOut: () => {
return page.getByRole('menuitem', { name: /Sign out$/i }).click();
},
triggerManageAccount: () => {
return page.getByRole('menuitem', { name: /Manage account/i }).click();
},
};
return self;
};