From be58f3142d7d1865c09137de3b93646dc4736489 Mon Sep 17 00:00:00 2001 From: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com> Date: Wed, 3 Apr 2024 17:06:54 +0700 Subject: [PATCH] V14 QA Fixed/Cleaned up the api acceptance tests (#15964) * Removed api tests for RelationType since it is impossible to create/update/delete relation type * Fixed api tests for UserGroup * Fixed api tests for UserAvatar * Fixed api tests for User * Fixed api tests for Temporary File * Fixed api tests for Dictionary * Fixed api tests for DataType * Fixed api tests for DataTypeFolder * Cleaned up * Bumped version of test helper * Update tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Dictionary/Dictionary.spec.ts Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com> * Reversed the api tests for Relation Type --------- Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com> --- .../package-lock.json | 8 +-- .../Umbraco.Tests.AcceptanceTest/package.json | 2 +- .../ApiTesting/DataType/DataType.spec.ts | 3 ++ .../DataType/DataTypeFolder.spec.ts | 11 ++--- .../ApiTesting/Dictionary/Dictionary.spec.ts | 49 +++++++------------ .../ApiTesting/Language/Language.spec.ts | 20 ++++---- .../RelationType/RelationType.spec.ts | 9 ++-- .../tests/ApiTesting/Script/Script.spec.ts | 2 +- .../ApiTesting/Template/Template.spec.ts | 8 +-- .../TemporaryFile/TemporaryFile.spec.ts | 4 +- .../tests/ApiTesting/User/User.spec.ts | 38 ++++++-------- .../tests/ApiTesting/User/UserAvatar.spec.ts | 20 +++----- .../ApiTesting/UserGroup/UserGroup.spec.ts | 19 +++---- 13 files changed, 82 insertions(+), 111 deletions(-) diff --git a/tests/Umbraco.Tests.AcceptanceTest/package-lock.json b/tests/Umbraco.Tests.AcceptanceTest/package-lock.json index 6a19368d773f..76a7d2fee46e 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/package-lock.json +++ b/tests/Umbraco.Tests.AcceptanceTest/package-lock.json @@ -8,7 +8,7 @@ "hasInstallScript": true, "dependencies": { "@umbraco/json-models-builders": "^2.0.4", - "@umbraco/playwright-testhelpers": "^2.0.0-beta.25", + "@umbraco/playwright-testhelpers": "^2.0.0-beta.26", "camelize": "^1.0.0", "dotenv": "^16.3.1", "faker": "^4.1.0", @@ -146,9 +146,9 @@ "integrity": "sha512-9tCqYEDHI5RYFQigXFwF1hnCwcWCOJl/hmll0lr5D2Ljjb0o4wphb69wikeJDz5qCEzXCoPvG6ss5SDP6IfOdg==" }, "node_modules/@umbraco/playwright-testhelpers": { - "version": "2.0.0-beta.25", - "resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-2.0.0-beta.25.tgz", - "integrity": "sha512-+rZ8TEDEJQKI4573sMZpGp6t5E9cPXWQ5RPLKwZu/2jyNc1nVAi7ToUwl954RNhWGwxA3wCqYqx5zMPW6DOdgQ==", + "version": "2.0.0-beta.26", + "resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-2.0.0-beta.26.tgz", + "integrity": "sha512-DCEHFPp8DSKZemocdNDHNgEiBKhyP1kbEiJq6dfP7iONQY+t2Nj+Ny1E7pjqS2hnr/cudWVAHbb/WoFMW+0vRQ==", "dependencies": { "@umbraco/json-models-builders": "2.0.4", "camelize": "^1.0.0", diff --git a/tests/Umbraco.Tests.AcceptanceTest/package.json b/tests/Umbraco.Tests.AcceptanceTest/package.json index 4dc9904d07c8..c35bb8eb0d3d 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/package.json +++ b/tests/Umbraco.Tests.AcceptanceTest/package.json @@ -21,7 +21,7 @@ }, "dependencies": { "@umbraco/json-models-builders": "^2.0.4", - "@umbraco/playwright-testhelpers": "^2.0.0-beta.25", + "@umbraco/playwright-testhelpers": "^2.0.0-beta.26", "camelize": "^1.0.0", "dotenv": "^16.3.1", "faker": "^4.1.0", diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/DataType/DataType.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/DataType/DataType.spec.ts index c520af75f1b5..e5bbf36b8991 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/DataType/DataType.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/DataType/DataType.spec.ts @@ -97,5 +97,8 @@ test.describe('DataType tests', () => { // Checks if both dataTypes exists expect(await umbracoApi.dataType.doesExist(dataTypeId)).toBeTruthy(); expect(await umbracoApi.dataType.doesExist(copiedDataTypeId)).toBeTruthy(); + + // Clean + await umbracoApi.dataType.delete(copiedDataTypeId); }); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/DataType/DataTypeFolder.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/DataType/DataTypeFolder.spec.ts index 75b48525ce94..c12474d534b8 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/DataType/DataTypeFolder.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/DataType/DataTypeFolder.spec.ts @@ -21,16 +21,13 @@ test.describe('DataTypeFolder tests', () => { expect(umbracoApi.dataType.doesFolderExist(dataTypeFolderId)).toBeTruthy(); }); - test('can update a dataType folder', async ({umbracoApi}) => { + test('can rename a dataType folder', async ({umbracoApi}) => { // Arrange - const oldDataTypeFolderName = 'Oldie'; - - dataTypeFolderId = await umbracoApi.dataType.createFolder(oldDataTypeFolderName); - const dataTypeFolder = await umbracoApi.dataType.getFolder(dataTypeFolderId); - dataTypeFolder.name = dataTypeFolderName; + const wrongDataTypeFolderName = 'WrongFolderName'; + dataTypeFolderId = await umbracoApi.dataType.createFolder(wrongDataTypeFolderName); // Act - await umbracoApi.dataType.updateFolder(dataTypeFolderId, dataTypeFolder); + await umbracoApi.dataType.renameFolder(dataTypeFolderId, dataTypeFolderName); // Assert expect(umbracoApi.dataType.doesFolderExist(dataTypeFolderId)).toBeTruthy(); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Dictionary/Dictionary.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Dictionary/Dictionary.spec.ts index 5d834e4364ec..2b9082806813 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Dictionary/Dictionary.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Dictionary/Dictionary.spec.ts @@ -4,7 +4,7 @@ import * as crypto from 'crypto'; test.describe('Dictionary tests', () => { let dictionaryId = ''; - const dictionaryName = 'Word'; + const dictionaryName = 'TestDictionary'; test.beforeEach(async ({umbracoApi}) => { await umbracoApi.dictionary.ensureNameNotExists(dictionaryName); @@ -15,25 +15,18 @@ test.describe('Dictionary tests', () => { }); test('can create a dictionary', async ({umbracoApi}) => { - // Arrange - const translationData = [ - { - 'isoCode': 'en-US', - 'translation': 'Word' - } - ]; - // Act - dictionaryId = await umbracoApi.dictionary.create(dictionaryName, translationData); + dictionaryId = await umbracoApi.dictionary.createDefaultDictionary(dictionaryName); // Assert - await expect(umbracoApi.dictionary.doesExist(dictionaryId)).toBeTruthy(); + expect(await umbracoApi.dictionary.doesExist(dictionaryId)).toBeTruthy(); }); test('can update a dictionary', async ({umbracoApi}) => { // Arrange - const oldDictionaryName = 'OldWord'; - dictionaryId = await umbracoApi.dictionary.create(oldDictionaryName); + const wrongDictionaryName = 'WrongTestDictionary'; + dictionaryId = await umbracoApi.dictionary.createDefaultDictionary(wrongDictionaryName); + expect(await umbracoApi.dictionary.doesNameExist(wrongDictionaryName)).toBeTruthy(); const dictionary = await umbracoApi.dictionary.get(dictionaryId); // Act @@ -43,25 +36,25 @@ test.describe('Dictionary tests', () => { // Assert // Checks if the dictionary was updated const newDictionary = await umbracoApi.dictionary.get(dictionaryId); - await expect(newDictionary.name).toEqual(dictionaryName); - await expect(umbracoApi.dictionary.doesExist(dictionaryId)).toBeTruthy(); + expect(newDictionary.name).toEqual(dictionaryName); + expect(await umbracoApi.dictionary.doesExist(dictionaryId)).toBeTruthy(); }); test('can delete a dictionary', async ({umbracoApi}) => { // Arrange dictionaryId = await umbracoApi.dictionary.create(dictionaryName); - await expect(umbracoApi.dictionary.doesExist(dictionaryId)).toBeTruthy(); + expect(await umbracoApi.dictionary.doesExist(dictionaryId)).toBeTruthy(); // Act await umbracoApi.dictionary.delete(dictionaryId); // Assert - await expect(await umbracoApi.dictionary.doesExist(dictionaryId)).toBeFalsy(); + expect(await umbracoApi.dictionary.doesExist(dictionaryId)).toBeFalsy(); }); test('can create a dictionary item in a dictionary', async ({umbracoApi}) => { // Arrange - const childDictionaryName = 'Book'; + const childDictionaryName = 'ChildDictionary'; await umbracoApi.dictionary.ensureNameNotExists(dictionaryName); dictionaryId = await umbracoApi.dictionary.create(dictionaryName); @@ -71,20 +64,20 @@ test.describe('Dictionary tests', () => { // Assert // Checks if the parent dictionary contains the child dictionary const dictionaryChildren = await umbracoApi.dictionary.getChildren(dictionaryId); - await expect(dictionaryChildren[0].name).toEqual(childDictionaryName); + expect(dictionaryChildren[0].name).toEqual(childDictionaryName); }); test('can export a dictionary', async ({umbracoApi}) => { // Arrange dictionaryId = await umbracoApi.dictionary.create(dictionaryName); - await expect(umbracoApi.dictionary.doesExist(dictionaryId)).toBeTruthy(); + expect(await umbracoApi.dictionary.doesExist(dictionaryId)).toBeTruthy(); // Act const exportResponse = await umbracoApi.dictionary.export(dictionaryId, false); // Assert // Checks if the .udt file is exported - await expect(exportResponse.headers()['content-disposition']).toContain(".udt"); + expect(exportResponse.headers()['content-disposition']).toContain(".udt"); }); test('can import a dictionary', async ({umbracoApi}) => { @@ -96,22 +89,16 @@ test.describe('Dictionary tests', () => { // This variable must not be changed as it is declared in the file TestDictionary.udt const importDictionaryName = 'TestImportDictionary'; - // Create a dictionary - dictionaryId = await umbracoApi.dictionary.create(dictionaryName); - await expect(umbracoApi.dictionary.doesExist(dictionaryId)).toBeTruthy(); - // Create temporary file await umbracoApi.temporaryFile.create(temporaryFileId, fileName, mimeType, filePath); - await expect(await umbracoApi.temporaryFile.exists(temporaryFileId)).toBeTruthy(); + expect(await umbracoApi.temporaryFile.doesExist(temporaryFileId)).toBeTruthy(); // Act - const importResponse = await umbracoApi.dictionary.import(temporaryFileId, dictionaryId); + const importResponse = await umbracoApi.dictionary.import(temporaryFileId, null); // Assert - await expect(importResponse.ok()).toBeTruthy(); - // Checks if the parent dictionary contains the import dictionary - const dictionaryChildren = await umbracoApi.dictionary.getChildren(dictionaryId); - await expect(dictionaryChildren[0].name).toEqual(importDictionaryName); + expect(importResponse.status).toBeTruthy(); + expect(await umbracoApi.dictionary.doesNameExist(importDictionaryName)).toBeTruthy(); // Clean await umbracoApi.temporaryFile.delete(temporaryFileId); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Language/Language.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Language/Language.spec.ts index 004c8d86fbfe..dd485b7a972f 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Language/Language.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Language/Language.spec.ts @@ -5,22 +5,22 @@ test.describe('Language tests', () => { const languageNameDanish = 'Dansk'; const isoCodeDanish = 'da-DK'; - test.beforeEach(async ({page, umbracoApi}) => { + test.beforeEach(async ({umbracoApi}) => { await umbracoApi.language.delete(isoCodeDanish); }); - test.afterEach(async ({page, umbracoApi}) => { + test.afterEach(async ({umbracoApi}) => { await umbracoApi.language.delete(isoCodeDanish); }); - test('can create a language', async ({page, umbracoApi, umbracoUi}) => { + test('can create a language', async ({umbracoApi}) => { await umbracoApi.language.create(languageNameDanish, false, false, isoCodeDanish); // Assert - await expect(await umbracoApi.language.doesExist(isoCodeDanish)).toBeTruthy(); + expect(await umbracoApi.language.doesExist(isoCodeDanish)).toBeTruthy(); }); - test('can update a language', async ({page, umbracoApi, umbracoUi}) => { + test('can update a language', async ({umbracoApi}) => { const wrongLanguageName = 'densk'; await umbracoApi.language.create(wrongLanguageName, false, false, isoCodeDanish); @@ -32,20 +32,20 @@ test.describe('Language tests', () => { await umbracoApi.language.update(isoCodeDanish, language); // Assert - await expect(await umbracoApi.language.doesExist(isoCodeDanish)).toBeTruthy(); + expect(await umbracoApi.language.doesExist(isoCodeDanish)).toBeTruthy(); // Checks if the language name was updated const updatedLanguage = await umbracoApi.language.get(isoCodeDanish); - await expect(updatedLanguage.name).toEqual(languageNameDanish); + expect(updatedLanguage.name).toEqual(languageNameDanish); }); - test('can delete a language', async ({page, umbracoApi, umbracoUi}) => { + test('can delete a language', async ({umbracoApi}) => { await umbracoApi.language.create(languageNameDanish, false, false, isoCodeDanish); - await expect(await umbracoApi.language.doesExist(isoCodeDanish)).toBeTruthy(); + expect(await umbracoApi.language.doesExist(isoCodeDanish)).toBeTruthy(); await umbracoApi.language.delete(isoCodeDanish); // Assert - await expect(await umbracoApi.language.doesExist(isoCodeDanish)).toBeFalsy(); + expect(await umbracoApi.language.doesExist(isoCodeDanish)).toBeFalsy(); }); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/RelationType/RelationType.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/RelationType/RelationType.spec.ts index 9c6ac0b67434..59b179f7dd4b 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/RelationType/RelationType.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/RelationType/RelationType.spec.ts @@ -16,7 +16,8 @@ test.describe('Relation type tests', () => { await umbracoApi.relationType.ensureNameNotExists(relationTypeName); }); - test('can create a relation type', async ({umbracoApi}) => { + // Skip this test because there is currently no endpoint available for creating a relation type anymore. + test.skip('can create a relation type', async ({umbracoApi}) => { // Act relationTypeId = await umbracoApi.relationType.create(relationTypeName, false, false, objectTypeId, objectTypeId); @@ -24,7 +25,8 @@ test.describe('Relation type tests', () => { expect(await umbracoApi.relationType.doesExist(relationTypeId)).toBeTruthy(); }); - test('can update a relation type', async ({umbracoApi}) => { + // Skip this test because there is currently no endpoint available for updating a relation type anymore. + test.skip('can update a relation type', async ({umbracoApi}) => { // Arrange const wrongRelationTypeName = 'Updated Relation Type'; relationTypeId = await umbracoApi.relationType.create(wrongRelationTypeName, false, false, objectTypeId, objectTypeId); @@ -41,7 +43,8 @@ test.describe('Relation type tests', () => { expect(updatedRelationType.name).toEqual(relationTypeName); }); - test('can delete a relation type', async ({umbracoApi}) => { + // Skip this test because there is currently no endpoint available for deleting a relation type anymore. + test.skip('can delete a relation type', async ({umbracoApi}) => { // Arrange relationTypeId = await umbracoApi.relationType.create(relationTypeName, false, false, objectTypeId, objectTypeId); expect(await umbracoApi.relationType.doesExist(relationTypeId)).toBeTruthy(); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Script/Script.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Script/Script.spec.ts index 2c413b5eade4..0d9b1fd9df8d 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Script/Script.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Script/Script.spec.ts @@ -39,7 +39,7 @@ test.describe('Script tests', () => { test('can update script content', async ({umbracoApi}) => { // Arrange - const newContent = 'Howdy'; + const newContent = 'BetterContent'; scriptPath = await umbracoApi.script.create(scriptName, 'test'); await umbracoApi.script.get(scriptPath); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Template/Template.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Template/Template.spec.ts index c1723948c475..c26385b3dbf8 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Template/Template.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/Template/Template.spec.ts @@ -2,7 +2,7 @@ import {expect} from "@playwright/test"; test.describe('Template tests', () => { - let templateId; + let templateId = ''; const templateName = 'TemplateTester'; const templateAlias = AliasHelper.toAlias(templateName); @@ -19,7 +19,7 @@ test.describe('Template tests', () => { templateId = await umbracoApi.template.create(templateName, templateAlias, 'Template Stuff'); // Assert - expect(umbracoApi.template.doesExist(templateId)).toBeTruthy(); + expect(await umbracoApi.template.doesExist(templateId)).toBeTruthy(); }); test('can update a template', async ({umbracoApi}) => { @@ -34,7 +34,7 @@ test.describe('Template tests', () => { await umbracoApi.template.update(templateId, templateData); // Assert - expect(umbracoApi.template.doesExist(templateId)).toBeTruthy(); + expect(await umbracoApi.template.doesExist(templateId)).toBeTruthy(); // Checks if the template alias was updated const updatedTemplate = await umbracoApi.template.get(templateId); expect(updatedTemplate.alias).toEqual(newTemplateAlias); @@ -43,7 +43,7 @@ test.describe('Template tests', () => { test('can delete template', async ({umbracoApi}) => { // Arrange templateId = await umbracoApi.template.create(templateName, templateAlias, 'More Template Stuff'); - expect(umbracoApi.template.doesExist(templateId)).toBeTruthy(); + expect(await umbracoApi.template.doesExist(templateId)).toBeTruthy(); // Act await umbracoApi.template.delete(templateId); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/TemporaryFile/TemporaryFile.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/TemporaryFile/TemporaryFile.spec.ts index 03eda6f97540..49b3ed703dfa 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/TemporaryFile/TemporaryFile.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/TemporaryFile/TemporaryFile.spec.ts @@ -21,7 +21,7 @@ test.describe('Temporary File tests', () => { await umbracoApi.temporaryFile.create(temporaryFileId, fileName, mimeType, filePath); // Assert - expect(await umbracoApi.temporaryFile.exists(temporaryFileId)).toBeTruthy(); + expect(await umbracoApi.temporaryFile.doesExist(temporaryFileId)).toBeTruthy(); }); test('can delete temporary file', async ({umbracoApi}) => { @@ -33,6 +33,6 @@ test.describe('Temporary File tests', () => { await umbracoApi.temporaryFile.delete(temporaryFileId); // Assert - expect(await umbracoApi.temporaryFile.exists(temporaryFileId)).toBeFalsy(); + expect(await umbracoApi.temporaryFile.doesExist(temporaryFileId)).toBeFalsy(); }); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/User/User.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/User/User.spec.ts index 07b27657fe59..ed25e99d5dcd 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/User/User.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/User/User.spec.ts @@ -2,12 +2,15 @@ import {expect} from "@playwright/test"; test.describe('User Tests', () => { - let userId = ""; - const userEmail = "user@email.com"; - const userName = "UserTests"; + let userId = ''; + let userGroupId = ''; + const userEmail = 'user@acceptance.test'; + const userName = 'UserTests'; test.beforeEach(async ({umbracoApi}) => { await umbracoApi.user.ensureNameNotExists(userName); + const userGroupData = await umbracoApi.userGroup.getByName('Writers'); + userGroupId = userGroupData.id; }); test.afterEach(async ({umbracoApi}) => { @@ -15,28 +18,20 @@ test.describe('User Tests', () => { }); test('can create a user', async ({umbracoApi}) => { - // Arrange - // Gets the id for the writers userGroup - const userGroup = await umbracoApi.userGroup.getByName("Writers"); - const userGroupId = [userGroup.id]; - // Act - userId = await umbracoApi.user.create(userEmail, userName, userGroupId); + userId = await umbracoApi.user.createDefaultUser(userName, userEmail, userGroupId); // Assert - expect(await umbracoApi.user.exists(userId)).toBeTruthy(); + expect(await umbracoApi.user.doesExist(userId)).toBeTruthy(); }); test('can update a user', async ({umbracoApi}) => { // Arrange - // Gets userGroup data for Writers and Translators - const userGroup = await umbracoApi.userGroup.getByName("Writers"); const anotherUserGroup = await umbracoApi.userGroup.getByName("Translators"); - const userGroupId = [userGroup.id]; - userId = await umbracoApi.user.create(userEmail, userName, userGroupId); + userId = await umbracoApi.user.createDefaultUser(userName, userEmail, userGroupId); const userData = await umbracoApi.user.get(userId); const newUserGroupData = [ - userGroup.id, + userGroupId, anotherUserGroup.id ]; userData.userGroupIds = newUserGroupData; @@ -45,7 +40,7 @@ test.describe('User Tests', () => { await umbracoApi.user.update(userId, userData); // Assert - await umbracoApi.user.exists(userId); + await umbracoApi.user.doesExist(userId); // Checks if the user was updated with another userGroupID const updatedUser = await umbracoApi.user.get(userId); expect(updatedUser.userGroupIds.toString()).toEqual(newUserGroupData.toString()); @@ -53,18 +48,13 @@ test.describe('User Tests', () => { test('can delete a user', async ({umbracoApi}) => { // Arrange - const userGroupData = await umbracoApi.userGroup.getByName("Writers"); - const userData = [ - userGroupData.id - ]; - - userId = await umbracoApi.user.create(userEmail, userName, userData); - expect(await umbracoApi.user.exists(userId)).toBeTruthy(); + userId = await umbracoApi.user.createDefaultUser(userName, userEmail, userGroupId); + expect(await umbracoApi.user.doesExist(userId)).toBeTruthy(); // Act await umbracoApi.user.delete(userId); // Assert - expect(await umbracoApi.user.exists(userId)).toBeFalsy(); + expect(await umbracoApi.user.doesExist(userId)).toBeFalsy(); }); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/User/UserAvatar.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/User/UserAvatar.spec.ts index 2d5d372ff03a..ec07d5da6a56 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/User/UserAvatar.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/User/UserAvatar.spec.ts @@ -4,11 +4,11 @@ import * as crypto from 'crypto'; test.describe('User Avatar Tests', () => { // User - let userId = ""; - const userEmail = "userAvatar@email.com"; - const userName = "UserAvatarTests"; + let userId = ''; + let userGroupId = ''; + const userEmail = 'userAvatar@acceptance.test'; + const userName = 'UserAvatarTests'; // Avatar - // Creates a random GUID const avatarFileId = crypto.randomUUID(); const avatarName = 'Umbraco.png'; const mimeType = 'image/png'; @@ -17,6 +17,8 @@ test.describe('User Avatar Tests', () => { test.beforeEach(async ({umbracoApi}) => { await umbracoApi.user.ensureNameNotExists(userName); await umbracoApi.temporaryFile.delete(avatarFileId); + const userGroupData = await umbracoApi.userGroup.getByName('Writers'); + userGroupId = userGroupData.id; }); test.afterEach(async ({umbracoApi}) => { @@ -26,10 +28,7 @@ test.describe('User Avatar Tests', () => { test('can add an avatar to a user', async ({umbracoApi}) => { // Arrange - const userGroup = await umbracoApi.userGroup.getByName("Writers"); - const userGroupData = [userGroup.id]; - - userId = await umbracoApi.user.create(userEmail, userName, userGroupData); + userId = await umbracoApi.user.createDefaultUser(userName, userEmail, userGroupId); await umbracoApi.temporaryFile.create(avatarFileId, avatarName, mimeType, avatarFilePath); // Act @@ -43,10 +42,7 @@ test.describe('User Avatar Tests', () => { test('can remove an avatar from a user', async ({umbracoApi}) => { // Arrange - const userGroup = await umbracoApi.userGroup.getByName("Writers"); - const userGroupData = [userGroup.id]; - - userId = await umbracoApi.user.create(userEmail, userName, userGroupData); + userId = await umbracoApi.user.createDefaultUser(userName, userEmail, userGroupId); await umbracoApi.temporaryFile.create(avatarFileId, avatarName, mimeType, avatarFilePath); await umbracoApi.user.addAvatar(userId, avatarFileId); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/UserGroup/UserGroup.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/UserGroup/UserGroup.spec.ts index 45fac9603407..f3194aa60694 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/UserGroup/UserGroup.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/ApiTesting/UserGroup/UserGroup.spec.ts @@ -2,8 +2,8 @@ import {expect} from "@playwright/test"; test.describe('User Group Tests', () => { - let userGroupId = ""; - const userGroupName = "UserGroupTest"; + let userGroupId = ''; + const userGroupName = 'UserGroupTest'; test.beforeEach(async ({umbracoApi}) => { await umbracoApi.userGroup.ensureNameNotExists(userGroupName); @@ -14,21 +14,16 @@ test.describe('User Group Tests', () => { }); test('can create a user group', async ({umbracoApi}) => { - // Arrange - const sections = ["Umb.Section.Content", - "Umb.Section.Forms", - "Umb.Section.Media"]; - // Act - userGroupId = await umbracoApi.userGroup.create(userGroupName, true, sections); + userGroupId = await umbracoApi.userGroup.createEmptyUserGroup(userGroupName); // Assert - expect(umbracoApi.userGroup.exist(userGroupId)).toBeTruthy(); + expect(await umbracoApi.userGroup.doesExist(userGroupId)).toBeTruthy(); }); test('can update a user group', async ({umbracoApi}) => { // Arrange - userGroupId = await umbracoApi.userGroup.create('UserGroupNameTest', true); + userGroupId = await umbracoApi.userGroup.createEmptyUserGroup('WrongUserGroupName'); const userGroupData = await umbracoApi.userGroup.get(userGroupId); userGroupData.name = userGroupName; @@ -42,12 +37,12 @@ test.describe('User Group Tests', () => { test('can delete a user group', async ({umbracoApi}) => { // Arrange - userGroupId = await umbracoApi.userGroup.create(userGroupName, true); + userGroupId = await umbracoApi.userGroup.createEmptyUserGroup(userGroupName); // Act await umbracoApi.userGroup.delete(userGroupId); // Assert - expect(await umbracoApi.userGroup.exist(userGroupId)).toBeFalsy(); + expect(await umbracoApi.userGroup.doesExist(userGroupId)).toBeFalsy(); }); });