@umbraco/playwright-testhelpers 2.0.0-beta.34 → 2.0.0-beta.36
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 +14 -0
- package/dist/lib/helpers/ApiHelpers.js +96 -0
- package/dist/lib/helpers/ApiHelpers.js.map +1 -1
- package/dist/lib/helpers/MemberApiHelper.d.ts +16 -0
- package/dist/lib/helpers/MemberApiHelper.js +88 -0
- package/dist/lib/helpers/MemberApiHelper.js.map +1 -0
- package/dist/lib/helpers/MemberGroupApiHelper.d.ts +14 -0
- package/dist/lib/helpers/MemberGroupApiHelper.js +63 -0
- package/dist/lib/helpers/MemberGroupApiHelper.js.map +1 -0
- package/dist/lib/helpers/MemberGroupUiHelper.d.ts +16 -0
- package/dist/lib/helpers/MemberGroupUiHelper.js +42 -0
- package/dist/lib/helpers/MemberGroupUiHelper.js.map +1 -0
- package/dist/lib/helpers/MemberTypeApiHelper.d.ts +17 -0
- package/dist/lib/helpers/MemberTypeApiHelper.js +121 -0
- package/dist/lib/helpers/MemberTypeApiHelper.js.map +1 -0
- package/dist/lib/helpers/MemberTypeUiHelper.d.ts +13 -0
- package/dist/lib/helpers/MemberTypeUiHelper.js +35 -0
- package/dist/lib/helpers/MemberTypeUiHelper.js.map +1 -0
- package/dist/lib/helpers/MemberUiHelper.d.ts +40 -0
- package/dist/lib/helpers/MemberUiHelper.js +114 -0
- package/dist/lib/helpers/MemberUiHelper.js.map +1 -0
- package/dist/lib/helpers/ModelsBuilderUiHelper.d.ts +0 -2
- package/dist/lib/helpers/ModelsBuilderUiHelper.js +0 -5
- package/dist/lib/helpers/ModelsBuilderUiHelper.js.map +1 -1
- package/dist/lib/helpers/ScriptUiHelper.d.ts +1 -1
- package/dist/lib/helpers/ScriptUiHelper.js +2 -2
- package/dist/lib/helpers/ScriptUiHelper.js.map +1 -1
- package/dist/lib/helpers/TemplateUiHelper.d.ts +3 -1
- package/dist/lib/helpers/TemplateUiHelper.js +9 -2
- package/dist/lib/helpers/TemplateUiHelper.js.map +1 -1
- package/dist/lib/helpers/UiBaseLocators.d.ts +3 -0
- package/dist/lib/helpers/UiBaseLocators.js +21 -2
- package/dist/lib/helpers/UiBaseLocators.js.map +1 -1
- package/dist/lib/helpers/UiHelpers.d.ts +6 -0
- package/dist/lib/helpers/UiHelpers.js +9 -0
- package/dist/lib/helpers/UiHelpers.js.map +1 -1
- package/dist/lib/helpers/testExtension.js +2 -0
- package/dist/lib/helpers/testExtension.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -24,6 +24,9 @@ import { ModelsBuilderApiHelper } from "./ModelsBuilderApiHelper";
|
|
|
24
24
|
import { HealthCheckApiHelper } from "./HealthCheckApiHelper";
|
|
25
25
|
import { IndexerApiHelper } from "./IndexerApiHelper";
|
|
26
26
|
import { PublishedCacheApiHelper } from "./PublishedCacheApiHelper";
|
|
27
|
+
import { MemberGroupApiHelper } from './MemberGroupApiHelper';
|
|
28
|
+
import { MemberApiHelper } from './MemberApiHelper';
|
|
29
|
+
import { MemberTypeApiHelper } from "./MemberTypeApiHelper";
|
|
27
30
|
export declare class ApiHelpers {
|
|
28
31
|
baseUrl: string;
|
|
29
32
|
page: Page;
|
|
@@ -52,6 +55,9 @@ export declare class ApiHelpers {
|
|
|
52
55
|
healthCheck: HealthCheckApiHelper;
|
|
53
56
|
indexer: IndexerApiHelper;
|
|
54
57
|
publishedCache: PublishedCacheApiHelper;
|
|
58
|
+
memberGroup: MemberGroupApiHelper;
|
|
59
|
+
member: MemberApiHelper;
|
|
60
|
+
memberType: MemberTypeApiHelper;
|
|
55
61
|
constructor(page: Page);
|
|
56
62
|
getBearerToken(): Promise<string>;
|
|
57
63
|
getCookie(): Promise<string>;
|
|
@@ -67,4 +73,12 @@ export declare class ApiHelpers {
|
|
|
67
73
|
delete(url: string, data?: object): Promise<import("playwright-core").APIResponse>;
|
|
68
74
|
put(url: string, data?: object): Promise<import("playwright-core").APIResponse>;
|
|
69
75
|
postMultiPartForm(url: string, id: any, name: string, mimeType: string, filePath: any): Promise<import("playwright-core").APIResponse>;
|
|
76
|
+
private getTokenIssuedTime;
|
|
77
|
+
private getTokenExpireTime;
|
|
78
|
+
private getRefreshToken;
|
|
79
|
+
isAccessTokenValid(): Promise<void>;
|
|
80
|
+
private currentDateToEpoch;
|
|
81
|
+
private dateToEpoch;
|
|
82
|
+
private refreshAccessToken;
|
|
83
|
+
private updateLocalStorage;
|
|
70
84
|
}
|
|
@@ -28,6 +28,9 @@ const ModelsBuilderApiHelper_1 = require("./ModelsBuilderApiHelper");
|
|
|
28
28
|
const HealthCheckApiHelper_1 = require("./HealthCheckApiHelper");
|
|
29
29
|
const IndexerApiHelper_1 = require("./IndexerApiHelper");
|
|
30
30
|
const PublishedCacheApiHelper_1 = require("./PublishedCacheApiHelper");
|
|
31
|
+
const MemberGroupApiHelper_1 = require("./MemberGroupApiHelper");
|
|
32
|
+
const MemberApiHelper_1 = require("./MemberApiHelper");
|
|
33
|
+
const MemberTypeApiHelper_1 = require("./MemberTypeApiHelper");
|
|
31
34
|
class ApiHelpers {
|
|
32
35
|
baseUrl = umbraco_config_1.umbracoConfig.environment.baseUrl;
|
|
33
36
|
page;
|
|
@@ -56,6 +59,9 @@ class ApiHelpers {
|
|
|
56
59
|
healthCheck;
|
|
57
60
|
indexer;
|
|
58
61
|
publishedCache;
|
|
62
|
+
memberGroup;
|
|
63
|
+
member;
|
|
64
|
+
memberType;
|
|
59
65
|
constructor(page) {
|
|
60
66
|
this.page = page;
|
|
61
67
|
this.alias = new AliasHelper_1.AliasHelper();
|
|
@@ -83,6 +89,9 @@ class ApiHelpers {
|
|
|
83
89
|
this.healthCheck = new HealthCheckApiHelper_1.HealthCheckApiHelper(this);
|
|
84
90
|
this.indexer = new IndexerApiHelper_1.IndexerApiHelper(this);
|
|
85
91
|
this.publishedCache = new PublishedCacheApiHelper_1.PublishedCacheApiHelper(this);
|
|
92
|
+
this.memberGroup = new MemberGroupApiHelper_1.MemberGroupApiHelper(this);
|
|
93
|
+
this.member = new MemberApiHelper_1.MemberApiHelper(this);
|
|
94
|
+
this.memberType = new MemberTypeApiHelper_1.MemberTypeApiHelper(this);
|
|
86
95
|
}
|
|
87
96
|
async getBearerToken() {
|
|
88
97
|
let someStorage = await this.page.context().storageState();
|
|
@@ -156,6 +165,93 @@ class ApiHelpers {
|
|
|
156
165
|
};
|
|
157
166
|
return await this.page.request.post(url, options);
|
|
158
167
|
}
|
|
168
|
+
async getTokenIssuedTime() {
|
|
169
|
+
let someStorage = await this.page.context().storageState();
|
|
170
|
+
let someObject = JSON.parse(someStorage.origins[0].localStorage[0].value);
|
|
171
|
+
return Number(someObject.issued_at);
|
|
172
|
+
}
|
|
173
|
+
async getTokenExpireTime() {
|
|
174
|
+
let someStorage = await this.page.context().storageState();
|
|
175
|
+
let someObject = JSON.parse(someStorage.origins[0].localStorage[0].value);
|
|
176
|
+
return Number(someObject.expires_in);
|
|
177
|
+
}
|
|
178
|
+
async getRefreshToken() {
|
|
179
|
+
let someStorage = await this.page.context().storageState();
|
|
180
|
+
let someObject = JSON.parse(someStorage.origins[0].localStorage[0].value);
|
|
181
|
+
return someObject.refresh_token;
|
|
182
|
+
}
|
|
183
|
+
async isAccessTokenValid() {
|
|
184
|
+
const tokenTimeIssued = await this.getTokenIssuedTime();
|
|
185
|
+
const tokenExpireTime = await this.getTokenExpireTime();
|
|
186
|
+
// Should use a global value
|
|
187
|
+
const globalTestTimeout = 40;
|
|
188
|
+
// We want to have the date minus the globalTimeout, the reason for this is that while a test is running, the token could expire.
|
|
189
|
+
const tokenRefreshTime = tokenTimeIssued + tokenExpireTime - globalTestTimeout;
|
|
190
|
+
// We need the currentTimeInEpoch so we can check if the tokenRefreshTime is close to expiring.
|
|
191
|
+
const currentTimeInEpoch = await this.currentDateToEpoch();
|
|
192
|
+
if (tokenRefreshTime <= currentTimeInEpoch) {
|
|
193
|
+
const localStorageValue = await this.refreshAccessToken();
|
|
194
|
+
return this.updateLocalStorage(localStorageValue);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
async currentDateToEpoch() {
|
|
198
|
+
const currentTime = new Date(Date.now());
|
|
199
|
+
return this.dateToEpoch(currentTime);
|
|
200
|
+
}
|
|
201
|
+
async dateToEpoch(date) {
|
|
202
|
+
const dateToEpoch = date.getTime();
|
|
203
|
+
// The epoch is in milliseconds, but we want it to be in seconds(Like it is in the token).
|
|
204
|
+
const millisecondsToSeconds = dateToEpoch / 1000;
|
|
205
|
+
// There is no need to have anything after .
|
|
206
|
+
return Number(millisecondsToSeconds.toString().split('.')[0]);
|
|
207
|
+
}
|
|
208
|
+
async refreshAccessToken() {
|
|
209
|
+
const response = await this.page.request.post(umbraco_config_1.umbracoConfig.environment.baseUrl + '/umbraco/management/api/v1/security/back-office/token', {
|
|
210
|
+
headers: {
|
|
211
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
212
|
+
Cookie: await this.getCookie()
|
|
213
|
+
},
|
|
214
|
+
form: {
|
|
215
|
+
grant_type: 'refresh_token',
|
|
216
|
+
client_id: 'umbraco-back-office',
|
|
217
|
+
redirect_uri: umbraco_config_1.umbracoConfig.environment.baseUrl + '/umbraco',
|
|
218
|
+
refresh_token: await this.getRefreshToken()
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
const newIssuedTime = await this.currentDateToEpoch();
|
|
222
|
+
const jsonStorageValue = await response.json();
|
|
223
|
+
// We need to define a new issued_at time.
|
|
224
|
+
jsonStorageValue.issued_at = newIssuedTime;
|
|
225
|
+
return jsonStorageValue;
|
|
226
|
+
}
|
|
227
|
+
async updateLocalStorage(localStorageValue) {
|
|
228
|
+
const currentStorageState = await this.page.context().storageState();
|
|
229
|
+
let currentLocalStorageValue = JSON.parse(currentStorageState.origins[0].localStorage[0].value);
|
|
230
|
+
currentLocalStorageValue.access_token = localStorageValue.access_token;
|
|
231
|
+
currentLocalStorageValue.refresh_token = localStorageValue.refresh_token;
|
|
232
|
+
currentLocalStorageValue.issued_at = localStorageValue.issued_at;
|
|
233
|
+
currentLocalStorageValue.expires_in = localStorageValue.expires_in.toString();
|
|
234
|
+
const filePath = process.env.STORAGE_STAGE_PATH;
|
|
235
|
+
// Updates the user.json file in our CMS project
|
|
236
|
+
if (filePath) {
|
|
237
|
+
const jsonString = fs.readFileSync(filePath, 'utf-8');
|
|
238
|
+
try {
|
|
239
|
+
const data = JSON.parse(jsonString);
|
|
240
|
+
const localStorage = data.origins[0].localStorage[0];
|
|
241
|
+
if (localStorage.name === 'umb:userAuthTokenResponse') {
|
|
242
|
+
localStorage.value = JSON.stringify(currentLocalStorageValue);
|
|
243
|
+
}
|
|
244
|
+
// Converts the object to JSON string
|
|
245
|
+
const updatedJsonString = JSON.stringify(data, null, 2);
|
|
246
|
+
// Writes the updated JSON content to the file
|
|
247
|
+
fs.writeFileSync(filePath, updatedJsonString, 'utf-8');
|
|
248
|
+
console.log('Access token updated successfully.');
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
console.error('Error updating access token:', error);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
159
255
|
}
|
|
160
256
|
exports.ApiHelpers = ApiHelpers;
|
|
161
257
|
//# sourceMappingURL=ApiHelpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiHelpers.js","sourceRoot":"","sources":["../../../lib/helpers/ApiHelpers.ts"],"names":[],"mappings":";;;AACA,yDAAmD;AACnD,iDAA4C;AAC5C,qEAAgE;AAChE,2DAAsD;AACtD,+DAA0D;AAC1D,mEAA8D;AAC9D,6DAAwD;AACxD,2DAAsD;AACtD,+CAA0C;AAC1C,2DAAsD;AACtD,mDAA8C;AAC9C,qEAAgE;AAChE,yDAAoD;AACpD,uDAAkD;AAClD,iEAA4D;AAC5D,+DAA0D;AAC1D,yBAAyB;AACzB,6DAAwD;AACxD,mEAA8D;AAC9D,2DAAs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E,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC;iBAClC;aACF;YACD,iBAAiB,EAAE,IAAI;SACxB,CAAA;QACD,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;CACF;AA1ID,gCA0IC","sourcesContent":["import {Page} from \"@playwright/test\"\nimport {umbracoConfig} from \"../../umbraco.config\";\nimport {ReportHelper} from \"./ReportHelper\";\nimport {TelemetryDataApiHelper} from \"./TelemetryDataApiHelper\";\nimport {LanguageApiHelper} from \"./LanguageApiHelper\";\nimport {DictionaryApiHelper} from \"./DictionaryApiHelper\";\nimport {RelationTypeApiHelper} from \"./RelationTypeApiHelper\";\nimport {UserGroupApiHelper} from \"./UserGroupApiHelper\";\nimport {TemplateApiHelper} from \"./TemplateApiHelper\";\nimport {AliasHelper} from \"./AliasHelper\";\nimport {DataTypeApiHelper} from \"./DataTypeApiHelper\";\nimport {UserApiHelper} from \"./UserApiHelper\";\nimport {TemporaryFileApiHelper} from \"./TemporaryFileApiHelper\";\nimport {PackageApiHelper} from \"./PackageApiHelper\";\nimport {ScriptApiHelper} from \"./ScriptApiHelper\";\nimport {PartialViewApiHelper} from \"./PartialViewApiHelper\";\nimport {StylesheetApiHelper} from \"./StylesheetApiHelper\";\nimport * as fs from \"fs\";\nimport {LogViewerApiHelper} from \"./LogViewerApiHelper\";\nimport {DocumentTypeApiHelper} from \"./DocumentTypeApiHelper\";\nimport {DocumentApiHelper} from \"./DocumentApiHelper\";\nimport {MediaTypeApiHelper} from \"./MediaTypeApiHelper\";\nimport {MediaApiHelper} from \"./MediaApiHelper\";\nimport {ObjectTypesApiHelper} from \"./ObjectTypesApiHelper\";\nimport {ModelsBuilderApiHelper} from \"./ModelsBuilderApiHelper\";\nimport {HealthCheckApiHelper} from \"./HealthCheckApiHelper\";\nimport {IndexerApiHelper} from \"./IndexerApiHelper\";\nimport {PublishedCacheApiHelper} from \"./PublishedCacheApiHelper\";\n\nexport class ApiHelpers {\n baseUrl: string = umbracoConfig.environment.baseUrl;\n page: Page;\n alias: AliasHelper;\n report: ReportHelper;\n telemetry: TelemetryDataApiHelper;\n language: LanguageApiHelper;\n dictionary: DictionaryApiHelper;\n relationType: RelationTypeApiHelper;\n userGroup: UserGroupApiHelper;\n template: TemplateApiHelper;\n dataType: DataTypeApiHelper;\n user: UserApiHelper;\n temporaryFile: TemporaryFileApiHelper;\n documentType: DocumentTypeApiHelper;\n document: DocumentApiHelper;\n package: PackageApiHelper;\n script: ScriptApiHelper;\n partialView: PartialViewApiHelper;\n stylesheet: StylesheetApiHelper;\n logViewer: LogViewerApiHelper;\n mediaType: MediaTypeApiHelper;\n media: MediaApiHelper;\n objectTypes: ObjectTypesApiHelper;\n modelsBuilder: ModelsBuilderApiHelper;\n healthCheck: HealthCheckApiHelper;\n indexer: IndexerApiHelper;\n publishedCache: PublishedCacheApiHelper;\n\n constructor(page: Page) {\n this.page = page;\n this.alias = new AliasHelper();\n this.report = new ReportHelper(this);\n this.telemetry = new TelemetryDataApiHelper(this);\n this.language = new LanguageApiHelper(this);\n this.dictionary = new DictionaryApiHelper(this);\n this.relationType = new RelationTypeApiHelper(this);\n this.userGroup = new UserGroupApiHelper(this);\n this.template = new TemplateApiHelper(this);\n this.dataType = new DataTypeApiHelper(this);\n this.user = new UserApiHelper(this);\n this.temporaryFile = new TemporaryFileApiHelper(this);\n this.documentType = new DocumentTypeApiHelper(this);\n this.document = new DocumentApiHelper(this);\n this.package = new PackageApiHelper(this);\n this.script = new ScriptApiHelper(this);\n this.partialView = new PartialViewApiHelper(this);\n this.stylesheet = new StylesheetApiHelper(this);\n this.logViewer = new LogViewerApiHelper(this);\n this.mediaType = new MediaTypeApiHelper(this);\n this.media = new MediaApiHelper(this);\n this.objectTypes = new ObjectTypesApiHelper(this);\n this.modelsBuilder = new ModelsBuilderApiHelper(this);\n this.healthCheck = new HealthCheckApiHelper(this);\n this.indexer = new IndexerApiHelper(this);\n this.publishedCache = new PublishedCacheApiHelper(this);\n }\n\n async getBearerToken() {\n let someStorage = await this.page.context().storageState();\n let someObject = JSON.parse(someStorage.origins[0].localStorage[0].value);\n return 'Bearer ' + someObject.access_token;\n }\n\n async getCookie() {\n let someStorage = await this.page.context().storageState();\n let cookieString = \"\";\n for (let cookie of someStorage.cookies) {\n cookieString += cookie.name + '=' + cookie.value + ';';\n }\n return cookieString;\n }\n\n async getHeaders() {\n return {\n 'Authorization': await this.getBearerToken(),\n 'Cookie': await this.getCookie(),\n }\n }\n\n async get(url: string, params?: { [key: string]: string | number | boolean; }) {\n const options = {\n headers: await this.getHeaders(),\n params: params,\n ignoreHTTPSErrors: true\n }\n return this.page.request.get(url, options);\n }\n\n async saveCodeFile(codeFile) {\n if (codeFile == null) {\n return;\n }\n return await this.post(umbracoConfig.environment.baseUrl + '/umbraco/backoffice/UmbracoApi/CodeFile/PostSave', codeFile);\n }\n\n async post(url: string, data?: object) {\n const options = {\n headers: await this.getHeaders(),\n data: data,\n ignoreHTTPSErrors: true\n }\n return await this.page.request.post(url, options);\n }\n\n async delete(url: string, data?: object) {\n const options = {\n headers: await this.getHeaders(),\n data: data,\n ignoreHTTPSErrors: true\n }\n return await this.page.request.delete(url, options);\n }\n\n async put(url: string, data?: object) {\n const options = {\n headers: await this.getHeaders(),\n data: data,\n ignoreHTTPSErrors: true\n }\n return await this.page.request.put(url, options);\n }\n\n async postMultiPartForm(url: string, id, name: string, mimeType: string, filePath) {\n const options = {\n headers: await this.getHeaders(),\n multipart: {\n Id: id,\n File: {\n name: name,\n mimeType: mimeType,\n buffer: fs.readFileSync(filePath)\n }\n },\n ignoreHTTPSErrors: true\n }\n return await this.page.request.post(url, options);\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"ApiHelpers.js","sourceRoot":"","sources":["../../../lib/helpers/ApiHelpers.ts"],"names":[],"mappings":";;;AACA,yDAAmD;AACnD,iDAA4C;AAC5C,qEAAgE;AAChE,2DAAsD;AACtD,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CAAC,YAAY,GAAG,iBAAiB,CAAC,YAAY,CAAC;QACvE,wBAAwB,CAAC,aAAa,GAAG,iBAAiB,CAAC,aAAa,CAAC;QACzE,wBAAwB,CAAC,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;QACjE,wBAAwB,CAAC,UAAU,GAAG,iBAAiB,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;QAE9E,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;QAChD,gDAAgD;QAChD,IAAI,QAAQ,EAAE;YACZ,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAEtD,IAAI;gBACF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBACpC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;gBACrD,IAAI,YAAY,CAAC,IAAI,KAAK,2BAA2B,EAAE;oBACrD,YAAY,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;iBAC/D;gBAED,qCAAqC;gBACrC,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;gBAExD,8CAA8C;gBAC9C,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC;gBAEvD,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;aACnD;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;aACtD;SACF;IACH,CAAC;CAEF;AAzPD,gCAyPC","sourcesContent":["import {Page} from \"@playwright/test\"\nimport {umbracoConfig} from \"../../umbraco.config\";\nimport {ReportHelper} from \"./ReportHelper\";\nimport {TelemetryDataApiHelper} from \"./TelemetryDataApiHelper\";\nimport {LanguageApiHelper} from \"./LanguageApiHelper\";\nimport {DictionaryApiHelper} from \"./DictionaryApiHelper\";\nimport {RelationTypeApiHelper} from \"./RelationTypeApiHelper\";\nimport {UserGroupApiHelper} from \"./UserGroupApiHelper\";\nimport {TemplateApiHelper} from \"./TemplateApiHelper\";\nimport {AliasHelper} from \"./AliasHelper\";\nimport {DataTypeApiHelper} from \"./DataTypeApiHelper\";\nimport {UserApiHelper} from \"./UserApiHelper\";\nimport {TemporaryFileApiHelper} from \"./TemporaryFileApiHelper\";\nimport {PackageApiHelper} from \"./PackageApiHelper\";\nimport {ScriptApiHelper} from \"./ScriptApiHelper\";\nimport {PartialViewApiHelper} from \"./PartialViewApiHelper\";\nimport {StylesheetApiHelper} from \"./StylesheetApiHelper\";\nimport * as fs from \"fs\";\nimport {LogViewerApiHelper} from \"./LogViewerApiHelper\";\nimport {DocumentTypeApiHelper} from \"./DocumentTypeApiHelper\";\nimport {DocumentApiHelper} from \"./DocumentApiHelper\";\nimport {MediaTypeApiHelper} from \"./MediaTypeApiHelper\";\nimport {MediaApiHelper} from \"./MediaApiHelper\";\nimport {ObjectTypesApiHelper} from \"./ObjectTypesApiHelper\";\nimport {ModelsBuilderApiHelper} from \"./ModelsBuilderApiHelper\";\nimport {HealthCheckApiHelper} from \"./HealthCheckApiHelper\";\nimport {IndexerApiHelper} from \"./IndexerApiHelper\";\nimport {PublishedCacheApiHelper} from \"./PublishedCacheApiHelper\";\nimport {MemberGroupApiHelper} from './MemberGroupApiHelper';\nimport {MemberApiHelper} from './MemberApiHelper';\nimport {MemberTypeApiHelper} from \"./MemberTypeApiHelper\";\n\nexport class ApiHelpers {\n baseUrl: string = umbracoConfig.environment.baseUrl;\n page: Page;\n alias: AliasHelper;\n report: ReportHelper;\n telemetry: TelemetryDataApiHelper;\n language: LanguageApiHelper;\n dictionary: DictionaryApiHelper;\n relationType: RelationTypeApiHelper;\n userGroup: UserGroupApiHelper;\n template: TemplateApiHelper;\n dataType: DataTypeApiHelper;\n user: UserApiHelper;\n temporaryFile: TemporaryFileApiHelper;\n documentType: DocumentTypeApiHelper;\n document: DocumentApiHelper;\n package: PackageApiHelper;\n script: ScriptApiHelper;\n partialView: PartialViewApiHelper;\n stylesheet: StylesheetApiHelper;\n logViewer: LogViewerApiHelper;\n mediaType: MediaTypeApiHelper;\n media: MediaApiHelper;\n objectTypes: ObjectTypesApiHelper;\n modelsBuilder: ModelsBuilderApiHelper;\n healthCheck: HealthCheckApiHelper;\n indexer: IndexerApiHelper;\n publishedCache: PublishedCacheApiHelper;\n memberGroup: MemberGroupApiHelper;\n member: MemberApiHelper;\n memberType: MemberTypeApiHelper;\n\n constructor(page: Page) {\n this.page = page;\n this.alias = new AliasHelper();\n this.report = new ReportHelper(this);\n this.telemetry = new TelemetryDataApiHelper(this);\n this.language = new LanguageApiHelper(this);\n this.dictionary = new DictionaryApiHelper(this);\n this.relationType = new RelationTypeApiHelper(this);\n this.userGroup = new UserGroupApiHelper(this);\n this.template = new TemplateApiHelper(this);\n this.dataType = new DataTypeApiHelper(this);\n this.user = new UserApiHelper(this);\n this.temporaryFile = new TemporaryFileApiHelper(this);\n this.documentType = new DocumentTypeApiHelper(this);\n this.document = new DocumentApiHelper(this);\n this.package = new PackageApiHelper(this);\n this.script = new ScriptApiHelper(this);\n this.partialView = new PartialViewApiHelper(this);\n this.stylesheet = new StylesheetApiHelper(this);\n this.logViewer = new LogViewerApiHelper(this);\n this.mediaType = new MediaTypeApiHelper(this);\n this.media = new MediaApiHelper(this);\n this.objectTypes = new ObjectTypesApiHelper(this);\n this.modelsBuilder = new ModelsBuilderApiHelper(this);\n this.healthCheck = new HealthCheckApiHelper(this);\n this.indexer = new IndexerApiHelper(this);\n this.publishedCache = new PublishedCacheApiHelper(this);\n this.memberGroup = new MemberGroupApiHelper(this);\n this.member = new MemberApiHelper(this);\n this.memberType = new MemberTypeApiHelper(this);\n }\n\n async getBearerToken() {\n let someStorage = await this.page.context().storageState();\n let someObject = JSON.parse(someStorage.origins[0].localStorage[0].value);\n return 'Bearer ' + someObject.access_token;\n }\n\n async getCookie() {\n let someStorage = await this.page.context().storageState();\n let cookieString = \"\";\n for (let cookie of someStorage.cookies) {\n cookieString += cookie.name + '=' + cookie.value + ';';\n }\n return cookieString;\n }\n\n async getHeaders() {\n return {\n 'Authorization': await this.getBearerToken(),\n 'Cookie': await this.getCookie(),\n }\n }\n\n async get(url: string, params?: { [key: string]: string | number | boolean; }) {\n const options = {\n headers: await this.getHeaders(),\n params: params,\n ignoreHTTPSErrors: true\n }\n return this.page.request.get(url, options);\n }\n\n async saveCodeFile(codeFile) {\n if (codeFile == null) {\n return;\n }\n return await this.post(umbracoConfig.environment.baseUrl + '/umbraco/backoffice/UmbracoApi/CodeFile/PostSave', codeFile);\n }\n\n async post(url: string, data?: object) {\n const options = {\n headers: await this.getHeaders(),\n data: data,\n ignoreHTTPSErrors: true\n }\n return await this.page.request.post(url, options);\n }\n\n async delete(url: string, data?: object) {\n const options = {\n headers: await this.getHeaders(),\n data: data,\n ignoreHTTPSErrors: true\n }\n return await this.page.request.delete(url, options);\n }\n\n async put(url: string, data?: object) {\n const options = {\n headers: await this.getHeaders(),\n data: data,\n ignoreHTTPSErrors: true\n }\n return await this.page.request.put(url, options);\n }\n\n async postMultiPartForm(url: string, id, name: string, mimeType: string, filePath) {\n const options = {\n headers: await this.getHeaders(),\n multipart: {\n Id: id,\n File: {\n name: name,\n mimeType: mimeType,\n buffer: fs.readFileSync(filePath)\n }\n },\n ignoreHTTPSErrors: true\n }\n return await this.page.request.post(url, options);\n }\n\n private async getTokenIssuedTime() {\n let someStorage = await this.page.context().storageState();\n let someObject = JSON.parse(someStorage.origins[0].localStorage[0].value);\n return Number(someObject.issued_at);\n }\n\n private async getTokenExpireTime() {\n let someStorage = await this.page.context().storageState();\n let someObject = JSON.parse(someStorage.origins[0].localStorage[0].value);\n return Number(someObject.expires_in);\n }\n\n private async getRefreshToken() {\n let someStorage = await this.page.context().storageState();\n let someObject = JSON.parse(someStorage.origins[0].localStorage[0].value);\n return someObject.refresh_token;\n }\n\n async isAccessTokenValid() {\n const tokenTimeIssued = await this.getTokenIssuedTime();\n const tokenExpireTime = await this.getTokenExpireTime();\n // Should use a global value\n const globalTestTimeout: number = 40;\n // We want to have the date minus the globalTimeout, the reason for this is that while a test is running, the token could expire.\n const tokenRefreshTime = tokenTimeIssued + tokenExpireTime - globalTestTimeout;\n // We need the currentTimeInEpoch so we can check if the tokenRefreshTime is close to expiring.\n const currentTimeInEpoch = await this.currentDateToEpoch();\n \n if (tokenRefreshTime <= currentTimeInEpoch) {\n const localStorageValue = await this.refreshAccessToken();\n return this.updateLocalStorage(localStorageValue);\n }\n }\n\n private async currentDateToEpoch() {\n const currentTime = new Date(Date.now());\n return this.dateToEpoch(currentTime);\n }\n\n private async dateToEpoch(date: Date) {\n const dateToEpoch = date.getTime();\n // The epoch is in milliseconds, but we want it to be in seconds(Like it is in the token).\n const millisecondsToSeconds = dateToEpoch / 1000;\n // There is no need to have anything after .\n return Number(millisecondsToSeconds.toString().split('.')[0]);\n }\n\n private async refreshAccessToken() {\n const response = await this.page.request.post(umbracoConfig.environment.baseUrl + '/umbraco/management/api/v1/security/back-office/token', {\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n Cookie: await this.getCookie()\n },\n form:\n {\n grant_type: 'refresh_token',\n client_id: 'umbraco-back-office',\n redirect_uri: umbracoConfig.environment.baseUrl + '/umbraco',\n refresh_token: await this.getRefreshToken()\n }\n });\n \n const newIssuedTime = await this.currentDateToEpoch();\n const jsonStorageValue = await response.json();\n // We need to define a new issued_at time.\n jsonStorageValue.issued_at = newIssuedTime;\n\n return jsonStorageValue;\n }\n\n private async updateLocalStorage(localStorageValue) {\n const currentStorageState = await this.page.context().storageState();\n let currentLocalStorageValue = JSON.parse(currentStorageState.origins[0].localStorage[0].value);\n\n currentLocalStorageValue.access_token = localStorageValue.access_token;\n currentLocalStorageValue.refresh_token = localStorageValue.refresh_token;\n currentLocalStorageValue.issued_at = localStorageValue.issued_at;\n currentLocalStorageValue.expires_in = localStorageValue.expires_in.toString();\n\n const filePath = process.env.STORAGE_STAGE_PATH;\n // Updates the user.json file in our CMS project\n if (filePath) {\n const jsonString = fs.readFileSync(filePath, 'utf-8');\n \n try {\n const data = JSON.parse(jsonString);\n const localStorage = data.origins[0].localStorage[0];\n if (localStorage.name === 'umb:userAuthTokenResponse') {\n localStorage.value = JSON.stringify(currentLocalStorageValue);\n }\n\n // Converts the object to JSON string\n const updatedJsonString = JSON.stringify(data, null, 2);\n\n // Writes the updated JSON content to the file\n fs.writeFileSync(filePath, updatedJsonString, 'utf-8');\n \n console.log('Access token updated successfully.');\n } catch (error) {\n console.error('Error updating access token:', error);\n }\n }\n }\n // TODO: Maybe we need to do the same for the cookie? As the cookie expires after some time as well\n}"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ApiHelpers } from "./ApiHelpers";
|
|
2
|
+
export declare class MemberApiHelper {
|
|
3
|
+
api: ApiHelpers;
|
|
4
|
+
constructor(api: ApiHelpers);
|
|
5
|
+
get(id: string): Promise<any>;
|
|
6
|
+
create(member: any): Promise<string | undefined>;
|
|
7
|
+
delete(id: string): Promise<number | undefined>;
|
|
8
|
+
getAll(): Promise<import("playwright-core").APIResponse>;
|
|
9
|
+
filterByMemberTypeId(memberTypeId: string): Promise<import("playwright-core").APIResponse>;
|
|
10
|
+
doesExist(id: string): Promise<boolean>;
|
|
11
|
+
doesNameExist(name: string): Promise<any>;
|
|
12
|
+
getByName(name: string): Promise<any>;
|
|
13
|
+
ensureNameNotExists(name: string): Promise<number | null | undefined>;
|
|
14
|
+
createDefaultMember(memberName: string, memberTypeId: string, email: string, username: string, password: string): Promise<string | undefined>;
|
|
15
|
+
createMemberWithMemberGroup(memberName: string, memberTypeId: string, email: string, username: string, password: string, memberGroupId: string): Promise<string | undefined>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemberApiHelper = void 0;
|
|
4
|
+
const json_models_builders_1 = require("@umbraco/json-models-builders");
|
|
5
|
+
class MemberApiHelper {
|
|
6
|
+
api;
|
|
7
|
+
constructor(api) {
|
|
8
|
+
this.api = api;
|
|
9
|
+
}
|
|
10
|
+
async get(id) {
|
|
11
|
+
const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/member/' + id);
|
|
12
|
+
return await response.json();
|
|
13
|
+
}
|
|
14
|
+
async create(member) {
|
|
15
|
+
if (member == null) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const response = await this.api.post(this.api.baseUrl + '/umbraco/management/api/v1/member', member);
|
|
19
|
+
return response.headers().location.split("v1/member/").pop();
|
|
20
|
+
}
|
|
21
|
+
async delete(id) {
|
|
22
|
+
if (id == null) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const response = await this.api.delete(this.api.baseUrl + '/umbraco/management/api/v1/member/' + id);
|
|
26
|
+
return response.status();
|
|
27
|
+
}
|
|
28
|
+
async getAll() {
|
|
29
|
+
return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/filter/member?orderBy=username&skip=0&take=10000');
|
|
30
|
+
}
|
|
31
|
+
async filterByMemberTypeId(memberTypeId) {
|
|
32
|
+
return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/filter/member?memberTypeId=' + memberTypeId + '&orderBy=username&skip=0&take=100');
|
|
33
|
+
}
|
|
34
|
+
async doesExist(id) {
|
|
35
|
+
const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/member/' + id);
|
|
36
|
+
return response.status() === 200;
|
|
37
|
+
}
|
|
38
|
+
async doesNameExist(name) {
|
|
39
|
+
return await this.getByName(name);
|
|
40
|
+
}
|
|
41
|
+
async getByName(name) {
|
|
42
|
+
const rootMembers = await this.getAll();
|
|
43
|
+
const jsonMembers = await rootMembers.json();
|
|
44
|
+
for (const member of jsonMembers.items) {
|
|
45
|
+
if (member.variants[0].name === name) {
|
|
46
|
+
return this.get(member.id);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
async ensureNameNotExists(name) {
|
|
52
|
+
const rootMembers = await this.getAll();
|
|
53
|
+
const jsonMembers = await rootMembers.json();
|
|
54
|
+
for (const member of jsonMembers.items) {
|
|
55
|
+
if (member.variants[0].name === name) {
|
|
56
|
+
return this.delete(member.id);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
async createDefaultMember(memberName, memberTypeId, email, username, password) {
|
|
62
|
+
const member = new json_models_builders_1.MemberBuilder()
|
|
63
|
+
.addVariant()
|
|
64
|
+
.withName(memberName)
|
|
65
|
+
.done()
|
|
66
|
+
.withEmail(email)
|
|
67
|
+
.withUsername(username)
|
|
68
|
+
.withPassword(password)
|
|
69
|
+
.withMemberTypeId(memberTypeId)
|
|
70
|
+
.build();
|
|
71
|
+
return await this.create(member);
|
|
72
|
+
}
|
|
73
|
+
async createMemberWithMemberGroup(memberName, memberTypeId, email, username, password, memberGroupId) {
|
|
74
|
+
const member = new json_models_builders_1.MemberBuilder()
|
|
75
|
+
.addVariant()
|
|
76
|
+
.withName(memberName)
|
|
77
|
+
.done()
|
|
78
|
+
.withEmail(email)
|
|
79
|
+
.withUsername(username)
|
|
80
|
+
.withPassword(password)
|
|
81
|
+
.withMemberTypeId(memberTypeId)
|
|
82
|
+
.addGroup(memberGroupId)
|
|
83
|
+
.build();
|
|
84
|
+
return await this.create(member);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.MemberApiHelper = MemberApiHelper;
|
|
88
|
+
//# sourceMappingURL=MemberApiHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MemberApiHelper.js","sourceRoot":"","sources":["../../../lib/helpers/MemberApiHelper.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,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,UAAkB,EAAE,YAAoB,EAAE,KAAa,EAAE,QAAgB,EAAE,QAAgB;QACnH,MAAM,MAAM,GAAG,IAAI,oCAAa,EAAE;aAC/B,UAAU,EAAE;aACV,QAAQ,CAAC,UAAU,CAAC;aACpB,IAAI,EAAE;aACR,SAAS,CAAC,KAAK,CAAC;aAChB,YAAY,CAAC,QAAQ,CAAC;aACtB,YAAY,CAAC,QAAQ,CAAC;aACtB,gBAAgB,CAAC,YAAY,CAAC;aAC9B,KAAK,EAAE,CAAC;QACX,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,2BAA2B,CAAC,UAAkB,EAAE,YAAoB,EAAE,KAAa,EAAE,QAAgB,EAAE,QAAgB,EAAE,aAAqB;QAClJ,MAAM,MAAM,GAAG,IAAI,oCAAa,EAAE;aAC/B,UAAU,EAAE;aACV,QAAQ,CAAC,UAAU,CAAC;aACpB,IAAI,EAAE;aACR,SAAS,CAAC,KAAK,CAAC;aAChB,YAAY,CAAC,QAAQ,CAAC;aACtB,YAAY,CAAC,QAAQ,CAAC;aACtB,gBAAgB,CAAC,YAAY,CAAC;aAC9B,QAAQ,CAAC,aAAa,CAAC;aACvB,KAAK,EAAE,CAAC;QACX,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;CACF;AA/FD,0CA+FC","sourcesContent":["import {ApiHelpers} from \"./ApiHelpers\";\nimport {MemberBuilder} from \"@umbraco/json-models-builders\";\n\nexport class MemberApiHelper {\n api: ApiHelpers;\n\n constructor(api: ApiHelpers) {\n this.api = api;\n }\n\n async get(id: string) {\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/member/' + id);\n return await response.json();\n }\n\n async create(member) {\n if (member == null) {\n return;\n }\n const response = await this.api.post(this.api.baseUrl + '/umbraco/management/api/v1/member', member);\n return response.headers().location.split(\"v1/member/\").pop();\n }\n\n async delete(id: string) {\n if (id == null) {\n return;\n }\n const response = await this.api.delete(this.api.baseUrl + '/umbraco/management/api/v1/member/' + id);\n return response.status();\n }\n\n async getAll() {\n return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/filter/member?orderBy=username&skip=0&take=10000');\n }\n\n async filterByMemberTypeId(memberTypeId: string) {\n return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/filter/member?memberTypeId='+ memberTypeId + '&orderBy=username&skip=0&take=100');\n }\n\n async doesExist(id: string) {\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/member/' + id);\n return response.status() === 200;\n }\n\n async doesNameExist(name: string) {\n return await this.getByName(name);\n }\n\n async getByName(name: string) {\n const rootMembers = await this.getAll();\n const jsonMembers = await rootMembers.json();\n\n for (const member of jsonMembers.items) {\n if (member.variants[0].name === name) {\n return this.get(member.id);\n }\n }\n return false;\n }\n\n async ensureNameNotExists(name: string) {\n const rootMembers = await this.getAll();\n const jsonMembers = await rootMembers.json();\n\n for (const member of jsonMembers.items) {\n if (member.variants[0].name === name) {\n return this.delete(member.id);\n }\n }\n return null;\n }\n\n async createDefaultMember(memberName: string, memberTypeId: string, email: string, username: string, password: string) {\n const member = new MemberBuilder()\n .addVariant()\n .withName(memberName)\n .done()\n .withEmail(email)\n .withUsername(username)\n .withPassword(password)\n .withMemberTypeId(memberTypeId)\n .build();\n return await this.create(member);\n }\n\n async createMemberWithMemberGroup(memberName: string, memberTypeId: string, email: string, username: string, password: string, memberGroupId: string) {\n const member = new MemberBuilder()\n .addVariant()\n .withName(memberName)\n .done()\n .withEmail(email)\n .withUsername(username)\n .withPassword(password)\n .withMemberTypeId(memberTypeId)\n .addGroup(memberGroupId)\n .build();\n return await this.create(member);\n }\n}"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ApiHelpers } from "./ApiHelpers";
|
|
2
|
+
export declare class MemberGroupApiHelper {
|
|
3
|
+
api: ApiHelpers;
|
|
4
|
+
constructor(api: ApiHelpers);
|
|
5
|
+
get(id: string): Promise<any>;
|
|
6
|
+
create(name: string, id?: string): Promise<any>;
|
|
7
|
+
rename(id: string, name: string): Promise<import("playwright-core").APIResponse>;
|
|
8
|
+
delete(id: string): Promise<import("playwright-core").APIResponse>;
|
|
9
|
+
getAll(): Promise<import("playwright-core").APIResponse>;
|
|
10
|
+
doesExist(id: string): Promise<boolean>;
|
|
11
|
+
doesNameExist(name: string): Promise<any>;
|
|
12
|
+
getByName(name: string): Promise<any>;
|
|
13
|
+
ensureNameNotExists(name: string): Promise<import("playwright-core").APIResponse | null>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemberGroupApiHelper = void 0;
|
|
4
|
+
class MemberGroupApiHelper {
|
|
5
|
+
api;
|
|
6
|
+
constructor(api) {
|
|
7
|
+
this.api = api;
|
|
8
|
+
}
|
|
9
|
+
async get(id) {
|
|
10
|
+
const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/member-group/' + id);
|
|
11
|
+
return await response.json();
|
|
12
|
+
}
|
|
13
|
+
async create(name, id) {
|
|
14
|
+
const memberGroupData = {
|
|
15
|
+
"name": name,
|
|
16
|
+
"id": id ? id : null,
|
|
17
|
+
};
|
|
18
|
+
const response = await this.api.post(this.api.baseUrl + '/umbraco/management/api/v1/member-group', memberGroupData);
|
|
19
|
+
const json = await response.json();
|
|
20
|
+
return json.id;
|
|
21
|
+
}
|
|
22
|
+
async rename(id, name) {
|
|
23
|
+
const memberGroupData = {
|
|
24
|
+
"name": name
|
|
25
|
+
};
|
|
26
|
+
return await this.api.put(this.api.baseUrl + '/umbraco/management/api/v1/member-group/' + id, memberGroupData);
|
|
27
|
+
}
|
|
28
|
+
async delete(id) {
|
|
29
|
+
return await this.api.delete(this.api.baseUrl + '/umbraco/management/api/v1/member-group/' + id);
|
|
30
|
+
}
|
|
31
|
+
async getAll() {
|
|
32
|
+
return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/tree/member-group/root?skip=0&take=10000');
|
|
33
|
+
}
|
|
34
|
+
async doesExist(id) {
|
|
35
|
+
const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/member-group/' + id);
|
|
36
|
+
return response.status() === 200;
|
|
37
|
+
}
|
|
38
|
+
async doesNameExist(name) {
|
|
39
|
+
return await this.getByName(name);
|
|
40
|
+
}
|
|
41
|
+
async getByName(name) {
|
|
42
|
+
const rootMemberGroups = await this.getAll();
|
|
43
|
+
const jsonMemberGroups = await rootMemberGroups.json();
|
|
44
|
+
for (const memberGroup of jsonMemberGroups.items) {
|
|
45
|
+
if (memberGroup.name === name) {
|
|
46
|
+
return this.get(memberGroup.id);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
async ensureNameNotExists(name) {
|
|
52
|
+
const rootMemberGroups = await this.getAll();
|
|
53
|
+
const jsonMemberGroups = await rootMemberGroups.json();
|
|
54
|
+
for (const memberGroup of jsonMemberGroups.items) {
|
|
55
|
+
if (memberGroup.name === name) {
|
|
56
|
+
return this.delete(memberGroup.id);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.MemberGroupApiHelper = MemberGroupApiHelper;
|
|
63
|
+
//# sourceMappingURL=MemberGroupApiHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MemberGroupApiHelper.js","sourceRoot":"","sources":["../../../lib/helpers/MemberGroupApiHelper.ts"],"names":[],"mappings":";;;AAEA,MAAa,oBAAoB;IAC/B,GAAG,CAAa;IAEhB,YAAY,GAAe;QACzB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,MAAM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AAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,0CAA0C,GAAG,EAAE,CAAC,CAAC;QACxG,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAAY;QAC9B,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAAY;QAC1B,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7C,MAAM,gBAAgB,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,CAAC;QAEvD,KAAK,MAAM,WAAW,IAAI,gBAAgB,CAAC,KAAK,EAAE;YAChD,IAAI,WAAW,CAAC,IAAI,KAAK,IAAI,EAAE;gBAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;aACjC;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,IAAY;QACpC,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7C,MAAM,gBAAgB,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,CAAC;QAEvD,KAAK,MAAM,WAAW,IAAI,gBAAgB,CAAC,KAAK,EAAE;YAChD,IAAI,WAAW,CAAC,IAAI,KAAK,IAAI,EAAE;gBAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;aACpC;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AArED,oDAqEC","sourcesContent":["import {ApiHelpers} from \"./ApiHelpers\";\n\nexport class MemberGroupApiHelper {\n api: ApiHelpers;\n\n constructor(api: ApiHelpers) {\n this.api = api;\n }\n\n async get(id: string) {\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/member-group/' + id);\n return await response.json();\n }\n\n async create(name: string, id?: string) {\n const memberGroupData = {\n \"name\": name,\n \"id\": id ? id : null,\n };\n const response = await this.api.post(this.api.baseUrl + '/umbraco/management/api/v1/member-group', memberGroupData);\n const json = await response.json();\n return json.id;\n }\n\n async rename(id: string, name: string) {\n const memberGroupData = {\n \"name\": name\n };\n return await this.api.put(this.api.baseUrl + '/umbraco/management/api/v1/member-group/' + id, memberGroupData);\n }\n\n async delete(id: string) {\n return await this.api.delete(this.api.baseUrl + '/umbraco/management/api/v1/member-group/' + id);\n }\n\n async getAll() {\n return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/tree/member-group/root?skip=0&take=10000');\n }\n\n async doesExist(id: string) {\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/member-group/' + id);\n return response.status() === 200;\n }\n\n async doesNameExist(name: string) {\n return await this.getByName(name);\n }\n\n async getByName(name: string) {\n const rootMemberGroups = await this.getAll();\n const jsonMemberGroups = await rootMemberGroups.json();\n\n for (const memberGroup of jsonMemberGroups.items) {\n if (memberGroup.name === name) {\n return this.get(memberGroup.id);\n }\n }\n return false;\n }\n\n async ensureNameNotExists(name: string) {\n const rootMemberGroups = await this.getAll();\n const jsonMemberGroups = await rootMemberGroups.json();\n\n for (const memberGroup of jsonMemberGroups.items) {\n if (memberGroup.name === name) {\n return this.delete(memberGroup.id);\n }\n }\n return null;\n }\n}"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Page } from "@playwright/test";
|
|
2
|
+
import { UiBaseLocators } from "./UiBaseLocators";
|
|
3
|
+
export declare class MemberGroupUiHelper extends UiBaseLocators {
|
|
4
|
+
private readonly memberGroupsTab;
|
|
5
|
+
private readonly memberGroupNameTxt;
|
|
6
|
+
private readonly actionsBtn;
|
|
7
|
+
private readonly leftArrowBtn;
|
|
8
|
+
private readonly memberGroupView;
|
|
9
|
+
constructor(page: Page);
|
|
10
|
+
clickMemberGroupsTab(): Promise<void>;
|
|
11
|
+
enterMemberGroupName(name: string): Promise<void>;
|
|
12
|
+
clickMemberGroupLinkByName(memberGroupName: string): Promise<void>;
|
|
13
|
+
clickActionsButton(): Promise<void>;
|
|
14
|
+
clickLeftArrowButton(): Promise<void>;
|
|
15
|
+
isMemberGroupNameVisible(memberGroupName: string, isVisible?: boolean): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemberGroupUiHelper = void 0;
|
|
4
|
+
const test_1 = require("@playwright/test");
|
|
5
|
+
const UiBaseLocators_1 = require("./UiBaseLocators");
|
|
6
|
+
class MemberGroupUiHelper extends UiBaseLocators_1.UiBaseLocators {
|
|
7
|
+
memberGroupsTab;
|
|
8
|
+
memberGroupNameTxt;
|
|
9
|
+
actionsBtn;
|
|
10
|
+
leftArrowBtn;
|
|
11
|
+
memberGroupView;
|
|
12
|
+
constructor(page) {
|
|
13
|
+
super(page);
|
|
14
|
+
this.memberGroupsTab = page.locator('uui-tab[label="Member Groups"]');
|
|
15
|
+
this.memberGroupNameTxt = page.locator('input#input');
|
|
16
|
+
this.actionsBtn = page.getByLabel('Actions', { exact: true });
|
|
17
|
+
this.leftArrowBtn = page.locator('[name="icon-arrow-left"] svg');
|
|
18
|
+
this.memberGroupView = page.locator('umb-member-group-table-collection-view');
|
|
19
|
+
}
|
|
20
|
+
async clickMemberGroupsTab() {
|
|
21
|
+
await this.memberGroupsTab.click();
|
|
22
|
+
}
|
|
23
|
+
async enterMemberGroupName(name) {
|
|
24
|
+
await (0, test_1.expect)(this.memberGroupNameTxt).toBeVisible();
|
|
25
|
+
await this.memberGroupNameTxt.clear();
|
|
26
|
+
await this.memberGroupNameTxt.fill(name);
|
|
27
|
+
}
|
|
28
|
+
async clickMemberGroupLinkByName(memberGroupName) {
|
|
29
|
+
await this.page.getByRole('link', { name: memberGroupName }).click();
|
|
30
|
+
}
|
|
31
|
+
async clickActionsButton() {
|
|
32
|
+
await this.actionsBtn.click();
|
|
33
|
+
}
|
|
34
|
+
async clickLeftArrowButton() {
|
|
35
|
+
await this.leftArrowBtn.click();
|
|
36
|
+
}
|
|
37
|
+
async isMemberGroupNameVisible(memberGroupName, isVisible = true) {
|
|
38
|
+
return (0, test_1.expect)(this.memberGroupView.filter({ hasText: memberGroupName })).toBeVisible({ visible: isVisible, timeout: 500 });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.MemberGroupUiHelper = MemberGroupUiHelper;
|
|
42
|
+
//# sourceMappingURL=MemberGroupUiHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MemberGroupUiHelper.js","sourceRoot":"","sources":["../../../lib/helpers/MemberGroupUiHelper.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;AACvD,qDAAgD;AAEhD,MAAa,mBAAoB,SAAQ,+BAAc;IACpC,eAAe,CAAU;IACzB,kBAAkB,CAAU;IAC5B,UAAU,CAAU;IACpB,YAAY,CAAU;IACtB,eAAe,CAAU;IAE1C,YAAY,IAAU;QACpB,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,gCAAgC,CAAC,CAAC;QACtE,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACtD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;QACjE,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,wCAAwC,CAAC,CAAC;IAChF,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,IAAY;QACrC,MAAM,IAAA,aAAM,EAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,WAAW,EAAE,CAAC;QACpD,MAAM,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QACtC,MAAM,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,0BAA0B,CAAC,eAAuB;QACtD,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAC,IAAI,EAAE,eAAe,EAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,wBAAwB,CAAC,eAAuB,EAAE,YAAqB,IAAI;QAC/E,OAAO,IAAA,aAAM,EAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAC,OAAO,EAAE,eAAe,EAAC,CAAC,CAAC,CAAC,WAAW,CAAC,EAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAC,CAAC,CAAC;IACzH,CAAC;CACF;AAzCD,kDAyCC","sourcesContent":["import {Page, Locator, expect} from \"@playwright/test\";\nimport {UiBaseLocators} from \"./UiBaseLocators\";\n\nexport class MemberGroupUiHelper extends UiBaseLocators {\n private readonly memberGroupsTab: Locator;\n private readonly memberGroupNameTxt: Locator;\n private readonly actionsBtn: Locator;\n private readonly leftArrowBtn: Locator;\n private readonly memberGroupView: Locator;\n\n constructor(page: Page) {\n super(page);\n this.memberGroupsTab = page.locator('uui-tab[label=\"Member Groups\"]');\n this.memberGroupNameTxt = page.locator('input#input');\n this.actionsBtn = page.getByLabel('Actions', {exact: true});\n this.leftArrowBtn = page.locator('[name=\"icon-arrow-left\"] svg');\n this.memberGroupView = page.locator('umb-member-group-table-collection-view');\n }\n\n async clickMemberGroupsTab() {\n await this.memberGroupsTab.click();\n }\n\n async enterMemberGroupName(name: string) {\n await expect(this.memberGroupNameTxt).toBeVisible();\n await this.memberGroupNameTxt.clear();\n await this.memberGroupNameTxt.fill(name);\n }\n\n async clickMemberGroupLinkByName(memberGroupName: string) {\n await this.page.getByRole('link', {name: memberGroupName}).click();\n }\n\n async clickActionsButton() {\n await this.actionsBtn.click();\n }\n\n async clickLeftArrowButton() {\n await this.leftArrowBtn.click();\n }\n\n async isMemberGroupNameVisible(memberGroupName: string, isVisible: boolean = true) {\n return expect(this.memberGroupView.filter({hasText: memberGroupName})).toBeVisible({visible: isVisible, timeout: 500});\n }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ApiHelpers } from "./ApiHelpers";
|
|
2
|
+
export declare class MemberTypeApiHelper {
|
|
3
|
+
api: ApiHelpers;
|
|
4
|
+
constructor(api: ApiHelpers);
|
|
5
|
+
ensureNameNotExists(name: string): Promise<number | null | undefined>;
|
|
6
|
+
create(memberType: any): Promise<string | undefined>;
|
|
7
|
+
update(id: string, updatedMemberType: any): Promise<import("playwright-core").APIResponse | undefined>;
|
|
8
|
+
get(id: string): Promise<any>;
|
|
9
|
+
delete(id: string): Promise<number | undefined>;
|
|
10
|
+
getAllAtRoot(): Promise<import("playwright-core").APIResponse>;
|
|
11
|
+
getByName(name: string): Promise<any>;
|
|
12
|
+
doesExist(id: string): Promise<boolean>;
|
|
13
|
+
doesNameExist(name: string): Promise<any>;
|
|
14
|
+
createDefaultMemberType(memberTypeName: string): Promise<string | undefined>;
|
|
15
|
+
createMemberTypeWithPropertyEditor(memberTypeName: string, dataTypeName: string, dataTypeId: string, groupName?: string): Promise<string | undefined>;
|
|
16
|
+
createMemberTypeWithTwoPropertyEditors(memberTypeName: string, dataTypeNameOne: string, dataTypeIdOne: string, dataTypeNameTwo: string, dataTypeIdTwo: string, groupName?: string): Promise<string | undefined>;
|
|
17
|
+
}
|