+@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
+@{
+\tLayout = null;
+}
+
+@Model.Title
`);
+
+ const content = new ContentBuilder()
+ .withContentTypeAlias(savedDocType["alias"])
+ .withAction("publishNew")
+ .addVariant()
+ .withName("Home")
+ .withSave(true)
+ .withPublish(true)
+ .addProperty()
+ .withAlias(propertyAlias)
+ .withValue(propertyValue)
+ .done()
+ .done()
+ .build()
+
+ await umbracoApi.content.save(content);
+
+ // Navigate to the document type
+ await umbracoUi.goToSection(ConstantHelper.sections.settings);
+ await umbracoUi.clickElement(umbracoUi.getTreeItem("settings", ["templates", docTypeName]));
+ const editor = await page.locator('.ace_content');
+ await editor.click();
+ // We only have to type out the opening tag, the editor adds the closing tag automatically.
+ await editor.type("Edited")
+ await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.save))
+
+ await umbracoUi.isSuccessNotificationVisible();
+ await umbracoApi.content.verifyRenderedContent("/", "
" + propertyValue + "
Edited
", true)
+
+ await umbracoApi.content.deleteAllContent();
+ await umbracoApi.documentTypes.ensureNameNotExists(docTypeName);
+ await umbracoApi.templates.ensureNameNotExists(docTypeName);
+ });
+
+ test('Can update view and document type', async ({page, umbracoApi, umbracoUi}) => {
+ const docTypeName = "TestDocument";
+ const docTypeAlias = AliasHelper.toAlias(docTypeName);
+ const propertyAlias = "title";
+ const propertyValue = "Hello world!"
+ const contentName = "Home";
+
+ await umbracoApi.content.deleteAllContent();
+ await umbracoApi.documentTypes.ensureNameNotExists(docTypeName);
+ await umbracoApi.templates.ensureNameNotExists(docTypeName);
+
+ const docType = new DocumentTypeBuilder()
+ .withName(docTypeName)
+ .withAlias(docTypeAlias)
+ .withAllowAsRoot(true)
+ .withDefaultTemplate(docTypeAlias)
+ .addTab()
+ .withName("Content")
+ .addTextBoxProperty()
+ .withAlias(propertyAlias)
+ .done()
+ .done()
+ .build();
+
+ const savedDocType = await umbracoApi.documentTypes.save(docType);
+ await umbracoApi.templates.edit(docTypeName, `@using Umbraco.Cms.Web.Common.PublishedModels;
+@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
+@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
+@{
+\tLayout = null;
+}
+
+@Model.Title
`);
+
+ const content = new ContentBuilder()
+ .withContentTypeAlias(savedDocType["alias"])
+ .withAction("publishNew")
+ .addVariant()
+ .withName(contentName)
+ .withSave(true)
+ .withPublish(true)
+ .addProperty()
+ .withAlias(propertyAlias)
+ .withValue(propertyValue)
+ .done()
+ .done()
+ .build()
+
+ await umbracoApi.content.save(content);
+
+ // Navigate to the document type
+ await umbracoUi.goToSection(ConstantHelper.sections.settings);
+ await umbracoUi.clickElement(umbracoUi.getTreeItem("settings", ["Document Types", docTypeName]));
+ // Add a new property (this might cause a version error if the viewcache is not cleared, hence this test
+ await page.locator('.umb-box-content >> [data-element="property-add"]').click();
+ await page.locator('[data-element="property-name"]').type("Bod");
+ await page.locator('[data-element="editor-add"]').click();
+ await page.locator('[input-id="datatype-search"]').type("Textstring");
+ await page.locator('.umb-card-grid >> [title="Textstring"]').click();
+ await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.submit));
+ await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.save));
+ await umbracoUi.isSuccessNotificationVisible();
+
+ // Update the template
+ await umbracoUi.clickElement(umbracoUi.getTreeItem("settings", ["templates", docTypeName]));
+ const editor = await page.locator('.ace_content');
+ await editor.click();
+ // We only have to type out the opening tag, the editor adds the closing tag automatically.
+ await editor.type("@Model.Bod")
+ await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.save))
+ await umbracoUi.isSuccessNotificationVisible();
+
+ // Navigate to the content section and update the content
+ await umbracoUi.goToSection(ConstantHelper.sections.content);
+ await umbracoUi.refreshContentTree();
+ await umbracoUi.clickElement(umbracoUi.getTreeItem("content", [contentName]));
+ await page.locator("#bod").type("Fancy body text");
+
+ await umbracoApi.content.verifyRenderedContent("/", "
" + propertyValue + "
Fancy body text
", true);
+
+ await umbracoApi.content.deleteAllContent();
+ await umbracoApi.documentTypes.ensureNameNotExists(docTypeName);
+ await umbracoApi.templates.ensureNameNotExists(docTypeName)
+ });
+});