forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserProfilePageObject.ts
More file actions
74 lines (70 loc) · 2.58 KB
/
Copy pathuserProfilePageObject.ts
File metadata and controls
74 lines (70 loc) · 2.58 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import type { Browser, BrowserContext } from '@playwright/test';
import type { createAppPageObject } from './appPageObject';
import { common } from './commonPageObject';
export type EnchancedPage = ReturnType<typeof createAppPageObject>;
export type TestArgs = { page: EnchancedPage; context: BrowserContext; browser: Browser };
export type Sections = 'profile' | 'emailAddresses' | 'username' | 'phoneNumbers' | 'danger';
export const createUserProfileComponentPageObject = (testArgs: TestArgs) => {
const { page } = testArgs;
const self = {
...common(testArgs),
goTo: async (opts?: { searchParams: URLSearchParams }) => {
await page.goToRelative('/user', opts);
return self.waitForMounted();
},
switchToSecurityTab: async () => {
await page.getByText(/Security/i).click();
},
waitForMounted: () => {
return page.waitForSelector('.cl-userProfile-root', { state: 'attached' });
},
clickSetUsername: () => {
return page.getByText(/Set username/i).click();
},
clickToUpdateProfile: () => {
return page.getByText(/update profile/i).click();
},
clickUpdateUsername: () => {
return page.getByText(/update username/i).click();
},
clickSetPassword: () => {
return page.getByText(/Set password/i).click();
},
waitForSectionCard: (section: Sections, opened: boolean) => {
return page.waitForSelector(`.cl-profileSectionContent__${section} .cl-headerTitle`, {
state: opened ? 'visible' : 'detached',
});
},
waitForSectionCardOpened: (section: Sections) => {
return self.waitForSectionCard(section, true);
},
waitForSectionCardClosed: (section: Sections) => {
return self.waitForSectionCard(section, false);
},
typeUsername: (value: string) => {
return self.getUsernameInput().fill(value);
},
typeFirstName: (value: string) => {
return self.getFirstNameInput().fill(value);
},
typeLastName: (value: string) => {
return self.getLastNameInput().fill(value);
},
typePhoneNumber: (value: string) => {
return self.getPhoneNumberInput().fill(value);
},
clickAddEmailAddress: () => {
return page.getByText(/add email address/i).click();
},
clickAddPhoneNumber: () => {
return page.getByText(/add phone number/i).click();
},
typeEmailAddress: (value: string) => {
return page.getByLabel(/Email address/i).fill(value);
},
waitForUserProfileModal: () => {
return page.waitForSelector('.cl-modalContent > .cl-userProfile-root', { state: 'visible' });
},
};
return self;
};