Skip to content

Commit 9964e0b

Browse files
authored
V16 QA Added acceptance tests for granular property value permission (#19458)
* Updated due to test helper changes * Updated user group tests due to api helper changes * Updated tests for user group default configuration due to UI changes * Added tests for document property value permission * Added tests for document property value permission in content with block * Bumped version * Make specific tests run in the pipeline * Added skip tag and issue link for the failing tests * Added tests for granular property value permission * Fixed comment * Bumped version * Bumped version * Fixed comments * Bumped version and reverted npm command * Make all tests for user group permission run in the pipeline * Updated smokeTest command * Fixed comments * Reverted npm command
1 parent 9d11c76 commit 9964e0b

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
import { expect } from '@playwright/test';
2+
import {AliasHelper, ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers';
3+
4+
const testUser = ConstantHelper.testUserCredentials;
5+
let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""};
6+
7+
const userGroupName = 'TestPropertyValuePermission';
8+
let userGroupId = null;
9+
10+
const firstDocumentName = 'FirstTestDocument';
11+
const secondDocumentName = 'SecondTestDocument';
12+
const documentTypeName = 'TestDocumentType';
13+
const firstPropertyName = ['Textstring', 'text-box'];
14+
const secondPropertyName = ['True/false', 'toggle'];
15+
let documentTypeId = null;
16+
let firstDocumentId = null;
17+
18+
test.beforeEach(async ({umbracoApi}) => {
19+
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
20+
await umbracoApi.document.ensureNameNotExists(firstDocumentName);
21+
await umbracoApi.document.ensureNameNotExists(secondDocumentName);
22+
const firstPropertyData = await umbracoApi.dataType.getByName(firstPropertyName[0]);
23+
const secondPropertyData = await umbracoApi.dataType.getByName(secondPropertyName[0]);
24+
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithTwoPropertyEditors(documentTypeName, firstPropertyName[0], firstPropertyData.id, secondPropertyName[0], secondPropertyData.id);
25+
firstDocumentId = await umbracoApi.document.createDefaultDocument(firstDocumentName, documentTypeId);
26+
await umbracoApi.document.createDefaultDocument(secondDocumentName, documentTypeId);
27+
});
28+
29+
test.afterEach(async ({umbracoApi}) => {
30+
// Ensure we are logged in to admin
31+
await umbracoApi.loginToAdminUser(testUserCookieAndToken.cookie, testUserCookieAndToken.accessToken, testUserCookieAndToken.refreshToken);
32+
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
33+
await umbracoApi.document.ensureNameNotExists(firstDocumentName);
34+
await umbracoApi.document.ensureNameNotExists(secondDocumentName);
35+
await umbracoApi.userGroup.ensureNameNotExists(userGroupName);
36+
});
37+
38+
test('can only see property values for specific document with read UI enabled', async ({umbracoApi, umbracoUi}) => {
39+
// Arrange
40+
userGroupId = await umbracoApi.userGroup.createUserGroupWithPermissionsForSpecificDocumentAndTwoPropertyValues(userGroupName, firstDocumentId, documentTypeId, firstPropertyName[0], true, false, secondPropertyName[0], true, false);
41+
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId);
42+
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);
43+
await umbracoUi.goToBackOffice();
44+
45+
// Act
46+
await umbracoUi.content.goToSection(ConstantHelper.sections.content, false);
47+
48+
// Assert
49+
await umbracoUi.content.goToContentWithName(firstDocumentName);
50+
await umbracoUi.content.isPropertyEditorUiWithNameReadOnly(firstPropertyName[1]);
51+
await umbracoUi.content.isPropertyEditorUiWithNameReadOnly(secondPropertyName[1]);
52+
await umbracoUi.content.goToContentWithName(secondDocumentName);
53+
await umbracoUi.content.doesErrorNotificationHaveText(NotificationConstantHelper.error.permissionDenied);
54+
});
55+
56+
test('cannot see specific property value without UI read permission enabled', async ({umbracoApi, umbracoUi}) => {
57+
// Arrange
58+
userGroupId = await umbracoApi.userGroup.createUserGroupWithPermissionsForSpecificDocumentAndTwoPropertyValues(userGroupName, firstDocumentId, documentTypeId, firstPropertyName[0], false, false, secondPropertyName[0], false, false);
59+
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId);
60+
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);
61+
await umbracoUi.goToBackOffice();
62+
63+
// Act
64+
await umbracoUi.content.goToSection(ConstantHelper.sections.content, false);
65+
await umbracoUi.content.goToContentWithName(firstDocumentName);
66+
67+
// Assert
68+
await umbracoUi.content.isPropertyEditorUiWithNameVisible(firstPropertyName[1], false);
69+
await umbracoUi.content.isPropertyEditorUiWithNameVisible(secondPropertyName[1], false);
70+
});
71+
72+
test('can see specific property values with UI read permission enabled', async ({umbracoApi, umbracoUi}) => {
73+
// Arrange
74+
userGroupId = await umbracoApi.userGroup.createUserGroupWithPermissionsForSpecificDocumentAndTwoPropertyValues(userGroupName, firstDocumentId, documentTypeId, firstPropertyName[0], true, false, secondPropertyName[0], true, false);
75+
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId);
76+
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);
77+
await umbracoUi.goToBackOffice();
78+
79+
// Act
80+
await umbracoUi.content.goToSection(ConstantHelper.sections.content, false);
81+
await umbracoUi.content.goToContentWithName(firstDocumentName);
82+
83+
// Assert
84+
await umbracoUi.content.isPropertyEditorUiWithNameReadOnly(firstPropertyName[1]);
85+
await umbracoUi.content.isPropertyEditorUiWithNameReadOnly(secondPropertyName[1]);
86+
});
87+
88+
test('can see property with UI read enabled but not another property with UI read disabled in the same document', async ({umbracoApi, umbracoUi}) => {
89+
// Arrange
90+
userGroupId = await umbracoApi.userGroup.createUserGroupWithPermissionsForSpecificDocumentAndTwoPropertyValues(userGroupName, firstDocumentId, documentTypeId, firstPropertyName[0], true, false, secondPropertyName[0], false, false);
91+
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId);
92+
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);
93+
await umbracoUi.goToBackOffice();
94+
95+
// Act
96+
await umbracoUi.content.goToSection(ConstantHelper.sections.content, false);
97+
await umbracoUi.content.goToContentWithName(firstDocumentName);
98+
99+
// Assert
100+
await umbracoUi.content.isPropertyEditorUiWithNameReadOnly(firstPropertyName[1]);
101+
await umbracoUi.content.isPropertyEditorUiWithNameVisible(secondPropertyName[1], false);
102+
});
103+
104+
// Remove .skip when the front-end is ready.
105+
// Issue link: https://github.com/umbraco/Umbraco-CMS/issues/19395
106+
test.skip('can edit specific property values with UI read and write permission enabled', async ({umbracoApi, umbracoUi}) => {
107+
// Arrange
108+
const inputText = 'This is test text';
109+
userGroupId = await umbracoApi.userGroup.createUserGroupWithPermissionsForSpecificDocumentAndTwoPropertyValues(userGroupName, firstDocumentId, documentTypeId, firstPropertyName[0], true, true, secondPropertyName[0], true, true);
110+
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId);
111+
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);
112+
await umbracoUi.goToBackOffice();
113+
114+
// Act
115+
await umbracoUi.content.goToSection(ConstantHelper.sections.content, false);
116+
await umbracoUi.content.goToContentWithName(firstDocumentName);
117+
await umbracoUi.content.enterTextstring(inputText);
118+
await umbracoUi.content.clickToggleButton();
119+
await umbracoUi.content.clickSaveButton();
120+
121+
// Assert
122+
const firstDocumentData = await umbracoApi.document.getByName(firstDocumentName);
123+
expect(firstDocumentData.values[0].alias).toEqual(AliasHelper.toAlias(firstPropertyName[0]));
124+
expect(firstDocumentData.values[0].value).toEqual(inputText);
125+
expect(firstDocumentData.values[1].alias).toEqual(AliasHelper.toAlias(secondPropertyName[0]));
126+
expect(firstDocumentData.values[1].value).toEqual(true);
127+
});
128+
129+
test('cannot see specific property values with UI write permission enabled and UI read permission disabled', async ({umbracoApi, umbracoUi}) => {
130+
// Arrange
131+
userGroupId = await umbracoApi.userGroup.createUserGroupWithPermissionsForSpecificDocumentAndTwoPropertyValues(userGroupName, firstDocumentId, documentTypeId, firstPropertyName[0], false, true, secondPropertyName[0], false, true);
132+
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId);
133+
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);
134+
await umbracoUi.goToBackOffice();
135+
136+
// Act
137+
await umbracoUi.content.goToSection(ConstantHelper.sections.content, false);
138+
await umbracoUi.content.goToContentWithName(firstDocumentName);
139+
140+
// Assert
141+
await umbracoUi.content.isPropertyEditorUiWithNameVisible(firstPropertyName[1], false);
142+
await umbracoUi.content.isPropertyEditorUiWithNameVisible(secondPropertyName[1], false);
143+
});

0 commit comments

Comments
 (0)