Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/helpers/ContentRenderUiHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import {umbracoConfig} from "../../umbraco.config";

export class ContentRenderUiHelper extends UiBaseLocators {
private readonly contentRenderValue: Locator;
private readonly dataSourceRenderValue: Locator;

constructor(page: Page) {
super(page);
this.contentRenderValue = page.getByTestId('content-render-value');
this.dataSourceRenderValue = page.getByTestId('data-source-render-value');
}

async navigateToRenderedContentPage(contentURL: string) {
Expand All @@ -30,4 +32,8 @@ export class ContentRenderUiHelper extends UiBaseLocators {
async doesContentRenderValueHaveLink(linkSrc: string) {
return await expect(this.contentRenderValue.locator('a')).toHaveAttribute('href', linkSrc);
}

async doesDataSourceRenderValueHaveText(text: string) {
return await expect(this.dataSourceRenderValue).toHaveText(text);
}
}
25 changes: 25 additions & 0 deletions lib/helpers/ContentUiHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ export class ContentUiHelper extends UiBaseLocators {
private readonly refListBlock: Locator;
private readonly propertyActionMenu: Locator;
private readonly listViewCustomRows: Locator;
private readonly collectionMenu: Locator;
private readonly entityPickerTree: Locator;

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

async enterContentName(name: string) {
Expand Down Expand Up @@ -1769,4 +1774,24 @@ export class ContentUiHelper extends UiBaseLocators {
await expect(this.nextBtn).toBeVisible();
await this.nextBtn.click();
}

// Entity Data Picker
async chooseCollectionMenuItemWithName(name: string) {
await this.clickChooseButton();
await this.collectionMenu.locator('umb-collection-menu-item', {hasText: name}).click();
await this.clickChooseContainerButton();
}

async chooseTreeMenuItemWithName(name: string, parentNames: string[] = []) {
await this.clickChooseButton();
for (const itemName of parentNames) {
await this.entityPickerTree.locator('umb-tree-item').getByLabel('Expand child items for ' + itemName).click();
}
await this.container.getByLabel(name).click();
await this.clickChooseContainerButton();
}

async isChooseButtonVisible(isVisible: boolean = true) {
await expect(this.chooseBtn).toBeVisible({visible: isVisible});
}
}
27 changes: 26 additions & 1 deletion lib/helpers/DataTypeApiHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
NumericDataTypeBuilder,
TagsDataTypeBuilder,
MultiNodeTreePickerDataTypeBuilder,
DateTimeWithTimeZonePickerDataTypeBuilder
DateTimeWithTimeZonePickerDataTypeBuilder, EntityDataPickerDataTypeBuilder
} from "@umbraco/json-models-builders";

export class DataTypeApiHelper {
Expand Down Expand Up @@ -1939,4 +1939,29 @@ export class DataTypeApiHelper {
const existingZones = timeZonesData.value.timeZones;
return timeZones.every(timeZone => existingZones.includes(timeZone));
}

// Entity Data Picker
async createEntityDataPickerDataType(name: string, dataSource: string) {
await this.ensureNameNotExists(name);

const dataType = new EntityDataPickerDataTypeBuilder()
.withName(name)
.withDataSource(dataSource)
.build();

return await this.save(dataType);
}

async createEntityDataPickerDataTypeWithMinAndMaxValues(name: string, dataSource: string, min: number, max: number) {
await this.ensureNameNotExists(name);

const dataType = new EntityDataPickerDataTypeBuilder()
.withName(name)
.withDataSource(dataSource)
.withMinValue(min)
.withMaxValue(max)
.build();

return await this.save(dataType);
}
}
9 changes: 9 additions & 0 deletions lib/helpers/DataTypeUiHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export class DataTypeUiHelper extends UiBaseLocators {
private readonly propertyCrops: Locator;
private readonly addTimeZoneBtn: Locator;
private readonly timeZoneDropDown: Locator;
private readonly dataSourceChooseBtn: Locator;

constructor(page: Page) {
super(page);
Expand Down Expand Up @@ -317,6 +318,9 @@ export class DataTypeUiHelper extends UiBaseLocators {
// Date Time with Time Zone Picker
this.addTimeZoneBtn = page.locator('#add-time-zone [name="icon-add"] svg');
this.timeZoneDropDown = page.locator('umb-input-time-zone-picker uui-combobox');

// Entity Picker Source
this.dataSourceChooseBtn = page.locator('[label="Data Source"]').locator(this.chooseBtn);
}

async clickActionsMenuForDataType(name: string) {
Expand Down Expand Up @@ -1277,4 +1281,9 @@ export class DataTypeUiHelper extends UiBaseLocators {
await this.addTimeZoneBtn.click();
}
}

async clickChooseDataSourceButton(){
await expect(this.dataSourceChooseBtn).toBeVisible();
await this.dataSourceChooseBtn.click();
}
}
6 changes: 6 additions & 0 deletions lib/helpers/TemplateApiHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,10 @@ export class TemplateApiHelper {
'\n<ul>';
return this.createTemplateWithDisplayingValue(name, templateContent);
}

async createTemplateWithContent(name: string, templateContent: string) {
await this.ensureNameNotExists(name);
const alias = AliasHelper.toAlias(name);
return await this.create(name, alias, templateContent);
}
}
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@umbraco/playwright-testhelpers",
"version": "17.0.4",
"version": "17.0.5",
"description": "Test helpers for making playwright tests for Umbraco solutions",
"main": "dist/lib/index.js",
"files": [
Expand Down Expand Up @@ -34,7 +34,7 @@
"typescript": "^4.8.3"
},
"dependencies": {
"@umbraco/json-models-builders": "2.0.41",
"@umbraco/json-models-builders": "2.0.42",
"node-fetch": "^2.6.7"
}
}