Skip to content
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

V14 QA Added user groups acceptance tests #17344

Merged
merged 22 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
87bc0a3
Added tests for userGroup
andr317c Mar 13, 2024
71b6b6f
Clean up
andr317c Mar 13, 2024
1e5dc1d
Merge branch 'v14/dev' into v14/QA/user-groups-acceptance-tests
andr317c Oct 10, 2024
ef22f68
Merge branch 'refs/heads/v14/dev' into v14/QA/user-groups-acceptance-…
andr317c Oct 16, 2024
966d343
Merge branch 'v14/dev' into v14/QA/user-groups-acceptance-tests
andr317c Oct 16, 2024
f44c848
Updated userGroup tests
andr317c Oct 16, 2024
dc5a4cf
Updated tests
andr317c Oct 16, 2024
a9a9be7
Merge remote-tracking branch 'origin/v14/dev' into v14/QA/user-groups…
andr317c Oct 17, 2024
18e2dba
Updated tests
andr317c Oct 18, 2024
cebf42b
Cleane up
andr317c Oct 22, 2024
fe789bb
Merge remote-tracking branch 'refs/remotes/origin/v14/dev' into v14/Q…
andr317c Oct 23, 2024
a1ee849
Cleaned up
andr317c Oct 23, 2024
fad0f9d
Bumped versions
andr317c Oct 23, 2024
993ff1f
Run user tests
andr317c Oct 23, 2024
5fcb814
Cleaned up
andr317c Oct 23, 2024
8b22cde
Added method for checking if the document tree is empty
andr317c Oct 24, 2024
4971748
Bumped version
andr317c Oct 24, 2024
95e8453
Merge remote-tracking branch 'origin/v14/dev' into v14/QA/user-groups…
andr317c Oct 24, 2024
d47fbcc
Merge remote-tracking branch 'origin/v14/dev' into v14/QA/user-groups…
andr317c Oct 25, 2024
3bbc99b
Reverted
andr317c Oct 25, 2024
5cc5725
Merge remote-tracking branch 'origin/v14/dev' into v14/QA/user-groups…
andr317c Oct 25, 2024
6535e80
Merge remote-tracking branch 'origin/v14/dev' into v14/QA/user-groups…
andr317c Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from '@playwright/test';

const testUser = {
name: 'Test User',
email: 'verySecureEmail@123.test',
password: 'verySecurePassword123',
};
const testUser = ConstantHelper.testUserCredentials;
let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""};

const userGroupName = 'TestUserGroup';
let userGroupId = null;

const rootDocumentTypeName = 'RootDocumentType';
const childDocumentTypeOneName = 'ChildDocumentTypeOne';
const childDocumentTypeTwoName = 'ChildDocumentTypeTwo';
let childDocumentTypeOneId = null;
let rootDocumentTypeId = null;

let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""};

let rootDocumentId = null;
let childDocumentOneId = null;
const rootDocumentName = 'RootDocument';
const childDocumentOneName = 'ChildDocumentOne';
const childDocumentTwoName = 'ChildDocumentTwo';

let userGroupId = null;
let rootDocumentId = null;
let childDocumentOneId = null;

test.beforeEach(async ({umbracoApi}) => {
await umbracoApi.documentType.ensureNameNotExists(rootDocumentTypeName);
Expand Down Expand Up @@ -59,10 +51,10 @@ test('can see root start node and children', async ({umbracoApi, umbracoUi}) =>
await umbracoUi.user.goToSection(ConstantHelper.sections.content, false);

// Assert
await umbracoUi.content.isContentVisible(rootDocumentName);
await umbracoUi.content.isContentInTreeVisible(rootDocumentName);
await umbracoUi.content.clickCaretButtonForContentName(rootDocumentName);
await umbracoUi.content.isChildContentVisible(rootDocumentName, childDocumentOneName);
await umbracoUi.content.isChildContentVisible(rootDocumentName, childDocumentTwoName);
await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentOneName);
await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentTwoName);
});

