@umbraco/playwright-testhelpers 2.0.0-beta.49 → 2.0.0-beta.50
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/ContentUiHelper.d.ts +20 -0
- package/dist/lib/helpers/ContentUiHelper.js +66 -6
- package/dist/lib/helpers/ContentUiHelper.js.map +1 -1
- package/dist/lib/helpers/DocumentApiHelper.d.ts +2 -0
- package/dist/lib/helpers/DocumentApiHelper.js +18 -0
- package/dist/lib/helpers/DocumentApiHelper.js.map +1 -1
- package/dist/lib/helpers/DocumentTypeApiHelper.d.ts +2 -1
- package/dist/lib/helpers/DocumentTypeApiHelper.js +17 -1
- package/dist/lib/helpers/DocumentTypeApiHelper.js.map +1 -1
- package/dist/lib/helpers/MediaUiHelper.d.ts +0 -3
- package/dist/lib/helpers/MediaUiHelper.js +0 -11
- package/dist/lib/helpers/MediaUiHelper.js.map +1 -1
- package/dist/lib/helpers/RedirectManagementUiHelper.d.ts +2 -0
- package/dist/lib/helpers/RedirectManagementUiHelper.js +8 -0
- package/dist/lib/helpers/RedirectManagementUiHelper.js.map +1 -1
- package/dist/lib/helpers/UiBaseLocators.d.ts +4 -0
- package/dist/lib/helpers/UiBaseLocators.js +15 -2
- package/dist/lib/helpers/UiBaseLocators.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -26,6 +26,14 @@ export declare class ContentUiHelper extends UiBaseLocators {
|
|
|
26
26
|
private readonly deleteDomainBtn;
|
|
27
27
|
private readonly reloadChildrenThreeDotsBtn;
|
|
28
28
|
private readonly contentTree;
|
|
29
|
+
private readonly richTextAreaTxt;
|
|
30
|
+
private readonly textAreaTxt;
|
|
31
|
+
private readonly plusIconBtn;
|
|
32
|
+
private readonly enterTagTxt;
|
|
33
|
+
private readonly sidebarModal;
|
|
34
|
+
private readonly menuItemTree;
|
|
35
|
+
private readonly domainComboBox;
|
|
36
|
+
private readonly confirmToUnpublishBtn;
|
|
29
37
|
constructor(page: Page);
|
|
30
38
|
enterContentName(name: string): Promise<void>;
|
|
31
39
|
clickSaveAndPublishButton(): Promise<void>;
|
|
@@ -41,6 +49,11 @@ export declare class ContentUiHelper extends UiBaseLocators {
|
|
|
41
49
|
waitForModalHidden(): Promise<void>;
|
|
42
50
|
enterTextstring(text: string): Promise<void>;
|
|
43
51
|
doesContentTreeHaveName(contentName: string): Promise<void>;
|
|
52
|
+
enterRichTextArea(value: string): Promise<void>;
|
|
53
|
+
enterTextArea(value: string): Promise<void>;
|
|
54
|
+
addTags(tagName: string): Promise<void>;
|
|
55
|
+
addContentPicker(contentName: string): Promise<void>;
|
|
56
|
+
clickConfirmToUnpublishButton(): Promise<void>;
|
|
44
57
|
clickInfoTab(): Promise<void>;
|
|
45
58
|
doesLinkHaveText(text: string): Promise<void>;
|
|
46
59
|
doesHistoryHaveText(text: string): Promise<void>;
|
|
@@ -49,6 +62,13 @@ export declare class ContentUiHelper extends UiBaseLocators {
|
|
|
49
62
|
doesIdHaveText(text: string): Promise<void>;
|
|
50
63
|
clickEditDocumentTypeButton(): Promise<void>;
|
|
51
64
|
clickAddTemplateButton(): Promise<void>;
|
|
65
|
+
clickDocumentTypeByName(documentTypeName: string): Promise<void>;
|
|
66
|
+
clickTemplateByName(templateName: string): Promise<void>;
|
|
67
|
+
isDocumentTypeModalVisible(documentTypeName: string): Promise<void>;
|
|
68
|
+
isTemplateModalVisible(templateName: string): Promise<void>;
|
|
69
|
+
clickEditTemplateByName(templateName: string): Promise<void>;
|
|
70
|
+
changeTemplate(oldTemplate: string, newTemplate: string): Promise<void>;
|
|
71
|
+
isTemplateNameDisabled(templateName: string): Promise<void>;
|
|
52
72
|
clickCultureAndHostnamesButton(): Promise<void>;
|
|
53
73
|
selectCultureLanguageOption(option: string): Promise<void>;
|
|
54
74
|
selectDomainLanguageOption(option: string, index?: number): Promise<void>;
|
|
@@ -29,6 +29,14 @@ class ContentUiHelper extends UiBaseLocators_1.UiBaseLocators {
|
|
|
29
29
|
deleteDomainBtn;
|
|
30
30
|
reloadChildrenThreeDotsBtn;
|
|
31
31
|
contentTree;
|
|
32
|
+
richTextAreaTxt;
|
|
33
|
+
textAreaTxt;
|
|
34
|
+
plusIconBtn;
|
|
35
|
+
enterTagTxt;
|
|
36
|
+
sidebarModal;
|
|
37
|
+
menuItemTree;
|
|
38
|
+
domainComboBox;
|
|
39
|
+
confirmToUnpublishBtn;
|
|
32
40
|
constructor(page) {
|
|
33
41
|
super(page);
|
|
34
42
|
this.contentNameTxt = page.locator('#name-input input');
|
|
@@ -41,12 +49,19 @@ class ContentUiHelper extends UiBaseLocators_1.UiBaseLocators {
|
|
|
41
49
|
this.textstringTxt = page.locator('umb-property-layout[label="Textstring"] #input');
|
|
42
50
|
this.reloadChildrenThreeDotsBtn = page.getByRole('button', { name: 'Reload children...' });
|
|
43
51
|
this.contentTree = page.locator('umb-tree[alias="Umb.Tree.Document"]');
|
|
52
|
+
this.richTextAreaTxt = page.frameLocator('iframe[title="Rich Text Area"]').locator('#tinymce');
|
|
53
|
+
this.textAreaTxt = page.locator('umb-property-editor-ui-textarea textarea');
|
|
54
|
+
this.plusIconBtn = page.locator('#icon-add svg');
|
|
55
|
+
this.enterTagTxt = page.getByPlaceholder('Enter tag');
|
|
56
|
+
this.sidebarModal = page.locator('uui-modal-sidebar');
|
|
57
|
+
this.menuItemTree = page.locator('umb-menu-item-tree-default');
|
|
58
|
+
this.confirmToUnpublishBtn = page.locator('umb-document-unpublish-modal').getByLabel('Unpublish');
|
|
44
59
|
// Info tab
|
|
45
60
|
this.infoTab = page.getByRole('tab', { name: 'Info' });
|
|
46
|
-
this.linkContent = page.locator('link-content');
|
|
61
|
+
this.linkContent = page.locator('.link-content');
|
|
47
62
|
this.historyItems = page.locator('umb-history-item');
|
|
48
|
-
this.generalItem = page.locator('general-item');
|
|
49
|
-
this.publicationStatus = this.generalItem.filter({ hasText: 'Publication Status' }).locator('
|
|
63
|
+
this.generalItem = page.locator('.general-item');
|
|
64
|
+
this.publicationStatus = this.generalItem.filter({ hasText: 'Publication Status' }).locator('uui-tag');
|
|
50
65
|
this.createdDate = this.generalItem.filter({ hasText: 'Created' }).locator('umb-localize-date');
|
|
51
66
|
this.editDocumentTypeBtn = this.generalItem.filter({ hasText: 'Document Type' }).locator('#button');
|
|
52
67
|
this.addTemplateBtn = this.generalItem.filter({ hasText: 'Template' }).locator('#button');
|
|
@@ -58,6 +73,7 @@ class ContentUiHelper extends UiBaseLocators_1.UiBaseLocators {
|
|
|
58
73
|
this.domainTxt = page.getByLabel('Domain', { exact: true });
|
|
59
74
|
this.domainLanguageDropdownBox = page.locator('[headline="Domains"]').getByLabel('combobox-input');
|
|
60
75
|
this.deleteDomainBtn = page.locator('[headline="Domains"] [name="icon-trash"] svg');
|
|
76
|
+
this.domainComboBox = page.locator('#domains uui-combobox');
|
|
61
77
|
}
|
|
62
78
|
async enterContentName(name) {
|
|
63
79
|
await (0, test_1.expect)(this.contentNameTxt).toBeVisible();
|
|
@@ -83,13 +99,13 @@ class ContentUiHelper extends UiBaseLocators_1.UiBaseLocators {
|
|
|
83
99
|
await this.actionMenuForContentBtn.click();
|
|
84
100
|
}
|
|
85
101
|
async openContent(contentName) {
|
|
86
|
-
await this.
|
|
102
|
+
await this.menuItemTree.getByText(contentName, { exact: true }).click();
|
|
87
103
|
}
|
|
88
104
|
async clickActionsMenuForContent(name) {
|
|
89
105
|
await this.clickActionsMenuForName(name);
|
|
90
106
|
}
|
|
91
107
|
async clickCaretButtonForContentName(name) {
|
|
92
|
-
await this.
|
|
108
|
+
await this.menuItemTree.filter({ hasText: name }).last().locator('#caret-button').last().click();
|
|
93
109
|
}
|
|
94
110
|
async waitForModalVisible() {
|
|
95
111
|
await this.openedModal.waitFor({ state: 'attached' });
|
|
@@ -104,6 +120,27 @@ class ContentUiHelper extends UiBaseLocators_1.UiBaseLocators {
|
|
|
104
120
|
async doesContentTreeHaveName(contentName) {
|
|
105
121
|
await (0, test_1.expect)(this.contentTree).toContainText(contentName);
|
|
106
122
|
}
|
|
123
|
+
async enterRichTextArea(value) {
|
|
124
|
+
await (0, test_1.expect)(this.richTextAreaTxt).toBeVisible();
|
|
125
|
+
await this.richTextAreaTxt.fill(value);
|
|
126
|
+
}
|
|
127
|
+
async enterTextArea(value) {
|
|
128
|
+
await (0, test_1.expect)(this.textAreaTxt).toBeVisible();
|
|
129
|
+
await this.textAreaTxt.fill(value);
|
|
130
|
+
}
|
|
131
|
+
async addTags(tagName) {
|
|
132
|
+
await this.plusIconBtn.click();
|
|
133
|
+
await this.enterTagTxt.fill(tagName);
|
|
134
|
+
await this.enterTagTxt.press('Enter');
|
|
135
|
+
}
|
|
136
|
+
async addContentPicker(contentName) {
|
|
137
|
+
await this.clickChooseButton();
|
|
138
|
+
await this.sidebarModal.getByText(contentName).click();
|
|
139
|
+
await this.chooseModalBtn.click();
|
|
140
|
+
}
|
|
141
|
+
async clickConfirmToUnpublishButton() {
|
|
142
|
+
await this.confirmToUnpublishBtn.click();
|
|
143
|
+
}
|
|
107
144
|
// Info Tab
|
|
108
145
|
async clickInfoTab() {
|
|
109
146
|
await this.infoTab.click({ force: true });
|
|
@@ -129,6 +166,29 @@ class ContentUiHelper extends UiBaseLocators_1.UiBaseLocators {
|
|
|
129
166
|
async clickAddTemplateButton() {
|
|
130
167
|
await this.addTemplateBtn.click();
|
|
131
168
|
}
|
|
169
|
+
async clickDocumentTypeByName(documentTypeName) {
|
|
170
|
+
await this.page.locator('uui-ref-node-document-type[name="' + documentTypeName + '"]').click();
|
|
171
|
+
}
|
|
172
|
+
async clickTemplateByName(templateName) {
|
|
173
|
+
await this.page.locator('uui-ref-node[name="' + templateName + '"]').click();
|
|
174
|
+
}
|
|
175
|
+
async isDocumentTypeModalVisible(documentTypeName) {
|
|
176
|
+
await (0, test_1.expect)(this.sidebarModal.locator('umb-document-type-workspace-editor [value="' + documentTypeName + '"]')).toBeVisible();
|
|
177
|
+
}
|
|
178
|
+
async isTemplateModalVisible(templateName) {
|
|
179
|
+
await (0, test_1.expect)(this.sidebarModal.getByText(templateName)).toBeVisible();
|
|
180
|
+
}
|
|
181
|
+
async clickEditTemplateByName(templateName) {
|
|
182
|
+
await this.page.locator('uui-ref-node[name="' + templateName + '"]').getByLabel('Edit').click();
|
|
183
|
+
}
|
|
184
|
+
async changeTemplate(oldTemplate, newTemplate) {
|
|
185
|
+
await this.clickEditTemplateByName(oldTemplate);
|
|
186
|
+
await this.sidebarModal.getByLabel(newTemplate).click();
|
|
187
|
+
await this.chooseModalBtn.click();
|
|
188
|
+
}
|
|
189
|
+
async isTemplateNameDisabled(templateName) {
|
|
190
|
+
await (0, test_1.expect)(this.sidebarModal.getByLabel(templateName)).toBeDisabled();
|
|
191
|
+
}
|
|
132
192
|
// Culture and Hostnames
|
|
133
193
|
async clickCultureAndHostnamesButton() {
|
|
134
194
|
await this.cultureAndHostnamesBtn.click();
|
|
@@ -139,7 +199,7 @@ class ContentUiHelper extends UiBaseLocators_1.UiBaseLocators {
|
|
|
139
199
|
}
|
|
140
200
|
async selectDomainLanguageOption(option, index = 0) {
|
|
141
201
|
await this.domainLanguageDropdownBox.nth(index).click();
|
|
142
|
-
await this.
|
|
202
|
+
await this.domainComboBox.nth(index).getByText(option).click();
|
|
143
203
|
}
|
|
144
204
|
async clickAddNewDomainButton() {
|
|
145
205
|
await this.addNewDomainBtn.click();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentUiHelper.js","sourceRoot":"","sources":["../../../lib/helpers/ContentUiHelper.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;AACvD,qDAAgD;AAEhD,MAAa,eAAgB,SAAQ,+BAAc;IAChC,cAAc,CAAU;IACxB,iBAAiB,CAAU;IAC3B,UAAU,CAAU;IACpB,UAAU,CAAU;IACpB,YAAY,CAAU;IACtB,uBAAuB,CAAU;IACjC,WAAW,CAAU;IACrB,aAAa,CAAU;IACvB,OAAO,CAAU;IACjB,WAAW,CAAU;IACrB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AAc,EAAE,QAAgB,CAAC;QAChE,MAAM,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;QACxD,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;IACxF,CAAC;IAED,KAAK,CAAC,uBAAuB;QAC3B,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAa,EAAE,QAAgB,CAAC;QAChD,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;QACxC,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,uBAAuB;QAC3B,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC;IAC7C,CAAC;CACF;AAjLD,0CAiLC","sourcesContent":["import {Page, Locator, expect} from \"@playwright/test\";\nimport {UiBaseLocators} from \"./UiBaseLocators\";\n\nexport class ContentUiHelper extends UiBaseLocators {\n private readonly contentNameTxt: Locator;\n private readonly saveAndPublishBtn: Locator;\n private readonly actionsBtn: Locator;\n private readonly publishBtn: Locator;\n private readonly unpublishBtn: Locator;\n private readonly actionMenuForContentBtn: Locator;\n private readonly openedModal: Locator;\n private readonly textstringTxt: Locator;\n private readonly infoTab: Locator;\n private readonly linkContent: Locator;\n private readonly historyItems: Locator;\n private readonly generalItem: Locator;\n private readonly publicationStatus: Locator;\n private readonly createdDate: Locator;\n private readonly editDocumentTypeBtn: Locator;\n private readonly addTemplateBtn: Locator;\n private readonly id: Locator;\n private readonly cultureAndHostnamesBtn: Locator;\n private readonly cultureLanguageDropdownBox: Locator;\n private readonly addNewDomainBtn: Locator;\n private readonly domainTxt: Locator;\n private readonly domainLanguageDropdownBox: Locator;\n private readonly deleteDomainBtn: Locator;\n private readonly reloadChildrenThreeDotsBtn: Locator;\n private readonly contentTree: Locator;\n\n constructor(page: Page) {\n super(page);\n this.contentNameTxt = page.locator('#name-input input');\n this.saveAndPublishBtn = page.getByLabel('Save And Publish');\n this.actionsBtn = page.getByLabel('Actions', { exact: true });\n this.publishBtn = page.getByLabel('Publish', { exact: true });\n this.unpublishBtn = page.getByLabel('Unpublish', { exact: true });\n this.actionMenuForContentBtn = page.locator('#header [label=\"Open actions menu\"]');\n this.openedModal = page.locator('uui-modal-container[backdrop]');\n this.textstringTxt = page.locator('umb-property-layout[label=\"Textstring\"] #input');\n this.reloadChildrenThreeDotsBtn = page.getByRole('button', {name: 'Reload children...'});\n this.contentTree = page.locator('umb-tree[alias=\"Umb.Tree.Document\"]');\n // Info tab\n this.infoTab = page.getByRole('tab', {name: 'Info'});\n this.linkContent = page.locator('link-content');\n this.historyItems = page.locator('umb-history-item');\n this.generalItem = page.locator('general-item');\n this.publicationStatus = this.generalItem.filter({hasText: 'Publication Status'}).locator('umb-localize');\n this.createdDate = this.generalItem.filter({hasText: 'Created'}).locator('umb-localize-date');\n this.editDocumentTypeBtn = this.generalItem.filter({hasText: 'Document Type'}).locator('#button');\n this.addTemplateBtn = this.generalItem.filter({hasText: 'Template'}).locator('#button');\n this.id = this.generalItem.filter({hasText: 'Id'}).locator('span');\n // Culure and Hostname\n this.cultureAndHostnamesBtn = page.getByLabel('Culture and Hostnames');\n this.cultureLanguageDropdownBox = page.locator('[headline=\"Culture\"]').getByLabel('combobox-input');\n this.addNewDomainBtn = page.getByLabel('Add new domain');\n this.domainTxt = page.getByLabel('Domain', { exact: true });\n this.domainLanguageDropdownBox = page.locator('[headline=\"Domains\"]').getByLabel('combobox-input');\n this.deleteDomainBtn = page.locator('[headline=\"Domains\"] [name=\"icon-trash\"] svg');\n }\n\n async enterContentName(name: string) {\n await expect(this.contentNameTxt).toBeVisible();\n await this.contentNameTxt.clear();\n await this.contentNameTxt.fill(name);\n }\n\n async clickSaveAndPublishButton() {\n await this.saveAndPublishBtn.click();\n }\n\n async clickActionsButton() {\n await this.actionsBtn.click();\n }\n\n async clickPublishButton() {\n await this.publishBtn.click();\n }\n\n async clickUnpublishButton() {\n await this.unpublishBtn.click();\n }\n\n async clickReloadChildrenThreeDotsButton() {\n await this.reloadChildrenThreeDotsBtn.click();\n }\n\n async clickActionsMenuAtRoot() {\n await this.actionMenuForContentBtn.click();\n }\n\n async openContent(contentName: string) {\n await this.page.locator('umb-menu-item-tree-default').getByText(contentName, {exact: true}).click();\n }\n\n async clickActionsMenuForContent(name: string) {\n await this.clickActionsMenuForName(name);\n }\n\n async clickCaretButtonForContentName(name: string) {\n await this.page.locator('umb-menu-item-tree-default').filter({hasText: name}).last().locator('#caret-button').last().click();\n }\n\n async waitForModalVisible() {\n await this.openedModal.waitFor({state: 'attached'});\n }\n\n async waitForModalHidden() {\n await this.openedModal.waitFor({state: 'hidden'});\n }\n\n async enterTextstring(text: string) {\n await this.textstringTxt.clear();\n await this.textstringTxt.fill(text);\n }\n\n async doesContentTreeHaveName(contentName: string) {\n await expect(this.contentTree).toContainText(contentName);\n }\n\n // Info Tab\n async clickInfoTab() {\n await this.infoTab.click({force: true});\n }\n\n async doesLinkHaveText(text: string) {\n await expect(this.linkContent).toHaveText(text);\n }\n\n async doesHistoryHaveText(text: string) {\n await expect(this.historyItems).toHaveText(text);\n }\n\n async doesPublicationStatusHaveText(text: string) {\n await expect(this.publicationStatus).toHaveText(text);\n }\n\n async doesCreatedDateHaveText(text: string) {\n await expect(this.createdDate).toHaveText(text);\n }\n\n async doesIdHaveText(text: string) {\n await expect(this.id).toHaveText(text);\n }\n\n async clickEditDocumentTypeButton() {\n await this.editDocumentTypeBtn.click();\n }\n\n async clickAddTemplateButton() {\n await this.addTemplateBtn.click();\n }\n\n // Culture and Hostnames\n async clickCultureAndHostnamesButton() {\n await this.cultureAndHostnamesBtn.click();\n }\n\n async selectCultureLanguageOption(option: string) {\n await this.cultureLanguageDropdownBox.click();\n await this.page.getByText(option).click();\n }\n\n async selectDomainLanguageOption(option: string, index: number = 0) {\n await this.domainLanguageDropdownBox.nth(index).click();\n await this.page.locator('#domains uui-combobox').nth(index).getByText(option).click();\n }\n\n async clickAddNewDomainButton() {\n await this.addNewDomainBtn.click();\n }\n\n async enterDomain(value: string, index: number = 0) {\n await this.domainTxt.nth(index).clear();\n await this.domainTxt.nth(index).fill(value);\n }\n\n async clickDeleteDomainButton() {\n await this.deleteDomainBtn.first().click();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ContentUiHelper.js","sourceRoot":"","sources":["../../../lib/helpers/ContentUiHelper.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;AACvD,qDAAgD;AAEhD,MAAa,eAAgB,SAAQ,+BAAc;IAChC,cAAc,CAAU;IACxB,iBAAiB,CAAU;IAC3B,UAAU,CAAU;IACpB,UAAU,CAAU;IACpB,YAAY,CAAU;IACtB,uBAAuB,CAAU;IACjC,WAAW,CAAU;IACrB,aAAa,CAAU;IACvB,OAAO,CAAU;IACjB,WAAW,CAAU;IACrB,YAAY,CAAU;IACtB,WAAW,CAAU;IACrB,iBAAiB,CAAU;IAC3B,WAAW,CAAU;IACrB,mBAAmB,CAAU;IAC7B,cAAc,CAAU;IACxB,EAAE,CAAU;IACZ,sBAAsB,CAAU;IAChC,0BAA0B,CAAU;IACpC,eAAe,CAAU;IACzB,SAAS,CAAU;IACnB,yBAAyB,CAAU;IACnC,eAAe,CAAU;IACzB,0BAA0B,CAAU;IACpC,WAAW,CAAU;IACrB,eAAe,CAAU;IACzB,WAAW,CAAU;IACrB,WAAW,CAAU;IACrB,WAAW,CAAU;IACrB,YAAY,CAAU;IACtB,YAAY,CAAU;IACtB,cAAc,CAAU;IACxB,qBAAqB,CAAU;IAEhD,YAAY,IAAU;QACpB,KAAK,CA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AE,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,0BAA0B,CAAC,MAAc,EAAE,QAAgB,CAAC;QAChE,MAAM,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;QACxD,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,uBAAuB;QAC3B,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAa,EAAE,QAAgB,CAAC;QAChD,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;QACxC,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,uBAAuB;QAC3B,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC;IAC7C,CAAC;CACF;AAzPD,0CAyPC","sourcesContent":["import {Page, Locator, expect} from \"@playwright/test\";\nimport {UiBaseLocators} from \"./UiBaseLocators\";\n\nexport class ContentUiHelper extends UiBaseLocators {\n private readonly contentNameTxt: Locator;\n private readonly saveAndPublishBtn: Locator;\n private readonly actionsBtn: Locator;\n private readonly publishBtn: Locator;\n private readonly unpublishBtn: Locator;\n private readonly actionMenuForContentBtn: Locator;\n private readonly openedModal: Locator;\n private readonly textstringTxt: Locator;\n private readonly infoTab: Locator;\n private readonly linkContent: Locator;\n private readonly historyItems: Locator;\n private readonly generalItem: Locator;\n private readonly publicationStatus: Locator;\n private readonly createdDate: Locator;\n private readonly editDocumentTypeBtn: Locator;\n private readonly addTemplateBtn: Locator;\n private readonly id: Locator;\n private readonly cultureAndHostnamesBtn: Locator;\n private readonly cultureLanguageDropdownBox: Locator;\n private readonly addNewDomainBtn: Locator;\n private readonly domainTxt: Locator;\n private readonly domainLanguageDropdownBox: Locator;\n private readonly deleteDomainBtn: Locator;\n private readonly reloadChildrenThreeDotsBtn: Locator;\n private readonly contentTree: Locator;\n private readonly richTextAreaTxt: Locator;\n private readonly textAreaTxt: Locator;\n private readonly plusIconBtn: Locator;\n private readonly enterTagTxt: Locator;\n private readonly sidebarModal: Locator;\n private readonly menuItemTree: Locator;\n private readonly domainComboBox: Locator;\n private readonly confirmToUnpublishBtn: Locator;\n\n constructor(page: Page) {\n super(page);\n this.contentNameTxt = page.locator('#name-input input');\n this.saveAndPublishBtn = page.getByLabel('Save And Publish');\n this.actionsBtn = page.getByLabel('Actions', {exact: true});\n this.publishBtn = page.getByLabel('Publish', {exact: true});\n this.unpublishBtn = page.getByLabel('Unpublish', {exact: true});\n this.actionMenuForContentBtn = page.locator('#header [label=\"Open actions menu\"]');\n this.openedModal = page.locator('uui-modal-container[backdrop]');\n this.textstringTxt = page.locator('umb-property-layout[label=\"Textstring\"] #input');\n this.reloadChildrenThreeDotsBtn = page.getByRole('button', {name: 'Reload children...'});\n this.contentTree = page.locator('umb-tree[alias=\"Umb.Tree.Document\"]');\n this.richTextAreaTxt = page.frameLocator('iframe[title=\"Rich Text Area\"]').locator('#tinymce');\n this.textAreaTxt = page.locator('umb-property-editor-ui-textarea textarea');\n this.plusIconBtn = page.locator('#icon-add svg');\n this.enterTagTxt = page.getByPlaceholder('Enter tag');\n this.sidebarModal = page.locator('uui-modal-sidebar');\n this.menuItemTree = page.locator('umb-menu-item-tree-default');\n this.confirmToUnpublishBtn = page.locator('umb-document-unpublish-modal').getByLabel('Unpublish');\n // Info tab\n this.infoTab = page.getByRole('tab', {name: 'Info'});\n this.linkContent = page.locator('.link-content');\n this.historyItems = page.locator('umb-history-item');\n this.generalItem = page.locator('.general-item');\n this.publicationStatus = this.generalItem.filter({hasText: 'Publication Status'}).locator('uui-tag');\n this.createdDate = this.generalItem.filter({hasText: 'Created'}).locator('umb-localize-date');\n this.editDocumentTypeBtn = this.generalItem.filter({hasText: 'Document Type'}).locator('#button');\n this.addTemplateBtn = this.generalItem.filter({hasText: 'Template'}).locator('#button');\n this.id = this.generalItem.filter({hasText: 'Id'}).locator('span');\n // Culure and Hostname\n this.cultureAndHostnamesBtn = page.getByLabel('Culture and Hostnames');\n this.cultureLanguageDropdownBox = page.locator('[headline=\"Culture\"]').getByLabel('combobox-input');\n this.addNewDomainBtn = page.getByLabel('Add new domain');\n this.domainTxt = page.getByLabel('Domain', { exact: true });\n this.domainLanguageDropdownBox = page.locator('[headline=\"Domains\"]').getByLabel('combobox-input');\n this.deleteDomainBtn = page.locator('[headline=\"Domains\"] [name=\"icon-trash\"] svg');\n this.domainComboBox = page.locator('#domains uui-combobox');\n }\n\n async enterContentName(name: string) {\n await expect(this.contentNameTxt).toBeVisible();\n await this.contentNameTxt.clear();\n await this.contentNameTxt.fill(name);\n }\n\n async clickSaveAndPublishButton() {\n await this.saveAndPublishBtn.click();\n }\n\n async clickActionsButton() {\n await this.actionsBtn.click();\n }\n\n async clickPublishButton() {\n await this.publishBtn.click();\n }\n\n async clickUnpublishButton() {\n await this.unpublishBtn.click();\n }\n\n async clickReloadChildrenThreeDotsButton() {\n await this.reloadChildrenThreeDotsBtn.click();\n }\n\n async clickActionsMenuAtRoot() {\n await this.actionMenuForContentBtn.click();\n }\n\n async openContent(contentName: string) {\n await this.menuItemTree.getByText(contentName, {exact: true}).click();\n }\n\n async clickActionsMenuForContent(name: string) {\n await this.clickActionsMenuForName(name);\n }\n\n async clickCaretButtonForContentName(name: string) {\n await this.menuItemTree.filter({hasText: name}).last().locator('#caret-button').last().click();\n }\n\n async waitForModalVisible() {\n await this.openedModal.waitFor({state: 'attached'});\n }\n\n async waitForModalHidden() {\n await this.openedModal.waitFor({state: 'hidden'});\n }\n\n async enterTextstring(text: string) {\n await this.textstringTxt.clear();\n await this.textstringTxt.fill(text);\n }\n\n async doesContentTreeHaveName(contentName: string) {\n await expect(this.contentTree).toContainText(contentName);\n }\n\n async enterRichTextArea(value: string) {\n await expect(this.richTextAreaTxt).toBeVisible();\n await this.richTextAreaTxt.fill(value);\n }\n\n async enterTextArea(value: string) {\n await expect(this.textAreaTxt).toBeVisible();\n await this.textAreaTxt.fill(value);\n }\n\n async addTags(tagName: string) {\n await this.plusIconBtn.click();\n await this.enterTagTxt.fill(tagName);\n await this.enterTagTxt.press('Enter');\n }\n\n async addContentPicker(contentName: string) {\n await this.clickChooseButton();\n await this.sidebarModal.getByText(contentName).click();\n await this.chooseModalBtn.click();\n }\n\n async clickConfirmToUnpublishButton() {\n await this.confirmToUnpublishBtn.click();\n }\n\n // Info Tab\n async clickInfoTab() {\n await this.infoTab.click({force: true});\n }\n\n async doesLinkHaveText(text: string) {\n await expect(this.linkContent).toHaveText(text);\n }\n\n async doesHistoryHaveText(text: string) {\n await expect(this.historyItems).toHaveText(text);\n }\n\n async doesPublicationStatusHaveText(text: string) {\n await expect(this.publicationStatus).toHaveText(text);\n }\n\n async doesCreatedDateHaveText(text: string) {\n await expect(this.createdDate).toHaveText(text);\n }\n\n async doesIdHaveText(text: string) {\n await expect(this.id).toHaveText(text);\n }\n\n async clickEditDocumentTypeButton() {\n await this.editDocumentTypeBtn.click();\n }\n\n async clickAddTemplateButton() {\n await this.addTemplateBtn.click();\n }\n\n async clickDocumentTypeByName(documentTypeName:string) {\n await this.page.locator('uui-ref-node-document-type[name=\"' + documentTypeName + '\"]').click();\n }\n\n async clickTemplateByName(templateName:string) {\n await this.page.locator('uui-ref-node[name=\"' + templateName + '\"]').click();\n }\n\n async isDocumentTypeModalVisible(documentTypeName: string) {\n await expect(this.sidebarModal.locator('umb-document-type-workspace-editor [value=\"' + documentTypeName + '\"]')).toBeVisible();\n }\n\n async isTemplateModalVisible(templateName: string) {\n await expect(this.sidebarModal.getByText(templateName)).toBeVisible();\n }\n\n async clickEditTemplateByName(templateName:string) {\n await this.page.locator('uui-ref-node[name=\"' + templateName + '\"]').getByLabel('Edit').click();\n }\n\n async changeTemplate(oldTemplate: string, newTemplate: string) {\n await this.clickEditTemplateByName(oldTemplate);\n await this.sidebarModal.getByLabel(newTemplate).click();\n await this.chooseModalBtn.click();\n }\n\n async isTemplateNameDisabled(templateName:string) {\n await expect(this.sidebarModal.getByLabel(templateName)).toBeDisabled();\n }\n\n // Culture and Hostnames\n async clickCultureAndHostnamesButton() {\n await this.cultureAndHostnamesBtn.click();\n }\n\n async selectCultureLanguageOption(option: string) {\n await this.cultureLanguageDropdownBox.click();\n await this.page.getByText(option).click();\n }\n\n async selectDomainLanguageOption(option: string, index: number = 0) {\n await this.domainLanguageDropdownBox.nth(index).click();\n await this.domainComboBox.nth(index).getByText(option).click();\n }\n\n async clickAddNewDomainButton() {\n await this.addNewDomainBtn.click();\n }\n\n async enterDomain(value: string, index: number = 0) {\n await this.domainTxt.nth(index).clear();\n await this.domainTxt.nth(index).fill(value);\n }\n\n async clickDeleteDomainButton() {\n await this.deleteDomainBtn.first().click();\n }\n}\n"]}
|
|
@@ -14,9 +14,11 @@ export declare class DocumentApiHelper {
|
|
|
14
14
|
private recurseChildren;
|
|
15
15
|
getByName(name: string): Promise<any>;
|
|
16
16
|
ensureNameNotExists(name: string): Promise<void>;
|
|
17
|
+
publish(id: string, publishSchedulesData: any): Promise<number | undefined>;
|
|
17
18
|
createDefaultDocument(documentName: string, documentTypeId: string): Promise<string | undefined>;
|
|
18
19
|
createDocumentWithTextContent(documentName: string, documentTypeId: string, textContent: string, dataTypeName: string): Promise<string | undefined>;
|
|
19
20
|
createDefaultDocumentWithParent(documentName: string, documentTypeId: string, parentId: string): Promise<string | undefined>;
|
|
21
|
+
createDocumentWithTemplate(documentName: string, documentTypeId: string, templateId: string): Promise<string | undefined>;
|
|
20
22
|
getDomains(id: string): Promise<any>;
|
|
21
23
|
updateDomains(id: string, domains: any): Promise<import("playwright-core").APIResponse>;
|
|
22
24
|
}
|
|
@@ -122,6 +122,13 @@ class DocumentApiHelper {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
+
async publish(id, publishSchedulesData) {
|
|
126
|
+
if (id == null) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const response = await this.api.put(this.api.baseUrl + '/umbraco/management/api/v1/document/' + id + '/publish', publishSchedulesData);
|
|
130
|
+
return response.status();
|
|
131
|
+
}
|
|
125
132
|
async createDefaultDocument(documentName, documentTypeId) {
|
|
126
133
|
await this.ensureNameNotExists(documentName);
|
|
127
134
|
const document = new json_models_builders_1.DocumentBuilder()
|
|
@@ -157,6 +164,17 @@ class DocumentApiHelper {
|
|
|
157
164
|
.build();
|
|
158
165
|
return await this.create(document);
|
|
159
166
|
}
|
|
167
|
+
async createDocumentWithTemplate(documentName, documentTypeId, templateId) {
|
|
168
|
+
await this.ensureNameNotExists(documentName);
|
|
169
|
+
const document = new json_models_builders_1.DocumentBuilder()
|
|
170
|
+
.withDocumentTypeId(documentTypeId)
|
|
171
|
+
.addVariant()
|
|
172
|
+
.withName(documentName)
|
|
173
|
+
.done()
|
|
174
|
+
.withTemplateId(templateId)
|
|
175
|
+
.build();
|
|
176
|
+
return await this.create(document);
|
|
177
|
+
}
|
|
160
178
|
// Domains
|
|
161
179
|
async getDomains(id) {
|
|
162
180
|
const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/document/' + id + '/domains');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentApiHelper.js","sourceRoot":"","sources":["../../../lib/helpers/DocumentApiHelper.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAE1C,wEAA8D;AAE9D,MAAa,iBAAiB;IAC5B,GAAG,CAAY;IAEf,YAAY,GAAe;QACzB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAA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QACrC,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,sCAAsC,GAAG,EAAE,GAAG,UAAU,EAAE,OAAO,CAAC,CAAC;IAClH,CAAC;CACF;AApLD,8CAoLC","sourcesContent":["import {AliasHelper} from \"./AliasHelper\";\nimport {ApiHelpers} from \"./ApiHelpers\";\nimport {DocumentBuilder} from \"@umbraco/json-models-builders\";\n\nexport class DocumentApiHelper {\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/document/' + id);\n return await response.json();\n }\n\n async doesExist(id: string) {\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/document/' + id);\n return response.status() === 200;\n }\n\n async create(document) {\n if (document == null) {\n return;\n }\n const response = await this.api.post(this.api.baseUrl + '/umbraco/management/api/v1/document', document);\n return response.headers().location.split(\"v1/document/\").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/document/' + id);\n return response.status();\n }\n\n async update(id: string, document) {\n if (document == null) {\n return;\n }\n const variantsData = document.variants.map(variant => ({\n culture: variant.culture,\n segment: variant.segment,\n name: variant.name\n }));\n \n const updateData = {\n values: document.values,\n variants: variantsData,\n template: document.template\n };\n return await this.api.put(this.api.baseUrl + '/umbraco/management/api/v1/document/' + id, updateData);\n }\n\n async getAllAtRoot() {\n return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/tree/document/root?skip=0&take=10000');\n }\n\n async getChildren(id: string) {\n const response = await this.api.get(`${this.api.baseUrl}/umbraco/management/api/v1/tree/document/children?parentId=${id}&skip=0&take=10000`);\n const items = await response.json();\n return items.items;\n }\n\n async doesNameExist(name: string) {\n return await this.getByName(name);\n }\n\n private async recurseDeleteChildren(id: string) {\n const items = await this.getChildren(id);\n\n for (const child of items) {\n if (child.hasChildren) {\n await this.recurseDeleteChildren(child.id);\n } else {\n await this.delete(child.id);\n }\n }\n return await this.delete(id);\n }\n\n private async recurseChildren(name: string, id: string, toDelete: boolean) {\n const items = await this.getChildren(id);\n\n for (const child of items) {\n if (child.variants[0].name === name) {\n if (!toDelete) {\n return await this.get(child.id);\n }\n if (child.hasChildren) {\n return await this.recurseDeleteChildren(child.id);\n } else {\n return await this.delete(child.id);\n }\n } else if (child.hasChildren) {\n await this.recurseChildren(name, child.id, toDelete);\n }\n }\n return false;\n }\n\n async getByName(name: string) {\n const rootDocuments = await this.getAllAtRoot();\n const jsonDocuments = await rootDocuments.json();\n\n for (const document of jsonDocuments.items) {\n if (document.variants[0].name === name) {\n return this.get(document.id);\n } else if (document.hasChildren) {\n const result = await this.recurseChildren(name, document.id, false);\n if (result) {\n return result;\n }\n }\n }\n return false;\n }\n\n async ensureNameNotExists(name: string) {\n const rootDocuments = await this.getAllAtRoot();\n const jsonDocuments = await rootDocuments.json();\n\n for (const document of jsonDocuments.items) {\n if (document.variants[0].name === name) {\n if (document.hasChildren) {\n await this.recurseDeleteChildren(document.id);\n }\n await this.delete(document.id);\n } else {\n if (document.hasChildren) {\n await this.recurseChildren(name, document.id, true);\n }\n }\n }\n }\n\n async createDefaultDocument(documentName: string, documentTypeId: string) {\n await this.ensureNameNotExists(documentName);\n const document = new DocumentBuilder()\n .withDocumentTypeId(documentTypeId)\n .addVariant()\n .withName(documentName)\n .done()\n .build();\n return await this.create(document);\n }\n\n async createDocumentWithTextContent(documentName: string, documentTypeId: string, textContent: string, dataTypeName: string) {\n await this.ensureNameNotExists(documentName);\n const document = new DocumentBuilder()\n .withDocumentTypeId(documentTypeId)\n .addVariant()\n .withName(documentName)\n .done()\n .addValue()\n .withAlias(AliasHelper.toAlias(dataTypeName))\n .withValue(textContent)\n .done()\n .build();\n return await this.create(document);\n }\n\n async createDefaultDocumentWithParent(documentName: string, documentTypeId: string, parentId: string) {\n await this.ensureNameNotExists(documentName);\n const document = new DocumentBuilder()\n .withDocumentTypeId(documentTypeId)\n .withParentId(parentId)\n .addVariant()\n .withName(documentName)\n .done()\n .build();\n return await this.create(document);\n }\n\n // Domains\n async getDomains(id: string) {\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/document/' + id + '/domains');\n return await response.json();\n }\n\n async updateDomains(id: string, domains) {\n return await this.api.put(this.api.baseUrl + '/umbraco/management/api/v1/document/' + id + '/domains', domains);\n }\n} "]}
|
|
1
|
+
{"version":3,"file":"DocumentApiHelper.js","sourceRoot":"","sources":["../../../lib/helpers/DocumentApiHelper.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAE1C,wEAA8D;AAE9D,MAAa,iBAAiB;IAC5B,GAAG,CAAY;IAEf,YAAY,GAAe;QACzB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,sCAAsC,GAAG,EAAE,CAAC,CAAC;QACpG,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,EAAU;QACxB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,sCAAsC,GAAG,EAAE,CAAC,CAAC;QACpG,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAQ;QACnB,IAAI,QAAQ,IAAI,IAAI,EAAE;YACpB,OAAO;SACR;QACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,qCAAqC,EAAE,QAAQ,CAAC,CAAC;QACzG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,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAAU,EAAE,OAAO;QACrC,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,sCAAsC,GAAG,EAAE,GAAG,UAAU,EAAE,OAAO,CAAC,CAAC;IAClH,CAAC;CACF;AAxMD,8CAwMC","sourcesContent":["import {AliasHelper} from \"./AliasHelper\";\nimport {ApiHelpers} from \"./ApiHelpers\";\nimport {DocumentBuilder} from \"@umbraco/json-models-builders\";\n\nexport class DocumentApiHelper {\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/document/' + id);\n return await response.json();\n }\n\n async doesExist(id: string) {\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/document/' + id);\n return response.status() === 200;\n }\n\n async create(document) {\n if (document == null) {\n return;\n }\n const response = await this.api.post(this.api.baseUrl + '/umbraco/management/api/v1/document', document);\n return response.headers().location.split(\"v1/document/\").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/document/' + id);\n return response.status();\n }\n\n async update(id: string, document) {\n if (document == null) {\n return;\n }\n const variantsData = document.variants.map(variant => ({\n culture: variant.culture,\n segment: variant.segment,\n name: variant.name\n }));\n \n const updateData = {\n values: document.values,\n variants: variantsData,\n template: document.template\n };\n return await this.api.put(this.api.baseUrl + '/umbraco/management/api/v1/document/' + id, updateData);\n }\n\n async getAllAtRoot() {\n return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/tree/document/root?skip=0&take=10000');\n }\n\n async getChildren(id: string) {\n const response = await this.api.get(`${this.api.baseUrl}/umbraco/management/api/v1/tree/document/children?parentId=${id}&skip=0&take=10000`);\n const items = await response.json();\n return items.items;\n }\n\n async doesNameExist(name: string) {\n return await this.getByName(name);\n }\n\n private async recurseDeleteChildren(id: string) {\n const items = await this.getChildren(id);\n\n for (const child of items) {\n if (child.hasChildren) {\n await this.recurseDeleteChildren(child.id);\n } else {\n await this.delete(child.id);\n }\n }\n return await this.delete(id);\n }\n\n private async recurseChildren(name: string, id: string, toDelete: boolean) {\n const items = await this.getChildren(id);\n\n for (const child of items) {\n if (child.variants[0].name === name) {\n if (!toDelete) {\n return await this.get(child.id);\n }\n if (child.hasChildren) {\n return await this.recurseDeleteChildren(child.id);\n } else {\n return await this.delete(child.id);\n }\n } else if (child.hasChildren) {\n await this.recurseChildren(name, child.id, toDelete);\n }\n }\n return false;\n }\n\n async getByName(name: string) {\n const rootDocuments = await this.getAllAtRoot();\n const jsonDocuments = await rootDocuments.json();\n\n for (const document of jsonDocuments.items) {\n if (document.variants[0].name === name) {\n return this.get(document.id);\n } else if (document.hasChildren) {\n const result = await this.recurseChildren(name, document.id, false);\n if (result) {\n return result;\n }\n }\n }\n return false;\n }\n\n async ensureNameNotExists(name: string) {\n const rootDocuments = await this.getAllAtRoot();\n const jsonDocuments = await rootDocuments.json();\n\n for (const document of jsonDocuments.items) {\n if (document.variants[0].name === name) {\n if (document.hasChildren) {\n await this.recurseDeleteChildren(document.id);\n }\n await this.delete(document.id);\n } else {\n if (document.hasChildren) {\n await this.recurseChildren(name, document.id, true);\n }\n }\n }\n }\n\n async publish(id: string, publishSchedulesData) {\n if (id == null) {\n return;\n }\n const response = await this.api.put(this.api.baseUrl + '/umbraco/management/api/v1/document/' + id + '/publish', publishSchedulesData);\n return response.status();\n }\n\n async createDefaultDocument(documentName: string, documentTypeId: string) {\n await this.ensureNameNotExists(documentName);\n const document = new DocumentBuilder()\n .withDocumentTypeId(documentTypeId)\n .addVariant()\n .withName(documentName)\n .done()\n .build();\n return await this.create(document);\n }\n\n async createDocumentWithTextContent(documentName: string, documentTypeId: string, textContent: string, dataTypeName: string) {\n await this.ensureNameNotExists(documentName);\n const document = new DocumentBuilder()\n .withDocumentTypeId(documentTypeId)\n .addVariant()\n .withName(documentName)\n .done()\n .addValue()\n .withAlias(AliasHelper.toAlias(dataTypeName))\n .withValue(textContent)\n .done()\n .build();\n return await this.create(document);\n }\n\n async createDefaultDocumentWithParent(documentName: string, documentTypeId: string, parentId: string) {\n await this.ensureNameNotExists(documentName);\n const document = new DocumentBuilder()\n .withDocumentTypeId(documentTypeId)\n .withParentId(parentId)\n .addVariant()\n .withName(documentName)\n .done()\n .build();\n return await this.create(document);\n }\n\n async createDocumentWithTemplate(documentName: string, documentTypeId: string, templateId: string) {\n await this.ensureNameNotExists(documentName);\n const document = new DocumentBuilder()\n .withDocumentTypeId(documentTypeId)\n .addVariant()\n .withName(documentName)\n .done()\n .withTemplateId(templateId)\n .build();\n return await this.create(document);\n }\n\n // Domains\n async getDomains(id: string) {\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/document/' + id + '/domains');\n return await response.json();\n }\n\n async updateDomains(id: string, domains) {\n return await this.api.put(this.api.baseUrl + '/umbraco/management/api/v1/document/' + id + '/domains', domains);\n }\n} "]}
|
|
@@ -22,7 +22,8 @@ export declare class DocumentTypeApiHelper {
|
|
|
22
22
|
createDocumentTypeWithTwoPropertyEditors(documentTypeName: string, dataTypeNameOne: string, dataTypeIdOne: string, dataTypeNameTwo: string, dataTypeIdTwo: string, groupName?: string): Promise<string | undefined>;
|
|
23
23
|
createDefaultDocumentTypeWithAllowAsRoot(documentTypeName: string): Promise<string | undefined>;
|
|
24
24
|
createDocumentTypeWithAllowedChildNode(documentTypeName: string, allowedChildNodeId: string): Promise<string | undefined>;
|
|
25
|
-
createDocumentTypeWithAllowedTemplate(documentTypeName: string, allowedTemplateId: string): Promise<string | undefined>;
|
|
25
|
+
createDocumentTypeWithAllowedTemplate(documentTypeName: string, allowedTemplateId: string, isAllowedAsRoot?: boolean): Promise<string | undefined>;
|
|
26
|
+
createDocumentTypeWithTwoAllowedTemplates(documentTypeName: string, allowedTemplateOneId: string, allowedTemplateTwoId: string, isAllowedAsRoot?: boolean): Promise<string | undefined>;
|
|
26
27
|
createDocumentTypeWithTwoGroups(documentTypeName: string, dataType: string, dataTypeId: string, groupNameOne: string, groupNameTwo: string): Promise<string | undefined>;
|
|
27
28
|
createDocumentTypeWithAComposition(documentTypeName: string, compositionId: string): Promise<string | undefined>;
|
|
28
29
|
createDocumentTypeWithTwoTabs(documentTypeName: string, dataType: string, dataTypeId: string, tabNameOne: string, tabNameTwo: string): Promise<string | undefined>;
|
|
@@ -241,17 +241,33 @@ class DocumentTypeApiHelper {
|
|
|
241
241
|
.build();
|
|
242
242
|
return await this.create(documentType);
|
|
243
243
|
}
|
|
244
|
-
async createDocumentTypeWithAllowedTemplate(documentTypeName, allowedTemplateId) {
|
|
244
|
+
async createDocumentTypeWithAllowedTemplate(documentTypeName, allowedTemplateId, isAllowedAsRoot = false) {
|
|
245
245
|
await this.ensureNameNotExists(documentTypeName);
|
|
246
246
|
const documentType = new json_models_builders_1.DocumentTypeBuilder()
|
|
247
247
|
.withName(documentTypeName)
|
|
248
248
|
.withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName))
|
|
249
|
+
.withAllowedAsRoot(isAllowedAsRoot)
|
|
249
250
|
.addAllowedTemplateId()
|
|
250
251
|
.withId(allowedTemplateId)
|
|
251
252
|
.done()
|
|
252
253
|
.build();
|
|
253
254
|
return await this.create(documentType);
|
|
254
255
|
}
|
|
256
|
+
async createDocumentTypeWithTwoAllowedTemplates(documentTypeName, allowedTemplateOneId, allowedTemplateTwoId, isAllowedAsRoot = false) {
|
|
257
|
+
await this.ensureNameNotExists(documentTypeName);
|
|
258
|
+
const documentType = new json_models_builders_1.DocumentTypeBuilder()
|
|
259
|
+
.withName(documentTypeName)
|
|
260
|
+
.withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName))
|
|
261
|
+
.withAllowedAsRoot(isAllowedAsRoot)
|
|
262
|
+
.addAllowedTemplateId()
|
|
263
|
+
.withId(allowedTemplateOneId)
|
|
264
|
+
.done()
|
|
265
|
+
.addAllowedTemplateId()
|
|
266
|
+
.withId(allowedTemplateTwoId)
|
|
267
|
+
.done()
|
|
268
|
+
.build();
|
|
269
|
+
return await this.create(documentType);
|
|
270
|
+
}
|
|
255
271
|
async createDocumentTypeWithTwoGroups(documentTypeName, dataType, dataTypeId, groupNameOne, groupNameTwo) {
|
|
256
272
|
const crypto = require('crypto');
|
|
257
273
|
const groupOneId = crypto.randomUUID();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentTypeApiHelper.js","sourceRoot":"","sources":["../../../lib/helpers/DocumentTypeApiHelper.ts"],"names":[],"mappings":";;;AACA,wEAAkE;AAClE,+CAA0C;AAE1C,MAAa,qBAAqB;IAChC,GAAG,CAAY;IAEf,YAAY,GAAe;QACzB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,IAAY;QACpC,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QACpD,MAAM,iBAAiB,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,CAAC;QAEzD,KAAK,MAAM,YAAY,IAAI,iBAAiB,CAAC,KAAK,EAAE;YAClD,IAAI,YAAY,CAAC,IAAI,KAAK,IAAI,EAAE;gBAC9B,IAAI,YAAY,CAAC,QAAQ,EAAE;oBACzB,OAAO,MAAM,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;iBACvD;gBACD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;aAC3C;iBAAM,IAAI,YAAY,CAAC,WAAW,EAAE;gBACnC,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;aACzD;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,OAAO,MAA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CAAC;SACd;IACH,CAAC;IAED,KAAK,CAAC,sBAAsB,CAAC,gBAAwB,EAAE,aAAqB;QAC1E,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;QAC5D,MAAM,SAAS,GAAG,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC;QAC9E,IAAI,SAAS,EAAE;YACb,OAAO,SAAS,CAAC,EAAE,CAAC;SACrB;aAAM;YACL,OAAO,IAAI,CAAC;SACb;IACH,CAAC;CACF;AAtbD,sDAsbC","sourcesContent":["import {ApiHelpers} from \"./ApiHelpers\";\nimport {DocumentTypeBuilder} from \"@umbraco/json-models-builders\";\nimport {AliasHelper} from \"./AliasHelper\";\n\nexport class DocumentTypeApiHelper {\n api: ApiHelpers\n\n constructor(api: ApiHelpers) {\n this.api = api;\n }\n\n async ensureNameNotExists(name: string) {\n const rootDocumentTypes = await this.getAllAtRoot();\n const jsonDocumentTypes = await rootDocumentTypes.json();\n\n for (const documentType of jsonDocumentTypes.items) {\n if (documentType.name === name) {\n if (documentType.isFolder) {\n return await this.recurseDeleteChildren(documentType);\n }\n return await this.delete(documentType.id);\n } else if (documentType.hasChildren) {\n await this.recurseChildren(name, documentType.id, true);\n }\n }\n return null;\n }\n\n async getAllAtRoot() {\n return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/tree/document-type/root?skip=0&take=10000&foldersOnly=false');\n }\n\n private async recurseChildren(name: string, id: string, toDelete: boolean) {\n const items = await this.getChildren(id);\n\n for (const child of items) {\n if (child.name === name) {\n if (!toDelete) {\n if (child.isFolder) {\n return await this.getFolder(child.id);\n }\n return await this.get(child.id);\n }\n if (child.isFolder) {\n return await this.recurseDeleteChildren(child);\n }\n return await this.delete(child.id);\n } else if (child.hasChildren) {\n return await this.recurseChildren(name, child.id, toDelete);\n }\n }\n return false;\n }\n\n private async recurseDeleteChildren(documentTypeFolder) {\n if (!documentTypeFolder.hasChildren) {\n return await this.deleteFolder(documentTypeFolder.id);\n }\n const items = await this.getChildren(documentTypeFolder.id);\n\n for (const child of items) {\n if (child.hasChildren) {\n await this.recurseDeleteChildren(child);\n } else if (child.isFolder) {\n await this.deleteFolder(child.id);\n } else {\n await this.delete(child.id);\n }\n }\n return await this.deleteFolder(documentTypeFolder.id);\n }\n\n async getChildren(id: string) {\n const response = await this.api.get(`${this.api.baseUrl}/umbraco/management/api/v1/tree/document-type/children?parentId=${id}&skip=0&take=10000&foldersOnly=false`);\n const items = await response.json();\n return items.items;\n }\n\n async create(documentType) {\n if (documentType == null) {\n return;\n }\n const response = await this.api.post(this.api.baseUrl + '/umbraco/management/api/v1/document-type', documentType);\n return response.headers().location.split(\"/\").pop();\n }\n\n async get(id: string) {\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/document-type/' + id);\n const json = await response.json();\n if (json !== null) {\n return json;\n }\n return null;\n }\n\n async getByName(name: string) {\n const rootDocumentTypes = await this.getAllAtRoot();\n const jsonDocumentTypes = await rootDocumentTypes.json();\n\n for (const documentType of jsonDocumentTypes.items) {\n if (documentType.name === name) {\n if (documentType.isFolder) {\n return this.getFolder(documentType.id);\n }\n return this.get(documentType.id);\n } else if (documentType.hasChildren) {\n const result = await this.recurseChildren(name, documentType.id, false);\n if (result) {\n return result;\n }\n }\n }\n return false;\n }\n\n async doesNameExist(name: string) {\n return await this.getByName(name);\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/document-type/' + id);\n return response.status();\n }\n\n // FOLDER\n async getFolder(id: string) {\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/document-type/folder/' + id);\n return await response.json();\n }\n\n async deleteFolder(id: string) {\n return await this.api.delete(this.api.baseUrl + '/umbraco/management/api/v1/document-type/folder/' + id);\n }\n\n async createFolder(name: string, parentId?: string) {\n const folder = {\n name: name,\n parent: parentId ? {id: parentId} : null\n\n }\n const response = await this.api.post(this.api.baseUrl + '/umbraco/management/api/v1/document-type/folder', folder);\n return response.headers().location.split(\"/\").pop();\n }\n\n async renameFolder(folderId: string, folderName: string) {\n const folder = {\n name: folderName\n }\n return await this.api.put(this.api.baseUrl + '/umbraco/management/api/v1/document-type/folder/' + folderId, folder);\n }\n\n async createDefaultDocumentType(documentTypeName: string) {\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .build();\n return await this.create(documentType);\n }\n\n async createDocumentTypeWithPropertyEditor(documentTypeName: string, dataTypeName: string, dataTypeId: string, groupName: string = \"TestGroup\", varyByCulture: boolean = false) {\n const crypto = require('crypto');\n const containerId = crypto.randomUUID();\n\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .withAllowedAsRoot(true)\n .addContainer()\n .withName(groupName)\n .withId(containerId)\n .withType(\"Group\")\n .done()\n .addProperty()\n .withContainerId(containerId)\n .withAlias(AliasHelper.toAlias(dataTypeName))\n .withName(dataTypeName)\n .withDataTypeId(dataTypeId)\n .done()\n .withVariesByCulture(varyByCulture)\n .build();\n return await this.create(documentType);\n }\n\n async createDocumentTypeWithPropertyEditorInTab(documentTypeName: string, dataTypeName: string, dataTypeId: string, tabName: string, groupName: string = \"TestGroup\", varyByCulture: boolean = false) {\n const crypto = require('crypto');\n const tabId = crypto.randomUUID();\n const groupId = crypto.randomUUID();\n\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .addContainer()\n .withName(tabName)\n .withId(tabId)\n .withType(\"Tab\")\n .done()\n .addContainer()\n .withName(groupName)\n .withId(groupId)\n .withType(\"Group\")\n .withParentId(tabId)\n .done()\n .addProperty()\n .withContainerId(groupId)\n .withAlias(AliasHelper.toAlias(dataTypeName))\n .withName(dataTypeName)\n .withDataTypeId(dataTypeId)\n .done()\n .withVariesByCulture(varyByCulture)\n .build();\n return await this.create(documentType);\n }\n\n async createDocumentTypeWithTwoPropertyEditors(documentTypeName: string, dataTypeNameOne: string, dataTypeIdOne: string, dataTypeNameTwo: string, dataTypeIdTwo: string, groupName: string = \"TestGroup\") {\n const crypto = require('crypto');\n const containerId = crypto.randomUUID();\n\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .addContainer()\n .withName(groupName)\n .withId(containerId)\n .withType(\"Group\")\n .done()\n .addProperty()\n .withContainerId(containerId)\n .withAlias(AliasHelper.toAlias(dataTypeNameOne))\n .withName(dataTypeNameOne)\n .withDataTypeId(dataTypeIdOne)\n .done()\n .addProperty()\n .withContainerId(containerId)\n .withAlias(AliasHelper.toAlias(dataTypeNameTwo))\n .withName(dataTypeNameTwo)\n .withDataTypeId(dataTypeIdTwo)\n .done()\n .build();\n return await this.create(documentType);\n }\n\n async createDefaultDocumentTypeWithAllowAsRoot(documentTypeName: string) {\n await this.ensureNameNotExists(documentTypeName);\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .withAllowedAsRoot(true)\n .build();\n return await this.create(documentType);\n }\n\n async createDocumentTypeWithAllowedChildNode(documentTypeName: string, allowedChildNodeId: string) {\n await this.ensureNameNotExists(documentTypeName);\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .withAllowedAsRoot(true)\n .addAllowedDocumentType()\n .withId(allowedChildNodeId)\n .done()\n .build();\n return await this.create(documentType);\n }\n\n async createDocumentTypeWithAllowedTemplate(documentTypeName: string, allowedTemplateId: string) {\n await this.ensureNameNotExists(documentTypeName);\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .addAllowedTemplateId()\n .withId(allowedTemplateId)\n .done()\n .build();\n return await this.create(documentType);\n }\n \n async createDocumentTypeWithTwoGroups(documentTypeName: string,dataType: string, dataTypeId: string, groupNameOne: string, groupNameTwo: string) {\n const crypto = require('crypto');\n const groupOneId = crypto.randomUUID();\n const groupTwoId = crypto.randomUUID();\n\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .addContainer()\n .withName(groupNameOne)\n .withId(groupOneId)\n .withType(\"Group\")\n .withSortOrder(0)\n .done()\n .addContainer()\n .withName(groupNameTwo)\n .withId(groupTwoId)\n .withType(\"Group\")\n .withSortOrder(1)\n .done()\n .addProperty()\n .withContainerId(groupOneId)\n .withAlias(AliasHelper.toAlias(dataType + \"One\"))\n .withName(dataType + \"One\")\n .withDataTypeId(dataTypeId)\n .done()\n .addProperty()\n .withContainerId(groupTwoId)\n .withAlias(AliasHelper.toAlias(dataType + \"Two\"))\n .withName(dataType + \"Two\")\n .withDataTypeId(dataTypeId)\n .done()\n .build();\n return await this.create(documentType);\n }\n \n async createDocumentTypeWithAComposition(documentTypeName: string, compositionId: string) {\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .addComposition()\n .withDocumentTypeId(compositionId)\n .done()\n .build();\n return await this.create(documentType);\n }\n \n async createDocumentTypeWithTwoTabs(documentTypeName: string, dataType: string, dataTypeId: string, tabNameOne: string, tabNameTwo: string) {\n const crypto = require('crypto');\n const tabOneId = crypto.randomUUID();\n const tabTwoId = crypto.randomUUID();\n const groupOneId = crypto.randomUUID();\n const groupTwoId = crypto.randomUUID();\n\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .addContainer()\n .withName(tabNameOne)\n .withId(tabOneId)\n .withType(\"Tab\")\n .withSortOrder(0)\n .done()\n .addContainer()\n .withName(tabNameTwo)\n .withId(tabTwoId)\n .withType(\"Tab\")\n .withSortOrder(1)\n .done()\n .addContainer()\n .withName(\"GroupTestOne\")\n .withId(groupOneId)\n .withType(\"Group\")\n .withParentId(tabOneId)\n .done()\n .addProperty()\n .withContainerId(groupOneId)\n .withAlias(AliasHelper.toAlias(dataType + \"One\"))\n .withName(dataType + \"One\")\n .withDataTypeId(dataTypeId)\n .done()\n .addContainer()\n .withName(\"GroupTestTwo\")\n .withId(groupTwoId)\n .withType(\"Group\")\n .withParentId(tabTwoId)\n .done()\n .addProperty()\n .withContainerId(groupTwoId)\n .withAlias(AliasHelper.toAlias(dataType + \"Two\"))\n .withName(dataType + \"Two\")\n .withDataTypeId(dataTypeId)\n .done()\n .build();\n return await this.create(documentType);\n }\n\n async doesGroupContainCorrectPropertyEditor(documentTypeName: string, dataTypeName: string, dataTypeId: string, groupName: string) {\n const documentType = await this.getByName(documentTypeName);\n const group = documentType.containers.find(x => x.name === groupName);\n // Check if group is defined\n if (group) {\n // Check if the document type properties include the specified property, and it belongs to the group\n return documentType.properties.find(x => x.name === dataTypeName && x.dataType.id === dataTypeId && x.container.id === group.id);\n } else {\n // Group not found\n return false;\n }\n }\n\n async doesTabContainCorrectPropertyEditorInGroup(documentTypeName: string, dataTypeName: string, dataTypeId: string, tabName: string, groupName: string) {\n const documentType = await this.getByName(documentTypeName);\n const tab = documentType.containers.find(x => x.name === tabName);\n // Check if tab is defined\n if (tab) {\n const group = documentType.containers.find(x => x.name === groupName && x.parent.id === tab.id);\n // Check if group is defined\n if (group) {\n // Check if the document type properties include the specified property, and it belongs to the group\n return documentType.properties.find(x => x.name === dataTypeName && x.dataType.id === dataTypeId && x.container.id === group.id);\n } else {\n // Group not found\n return false;\n }\n } else {\n // Tab not found\n return false;\n }\n }\n \n async doesDocumentTypeGroupNameContainCorrectSortOrder(documentTypeName: string, groupName: string, sortOrder: number) {\n const documentType = await this.getByName(documentTypeName);\n const group = documentType.containers.find(x => x.name === groupName);\n // Check if group is defined\n if (group) {\n return group.sortOrder === sortOrder;\n } else {\n // Group not found\n return false;\n }\n }\n \n async doesDocumentTypeTabNameContainCorrectSortOrder(documentTypeName: string, tabName: string, sortOrder: number) {\n const documentType = await this.getByName(documentTypeName);\n const tab = documentType.containers.find(x => x.name === tabName);\n // Check if tab is defined\n if (tab) {\n return tab.sortOrder === sortOrder;\n } else {\n // Tab not found\n return false;\n }\n }\n \n async getContainerIdWithName(documentTypeName: string, containerName: string) {\n const documentType = await this.getByName(documentTypeName);\n const container = documentType.containers.find(x => x.name === containerName);\n if (container) {\n return container.id;\n } else {\n return null;\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"DocumentTypeApiHelper.js","sourceRoot":"","sources":["../../../lib/helpers/DocumentTypeApiHelper.ts"],"names":[],"mappings":";;;AACA,wEAAkE;AAClE,+CAA0C;AAE1C,MAAa,qBAAqB;IAChC,GAAG,CAAY;IAEf,YAAY,GAAe;QACzB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,IAAY;QACpC,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QACpD,MAAM,iBAAiB,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,CAAC;QAEzD,KAAK,MAAM,YAAY,IAAI,iBAAiB,CAAC,KAAK,EAAE;YAClD,IAAI,YAAY,CAAC,IAAI,KAAK,IAAI,EAAE;gBAC9B,IAAI,YAAY,CAAC,QAAQ,EAAE;oBACzB,OAAO,MAAM,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;iBACvD;gBACD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;aAC3C;iBAAM,IAAI,YAAY,CAAC,WAAW,EAAE;gBACnC,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;aACzD;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,OAAO,M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,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;QACtE,4BAA4B;QAC5B,IAAI,KAAK,EAAE;YACT,OAAO,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC;SACtC;aAAM;YACL,kBAAkB;YAClB,OAAO,KAAK,CAAC;SACd;IACH,CAAC;IAED,KAAK,CAAC,8CAA8C,CAAC,gBAAwB,EAAE,OAAe,EAAE,SAAiB;QAC/G,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;QAC5D,MAAM,GAAG,GAAG,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;QAClE,0BAA0B;QAC1B,IAAI,GAAG,EAAE;YACP,OAAO,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC;SACpC;aAAM;YACL,gBAAgB;YAChB,OAAO,KAAK,CAAC;SACd;IACH,CAAC;IAED,KAAK,CAAC,sBAAsB,CAAC,gBAAwB,EAAE,aAAqB;QAC1E,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;QAC5D,MAAM,SAAS,GAAG,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC;QAC9E,IAAI,SAAS,EAAE;YACb,OAAO,SAAS,CAAC,EAAE,CAAC;SACrB;aAAM;YACL,OAAO,IAAI,CAAC;SACb;IACH,CAAC;CACF;AAvcD,sDAucC","sourcesContent":["import {ApiHelpers} from \"./ApiHelpers\";\nimport {DocumentTypeBuilder} from \"@umbraco/json-models-builders\";\nimport {AliasHelper} from \"./AliasHelper\";\n\nexport class DocumentTypeApiHelper {\n api: ApiHelpers\n\n constructor(api: ApiHelpers) {\n this.api = api;\n }\n\n async ensureNameNotExists(name: string) {\n const rootDocumentTypes = await this.getAllAtRoot();\n const jsonDocumentTypes = await rootDocumentTypes.json();\n\n for (const documentType of jsonDocumentTypes.items) {\n if (documentType.name === name) {\n if (documentType.isFolder) {\n return await this.recurseDeleteChildren(documentType);\n }\n return await this.delete(documentType.id);\n } else if (documentType.hasChildren) {\n await this.recurseChildren(name, documentType.id, true);\n }\n }\n return null;\n }\n\n async getAllAtRoot() {\n return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/tree/document-type/root?skip=0&take=10000&foldersOnly=false');\n }\n\n private async recurseChildren(name: string, id: string, toDelete: boolean) {\n const items = await this.getChildren(id);\n\n for (const child of items) {\n if (child.name === name) {\n if (!toDelete) {\n if (child.isFolder) {\n return await this.getFolder(child.id);\n }\n return await this.get(child.id);\n }\n if (child.isFolder) {\n return await this.recurseDeleteChildren(child);\n }\n return await this.delete(child.id);\n } else if (child.hasChildren) {\n return await this.recurseChildren(name, child.id, toDelete);\n }\n }\n return false;\n }\n\n private async recurseDeleteChildren(documentTypeFolder) {\n if (!documentTypeFolder.hasChildren) {\n return await this.deleteFolder(documentTypeFolder.id);\n }\n const items = await this.getChildren(documentTypeFolder.id);\n\n for (const child of items) {\n if (child.hasChildren) {\n await this.recurseDeleteChildren(child);\n } else if (child.isFolder) {\n await this.deleteFolder(child.id);\n } else {\n await this.delete(child.id);\n }\n }\n return await this.deleteFolder(documentTypeFolder.id);\n }\n\n async getChildren(id: string) {\n const response = await this.api.get(`${this.api.baseUrl}/umbraco/management/api/v1/tree/document-type/children?parentId=${id}&skip=0&take=10000&foldersOnly=false`);\n const items = await response.json();\n return items.items;\n }\n\n async create(documentType) {\n if (documentType == null) {\n return;\n }\n const response = await this.api.post(this.api.baseUrl + '/umbraco/management/api/v1/document-type', documentType);\n return response.headers().location.split(\"/\").pop();\n }\n\n async get(id: string) {\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/document-type/' + id);\n const json = await response.json();\n if (json !== null) {\n return json;\n }\n return null;\n }\n\n async getByName(name: string) {\n const rootDocumentTypes = await this.getAllAtRoot();\n const jsonDocumentTypes = await rootDocumentTypes.json();\n\n for (const documentType of jsonDocumentTypes.items) {\n if (documentType.name === name) {\n if (documentType.isFolder) {\n return this.getFolder(documentType.id);\n }\n return this.get(documentType.id);\n } else if (documentType.hasChildren) {\n const result = await this.recurseChildren(name, documentType.id, false);\n if (result) {\n return result;\n }\n }\n }\n return false;\n }\n\n async doesNameExist(name: string) {\n return await this.getByName(name);\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/document-type/' + id);\n return response.status();\n }\n\n // FOLDER\n async getFolder(id: string) {\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/document-type/folder/' + id);\n return await response.json();\n }\n\n async deleteFolder(id: string) {\n return await this.api.delete(this.api.baseUrl + '/umbraco/management/api/v1/document-type/folder/' + id);\n }\n\n async createFolder(name: string, parentId?: string) {\n const folder = {\n name: name,\n parent: parentId ? {id: parentId} : null\n\n }\n const response = await this.api.post(this.api.baseUrl + '/umbraco/management/api/v1/document-type/folder', folder);\n return response.headers().location.split(\"/\").pop();\n }\n\n async renameFolder(folderId: string, folderName: string) {\n const folder = {\n name: folderName\n }\n return await this.api.put(this.api.baseUrl + '/umbraco/management/api/v1/document-type/folder/' + folderId, folder);\n }\n\n async createDefaultDocumentType(documentTypeName: string) {\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .build();\n return await this.create(documentType);\n }\n\n async createDocumentTypeWithPropertyEditor(documentTypeName: string, dataTypeName: string, dataTypeId: string, groupName: string = \"TestGroup\", varyByCulture: boolean = false) {\n const crypto = require('crypto');\n const containerId = crypto.randomUUID();\n\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .withAllowedAsRoot(true)\n .addContainer()\n .withName(groupName)\n .withId(containerId)\n .withType(\"Group\")\n .done()\n .addProperty()\n .withContainerId(containerId)\n .withAlias(AliasHelper.toAlias(dataTypeName))\n .withName(dataTypeName)\n .withDataTypeId(dataTypeId)\n .done()\n .withVariesByCulture(varyByCulture)\n .build();\n return await this.create(documentType);\n }\n\n async createDocumentTypeWithPropertyEditorInTab(documentTypeName: string, dataTypeName: string, dataTypeId: string, tabName: string, groupName: string = \"TestGroup\", varyByCulture: boolean = false) {\n const crypto = require('crypto');\n const tabId = crypto.randomUUID();\n const groupId = crypto.randomUUID();\n\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .addContainer()\n .withName(tabName)\n .withId(tabId)\n .withType(\"Tab\")\n .done()\n .addContainer()\n .withName(groupName)\n .withId(groupId)\n .withType(\"Group\")\n .withParentId(tabId)\n .done()\n .addProperty()\n .withContainerId(groupId)\n .withAlias(AliasHelper.toAlias(dataTypeName))\n .withName(dataTypeName)\n .withDataTypeId(dataTypeId)\n .done()\n .withVariesByCulture(varyByCulture)\n .build();\n return await this.create(documentType);\n }\n\n async createDocumentTypeWithTwoPropertyEditors(documentTypeName: string, dataTypeNameOne: string, dataTypeIdOne: string, dataTypeNameTwo: string, dataTypeIdTwo: string, groupName: string = \"TestGroup\") {\n const crypto = require('crypto');\n const containerId = crypto.randomUUID();\n\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .addContainer()\n .withName(groupName)\n .withId(containerId)\n .withType(\"Group\")\n .done()\n .addProperty()\n .withContainerId(containerId)\n .withAlias(AliasHelper.toAlias(dataTypeNameOne))\n .withName(dataTypeNameOne)\n .withDataTypeId(dataTypeIdOne)\n .done()\n .addProperty()\n .withContainerId(containerId)\n .withAlias(AliasHelper.toAlias(dataTypeNameTwo))\n .withName(dataTypeNameTwo)\n .withDataTypeId(dataTypeIdTwo)\n .done()\n .build();\n return await this.create(documentType);\n }\n\n async createDefaultDocumentTypeWithAllowAsRoot(documentTypeName: string) {\n await this.ensureNameNotExists(documentTypeName);\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .withAllowedAsRoot(true)\n .build();\n return await this.create(documentType);\n }\n\n async createDocumentTypeWithAllowedChildNode(documentTypeName: string, allowedChildNodeId: string) {\n await this.ensureNameNotExists(documentTypeName);\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .withAllowedAsRoot(true)\n .addAllowedDocumentType()\n .withId(allowedChildNodeId)\n .done()\n .build();\n return await this.create(documentType);\n }\n\n async createDocumentTypeWithAllowedTemplate(documentTypeName: string, allowedTemplateId: string, isAllowedAsRoot:boolean = false) {\n await this.ensureNameNotExists(documentTypeName);\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .withAllowedAsRoot(isAllowedAsRoot)\n .addAllowedTemplateId()\n .withId(allowedTemplateId)\n .done()\n .build();\n return await this.create(documentType);\n }\n\n async createDocumentTypeWithTwoAllowedTemplates(documentTypeName: string, allowedTemplateOneId: string, allowedTemplateTwoId: string, isAllowedAsRoot:boolean = false) {\n await this.ensureNameNotExists(documentTypeName);\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .withAllowedAsRoot(isAllowedAsRoot)\n .addAllowedTemplateId()\n .withId(allowedTemplateOneId)\n .done()\n .addAllowedTemplateId()\n .withId(allowedTemplateTwoId)\n .done()\n .build();\n return await this.create(documentType);\n }\n \n async createDocumentTypeWithTwoGroups(documentTypeName: string,dataType: string, dataTypeId: string, groupNameOne: string, groupNameTwo: string) {\n const crypto = require('crypto');\n const groupOneId = crypto.randomUUID();\n const groupTwoId = crypto.randomUUID();\n\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .addContainer()\n .withName(groupNameOne)\n .withId(groupOneId)\n .withType(\"Group\")\n .withSortOrder(0)\n .done()\n .addContainer()\n .withName(groupNameTwo)\n .withId(groupTwoId)\n .withType(\"Group\")\n .withSortOrder(1)\n .done()\n .addProperty()\n .withContainerId(groupOneId)\n .withAlias(AliasHelper.toAlias(dataType + \"One\"))\n .withName(dataType + \"One\")\n .withDataTypeId(dataTypeId)\n .done()\n .addProperty()\n .withContainerId(groupTwoId)\n .withAlias(AliasHelper.toAlias(dataType + \"Two\"))\n .withName(dataType + \"Two\")\n .withDataTypeId(dataTypeId)\n .done()\n .build();\n return await this.create(documentType);\n }\n \n async createDocumentTypeWithAComposition(documentTypeName: string, compositionId: string) {\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .addComposition()\n .withDocumentTypeId(compositionId)\n .done()\n .build();\n return await this.create(documentType);\n }\n \n async createDocumentTypeWithTwoTabs(documentTypeName: string, dataType: string, dataTypeId: string, tabNameOne: string, tabNameTwo: string) {\n const crypto = require('crypto');\n const tabOneId = crypto.randomUUID();\n const tabTwoId = crypto.randomUUID();\n const groupOneId = crypto.randomUUID();\n const groupTwoId = crypto.randomUUID();\n\n const documentType = new DocumentTypeBuilder()\n .withName(documentTypeName)\n .withAlias(AliasHelper.toAlias(documentTypeName))\n .addContainer()\n .withName(tabNameOne)\n .withId(tabOneId)\n .withType(\"Tab\")\n .withSortOrder(0)\n .done()\n .addContainer()\n .withName(tabNameTwo)\n .withId(tabTwoId)\n .withType(\"Tab\")\n .withSortOrder(1)\n .done()\n .addContainer()\n .withName(\"GroupTestOne\")\n .withId(groupOneId)\n .withType(\"Group\")\n .withParentId(tabOneId)\n .done()\n .addProperty()\n .withContainerId(groupOneId)\n .withAlias(AliasHelper.toAlias(dataType + \"One\"))\n .withName(dataType + \"One\")\n .withDataTypeId(dataTypeId)\n .done()\n .addContainer()\n .withName(\"GroupTestTwo\")\n .withId(groupTwoId)\n .withType(\"Group\")\n .withParentId(tabTwoId)\n .done()\n .addProperty()\n .withContainerId(groupTwoId)\n .withAlias(AliasHelper.toAlias(dataType + \"Two\"))\n .withName(dataType + \"Two\")\n .withDataTypeId(dataTypeId)\n .done()\n .build();\n return await this.create(documentType);\n }\n\n async doesGroupContainCorrectPropertyEditor(documentTypeName: string, dataTypeName: string, dataTypeId: string, groupName: string) {\n const documentType = await this.getByName(documentTypeName);\n const group = documentType.containers.find(x => x.name === groupName);\n // Check if group is defined\n if (group) {\n // Check if the document type properties include the specified property, and it belongs to the group\n return documentType.properties.find(x => x.name === dataTypeName && x.dataType.id === dataTypeId && x.container.id === group.id);\n } else {\n // Group not found\n return false;\n }\n }\n\n async doesTabContainCorrectPropertyEditorInGroup(documentTypeName: string, dataTypeName: string, dataTypeId: string, tabName: string, groupName: string) {\n const documentType = await this.getByName(documentTypeName);\n const tab = documentType.containers.find(x => x.name === tabName);\n // Check if tab is defined\n if (tab) {\n const group = documentType.containers.find(x => x.name === groupName && x.parent.id === tab.id);\n // Check if group is defined\n if (group) {\n // Check if the document type properties include the specified property, and it belongs to the group\n return documentType.properties.find(x => x.name === dataTypeName && x.dataType.id === dataTypeId && x.container.id === group.id);\n } else {\n // Group not found\n return false;\n }\n } else {\n // Tab not found\n return false;\n }\n }\n \n async doesDocumentTypeGroupNameContainCorrectSortOrder(documentTypeName: string, groupName: string, sortOrder: number) {\n const documentType = await this.getByName(documentTypeName);\n const group = documentType.containers.find(x => x.name === groupName);\n // Check if group is defined\n if (group) {\n return group.sortOrder === sortOrder;\n } else {\n // Group not found\n return false;\n }\n }\n \n async doesDocumentTypeTabNameContainCorrectSortOrder(documentTypeName: string, tabName: string, sortOrder: number) {\n const documentType = await this.getByName(documentTypeName);\n const tab = documentType.containers.find(x => x.name === tabName);\n // Check if tab is defined\n if (tab) {\n return tab.sortOrder === sortOrder;\n } else {\n // Tab not found\n return false;\n }\n }\n \n async getContainerIdWithName(documentTypeName: string, containerName: string) {\n const documentType = await this.getByName(documentTypeName);\n const container = documentType.containers.find(x => x.name === containerName);\n if (container) {\n return container.id;\n } else {\n return null;\n }\n }\n}"]}
|
|
@@ -4,7 +4,6 @@ export declare class MediaUiHelper extends UiBaseLocators {
|
|
|
4
4
|
private readonly createMediaItemBtn;
|
|
5
5
|
private readonly mediaTypePopoverBtn;
|
|
6
6
|
private readonly mediaNameTxt;
|
|
7
|
-
private readonly clickToUploadBtn;
|
|
8
7
|
private readonly actionModalCreateBtn;
|
|
9
8
|
private readonly mediaSearchTxt;
|
|
10
9
|
private readonly mediaCardItems;
|
|
@@ -21,8 +20,6 @@ export declare class MediaUiHelper extends UiBaseLocators {
|
|
|
21
20
|
clickCreateMediaItemButton(): Promise<void>;
|
|
22
21
|
enterMediaItemName(name: string): Promise<void>;
|
|
23
22
|
clickMediaTypeWithNameButton(mediaTypeName: string): Promise<void>;
|
|
24
|
-
clickToUploadButton(): Promise<void>;
|
|
25
|
-
changeFileTypeWithFileChooser(filePath: string): Promise<void>;
|
|
26
23
|
searchForMediaItemByName(name: string): Promise<void>;
|
|
27
24
|
doesMediaCardsContainAmount(count: number): Promise<void>;
|
|
28
25
|
doesMediaCardContainText(name: string): Promise<void>;
|
|
@@ -7,7 +7,6 @@ class MediaUiHelper extends UiBaseLocators_1.UiBaseLocators {
|
|
|
7
7
|
createMediaItemBtn;
|
|
8
8
|
mediaTypePopoverBtn;
|
|
9
9
|
mediaNameTxt;
|
|
10
|
-
clickToUploadBtn;
|
|
11
10
|
actionModalCreateBtn;
|
|
12
11
|
mediaSearchTxt;
|
|
13
12
|
mediaCardItems;
|
|
@@ -25,7 +24,6 @@ class MediaUiHelper extends UiBaseLocators_1.UiBaseLocators {
|
|
|
25
24
|
this.createMediaItemBtn = page.locator('umb-create-media-collection-action').getByLabel('Create');
|
|
26
25
|
this.mediaTypePopoverBtn = page.locator('#collection-action-menu-popover');
|
|
27
26
|
this.mediaNameTxt = page.locator('#name-input #input');
|
|
28
|
-
this.clickToUploadBtn = page.getByLabel('Click to upload');
|
|
29
27
|
this.actionModalCreateBtn = page.locator('#action-modal').getByLabel('Create');
|
|
30
28
|
this.mediaSearchTxt = page.getByLabel('Search', { exact: true });
|
|
31
29
|
this.mediaCardItems = page.locator('uui-card-media');
|
|
@@ -49,15 +47,6 @@ class MediaUiHelper extends UiBaseLocators_1.UiBaseLocators {
|
|
|
49
47
|
async clickMediaTypeWithNameButton(mediaTypeName) {
|
|
50
48
|
await this.mediaTypePopoverBtn.getByLabel(mediaTypeName).click();
|
|
51
49
|
}
|
|
52
|
-
async clickToUploadButton() {
|
|
53
|
-
await this.clickToUploadBtn.click();
|
|
54
|
-
}
|
|
55
|
-
async changeFileTypeWithFileChooser(filePath) {
|
|
56
|
-
const fileChooserPromise = this.page.waitForEvent('filechooser');
|
|
57
|
-
await this.clickToUploadButton();
|
|
58
|
-
const fileChooser = await fileChooserPromise;
|
|
59
|
-
await fileChooser.setFiles(filePath);
|
|
60
|
-
}
|
|
61
50
|
async searchForMediaItemByName(name) {
|
|
62
51
|
await this.mediaSearchTxt.clear();
|
|
63
52
|
await this.mediaSearchTxt.fill(name);
|