-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Block Custom View: Add tests for create and using block custom view #20472
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
base: main
Are you sure you want to change the base?
Changes from all commits
1249740
6f14694
bac6354
409741e
bab5679
31686b3
87b125a
3be5571
720ad66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "$schema": "../../umbraco-package-schema.json", | ||
| "name": "My.CustomViewPackage", | ||
| "version": "0.1.0", | ||
| "extensions": [ | ||
| { | ||
| "type": "blockEditorCustomView", | ||
| "alias": "my.blockEditorCustomView.Example", | ||
| "name": "My Example Custom View", | ||
| "element": "/App_Plugins/block-custom-view/block-custom-view.js", | ||
| "forContentTypeAlias": "elementTypeForCustomBlockView" | ||
| }, | ||
| { | ||
| "type": "blockEditorCustomView", | ||
| "alias": "my.blockGridCustomView.Example", | ||
| "name": "My Block Grid Custom View", | ||
| "element": "/App_Plugins/block-custom-view/block-grid-custom-view.js", | ||
| "forBlockEditor": "block-grid" | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; | ||
|
|
||
| // Content | ||
| const contentName = 'TestContent'; | ||
| const contentGroupName = 'TestContentGroup'; | ||
| // DocumentType | ||
| const documentTypeName = 'TestDocumentTypeForContent'; | ||
| // DataType | ||
| const dataTypeName = 'Textstring'; | ||
| const textAreaDataTypeName = 'Textarea'; | ||
| // BlockType | ||
| const blockGridName = 'TestBlockGridForContent'; | ||
| const blockListName = 'TestBlockListForContent'; | ||
| // ElementType | ||
| const elementGroupName = 'TestElementGroupForContent'; | ||
| const firstElementTypeName = 'TestElementTypeForContent'; | ||
| const secondElementTypeName = 'Element Type For Custom Block View'; | ||
| // Setting Model | ||
| const settingModelName = 'Test Setting Model'; | ||
| const groupName = 'Test Group'; | ||
| // Block Custom View | ||
| const blockGridCustomViewLocator = 'block-grid-custom-view'; | ||
| const blockCustomViewLocator = 'block-custom-view'; | ||
| // Property Editor | ||
| const propertyEditorName = 'Heading'; | ||
| const propertyEditorSettingName = 'Theme'; | ||
|
|
||
| test.afterEach(async ({ umbracoApi }) => { | ||
| await umbracoApi.document.ensureNameNotExists(contentName); | ||
NguyenThuyLan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| await umbracoApi.documentType.ensureNameNotExists(documentTypeName); | ||
| await umbracoApi.dataType.ensureNameNotExists(blockGridName); | ||
| await umbracoApi.dataType.ensureNameNotExists(blockListName); | ||
| await umbracoApi.documentType.ensureNameNotExists(firstElementTypeName); | ||
| await umbracoApi.documentType.ensureNameNotExists(secondElementTypeName); | ||
| await umbracoApi.dataType.ensureNameNotExists(dataTypeName); | ||
| }); | ||
|
|
||
| test('block custom view appears in a specific block type', async ({umbracoApi, umbracoUi}) => { | ||
| // Arrange | ||
| const textStringDataType = await umbracoApi.dataType.getByName(dataTypeName); | ||
| const elementTypeId = await umbracoApi.documentType.createDefaultElementType(firstElementTypeName, elementGroupName, dataTypeName, textStringDataType.id); | ||
| const blockGridId = await umbracoApi.dataType.createBlockGridWithABlock(blockGridName, elementTypeId); | ||
| const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockGridName, blockGridId, contentGroupName); | ||
| await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); | ||
|
|
||
| // Act | ||
| await umbracoUi.goToBackOffice(); | ||
| await umbracoUi.content.goToSection(ConstantHelper.sections.content); | ||
| await umbracoUi.content.goToContentWithName(contentName); | ||
| await umbracoUi.content.clickAddBlockElementButton(); | ||
| await umbracoUi.content.clickBlockElementWithName(firstElementTypeName); | ||
| await umbracoUi.content.clickCreateModalButton(); | ||
|
|
||
| // Assert | ||
| await umbracoUi.content.isBlockCustomViewVisible(blockGridCustomViewLocator); | ||
| await umbracoUi.content.isSingleBlockElementVisible(false); | ||
| }); | ||
|
|
||
| test('block custom view does not appear in block list editor when configured for block grid only', async ({umbracoApi, umbracoUi}) => { | ||
| // Arrange | ||
| const textStringDataType = await umbracoApi.dataType.getByName(dataTypeName); | ||
| const elementTypeId = await umbracoApi.documentType.createDefaultElementType(firstElementTypeName, elementGroupName, dataTypeName, textStringDataType.id); | ||
| const blockListId = await umbracoApi.dataType.createBlockListDataTypeWithABlock(blockListName, elementTypeId); | ||
| const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockListName, blockListId, contentGroupName); | ||
| await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); | ||
|
|
||
| // Act | ||
| await umbracoUi.goToBackOffice(); | ||
| await umbracoUi.content.goToSection(ConstantHelper.sections.content); | ||
| await umbracoUi.content.goToContentWithName(contentName); | ||
| await umbracoUi.content.clickAddBlockElementButton(); | ||
| await umbracoUi.content.clickBlockElementWithName(firstElementTypeName); | ||
| await umbracoUi.content.clickCreateModalButton(); | ||
|
|
||
| // Assert | ||
| await umbracoUi.content.isBlockCustomViewVisible(blockGridCustomViewLocator, false); | ||
| await umbracoUi.content.isSingleBlockElementVisible(); | ||
| }); | ||
|
|
||
| test('block custom view applies to correct content type', async ({umbracoApi, umbracoUi}) => { | ||
| // Arrange | ||
| const textStringDataType = await umbracoApi.dataType.getByName(dataTypeName); | ||
| const firstElementTypeId = await umbracoApi.documentType.createDefaultElementType(firstElementTypeName, elementGroupName, dataTypeName, textStringDataType.id); | ||
| const secondElementTypeId = await umbracoApi.documentType.createDefaultElementType(secondElementTypeName, elementGroupName, dataTypeName, textStringDataType.id); | ||
| const blockListId = await umbracoApi.dataType.createBlockListDataTypeWithTwoBlocks(blockListName, firstElementTypeId, secondElementTypeId); | ||
| const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockListName, blockListId, contentGroupName); | ||
| await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); | ||
|
|
||
| // Act | ||
| await umbracoUi.goToBackOffice(); | ||
| await umbracoUi.content.goToSection(ConstantHelper.sections.content); | ||
| await umbracoUi.content.goToContentWithName(contentName); | ||
| await umbracoUi.content.clickAddBlockElementButton(); | ||
| await umbracoUi.content.clickBlockCardWithName(secondElementTypeName); | ||
| await umbracoUi.content.clickCreateModalButton(); | ||
| await umbracoUi.content.clickAddBlockElementButton(); | ||
| await umbracoUi.content.clickBlockCardWithName(firstElementTypeName); | ||
| await umbracoUi.content.clickCreateModalButton(); | ||
|
|
||
| // Assert | ||
| await umbracoUi.content.isBlockCustomViewVisible(blockCustomViewLocator); | ||
| await umbracoUi.content.isSingleBlockElementVisible(); | ||
| }); | ||
|
|
||
| test('block custom view can display values from the content and settings parts', async ({umbracoApi, umbracoUi}) => { | ||
| // Arrange | ||
| const contentValue = 'This is block test'; | ||
| const settingValue = 'This is setting test'; | ||
| const valueText = `Heading and Theme: ${contentValue} - ${settingValue}`; | ||
| const textStringDataType = await umbracoApi.dataType.getByName(dataTypeName); | ||
| const textAreaDataType = await umbracoApi.dataType.getByName(textAreaDataTypeName); | ||
| const elementTypeId = await umbracoApi.documentType.createDefaultElementType(secondElementTypeName, elementGroupName, propertyEditorName, textStringDataType.id); | ||
| const settingsElementTypeId = await umbracoApi.documentType.createDefaultElementType(settingModelName, groupName, propertyEditorSettingName, textAreaDataType.id); | ||
| const blockListId = await umbracoApi.dataType.createBlockListDataTypeWithContentAndSettingsElementType(blockListName, elementTypeId, settingsElementTypeId); | ||
| const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockListName, blockListId, contentGroupName); | ||
| await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); | ||
|
|
||
| // Act | ||
| await umbracoUi.goToBackOffice(); | ||
| await umbracoUi.content.goToSection(ConstantHelper.sections.content); | ||
| await umbracoUi.content.goToContentWithName(contentName); | ||
| await umbracoUi.content.clickAddBlockElementButton(); | ||
| await umbracoUi.content.clickBlockCardWithName(secondElementTypeName); | ||
| await umbracoUi.content.enterTextstring(contentValue); | ||
| await umbracoUi.content.clickAddBlockSettingsTabButton(); | ||
| await umbracoUi.content.enterTextArea(settingValue); | ||
| await umbracoUi.content.clickCreateModalButton(); | ||
|
|
||
| // Assert | ||
| await umbracoUi.content.isBlockCustomViewVisible(blockCustomViewLocator); | ||
| await umbracoUi.content.doesBlockCustomViewHaveValue(blockCustomViewLocator, valueText); | ||
| }); | ||
|
|
||
| test('block custom view can display values from the content and settings parts after update', async ({umbracoApi, umbracoUi}) => { | ||
| // Arrange | ||
| const contentValue = 'This is block test'; | ||
| const settingValue = 'This is setting test'; | ||
| const updatedContentValue = 'This is updated block test'; | ||
| const updatedSettingValue = 'This is updated setting test'; | ||
| const updatedValueText = `Heading and Theme: ${updatedContentValue} - ${updatedSettingValue}`; | ||
| const textStringDataType = await umbracoApi.dataType.getByName(dataTypeName); | ||
| const textAreaDataType = await umbracoApi.dataType.getByName(textAreaDataTypeName); | ||
| const elementTypeId = await umbracoApi.documentType.createDefaultElementType(secondElementTypeName, elementGroupName, propertyEditorName, textStringDataType.id); | ||
| const settingsElementTypeId = await umbracoApi.documentType.createDefaultElementType(settingModelName, groupName, propertyEditorSettingName, textAreaDataType.id); | ||
| const blockListId = await umbracoApi.dataType.createBlockListDataTypeWithContentAndSettingsElementType(blockListName, elementTypeId, settingsElementTypeId); | ||
| const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockListName, blockListId, contentGroupName); | ||
| await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); | ||
|
|
||
| // Act | ||
| await umbracoUi.goToBackOffice(); | ||
| await umbracoUi.content.goToSection(ConstantHelper.sections.content); | ||
| await umbracoUi.content.goToContentWithName(contentName); | ||
| await umbracoUi.content.clickAddBlockElementButton(); | ||
| await umbracoUi.content.clickBlockCardWithName(secondElementTypeName); | ||
| await umbracoUi.content.enterTextstring(contentValue); | ||
| await umbracoUi.content.clickAddBlockSettingsTabButton(); | ||
| await umbracoUi.content.enterTextArea(settingValue); | ||
| await umbracoUi.content.clickCreateModalButton(); | ||
| await umbracoUi.content.clickEditBlockListBlockButton(); | ||
| await umbracoUi.content.enterTextstring(updatedContentValue); | ||
| await umbracoUi.content.clickAddBlockSettingsTabButton(); | ||
| await umbracoUi.content.enterTextArea(updatedSettingValue); | ||
| await umbracoUi.content.clickUpdateButton(); | ||
|
|
||
| // Assert | ||
| await umbracoUi.content.isBlockCustomViewVisible(blockCustomViewLocator); | ||
| await umbracoUi.content.doesBlockCustomViewHaveValue(blockCustomViewLocator, updatedValueText); | ||
| }); | ||
NguyenThuyLan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.