test('can see parent of start node but not access it', async ({umbracoApi, umbracoUi}) => {
Expand All @@ -75,12 +67,12 @@ test('can see parent of start node but not access it', async ({umbracoApi, umbra
await umbracoUi.user.goToSection(ConstantHelper.sections.content, false);

// Assert
await umbracoUi.content.isContentVisible(rootDocumentName);
await umbracoUi.content.isContentInTreeVisible(rootDocumentName);
await umbracoUi.content.goToContentWithName(rootDocumentName);
await umbracoUi.content.isTextWithMessageVisible('The authenticated user do not have access to this resource');
await umbracoUi.content.clickCaretButtonForContentName(rootDocumentName);
await umbracoUi.content.isChildContentVisible(rootDocumentName, childDocumentOneName);
await umbracoUi.content.isChildContentVisible(rootDocumentName, childDocumentTwoName, false);
await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentOneName);
await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentTwoName, false);
});

test('can not see any content when no start nodes specified', async ({umbracoApi, umbracoUi}) => {
Expand All @@ -93,5 +85,5 @@ test('can not see any content when no start nodes specified', async ({umbracoApi
await umbracoUi.user.goToSection(ConstantHelper.sections.content, false);

// Assert
await umbracoUi.content.isContentVisible(rootDocumentName, false);
await umbracoUi.content.isDocumentTreeEmpty();
});
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';

const testUser = {
name: 'Test User',
email: 'verySecureEmail@123.test',
password: 'verySecurePassword123',
};
const testUser = ConstantHelper.testUserCredentials;
let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""};

const userGroupName = 'TestUserGroup';
let userGroupId = null;

let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""};

let rootFolderId = null;
let childFolderOneId = null;
const rootFolderName = 'RootFolder';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';

const testUser = {
name: 'Test User',
email: 'verySecureEmail@123.test',
password: 'verySecurePassword123',
};
const testUser = ConstantHelper.testUserCredentials;
let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""};

const userGroupName = 'TestUserGroup';

let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""};
let userGroupId = null;

test.beforeEach(async ({umbracoApi}) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';

const testUser = ConstantHelper.testUserCredentials;
let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""};

const userGroupName = 'TestUserGroup';
let userGroupId = null;

const rootDocumentTypeName = 'RootDocumentType';
const childDocumentTypeOneName = 'ChildDocumentTypeOne';
const childDocumentTypeTwoName = 'ChildDocumentTypeTwo';
let childDocumentTypeOneId = null;
let childDocumentTypeTwoId = null;
let rootDocumentTypeId = null;
const rootDocumentName = 'RootDocument';
const childDocumentOneName = 'ChildDocumentOne';
const childDocumentTwoName = 'ChildDocumentTwo';
let rootDocumentId = null;
let childDocumentOneId = null;

test.beforeEach(async ({umbracoApi}) => {
await umbracoApi.documentType.ensureNameNotExists(rootDocumentTypeName);
await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeOneName);
await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeTwoName);
await umbracoApi.user.ensureNameNotExists(testUser.name);
await umbracoApi.userGroup.ensureNameNotExists(userGroupName);
childDocumentTypeOneId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeOneName);
childDocumentTypeTwoId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeTwoName);
rootDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedTwoChildNodes(rootDocumentTypeName, childDocumentTypeOneId, childDocumentTypeTwoId);
rootDocumentId = await umbracoApi.document.createDefaultDocument(rootDocumentName, rootDocumentTypeId);
childDocumentOneId = await umbracoApi.document.createDefaultDocumentWithParent(childDocumentOneName, childDocumentTypeOneId, rootDocumentId);
await umbracoApi.document.createDefaultDocumentWithParent(childDocumentTwoName, childDocumentTypeTwoId, rootDocumentId);
});

test.afterEach(async ({umbracoApi}) => {
// Ensure we are logged in to admin
await umbracoApi.loginToAdminUser(testUserCookieAndToken.cookie, testUserCookieAndToken.accessToken, testUserCookieAndToken.refreshToken);
await umbracoApi.documentType.ensureNameNotExists(rootDocumentTypeName);
await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeOneName);
await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeTwoName);
await umbracoApi.userGroup.ensureNameNotExists(userGroupName);
});

