Added acceptance tests for testing the API for the UserGroups section. (#14448)

* Added auth to gitignore

* Added a setup for logging in which allows us to save the token for the user

* Added simple acceptance test for testing our api for the DataTypes

* Added simple acceptance tests for testing the API for the PartialView section

* Added simple acceptance tests for testing the API for the Script section

* Added acceptance tests for testing the API for the Stylesheet section.

* Added acceptance tests for testing the API for the User section

* Bumped the version of our testhelpers!

* Added acceptance tests for testing the API for the Dictionary section.

* Added acceptance tests for testing the API for the Language section.

* Added acceptance tests for testing the API for the UserGroups section.

* Added acceptance tests for testing the API for the Template section (#14450)

* Added acceptance tests for testing the API for the Template section

* Added acceptance tests for testing the API for the TemporaryFiles section (#14451)
This commit is contained in:
Andreas Zerbst
2023-06-26 13:09:41 +02:00
committed by GitHub
parent ad419dd460
commit acf8f575a8
3 changed files with 137 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
import {AliasHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";
test.describe('Template tests', () => {
const templateName = 'TemplateTester';
const templateAlias = AliasHelper.toAlias(templateName);
test.beforeEach(async ({page, umbracoApi}) => {
await umbracoApi.template.ensureTemplateNameNotExistsAtRoot(templateName);
});
test.afterEach(async ({page, umbracoApi}) => {
await umbracoApi.template.ensureTemplateNameNotExistsAtRoot(templateName);
})
test('can create a template', async ({page, umbracoApi, umbracoUi}) => {
await umbracoApi.template.createTemplate(templateName, templateAlias, 'Template Stuff');
// Assert
await expect(umbracoApi.template.doesTemplateWithNameExistAtRoot(templateName)).toBeTruthy();
});
test('can update a template', async ({page, umbracoApi, umbracoUi}) => {
const newTemplateAlias = 'betterAlias';
await umbracoApi.template.createTemplate(templateName, templateAlias, 'Template Stuff');
const templateData = await umbracoApi.template.getTemplateByNameAtRoot(templateName);
// Updates the template
templateData.alias = newTemplateAlias;
await umbracoApi.template.updateTemplateById(templateData.id, templateData);
// Assert
await expect(umbracoApi.template.doesTemplateWithNameExistAtRoot(templateName)).toBeTruthy();
// Checks if the template alias was updated
const updatedTemplate = await umbracoApi.template.getTemplateByNameAtRoot(templateName);
await expect(updatedTemplate.alias == newTemplateAlias).toBeTruthy();
});
test('can delete template', async ({page, umbracoApi, umbracoUi}) => {
await umbracoApi.template.createTemplate(templateName, templateAlias, 'More Template Stuff');
await expect(umbracoApi.template.doesTemplateWithNameExistAtRoot(templateName)).toBeTruthy();
await umbracoApi.template.deleteTemplateByNameAtRoot(templateName);
// Assert
await expect(await umbracoApi.template.doesTemplateWithNameExistAtRoot(templateName)).toBeFalsy();
});
});

View File

@@ -0,0 +1,35 @@
import {test} from "@umbraco/playwright-testhelpers";
import {expect} from "@playwright/test";
test.describe('Temporary File tests', () => {
const temporaryFileId = crypto.randomUUID();
const fileName = 'Umbraco.png';
const mimeType = 'image/png';
const filePath = './fixtures/mediaLibrary/Umbraco.png';
test.beforeEach(async ({page, umbracoApi}) => {
await umbracoApi.temporaryFile.ensureTemporaryFileWithIdNotExists(temporaryFileId);
});
test.afterEach(async ({page, umbracoApi}) => {
await umbracoApi.temporaryFile.ensureTemporaryFileWithIdNotExists(temporaryFileId);
});
test('can create temporary file', async ({page, umbracoApi, umbracoUi}) => {
await umbracoApi.temporaryFile.createTemporaryFile(temporaryFileId, fileName, mimeType, filePath);
// Assert
await expect(await umbracoApi.temporaryFile.doesTemporaryFileWithIdExist(temporaryFileId)).toBeTruthy();
});
test('can delete temporary file', async ({page, umbracoApi, umbracoUi}) => {
await umbracoApi.temporaryFile.createTemporaryFile(temporaryFileId, fileName, mimeType, filePath);
await expect(await umbracoApi.temporaryFile.getTemporaryFileById(temporaryFileId)).toBeTruthy();
await umbracoApi.temporaryFile.deleteTemporaryFileById(temporaryFileId);
// Assert
await expect(await umbracoApi.temporaryFile.doesTemporaryFileWithIdExist(temporaryFileId)).toBeFalsy();
});
});

View File

@@ -0,0 +1,51 @@
import {test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";
test.describe('User Group Tests', () => {
const userGroupName = "UserGroupTest";
test.beforeEach(async ({page, umbracoApi}) => {
await umbracoApi.userGroup.ensureUserGroupNameNotExists(userGroupName);
});
test.afterEach(async ({page, umbracoApi}) => {
await umbracoApi.userGroup.ensureUserGroupNameNotExists(userGroupName);
});
test('can create a user group', async ({page, umbracoApi, umbracoUi}) => {
const sections = ["Umb.Section.Content",
"Umb.Section.Forms",
"Umb.Section.Media"];
await umbracoApi.userGroup.createUserGroup(userGroupName, true, sections);
// Assert
await expect(umbracoApi.userGroup.doesUserGroupWithNameExists(userGroupName)).toBeTruthy();
});
test('can update a user group', async ({page, umbracoApi, umbracoUi}) => {
await umbracoApi.userGroup.createUserGroup('UserGroupNameTest', true);
const userGroupData = await umbracoApi.userGroup.getUserGroupByName('UserGroupNameTest');
// Updates name of the user group
userGroupData.name = userGroupName;
await umbracoApi.userGroup.updateUserGroupById(userGroupData.id, userGroupData);
// Assert
const updatedUserGroupData = await umbracoApi.userGroup.getUserGroupById(userGroupData.id);
await expect(updatedUserGroupData.name == userGroupName).toBeTruthy();
});
test('can delete a user group', async ({page, umbracoApi, umbracoUi}) => {
await umbracoApi.userGroup.createUserGroup(userGroupName, true);
const userGroupData = await umbracoApi.userGroup.getUserGroupByName(userGroupName);
await umbracoApi.userGroup.deleteUserGroupById(userGroupData.id);
// Assert
await expect(await umbracoApi.userGroup.doesUserGroupWithNameExists(userGroupName)).toBeFalsy();
});
});