V14 QA Added acceptance tests for Dictionary (#15479)
* Bumped version of TestHelper * Added .udt test files * Updated api tests for Dictionary * Added ui tests for Dictionary * Updated ui tets for Dictionary as TestHelper is changed * Updated ui tests of Dictionary * Updated verify step * Fixed comments * Imported crypto into Dictionary.spec.ts Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com> * Fixed format --------- Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<DictionaryItem Key="5e2d8582-14e1-4159-ac2d-7d29652dac10" Name="TestImportParent"><Value LanguageCultureAlias="en-US"><![CDATA[parente]]></Value><DictionaryItem Key="0f5a0e39-1bfb-4e76-ba05-b3c337ec299e" Name="TestImportChild"><Value LanguageCultureAlias="en-US"><![CDATA[child]]></Value></DictionaryItem></DictionaryItem>
|
||||
@@ -0,0 +1 @@
|
||||
<DictionaryItem Key="59f9f9de-09e8-4a2c-8bfd-2d24b186f703" Name="TestImportDictionary"><Value LanguageCultureAlias="en-US"><![CDATA[TestEnglish]]></Value></DictionaryItem>
|
||||
@@ -1,30 +1,29 @@
|
||||
import {test} from '@umbraco/playwright-testhelpers';
|
||||
import {expect} from "@playwright/test";
|
||||
import * as crypto from 'crypto';
|
||||
|
||||
test.describe('Dictionary tests', () => {
|
||||
let dictionaryId = "";
|
||||
const dictionaryName = 'Word'
|
||||
let dictionaryId = '';
|
||||
const dictionaryName = 'Word';
|
||||
|
||||
test.beforeEach(async ({umbracoApi}) => {
|
||||
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
|
||||
});
|
||||
|
||||
test.afterEach(async ({umbracoApi}) => {
|
||||
await umbracoApi.dictionary.delete(dictionaryId);
|
||||
})
|
||||
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
|
||||
});
|
||||
|
||||
test('can create a dictionary', async ({umbracoApi}) => {
|
||||
// Arrange
|
||||
const translationData = [
|
||||
{
|
||||
'isoCode': 'en-US',
|
||||
'translation': 'Word'
|
||||
},
|
||||
{
|
||||
'isoCode': 'da-DK',
|
||||
'translation': 'Ord'
|
||||
}
|
||||
];
|
||||
|
||||
// Act
|
||||
dictionaryId = await umbracoApi.dictionary.create(dictionaryName, translationData);
|
||||
|
||||
// Assert
|
||||
@@ -32,13 +31,12 @@ test.describe('Dictionary tests', () => {
|
||||
});
|
||||
|
||||
test('can update a dictionary', async ({umbracoApi}) => {
|
||||
// Arrange
|
||||
const oldDictionaryName = 'OldWord';
|
||||
|
||||
dictionaryId = await umbracoApi.dictionary.create(oldDictionaryName);
|
||||
|
||||
const dictionary = await umbracoApi.dictionary.get(dictionaryId);
|
||||
|
||||
// Updates the dictionary name
|
||||
// Act
|
||||
dictionary.name = dictionaryName;
|
||||
await umbracoApi.dictionary.update(dictionaryId, dictionary);
|
||||
|
||||
@@ -46,15 +44,15 @@ test.describe('Dictionary tests', () => {
|
||||
// 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();
|
||||
});
|
||||
|
||||
test('can delete a dictionary', async ({umbracoApi}) => {
|
||||
// Arrange
|
||||
dictionaryId = await umbracoApi.dictionary.create(dictionaryName);
|
||||
|
||||
await expect(umbracoApi.dictionary.doesExist(dictionaryId)).toBeTruthy();
|
||||
|
||||
// Act
|
||||
await umbracoApi.dictionary.delete(dictionaryId);
|
||||
|
||||
// Assert
|
||||
@@ -62,18 +60,60 @@ test.describe('Dictionary tests', () => {
|
||||
});
|
||||
|
||||
test('can create a dictionary item in a dictionary', async ({umbracoApi}) => {
|
||||
const parentDictionaryName = 'Book';
|
||||
// Arrange
|
||||
const childDictionaryName = 'Book';
|
||||
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
|
||||
dictionaryId = await umbracoApi.dictionary.create(dictionaryName);
|
||||
|
||||
await umbracoApi.dictionary.ensureNameNotExists(parentDictionaryName);
|
||||
|
||||
dictionaryId = await umbracoApi.dictionary.create(parentDictionaryName);
|
||||
|
||||
await umbracoApi.dictionary.create(dictionaryName, [], dictionaryId);
|
||||
|
||||
const parentDictionaryChildren = await umbracoApi.dictionary.getChildren(dictionaryId);
|
||||
// Act
|
||||
await umbracoApi.dictionary.create(childDictionaryName, [], dictionaryId);
|
||||
|
||||
// Assert
|
||||
// Checks if the parent dictionary contains the child dictionary
|
||||
await expect(parentDictionaryChildren[0].name).toEqual(dictionaryName);
|
||||
const dictionaryChildren = await umbracoApi.dictionary.getChildren(dictionaryId);
|
||||
await 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();
|
||||
|
||||
// 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");
|
||||
});
|
||||
|
||||
test('can import a dictionary', async ({umbracoApi}) => {
|
||||
// Arrange
|
||||
const temporaryFileId = crypto.randomUUID();
|
||||
const fileName = 'TestSingleDictionary.udt';
|
||||
const mimeType = 'application/octet-stream';
|
||||
const filePath = './fixtures/dictionary/TestSingleDictionary.udt';
|
||||
// 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();
|
||||
|
||||
// Act
|
||||
const importResponse = await umbracoApi.dictionary.import(temporaryFileId, dictionaryId);
|
||||
|
||||
// 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);
|
||||
|
||||
// Clean
|
||||
await umbracoApi.temporaryFile.delete(temporaryFileId);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';
|
||||
import {expect} from "@playwright/test";
|
||||
|
||||
test.describe('Dictionary tests', () => {
|
||||
const dictionaryName = 'TestDictionaryItem';
|
||||
const parentDictionaryName = 'TestParentDictionary';
|
||||
|
||||
test.beforeEach(async ({umbracoUi}) => {
|
||||
await umbracoUi.goToBackOffice();
|
||||
});
|
||||
|
||||
test.afterEach(async ({umbracoApi}) => {
|
||||
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
|
||||
await umbracoApi.dictionary.ensureNameNotExists(parentDictionaryName);
|
||||
});
|
||||
|
||||
test('can create a dictionary item', async ({umbracoApi, umbracoUi}) => {
|
||||
// Arrange
|
||||
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
|
||||
await umbracoUi.dictionary.goToSection(ConstantHelper.sections.dictionary);
|
||||
|
||||
// Act
|
||||
await umbracoUi.dictionary.clickCreateDictionaryItemButton();
|
||||
await umbracoUi.dictionary.enterDictionaryName(dictionaryName);
|
||||
await umbracoUi.dictionary.clickSaveButton();
|
||||
|
||||
// Assert
|
||||
expect(await umbracoApi.dictionary.doesNameExist(dictionaryName)).toBeTruthy();
|
||||
await umbracoUi.dictionary.isSuccessNotificationVisible();
|
||||
// TODO: when frontend is ready, verify the new dictionary item displays in tree and in list
|
||||
// await umbracoUi.goToSection(ConstantHelper.sections.dictionary);
|
||||
// await umbracoUi.dictionary.isDictionaryListHasText(dictionaryName);
|
||||
});
|
||||
|
||||
test('can delete a dictionary item', async ({umbracoApi, umbracoUi}) => {
|
||||
// Arrange
|
||||
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
|
||||
await umbracoApi.dictionary.create(dictionaryName);
|
||||
await umbracoUi.dictionary.goToSection(ConstantHelper.sections.dictionary);
|
||||
|
||||
// Act
|
||||
await umbracoUi.dictionary.clickActionsMenuForDictionary(dictionaryName);
|
||||
await umbracoUi.dictionary.deleteDictionary();
|
||||
|
||||
// Assert
|
||||
expect(await umbracoApi.dictionary.doesNameExist(dictionaryName)).toBeFalsy();
|
||||
// TODO: when frontend is ready, verify the new dictionary item is NOT displayed in list view and in tree
|
||||
});
|
||||
|
||||
test('can create a dictionary item in a dictionary', async ({umbracoApi, umbracoUi}) => {
|
||||
// Arrange
|
||||
await umbracoApi.dictionary.ensureNameNotExists(parentDictionaryName);
|
||||
let parentDictionaryId = await umbracoApi.dictionary.create(parentDictionaryName);
|
||||
await umbracoUi.dictionary.goToSection(ConstantHelper.sections.dictionary);
|
||||
|
||||
// Act
|
||||
await umbracoUi.dictionary.clickActionsMenuForDictionary(parentDictionaryName);
|
||||
await umbracoUi.dictionary.clickCreateMenu();
|
||||
await umbracoUi.dictionary.enterDictionaryName(dictionaryName);
|
||||
await umbracoUi.dictionary.clickSaveButton();
|
||||
|
||||
// Assert
|
||||
const dictionaryChildren = await umbracoApi.dictionary.getChildren(parentDictionaryId);
|
||||
await expect(dictionaryChildren[0].name).toEqual(dictionaryName);
|
||||
// TODO: when frontend is ready, verify the notification displays
|
||||
});
|
||||
|
||||
// Remove skip when export function works
|
||||
test.skip('can export a dictionary item', async ({umbracoApi, umbracoUi}) => {
|
||||
// Arrange
|
||||
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
|
||||
await umbracoApi.dictionary.create(dictionaryName);
|
||||
await umbracoUi.dictionary.goToSection(ConstantHelper.sections.dictionary);
|
||||
|
||||
// Act
|
||||
await umbracoUi.dictionary.clickActionsMenuForDictionary(dictionaryName);
|
||||
await umbracoUi.dictionary.clickExportMenu();
|
||||
await umbracoUi.dictionary.exportDictionary(false);
|
||||
|
||||
// Assert
|
||||
// TODO: when frontend is ready, verify the notification displays
|
||||
});
|
||||
|
||||
// Remove skip when export function works
|
||||
test.skip('can export a dictionary item with descendants', async ({umbracoApi, umbracoUi}) => {
|
||||
// Arrange
|
||||
await umbracoApi.dictionary.ensureNameNotExists(parentDictionaryName);
|
||||
let parentDictionaryId = await umbracoApi.dictionary.create(parentDictionaryName);
|
||||
await umbracoApi.dictionary.create(dictionaryName, [], parentDictionaryId);
|
||||
await umbracoUi.dictionary.goToSection(ConstantHelper.sections.dictionary);
|
||||
|
||||
// Act
|
||||
await umbracoUi.dictionary.clickActionsMenuForDictionary(dictionaryName);
|
||||
await umbracoUi.dictionary.clickExportMenu();
|
||||
await umbracoUi.dictionary.exportDictionary(true);
|
||||
|
||||
// Assert
|
||||
// TODO: when frontend is ready, verify the notification displays
|
||||
});
|
||||
|
||||
// Remove skip when import function works
|
||||
test.skip('can import a dictionary item', async ({umbracoApi, umbracoUi}) => {
|
||||
// Arrange
|
||||
const udtFilePath = './fixtures/dictionary/TestSingleDictionary.udt';
|
||||
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
|
||||
await umbracoApi.dictionary.create(dictionaryName);
|
||||
await umbracoUi.dictionary.goToSection(ConstantHelper.sections.dictionary);
|
||||
|
||||
// Act
|
||||
await umbracoUi.dictionary.clickActionsMenuForDictionary(dictionaryName);
|
||||
await umbracoUi.dictionary.clickImportMenu();
|
||||
await umbracoUi.dictionary.importDictionary(udtFilePath);
|
||||
|
||||
// Assert
|
||||
// TODO: when frontend is ready, verify the notification displays
|
||||
// TODO: when frontend is ready, verify the imported dictionary items displays
|
||||
});
|
||||
|
||||
// Remove skip when import function works
|
||||
test.skip('can import a dictionary item with descendants', async ({umbracoApi, umbracoUi}) => {
|
||||
// Arrange
|
||||
const udtFilePath = './fixtures/dictionary/TestDictionaryWithDescendants.udt';
|
||||
await umbracoApi.dictionary.ensureNameNotExists(parentDictionaryName);
|
||||
let parentDictionaryId = await umbracoApi.dictionary.create(parentDictionaryName);
|
||||
await umbracoApi.dictionary.create(dictionaryName, [], parentDictionaryId);
|
||||
await umbracoUi.dictionary.goToSection(ConstantHelper.sections.dictionary);
|
||||
|
||||
// Act
|
||||
await umbracoUi.dictionary.clickActionsMenuForDictionary(dictionaryName);
|
||||
await umbracoUi.dictionary.clickImportMenu();
|
||||
await umbracoUi.dictionary.importDictionary(udtFilePath);
|
||||
|
||||
// Assert
|
||||
// TODO: when frontend is ready, verify the notification displays
|
||||
// TODO: when frontend is ready, verify the imported dictionary items displays
|
||||
});
|
||||
|
||||
test('can search a dictionary item in list when have results', async ({umbracoApi, umbracoUi}) => {
|
||||
// Arrange
|
||||
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
|
||||
await umbracoApi.dictionary.create(dictionaryName);
|
||||
await umbracoUi.dictionary.goToSection(ConstantHelper.sections.dictionary);
|
||||
|
||||
// Act
|
||||
await umbracoUi.dictionary.enterSearchKeywordAndPressEnter(dictionaryName);
|
||||
|
||||
// Assert
|
||||
expect (await umbracoUi.dictionary.doesDictionaryListHaveText(dictionaryName)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('can search a dictionary item in list when have no results', async ({umbracoApi, umbracoUi}) => {
|
||||
// Arrange
|
||||
const emptySearchResultMessage = 'No Dictionary items to choose from';
|
||||
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
|
||||
await umbracoApi.dictionary.create(dictionaryName);
|
||||
await umbracoUi.dictionary.goToSection(ConstantHelper.sections.dictionary);
|
||||
|
||||
// Act
|
||||
await umbracoUi.dictionary.enterSearchKeywordAndPressEnter('xyz');
|
||||
|
||||
// Assert
|
||||
await umbracoUi.dictionary.isSearchResultMessageDisplayEmpty(emptySearchResultMessage);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user