test('can see root start node and children', async ({umbracoApi, umbracoUi}) => {
// Arrange
userGroupId = await umbracoApi.userGroup.createUserGroupWithDocumentStartNode(userGroupName, rootDocumentId);
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId);
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);
await umbracoUi.goToBackOffice();

// Act
await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false);

// Assert
await umbracoUi.content.isContentInTreeVisible(rootDocumentName);
await umbracoUi.content.clickCaretButtonForContentName(rootDocumentName);
await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentOneName);
await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentTwoName);
});

test('can see parent of start node but not access it', async ({umbracoApi, umbracoUi}) => {
// Arrange
userGroupId = await umbracoApi.userGroup.createUserGroupWithDocumentStartNode(userGroupName, childDocumentOneId);
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId);
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);
await umbracoUi.goToBackOffice();

// Act
await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false);

// Assert
await umbracoUi.content.isContentInTreeVisible(rootDocumentName);
await umbracoUi.content.goToContentWithName(rootDocumentName);
await umbracoUi.content.isTextWithMessageVisible('The authenticated user do not have access to this resource');
await umbracoUi.content.clickCaretButtonForContentName(rootDocumentName);
await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentOneName);
await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentTwoName, false);
});

test('can not see any content when no start nodes specified', async ({umbracoApi, umbracoUi}) => {
// Arrange
userGroupId = await umbracoApi.userGroup.createSimpleUserGroupWithContentSection(userGroupName);
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId);
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);
await umbracoUi.goToBackOffice();

// Act
await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false);

// Assert
await umbracoUi.content.isDocumentTreeEmpty();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import {AliasHelper, ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers';

const testUser = ConstantHelper.testUserCredentials;
let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""};

const userGroupName = 'TestUserGroup';
let userGroupId = null;

const documentTypeName = 'TestDocumentType';
const documentName = 'TestDocument';
const englishDocumentName = 'EnglishDocument';
const danishDocumentName = 'DanishDocument';
const vietnameseDocumentName = 'VietnameseDocument';
let documentTypeId = null;

const dataTypeName = 'Textstring';
let dataTypeId = null;

const englishIsoCode = 'en-US';
const danishIsoCode = 'da';
const vietnameseIsoCode = 'vi';
const englishLanguageName = 'English (United States)';
const danishLanguageName = 'Danish';
const vietnameseLanguageName = 'Vietnamese';
const cultureVariants = [
{
isoCode: englishIsoCode,
name: englishDocumentName,
value: 'EnglishValue',
},
{
isoCode: danishIsoCode,
name: danishDocumentName,
value: 'DanishValue',
},
{
isoCode: vietnameseIsoCode,
name: vietnameseDocumentName,
value: 'VietnameseValue',
}
];

test.beforeEach(async ({umbracoApi}) => {
await umbracoApi.user.ensureNameNotExists(testUser.name);
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
await umbracoApi.language.ensureIsoCodeNotExists(danishIsoCode);
await umbracoApi.language.ensureIsoCodeNotExists(vietnameseIsoCode);
await umbracoApi.language.createDanishLanguage();
await umbracoApi.language.createVietnameseLanguage();
const dataType = await umbracoApi.dataType.getByName(dataTypeName);
dataTypeId = dataType.id;
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeId, 'TestGroup', true);
await umbracoApi.document.createDocumentWithMultipleVariants(documentName, documentTypeId, AliasHelper.toAlias(dataTypeName), cultureVariants);
});

test.afterEach(async ({umbracoApi}) => {
// Ensure we are logged in to admin
await umbracoApi.loginToAdminUser(testUserCookieAndToken.cookie, testUserCookieAndToken.accessToken, testUserCookieAndToken.refreshToken);
await umbracoApi.userGroup.ensureNameNotExists(userGroupName);
await umbracoApi.language.ensureIsoCodeNotExists(danishIsoCode);
await umbracoApi.language.ensureIsoCodeNotExists(vietnameseIsoCode);
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
});

test('can rename content with language set in userGroup', async ({umbracoApi, umbracoUi}) => {
// Arrange
const updatedContentName = 'UpdatedContentName';
userGroupId = await umbracoApi.userGroup.createUserGroupWithLanguageAndContentSection(userGroupName, englishIsoCode);
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId, [], false, [], false, englishIsoCode);
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);
await umbracoUi.goToBackOffice();
await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false);
await umbracoUi.content.goToContentWithName(englishDocumentName);

