@umbraco/playwright-testhelpers 17.0.6 → 17.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/helpers/ApiHelpers.d.ts +23 -13
- package/dist/lib/helpers/ApiHelpers.js +107 -49
- package/dist/lib/helpers/ApiHelpers.js.map +1 -1
- package/dist/lib/helpers/ContentUiHelper.js +2 -2
- package/dist/lib/helpers/ContentUiHelper.js.map +1 -1
- package/dist/lib/helpers/DataTypeUiHelper.js +4 -3
- package/dist/lib/helpers/DataTypeUiHelper.js.map +1 -1
- package/dist/lib/helpers/LoginApiHelper.d.ts +7 -3
- package/dist/lib/helpers/LoginApiHelper.js +7 -5
- package/dist/lib/helpers/LoginApiHelper.js.map +1 -1
- package/dist/lib/helpers/UiBaseLocators.d.ts +2 -0
- package/dist/lib/helpers/UiBaseLocators.js +15 -2
- package/dist/lib/helpers/UiBaseLocators.js.map +1 -1
- package/dist/lib/helpers/UserApiHelper.d.ts +6 -2
- package/dist/lib/helpers/UserApiHelper.js +1 -1
- package/dist/lib/helpers/UserApiHelper.js.map +1 -1
- package/dist/lib/helpers/UserGroupUiHelper.js +2 -2
- package/dist/lib/helpers/UserGroupUiHelper.js.map +1 -1
- package/dist/lib/helpers/UserUiHelper.d.ts +0 -1
- package/dist/lib/helpers/UserUiHelper.js +0 -2
- package/dist/lib/helpers/UserUiHelper.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoginApiHelper.js","sourceRoot":"","sources":["../../../lib/helpers/LoginApiHelper.ts"],"names":[],"mappings":";;;AAEA,mCAAkC;AAElC,MAAa,cAAc;IACzB,GAAG,CAAa;IAChB,IAAI,CAAO;IAEX,YAAY,GAAe,EAAE,IAAU;QACrC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;I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E,KAAK,GAAG,EAAE;YAC7B,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAC5C;QACD,OAAO,QAAQ,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,MAAc,EAAE,YAAoB;QACvD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,uDAAuD,EAAE;YACxH,OAAO,EAAE;gBACP,cAAc,EAAE,mCAAmC;gBACnD,MAAM,EAAE,MAAM;gBACd,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO;aACzB;YACD,IAAI,EAAE;gBACJ,UAAU,EAAE,eAAe;gBAC3B,SAAS,EAAE,qBAAqB;gBAChC,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,yBAAyB;gBAC1D,aAAa,EAAE,YAAY;aAC5B;YACD,iBAAiB,EAAE,IAAI;SACxB,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,EAAE;YAC7B,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;SACjC;aAAM;YACL,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;SAC/B;QACD,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;CACF;AA9GD,wCA8GC","sourcesContent":["import {ApiHelpers} from \"./ApiHelpers\";\nimport {Page} from \"@playwright/test\";\nimport {createHash} from \"crypto\";\n\nexport class LoginApiHelper {\n api: ApiHelpers;\n page: Page;\n\n constructor(api: ApiHelpers, page: Page) {\n this.api = api;\n this.page = page;\n }\n\n public async login(userEmail: string, password: string) {\n const codeVerifier = \"12345\"; // A static state value for testing\n const stateValue = 'myStateValue'; // A static state value for testing\n const cookie = await this.getCookie(userEmail, password);\n const codeChallenge = await this.createCodeChallenge(codeVerifier);\n const authorizationCode = await this.getAuthorizationCode(codeChallenge, cookie, stateValue);\n const setCookies = await this.getCookiesWithAccessTokenAndRefreshToken(cookie, codeVerifier, authorizationCode);\n let tokens = await this.api.updateLocalStorageTokens(setCookies);\n const accessToken = tokens.accessToken;\n const refreshToken = tokens.refreshToken;\n return {cookie, accessToken, refreshToken};\n }\n\n async getCookie(userEmail: string, password: string) {\n const response = await this.page.request.post(this.api.baseUrl + '/umbraco/management/api/v1/security/back-office/login', {\n headers: {\n 'Content-Type': 'application/json',\n Referer: this.api.baseUrl,\n Origin: this.api.baseUrl,\n },\n data: {\n username: userEmail,\n password: password\n },\n ignoreHTTPSErrors: true\n });\n\n // Ensure the cookie is properly captured\n return response.headers()['set-cookie'];\n }\n\n async createCodeChallenge(codeVerifier: string) {\n return createHash('sha256').update(codeVerifier, 'utf8').digest('base64').replace(/=/g, '').trim();\n }\n\n async getAuthorizationCode(codeChallenge: string, cookie: string, stateValue: string) {\n const authorizationUrl = `${this.api.baseUrl}/umbraco/management/api/v1/security/back-office/authorize?client_id=umbraco-back-office&response_type=code&redirect_uri=${encodeURIComponent(this.api.baseUrl + '/umbraco/oauth_complete')}&code_challenge_method=S256&code_challenge=${codeChallenge}&state=${stateValue}&scope=offline_access&prompt=consent&access_type=offline`;\n const response = await this.page.request.get(authorizationUrl, {\n headers: {\n Cookie: cookie,\n Referer: this.api.baseUrl,\n },\n ignoreHTTPSErrors: true,\n maxRedirects: 0\n });\n\n // Parse the authorization code from the redirect URL\n const locationHeader = response.headers()['location'];\n if (!locationHeader) {\n throw new Error('Authorization redirect location not found');\n }\n // Extract the authorization code from the location header\n return new URLSearchParams(locationHeader.split('?')[1]).get('code');\n }\n\n async getCookiesWithAccessTokenAndRefreshToken(cookie: string, codeVerifier: string, authorizationCode) {\n const response = await this.page.request.post(this.api.baseUrl + '/umbraco/management/api/v1/security/back-office/token', {\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n Cookie: cookie,\n Origin: this.api.baseUrl\n },\n form: {\n grant_type: 'authorization_code',\n client_id: 'umbraco-back-office',\n redirect_uri: this.api.baseUrl + '/umbraco/oauth_complete',\n code: authorizationCode,\n code_verifier: codeVerifier\n },\n ignoreHTTPSErrors: true\n });\n\n if (response.status() !== 200) {\n console.error('Failed to retrieve cookie');\n }\n return response.headers()['set-cookie'];\n }\n\n async getAccessToken(cookie: string, refreshToken: string) {\n const response = await this.page.request.post(this.api.baseUrl + '/umbraco/management/api/v1/security/back-office/token', {\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n Cookie: cookie,\n Origin: this.api.baseUrl\n },\n form: {\n grant_type: 'refresh_token',\n client_id: 'umbraco-back-office',\n redirect_uri: this.api.baseUrl + '/umbraco/oauth_complete',\n refresh_token: refreshToken,\n },\n ignoreHTTPSErrors: true\n });\n\n if (response.status() === 200) {\n console.log('Login successful');\n } else {\n console.error('Login failed');\n }\n return await response.json();\n }\n}\n"]}
|
|
@@ -151,6 +151,8 @@ export declare class UiBaseLocators {
|
|
|
151
151
|
readonly openedModal: Locator;
|
|
152
152
|
readonly uiLoader: Locator;
|
|
153
153
|
readonly createDocumentBlueprintModal: Locator;
|
|
154
|
+
readonly entityItem: Locator;
|
|
155
|
+
readonly sectionLinks: Locator;
|
|
154
156
|
constructor(page: Page);
|
|
155
157
|
clickActionsMenuForNameInSectionSidebar(name: string): Promise<void>;
|
|
156
158
|
clickActionsMenuForName(name: string): Promise<void>;
|
|
@@ -155,6 +155,8 @@ class UiBaseLocators {
|
|
|
155
155
|
openedModal;
|
|
156
156
|
uiLoader;
|
|
157
157
|
createDocumentBlueprintModal;
|
|
158
|
+
entityItem;
|
|
159
|
+
sectionLinks;
|
|
158
160
|
constructor(page) {
|
|
159
161
|
this.page = page;
|
|
160
162
|
this.saveBtn = page.getByLabel('Save', { exact: true });
|
|
@@ -302,6 +304,7 @@ class UiBaseLocators {
|
|
|
302
304
|
this.successStateIcon = this.successState.locator('#state');
|
|
303
305
|
this.workspaceAction = page.locator('umb-workspace-action');
|
|
304
306
|
this.caretBtn = page.locator('#caret-button');
|
|
307
|
+
this.sectionLinks = page.getByTestId('section-links');
|
|
305
308
|
// Entity Action
|
|
306
309
|
this.entityAction = page.locator('umb-entity-action-list umb-entity-action');
|
|
307
310
|
this.openEntityAction = page.locator('#action-modal[open]').locator(this.entityAction);
|
|
@@ -310,6 +313,7 @@ class UiBaseLocators {
|
|
|
310
313
|
this.monacoEditor = page.locator('.monaco-editor');
|
|
311
314
|
this.openedModal = page.locator('uui-modal-container[backdrop]');
|
|
312
315
|
this.uiLoader = page.locator('uui-loader');
|
|
316
|
+
this.entityItem = page.locator('umb-entity-item-ref');
|
|
313
317
|
}
|
|
314
318
|
async clickActionsMenuForNameInSectionSidebar(name) {
|
|
315
319
|
await this.sectionSidebar.locator('[label="' + name + '"]').hover();
|
|
@@ -317,6 +321,8 @@ class UiBaseLocators {
|
|
|
317
321
|
}
|
|
318
322
|
async clickActionsMenuForName(name) {
|
|
319
323
|
await (0, test_1.expect)(this.page.locator('uui-menu-item[label="' + name + '"]').locator('#menu-item').first()).toBeVisible();
|
|
324
|
+
// We need to wait for the load to be finished, otherwise we would run into flaky tests
|
|
325
|
+
await this.page.waitForTimeout(1000);
|
|
320
326
|
await this.page.locator('uui-menu-item[label="' + name + '"]').locator('#menu-item').first().hover({ force: true });
|
|
321
327
|
await this.page.locator('uui-menu-item[label="' + name + '"] #action-modal').first().click({ force: true });
|
|
322
328
|
}
|
|
@@ -594,10 +600,17 @@ class UiBaseLocators {
|
|
|
594
600
|
async goToSection(sectionName, checkSections = true) {
|
|
595
601
|
if (checkSections) {
|
|
596
602
|
for (let section in ConstantHelper_1.ConstantHelper.sections) {
|
|
597
|
-
await (0, test_1.expect)(this.
|
|
603
|
+
await (0, test_1.expect)(this.sectionLinks.getByRole('tab', { name: ConstantHelper_1.ConstantHelper.sections[section] })).toBeVisible({ timeout: 30000 });
|
|
598
604
|
}
|
|
599
605
|
}
|
|
600
|
-
|
|
606
|
+
// We need to check if we are on the section tab already, if we are, then we need to reload the page instead of clicking again
|
|
607
|
+
const alreadySelected = await this.sectionLinks.locator('[active]').getByText(sectionName).isVisible();
|
|
608
|
+
if (alreadySelected) {
|
|
609
|
+
await this.page.reload();
|
|
610
|
+
}
|
|
611
|
+
else {
|
|
612
|
+
await this.backOfficeHeader.getByRole('tab', { name: sectionName }).click();
|
|
613
|
+
}
|
|
601
614
|
}
|
|
602
615
|
async goToSettingsTreeItem(settingsTreeItemName) {
|
|
603
616
|
await this.goToSection(ConstantHelper_1.ConstantHelper.sections.settings);
|