WorkspaceView: Add tests for create and using custom workspace view (#20408)

* WorkspaceView: Add tests for create and using custom workspace view

* update helper version

* Update tests/Umbraco.Tests.AcceptanceTest/tests/ExtensionRegistry/WorkspaceView.spec.ts

Co-authored-by: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com>

* Update tests/Umbraco.Tests.AcceptanceTest/tests/ExtensionRegistry/WorkspaceView.spec.ts

Co-authored-by: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com>

* update format code

* Update tests/Umbraco.Tests.AcceptanceTest/tests/ExtensionRegistry/WorkspaceView.spec.ts

Co-authored-by: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com>

* Update tests/Umbraco.Tests.AcceptanceTest/tests/ExtensionRegistry/WorkspaceView.spec.ts

Co-authored-by: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com>

* Update tests/Umbraco.Tests.AcceptanceTest/tests/ExtensionRegistry/WorkspaceView.spec.ts

Co-authored-by: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com>

---------

Co-authored-by: Lan Nguyen Thuy <lnt@umbraco.dk>
Co-authored-by: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com>
This commit is contained in:
NguyenThuyLan
2025-10-15 13:33:24 +07:00
committed by GitHub
parent a19b9fb5fe
commit e22b459d9c
4 changed files with 97 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
{
"$schema": "../../umbraco-package-schema.json",
"name": "My workspace",
"version": "0.1.0",
"extensions": [
{
"type": "workspaceView",
"alias": "My.WorkspaceView",
"name": "My Workspace View",
"element": "/App_Plugins/workspace-view/workspace-view.js",
"meta": {
"label": "My Workspace View",
"pathname": "/my-workspace-view",
"icon": "icon-add"
},
"conditions": [
{
"alias": "Umb.Condition.WorkspaceAlias",
"match": "Umb.Workspace.Document"
}
]
}
]
}

View File

@@ -0,0 +1,28 @@
import { LitElement as n, html as a, css as c, customElement as p } from "@umbraco-cms/backoffice/external/lit";
import { UmbElementMixin as u } from "@umbraco-cms/backoffice/element-api";
var w = Object.getOwnPropertyDescriptor, v = (o, s, i, l) => {
for (var e = l > 1 ? void 0 : l ? w(s, i) : s, r = o.length - 1, m; r >= 0; r--)
(m = o[r]) && (e = m(e) || e);
return e;
};
let t = class extends u(n) {
render() {
return a`
<uui-box headline="Workspace View">
Welcome to my newly created workspace view.
</uui-box>
`;
}
};
t.styles = c`
uui-box {
margin: 20px;
}
`;
t = v([
p("my-workspaceview")
], t);
export {
t as default
};
//# sourceMappingURL=workspace-view.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"workspace-view.js","sources":["../../workspace-view/src/my-element.ts"],"sourcesContent":["import { LitElement, html, customElement, css } from \"@umbraco-cms/backoffice/external/lit\";\nimport { UmbElementMixin } from \"@umbraco-cms/backoffice/element-api\";\n\n@customElement('my-workspaceview')\nexport default class MyWorkspaceViewElement extends UmbElementMixin(LitElement) {\n\n render() {\n return html` \n <uui-box headline=\"Workspace View\">\n Welcome to my newly created workspace view.\n </uui-box> \n `\n }\n\n static styles = css`\n uui-box {\n margin: 20px;\n }\n `\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'my-workspaceview': MyWorkspaceViewElement\n }\n}\n"],"names":["MyWorkspaceViewElement","UmbElementMixin","LitElement","html","css","__decorateClass","customElement"],"mappings":";;;;;;;AAIA,IAAqBA,IAArB,cAAoDC,EAAgBC,CAAU,EAAE;AAAA,EAE5E,SAAS;AACL,WAAOC;AAAA;AAAA;AAAA;AAAA;AAAA,EAKX;AAOJ;AAfqBH,EAUV,SAASI;AAAA;AAAA;AAAA;AAAA;AAVCJ,IAArBK,EAAA;AAAA,EADCC,EAAc,kBAAkB;AAAA,GACZN,CAAA;"}

View File

@@ -0,0 +1,44 @@
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';
// Content
const contentName = 'TestContent';
// DocumentType
const documentTypeName = 'TestDocumentTypeForContent';
// DataType
const dataTypeName = 'Textstring';
// Media
const mediaName = 'TestMedia';
test.afterEach(async ({umbracoApi}) => {
await umbracoApi.document.ensureNameNotExists(contentName);
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
await umbracoApi.media.ensureNameNotExists(mediaName);
});
test('can see the custom workspace view in the content section', async ({umbracoApi, umbracoUi}) => {
// Arrange
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
await umbracoApi.document.createDocumentWithTextContent(contentName, documentTypeId, 'Test content', dataTypeName);
// Act
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
await umbracoUi.content.goToContentWithName(contentName);
// Assert
await umbracoUi.content.isWorkspaceViewTabWithAliasVisible('My.WorkspaceView', true);
});
test('cannot see the custom workspace view in the media section', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.media.createDefaultMediaWithImage(mediaName);
// Act
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.media);
await umbracoUi.media.goToMediaWithName(mediaName);
// Assert
await umbracoUi.media.isWorkspaceViewTabWithAliasVisible('My.WorkspaceView', false);
});