Added acceptance tests for testing the API for the Dictionary section. (#14446)
* 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.
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
import {test} from '@umbraco/playwright-testhelpers';
|
||||
import {expect} from "@playwright/test";
|
||||
|
||||
test.describe('Dictionary tests', () => {
|
||||
const dictionaryName = 'Word'
|
||||
|
||||
test.beforeEach(async ({page, umbracoApi}) => {
|
||||
await umbracoApi.dictionary.ensureDictionaryNameNotExists(dictionaryName);
|
||||
});
|
||||
|
||||
test.afterEach(async ({page, umbracoApi}) => {
|
||||
await umbracoApi.dictionary.ensureDictionaryNameNotExists(dictionaryName);
|
||||
})
|
||||
|
||||
test('can create a dictionary', async ({page, umbracoApi, umbracoUi}) => {
|
||||
const translationData = [
|
||||
{
|
||||
'isoCode': 'en-US',
|
||||
'translation': 'Word'
|
||||
},
|
||||
{
|
||||
'isoCode': 'da-DK',
|
||||
'translation': 'Ord'
|
||||
}
|
||||
];
|
||||
|
||||
await umbracoApi.dictionary.createDictionary(dictionaryName, translationData);
|
||||
|
||||
// Assert
|
||||
await expect(umbracoApi.dictionary.doesDictionaryWithNameExists(dictionaryName)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('can update a dictionary', async ({page, umbracoApi, umbracoUi}) => {
|
||||
const oldDictionaryName = 'OldWord';
|
||||
|
||||
await umbracoApi.dictionary.createDictionary(oldDictionaryName);
|
||||
|
||||
const dictionary = await umbracoApi.dictionary.getDictionaryByName(oldDictionaryName);
|
||||
|
||||
// Updates the dictionary name
|
||||
dictionary.name = dictionaryName;
|
||||
await umbracoApi.dictionary.updateDictionaryById(dictionary.id, dictionary);
|
||||
|
||||
// Assert
|
||||
// Checks if the dictionary was updated
|
||||
const newDictionary = await umbracoApi.dictionary.getDictionaryById(dictionary.id);
|
||||
await expect(newDictionary.name == dictionaryName).toBeTruthy();
|
||||
|
||||
await expect(umbracoApi.dictionary.doesDictionaryWithNameExists(dictionaryName)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('can delete a dictionary', async ({page, umbracoApi, umbracoUi}) => {
|
||||
await umbracoApi.dictionary.createDictionary(dictionaryName);
|
||||
|
||||
await expect(umbracoApi.dictionary.doesDictionaryWithNameExists(dictionaryName)).toBeTruthy();
|
||||
|
||||
await umbracoApi.dictionary.deleteDictionaryByName(dictionaryName);
|
||||
|
||||
// Assert
|
||||
await expect(await umbracoApi.dictionary.doesDictionaryWithNameExists(dictionaryName)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('can create a dictionary item in a dictionary', async ({page, umbracoApi, umbracoUi}) => {
|
||||
const parentDictionaryName = 'Book';
|
||||
|
||||
await umbracoApi.dictionary.ensureDictionaryNameNotExists(parentDictionaryName);
|
||||
|
||||
await umbracoApi.dictionary.createDictionary(parentDictionaryName);
|
||||
|
||||
const parentDictionary = await umbracoApi.dictionary.getDictionaryByName(parentDictionaryName);
|
||||
|
||||
await umbracoApi.dictionary.createDictionary(dictionaryName, [], parentDictionary.id);
|
||||
|
||||
const dictionaryChildren = await umbracoApi.dictionary.getDictionaryChildrenById(parentDictionary.id);
|
||||
|
||||
// Assert
|
||||
// Checks if the parent dictionary contains the child dictionary
|
||||
await expect(dictionaryChildren.items[0].name == dictionaryName).toBeTruthy();
|
||||
|
||||
// Clean
|
||||
await umbracoApi.dictionary.ensureDictionaryNameNotExists(parentDictionaryName);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user