-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Property action: Add tests for create and using Property Action UI Extension #20291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7e2d18e
add property action tests
LanThuyNguyen 172525c
add extension property action code
LanThuyNguyen 246f58a
remove extension registry config
LanThuyNguyen e7f0040
Merge branch 'main' of https://github.com/umbraco/Umbraco-CMS into v1…
LanThuyNguyen e4fb44a
update helper version
LanThuyNguyen 78e5098
fix conflict
LanThuyNguyen bdd514c
Merge branch 'main' of https://github.com/umbraco/Umbraco-CMS into v1…
LanThuyNguyen c2d6926
Merge branch 'main' of https://github.com/umbraco/Umbraco-CMS into v1…
LanThuyNguyen 4a2f1e5
Update tests/Umbraco.Tests.AcceptanceTest/tests/ExtensionRegistry/Pro…
NguyenThuyLan a654faf
Update tests/Umbraco.Tests.AcceptanceTest/tests/ExtensionRegistry/Pro…
NguyenThuyLan 1e7b229
Update tests/Umbraco.Tests.AcceptanceTest/tests/ExtensionRegistry/Add…
NguyenThuyLan 9c71eca
Update tests/Umbraco.Tests.AcceptanceTest/tests/ExtensionRegistry/Add…
NguyenThuyLan bb5909f
change tab space size
LanThuyNguyen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...onRegistry/AdditionalSetup/App_Plugins/my-property-action/my-property-action.manifests.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| export const manifests = [ | ||
| { | ||
| type: 'propertyAction', | ||
| kind: 'default', | ||
| alias: 'My.propertyAction.Write', | ||
| name: 'Write Property Action ', | ||
| forPropertyEditorUis: ["Umb.PropertyEditorUi.TextBox"], | ||
| api: () => import('./write-property-action.api.js'), | ||
| weight: 200, | ||
| meta: { | ||
| icon: 'icon-brush', | ||
| label: 'Write text', | ||
| } | ||
| }, | ||
| { | ||
| type: 'propertyAction', | ||
| kind: 'default', | ||
| alias: 'My.propertyAction.Read', | ||
| name: 'Read Property Action ', | ||
| forPropertyEditorUis: ["Umb.PropertyEditorUi.TextBox"], | ||
| api: () => import('./read-property-action.api.js'), | ||
| weight: 200, | ||
| meta: { | ||
| icon: 'icon-eye', | ||
| label: 'Read text', | ||
| } | ||
| } | ||
| ] |
21 changes: 21 additions & 0 deletions
21
...ensionRegistry/AdditionalSetup/App_Plugins/my-property-action/read-property-action.api.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { UmbPropertyActionBase } from '@umbraco-cms/backoffice/property-action'; | ||
| import { UMB_PROPERTY_CONTEXT } from '@umbraco-cms/backoffice/property'; | ||
| import { UMB_NOTIFICATION_CONTEXT } from '@umbraco-cms/backoffice/notification'; | ||
| export class ReadPropertyAction extends UmbPropertyActionBase { | ||
| async execute() { | ||
| const propertyContext = await this.getContext(UMB_PROPERTY_CONTEXT); | ||
| if (!propertyContext) { | ||
| return; | ||
| } | ||
| const value = propertyContext.getValue(); | ||
| const notificationContext = await this.getContext(UMB_NOTIFICATION_CONTEXT); | ||
| notificationContext?.peek('positive', { | ||
| data: { | ||
| headline: '', | ||
| message: value, | ||
| }, | ||
| }); | ||
| } | ||
| } | ||
| export { ReadPropertyAction as api }; | ||
|
|
||
12 changes: 12 additions & 0 deletions
12
...sts/ExtensionRegistry/AdditionalSetup/App_Plugins/my-property-action/umbraco-package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "name": "E2E Test Package", | ||
| "version": "1.0.0", | ||
| "extensions": [ | ||
| { | ||
| "type": "bundle", | ||
| "alias": "My.PropertyAction.Bundle", | ||
| "name": "My property action bundle", | ||
| "js": "/App_Plugins/my-property-action/my-property-action.manifests.js" | ||
| } | ||
| ] | ||
| } |
14 changes: 14 additions & 0 deletions
14
...nsionRegistry/AdditionalSetup/App_Plugins/my-property-action/write-property-action.api.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { UmbPropertyActionBase } from '@umbraco-cms/backoffice/property-action'; | ||
| import { UMB_PROPERTY_CONTEXT } from '@umbraco-cms/backoffice/property'; | ||
| export class WritePropertyAction extends UmbPropertyActionBase { | ||
| async execute() { | ||
| const propertyContext = await this.getContext(UMB_PROPERTY_CONTEXT); | ||
| if (!propertyContext) { | ||
| return; | ||
| } | ||
| propertyContext.setValue('Hello world'); | ||
|
|
||
| } | ||
| } | ||
| export { WritePropertyAction as api }; | ||
|
|
||
NguyenThuyLan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
59 changes: 59 additions & 0 deletions
59
tests/Umbraco.Tests.AcceptanceTest/tests/ExtensionRegistry/PropertyAction.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; | ||
| import { expect } from '@playwright/test'; | ||
|
|
||
| // Content | ||
| const contentName = 'TestContent'; | ||
| // DocumentType | ||
| const documentTypeName = 'TestDocumentTypeForContent'; | ||
| // GroupName | ||
| const groupName = 'Content'; | ||
| // DataType | ||
| const dataTypeName = 'Textstring'; | ||
| // Property actions name | ||
| const writeActionName = 'Write text'; | ||
| const readActionName = 'Read text'; | ||
| // Test values | ||
| const readTextValue = 'Test text value'; | ||
| const writeTextValue = 'Hello world'; | ||
|
|
||
| test.afterEach(async ({umbracoApi}) => { | ||
| await umbracoApi.document.ensureNameNotExists(contentName); | ||
| await umbracoApi.documentType.ensureNameNotExists(documentTypeName); | ||
| }); | ||
|
|
||
| test('can read value of Textstring editor via Read Property action', async ({umbracoApi, umbracoUi}) => { | ||
NguyenThuyLan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // Arrange | ||
| const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); | ||
| const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id, groupName); | ||
| await umbracoApi.document.createDocumentWithTextContent(contentName, documentTypeId, readTextValue, dataTypeName); | ||
| await umbracoUi.goToBackOffice(); | ||
| await umbracoUi.content.goToSection(ConstantHelper.sections.content); | ||
|
|
||
| // Act | ||
| await umbracoUi.content.goToContentWithName(contentName); | ||
| await umbracoUi.content.clickActionsMenuForProperty(groupName, dataTypeName); | ||
| await umbracoUi.content.clickPropertyActionWithName(readActionName); | ||
|
|
||
| // Assert | ||
| await umbracoUi.content.doesSuccessNotificationHaveText(readTextValue); | ||
| }); | ||
|
|
||
| test('can write value to Textstring editor via Write Property action', async ({umbracoApi, umbracoUi}) => { | ||
NguyenThuyLan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // Arrange | ||
| const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); | ||
| const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id, groupName); | ||
| const contentId = await umbracoApi.document.createDocumentWithTextContent(contentName, documentTypeId, '', dataTypeName); | ||
| await umbracoUi.goToBackOffice(); | ||
| await umbracoUi.content.goToSection(ConstantHelper.sections.content); | ||
|
|
||
| // Act | ||
| await umbracoUi.content.goToContentWithName(contentName); | ||
| await umbracoUi.content.clickActionsMenuForProperty(groupName, dataTypeName); | ||
| await umbracoUi.content.clickPropertyActionWithName(writeActionName); | ||
| await umbracoUi.content.clickSaveButton(); | ||
|
|
||
| // Assert | ||
| await umbracoUi.content.isSuccessStateVisibleForSaveButton(); | ||
| const updatedContentData = await umbracoApi.document.get(contentId); | ||
| expect(updatedContentData.values[0].value).toBe(writeTextValue); | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.