Skip to content

Commit 442b861

Browse files
nhudinh0309NguyenThuyLanLanThuyNguyenleekelleherandr317c
authored
Merging v16/dev to v17/dev branch (#315)
* Add helper: for property action, dashboard (#294) * Add helper for property action * add dashboard helper * Update lib/helpers/UiBaseLocators.ts Co-authored-by: Nhu Dinh <[email protected]> * Bumped version --------- Co-authored-by: Lan Nguyen Thuy <[email protected]> Co-authored-by: Nhu Dinh <[email protected]> Co-authored-by: Nhu Dinh <[email protected]> * Add helper: for block custom view (#299) * add helper for block custom view * Update lib/helpers/ContentUiHelper.ts Co-authored-by: Nhu Dinh <[email protected]> * Update lib/helpers/ContentUiHelper.ts Co-authored-by: Nhu Dinh <[email protected]> * Update lib/helpers/ContentUiHelper.ts Co-authored-by: Nhu Dinh <[email protected]> * Update lib/helpers/ContentUiHelper.ts Co-authored-by: Nhu Dinh <[email protected]> * Update lib/helpers/ContentUiHelper.ts Co-authored-by: Nhu Dinh <[email protected]> * Update lib/helpers/DataTypeApiHelper.ts Co-authored-by: Nhu Dinh <[email protected]> * change locator * Fix parameter name * add verson and format code * fix conflict --------- Co-authored-by: Lan Nguyen Thuy <[email protected]> Co-authored-by: Nhu Dinh <[email protected]> * Add helper: for workspace view (#298) * Add helper: for workspace view * Update lib/helpers/ContentUiHelper.ts Co-authored-by: Nhu Dinh <[email protected]> * move method into UiBaseLocators * update version --------- Co-authored-by: Lan Nguyen Thuy <[email protected]> Co-authored-by: Nhu Dinh <[email protected]> * V16: Updates Language menu label locator (#300) * Language menu locate exact label text This is to support PR umbraco/Umbraco-CMS#20458 * Bump version number * add new version (#302) Co-authored-by: Lan Nguyen Thuy <[email protected]> * V16 Cherrypick changes from 17 (#311) * Updated helpers * Bumped version * Add helper: for custom collection view (#313) * add helper for custom collection view * Update lib/helpers/ContentUiHelper.ts Co-authored-by: Nhu Dinh <[email protected]> * Update lib/helpers/ContentUiHelper.ts Co-authored-by: Nhu Dinh <[email protected]> * update some names --------- Co-authored-by: Lan Nguyen Thuy <[email protected]> Co-authored-by: Nhu Dinh <[email protected]> * V16 reverted updates from 17 (#314) * Updated helpers * Bumped version --------- Co-authored-by: NguyenThuyLan <[email protected]> Co-authored-by: Lan Nguyen Thuy <[email protected]> Co-authored-by: Lee Kelleher <[email protected]> Co-authored-by: Andreas Zerbst <[email protected]>
1 parent 2da10b2 commit 442b861

File tree

5 files changed

+98
-7
lines changed

5 files changed

+98
-7
lines changed

lib/helpers/ContentUiHelper.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ export class ContentUiHelper extends UiBaseLocators {
170170
private readonly mediaPickerSearchTxt: Locator;
171171
private readonly memberPickerSearchTxt: Locator;
172172
private readonly documentCreateOptionsModal: Locator;
173+
private readonly refListBlock: Locator;
174+
private readonly propertyActionMenu: Locator;
175+
private readonly documentCreateOptionsModal: Locator;
176+
private readonly listViewCustomRows: Locator;
173177

174178
constructor(page: Page) {
175179
super(page);
@@ -306,6 +310,7 @@ export class ContentUiHelper extends UiBaseLocators {
306310
this.blockGridAreasContainer = page.locator('umb-block-grid-areas-container');
307311
this.blockGridEntries = page.locator('umb-block-grid-entries');
308312
this.inlineCreateBtn = page.locator('uui-button-inline-create');
313+
this.refListBlock = page.locator('umb-ref-list-block');
309314
// TipTap
310315
this.tipTapPropertyEditor = page.locator('umb-property-editor-ui-tiptap');
311316
this.tipTapEditor = this.tipTapPropertyEditor.locator('#editor .tiptap');
@@ -348,6 +353,10 @@ export class ContentUiHelper extends UiBaseLocators {
348353
this.treePickerSearchTxt = this.page.locator('umb-tree-picker-modal #input');
349354
this.mediaPickerSearchTxt = this.page.locator('umb-media-picker-modal #search #input');
350355
this.memberPickerSearchTxt = this.page.locator('umb-member-picker-modal #input');
356+
// Property Actions
357+
this.propertyActionMenu = page.locator('#property-action-popover umb-popover-layout');
358+
// List view custom
359+
this.listViewCustomRows = page.locator('table tbody tr');
351360
}
352361

353362
async enterContentName(name: string) {
@@ -1708,6 +1717,33 @@ export class ContentUiHelper extends UiBaseLocators {
17081717
async isContentNameReadOnly() {
17091718
await expect(this.contentNameTxt).toHaveAttribute('readonly');
17101719
}
1720+
1721+
// Block Custom View
1722+
async isBlockCustomViewVisible(blockCustomViewLocator: string, isVisible: boolean = true) {
1723+
await expect(this.page.locator(blockCustomViewLocator)).toBeVisible({visible: isVisible});
1724+
}
1725+
1726+
async isSingleBlockElementVisible(isVisible: boolean = true) {
1727+
const count = await this.refListBlock.count();
1728+
if (isVisible) {
1729+
expect(count, `Expected only one element, but found ${count}`).toBe(1);
1730+
} else {
1731+
expect(count, `Expected only one element, but found ${count}`).toBe(0);
1732+
}
1733+
await expect(this.refListBlock).toBeVisible({visible: isVisible});
1734+
}
1735+
1736+
async doesBlockCustomViewHaveValue(customBlockViewLocator: string, valueText: string) {
1737+
const locator = this.page.locator(`${customBlockViewLocator} p`);
1738+
await expect(locator).toBeVisible();
1739+
await expect(locator).toHaveText(valueText);
1740+
}
1741+
1742+
async clickPropertyActionWithName(name: string) {
1743+
const actionLocator = this.propertyActionMenu.locator('umb-property-action uui-menu-item[label="' + name + '"]');
1744+
await expect(actionLocator).toBeVisible();
1745+
await actionLocator.click();
1746+
}
17111747

17121748
async isContentWithNameVisibleInList(contentName: string, isVisible: boolean = true) {
17131749
await expect(this.documentTableColumnName.filter({hasText: contentName})).toBeVisible({visible: isVisible});
@@ -1721,4 +1757,17 @@ export class ContentUiHelper extends UiBaseLocators {
17211757
async doesDocumentModalHaveText(text: string) {
17221758
await expect(this.documentCreateOptionsModal).toContainText(text);
17231759
}
1760+
1761+
async doesListViewItemsHaveCount(pageSize: number){
1762+
await expect(this.listViewCustomRows).toHaveCount(pageSize);
1763+
}
1764+
1765+
async isListViewItemWithNameVisible(itemName: string, index: number = 0){
1766+
await expect(this.listViewCustomRows.nth(index)).toContainText(itemName);
1767+
}
1768+
1769+
async clickPaginationNextButton(){
1770+
await expect(this.nextBtn).toBeVisible();
1771+
await this.nextBtn.click();
1772+
}
17241773
}

lib/helpers/DataTypeApiHelper.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,22 @@ export class DataTypeApiHelper {
314314

315315
return await this.save(blockList);
316316
}
317+
318+
async createBlockListDataTypeWithTwoBlocks(name: string, firstContentElementTypeId: string, secondContentElementTypeId: string) {
319+
await this.ensureNameNotExists(name);
320+
321+
const blockList = new BlockListDataTypeBuilder()
322+
.withName(name)
323+
.addBlock()
324+
.withContentElementTypeKey(firstContentElementTypeId)
325+
.done()
326+
.addBlock()
327+
.withContentElementTypeKey(secondContentElementTypeId)
328+
.done()
329+
.build();
330+
331+
return await this.save(blockList);
332+
}
317333

318334
async createBlockListDataTypeWithABlock(name: string, contentElementTypeId: string) {
319335
await this.ensureNameNotExists(name);
@@ -1204,6 +1220,32 @@ export class DataTypeApiHelper {
12041220
return await this.save(dataType);
12051221
}
12061222

1223+
async createListViewContentDataTypeWithLayoutAndPageSize(name: string = 'List View - Content Test', layoutAlias: string = 'Umb.CollectionView.Document.Table', layoutName: string = 'List', pageSize: number = 100 ) {
1224+
await this.ensureNameNotExists(name);
1225+
1226+
const dataType = new ListViewDataTypeBuilder()
1227+
.withName(name)
1228+
.withPageSize(pageSize)
1229+
.withOrderDirection('asc')
1230+
.addLayout()
1231+
.withName(layoutName)
1232+
.withIcon('icon-list')
1233+
.withCollectionView(layoutAlias)
1234+
.done()
1235+
.addColumnDisplayedProperty()
1236+
.withAlias('updateDate')
1237+
.withHeader('Last edited')
1238+
.withIsSystem(true)
1239+
.done()
1240+
.addColumnDisplayedProperty()
1241+
.withAlias('creator')
1242+
.withHeader('Updated by')
1243+
.withIsSystem(true)
1244+
.done()
1245+
.build();
1246+
return await this.save(dataType);
1247+
}
1248+
12071249
async createListViewContentDataTypeWithAllPermissions(name: string = 'List View - Content Test') {
12081250
await this.ensureNameNotExists(name);
12091251

lib/helpers/UiBaseLocators.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,10 @@ export class UiBaseLocators {
14081408
await this.clickEntityActionWithName('Lock');
14091409
}
14101410

1411+
async isDashboardTabWithNameVisible(name: string, isVisible: boolean = true) {
1412+
await expect(this.page.locator('uui-tab[label="' + name + '"]')).toBeVisible({visible: isVisible});
1413+
}
1414+
14111415
async enterMonacoEditorValue(value: string) {
14121416
await expect(this.monacoEditor).toBeVisible();
14131417
await this.monacoEditor.click();
@@ -1423,8 +1427,4 @@ export class UiBaseLocators {
14231427
async isWorkspaceViewTabWithAliasVisible(alias: string, isVisible: boolean = true) {
14241428
await expect(this.page.getByTestId('workspace:view-link:' + alias)).toBeVisible({ visible: isVisible });
14251429
}
1426-
1427-
async isDashboardTabWithNameVisible(name: string, isVisible: boolean = true) {
1428-
await expect(this.page.locator('uui-tab[label="' + name + '"]')).toBeVisible({visible: isVisible});
1429-
}
14301430
}

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@umbraco/playwright-testhelpers",
3-
"version": "17.0.0-beta.9",
3+
"version": "17.0.1",
44
"description": "Test helpers for making playwright tests for Umbraco solutions",
55
"main": "dist/lib/index.js",
66
"files": [

0 commit comments

Comments
 (0)