// Act
await umbracoUi.content.isDocumentReadOnly(false);
await umbracoUi.content.enterContentName(updatedContentName);
await umbracoUi.content.clickSaveButton();
await umbracoUi.content.clickSaveAndCloseButton();

// Assert
await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved);
await umbracoUi.content.isContentInTreeVisible(updatedContentName);
});

test('can not rename content with language not set in userGroup', async ({umbracoApi, umbracoUi}) => {
// Arrange
userGroupId = await umbracoApi.userGroup.createUserGroupWithLanguageAndContentSection(userGroupName, englishIsoCode);
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId, [], false, [], false, englishIsoCode);
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);
await umbracoUi.goToBackOffice();
await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false);
await umbracoUi.content.doesDocumentSectionHaveLanguageSelected(englishLanguageName);
await umbracoUi.content.changeDocumentSectionLanguage(danishLanguageName);

// Act
await umbracoUi.content.goToContentWithName(danishDocumentName);

// Assert
await umbracoUi.content.isDocumentReadOnly();
await umbracoUi.content.isDocumentNameInputEditable(false);
});

test('can update content property with language set in userGroup', async ({umbracoApi, umbracoUi}) => {
// Arrange
userGroupId = await umbracoApi.userGroup.createUserGroupWithLanguageAndContentSection(userGroupName, englishIsoCode);
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId);
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);
await umbracoUi.goToBackOffice();
await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false);
await umbracoUi.content.doesDocumentSectionHaveLanguageSelected(englishLanguageName);

// Act
await umbracoUi.content.goToContentWithName(englishDocumentName);

// Assert
await umbracoUi.content.isDocumentPropertyEditable(dataTypeName, true);
});

test('can not update content property with language not set in userGroup', async ({umbracoApi, umbracoUi}) => {
// Arrange
userGroupId = await umbracoApi.userGroup.createUserGroupWithLanguageAndContentSection(userGroupName, englishIsoCode);
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId);
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);
await umbracoUi.goToBackOffice();
await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false);
await umbracoUi.content.doesDocumentSectionHaveLanguageSelected(englishLanguageName);
await umbracoUi.content.changeDocumentSectionLanguage(vietnameseLanguageName);

// Act
await umbracoUi.content.goToContentWithName(vietnameseDocumentName);

// Assert
await umbracoUi.content.isDocumentPropertyEditable(dataTypeName, false);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';

const testUser = ConstantHelper.testUserCredentials;
let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""};

const userGroupName = 'TestUserGroup';
let userGroupId = null;

test.beforeEach(async ({umbracoApi}) => {
await umbracoApi.user.ensureNameNotExists(testUser.name);
await umbracoApi.userGroup.ensureNameNotExists(userGroupName);
});

test.afterEach(async ({umbracoApi}) => {
// Ensure we are logged in to admin
await umbracoApi.loginToAdminUser(testUserCookieAndToken.cookie, testUserCookieAndToken.accessToken, testUserCookieAndToken.refreshToken);
await umbracoApi.userGroup.ensureNameNotExists(userGroupName);
});

test('can go to section defined in userGroup', async ({umbracoApi, umbracoUi}) => {
// Arrange
userGroupId = await umbracoApi.userGroup.createSimpleUserGroupWithContentSection(userGroupName);
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId);
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);

// Act
await umbracoUi.goToBackOffice();

// Assert
await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.content);
await umbracoUi.content.goToSection(ConstantHelper.sections.content, false);
});

test('can not see section that is not defined in userGroup', async ({umbracoApi, umbracoUi}) => {
// Arrange
userGroupId = await umbracoApi.userGroup.createSimpleUserGroupWithContentSection(userGroupName);
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId);
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);

// Act
await umbracoUi.goToBackOffice();

// Assert
await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.content);
await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.media, false);
await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.settings, false);
await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.users, false);
await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.members, false);
await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.dictionary, false);
await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.packages, false);
});
Loading
Loading