Skip to content

Commit 4a01d19

Browse files
authored
V17 add entity picker helpers (#319)
* Added * Updated helpers * Bumped version * Clenaed up * Fixes
1 parent 81dc3bb commit 4a01d19

File tree

7 files changed

+83
-12
lines changed

7 files changed

+83
-12
lines changed

lib/helpers/ContentRenderUiHelper.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import {umbracoConfig} from "../../umbraco.config";
44

55
export class ContentRenderUiHelper extends UiBaseLocators {
66
private readonly contentRenderValue: Locator;
7+
private readonly dataSourceRenderValue: Locator;
78

89
constructor(page: Page) {
910
super(page);
1011
this.contentRenderValue = page.getByTestId('content-render-value');
12+
this.dataSourceRenderValue = page.getByTestId('data-source-render-value');
1113
}
1214

1315
async navigateToRenderedContentPage(contentURL: string) {
@@ -30,4 +32,8 @@ export class ContentRenderUiHelper extends UiBaseLocators {
3032
async doesContentRenderValueHaveLink(linkSrc: string) {
3133
return await expect(this.contentRenderValue.locator('a')).toHaveAttribute('href', linkSrc);
3234
}
35+
36+
async doesDataSourceRenderValueHaveText(text: string) {
37+
return await expect(this.dataSourceRenderValue).toHaveText(text);
38+
}
3339
}

lib/helpers/ContentUiHelper.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ export class ContentUiHelper extends UiBaseLocators {
173173
private readonly refListBlock: Locator;
174174
private readonly propertyActionMenu: Locator;
175175
private readonly listViewCustomRows: Locator;
176+
private readonly collectionMenu: Locator;
177+
private readonly entityPickerTree: Locator;
176178

177179
constructor(page: Page) {
178180
super(page);
@@ -356,6 +358,9 @@ export class ContentUiHelper extends UiBaseLocators {
356358
this.propertyActionMenu = page.locator('#property-action-popover umb-popover-layout');
357359
// List view custom
358360
this.listViewCustomRows = page.locator('table tbody tr');
361+
// Entity Data Picker
362+
this.collectionMenu = page.locator('umb-collection-menu');
363+
this.entityPickerTree = page.locator('umb-tree[alias="Umb.Tree.EntityDataPicker"]');
359364
}
360365

361366
async enterContentName(name: string) {
@@ -1769,4 +1774,24 @@ export class ContentUiHelper extends UiBaseLocators {
17691774
await expect(this.nextBtn).toBeVisible();
17701775
await this.nextBtn.click();
17711776
}
1777+
1778+
// Entity Data Picker
1779+
async chooseCollectionMenuItemWithName(name: string) {
1780+
await this.clickChooseButton();
1781+
await this.collectionMenu.locator('umb-collection-menu-item', {hasText: name}).click();
1782+
await this.clickChooseContainerButton();
1783+
}
1784+
1785+
async chooseTreeMenuItemWithName(name: string, parentNames: string[] = []) {
1786+
await this.clickChooseButton();
1787+
for (const itemName of parentNames) {
1788+
await this.entityPickerTree.locator('umb-tree-item').getByLabel('Expand child items for ' + itemName).click();
1789+
}
1790+
await this.container.getByLabel(name).click();
1791+
await this.clickChooseContainerButton();
1792+
}
1793+
1794+
async isChooseButtonVisible(isVisible: boolean = true) {
1795+
await expect(this.chooseBtn).toBeVisible({visible: isVisible});
1796+
}
17721797
}

lib/helpers/DataTypeApiHelper.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
NumericDataTypeBuilder,
3030
TagsDataTypeBuilder,
3131
MultiNodeTreePickerDataTypeBuilder,
32-
DateTimeWithTimeZonePickerDataTypeBuilder
32+
DateTimeWithTimeZonePickerDataTypeBuilder, EntityDataPickerDataTypeBuilder
3333
} from "@umbraco/json-models-builders";
3434

3535
export class DataTypeApiHelper {
@@ -1939,4 +1939,29 @@ export class DataTypeApiHelper {
19391939
const existingZones = timeZonesData.value.timeZones;
19401940
return timeZones.every(timeZone => existingZones.includes(timeZone));
19411941
}
1942+
1943+
// Entity Data Picker
1944+
async createEntityDataPickerDataType(name: string, dataSource: string) {
1945+
await this.ensureNameNotExists(name);
1946+
1947+
const dataType = new EntityDataPickerDataTypeBuilder()
1948+
.withName(name)
1949+
.withDataSource(dataSource)
1950+
.build();
1951+
1952+
return await this.save(dataType);
1953+
}
1954+
1955+
async createEntityDataPickerDataTypeWithMinAndMaxValues(name: string, dataSource: string, min: number, max: number) {
1956+
await this.ensureNameNotExists(name);
1957+
1958+
const dataType = new EntityDataPickerDataTypeBuilder()
1959+
.withName(name)
1960+
.withDataSource(dataSource)
1961+
.withMinValue(min)
1962+
.withMaxValue(max)
1963+
.build();
1964+
1965+
return await this.save(dataType);
1966+
}
19421967
}

lib/helpers/DataTypeUiHelper.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export class DataTypeUiHelper extends UiBaseLocators {
139139
private readonly propertyCrops: Locator;
140140
private readonly addTimeZoneBtn: Locator;
141141
private readonly timeZoneDropDown: Locator;
142+
private readonly dataSourceChooseBtn: Locator;
142143

143144
constructor(page: Page) {
144145
super(page);
@@ -317,6 +318,9 @@ export class DataTypeUiHelper extends UiBaseLocators {
317318
// Date Time with Time Zone Picker
318319
this.addTimeZoneBtn = page.locator('#add-time-zone [name="icon-add"] svg');
319320
this.timeZoneDropDown = page.locator('umb-input-time-zone-picker uui-combobox');
321+
322+
// Entity Picker Source
323+
this.dataSourceChooseBtn = page.locator('[label="Data Source"]').locator(this.chooseBtn);
320324
}
321325

322326
async clickActionsMenuForDataType(name: string) {
@@ -1277,4 +1281,9 @@ export class DataTypeUiHelper extends UiBaseLocators {
12771281
await this.addTimeZoneBtn.click();
12781282
}
12791283
}
1284+
1285+
async clickChooseDataSourceButton(){
1286+
await expect(this.dataSourceChooseBtn).toBeVisible();
1287+
await this.dataSourceChooseBtn.click();
1288+
}
12801289
}

lib/helpers/TemplateApiHelper.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,10 @@ export class TemplateApiHelper {
306306
'\n<ul>';
307307
return this.createTemplateWithDisplayingValue(name, templateContent);
308308
}
309+
310+
async createTemplateWithContent(name: string, templateContent: string) {
311+
await this.ensureNameNotExists(name);
312+
const alias = AliasHelper.toAlias(name);
313+
return await this.create(name, alias, templateContent);
314+
}
309315
}

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@umbraco/playwright-testhelpers",
3-
"version": "17.0.4",
3+
"version": "17.0.5",
44
"description": "Test helpers for making playwright tests for Umbraco solutions",
55
"main": "dist/lib/index.js",
66
"files": [
@@ -34,7 +34,7 @@
3434
"typescript": "^4.8.3"
3535
},
3636
"dependencies": {
37-
"@umbraco/json-models-builders": "2.0.41",
37+
"@umbraco/json-models-builders": "2.0.42",
3838
"node-fetch": "^2.6.7"
3939
}
4040
}

0 commit comments

Comments
 (0)