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 missing acceptance tests for Dictionary #16241

Merged
merged 10 commits into from
May 14, 2024
8 changes: 4 additions & 4 deletions tests/Umbraco.Tests.AcceptanceTest/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/Umbraco.Tests.AcceptanceTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"dependencies": {
"@umbraco/json-models-builders": "^2.0.5",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.40",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.43",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"faker": "^4.1.0",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";

andr317c marked this conversation as resolved.
Show resolved Hide resolved
// TODO: Remove smoke tag befor merging
test.describe('Translation tests @smoke', () => {
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);
nhudinh0309 marked this conversation as resolved.
Show resolved Hide resolved
});

test('can create a dictionary item', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
await umbracoUi.translation.goToSection(ConstantHelper.sections.translation);

// Act
await umbracoUi.translation.clickCreateLink();
await umbracoUi.translation.enterDictionaryName(dictionaryName);
await umbracoUi.translation.clickSaveButton();

// Assert
expect(await umbracoApi.dictionary.doesNameExist(dictionaryName)).toBeTruthy();
await umbracoUi.translation.isSuccessNotificationVisible();
await umbracoUi.translation.clickLeftArrowButton();
// Verify the dictionary item displays in the tree and in the list
await umbracoUi.translation.isDictionaryTreeItemVisible(dictionaryName);
expect(await umbracoUi.translation.doesDictionaryListHaveText(dictionaryName)).toBeTruthy();
});

test('can delete a dictionary item', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
await umbracoApi.dictionary.create(dictionaryName);
await umbracoUi.translation.goToSection(ConstantHelper.sections.translation);

// Act
await umbracoUi.translation.clickActionsMenuForDictionary(dictionaryName);
await umbracoUi.translation.deleteDictionary();

// Assert
await umbracoUi.translation.isSuccessNotificationVisible();
expect(await umbracoApi.dictionary.doesNameExist(dictionaryName)).toBeFalsy();
// Verify the dictionary item does not display in the tree
await umbracoUi.translation.isDictionaryTreeItemVisible(dictionaryName, false);
// TODO: Uncomment this when the front-end is ready. Currently the dictionary list is not updated immediately.
// Verify the dictionary item does not display in the list
//expect(await umbracoUi.translation.doesDictionaryListHaveText(dictionaryName)).toBeFalsy();

nhudinh0309 marked this conversation as resolved.
Show resolved Hide resolved
});

test('can create a dictionary item in a dictionary @smoke', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.dictionary.ensureNameNotExists(parentDictionaryName);
let parentDictionaryId = await umbracoApi.dictionary.create(parentDictionaryName);
await umbracoUi.translation.goToSection(ConstantHelper.sections.translation);

// Act
await umbracoUi.translation.clickActionsMenuForDictionary(parentDictionaryName);
await umbracoUi.translation.clickCreateDictionaryItemButton();
await umbracoUi.translation.enterDictionaryName(dictionaryName);
await umbracoUi.translation.clickSaveButton();

// Assert
await umbracoUi.translation.isSuccessNotificationVisible();
const dictionaryChildren = await umbracoApi.dictionary.getChildren(parentDictionaryId);
expect(dictionaryChildren[0].name).toEqual(dictionaryName);
await umbracoUi.translation.clickLeftArrowButton();
// Verify the new dictionary item displays in the list
expect(await umbracoUi.translation.doesDictionaryListHaveText(dictionaryName)).toBeTruthy();
// Verify the new dictionary item displays in the tree
await umbracoUi.translation.reloadTree(parentDictionaryName);
await umbracoUi.translation.isDictionaryTreeItemVisible(dictionaryName);
});

test('can export a dictionary item', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
const dictionaryId = await umbracoApi.dictionary.create(dictionaryName);
await umbracoUi.translation.goToSection(ConstantHelper.sections.translation);

// Act
await umbracoUi.translation.clickActionsMenuForDictionary(dictionaryName);
await umbracoUi.translation.clickExportMenu();
const exportData = await umbracoUi.translation.exportDictionary(false);

// Assert
expect(exportData).toEqual(dictionaryId + '.udt');
});

Check warning on line 95 in tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Translation/Translation.spec.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v14/dev)

❌ New issue: Code Duplication

The module contains 2 functions with similar structure: 'Translation tests @smoke'.'can export a dictionary item with descendants @smoke','Translation tests @smoke'.'can export a dictionary item'. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.

test('can export a dictionary item with descendants @smoke', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.dictionary.ensureNameNotExists(parentDictionaryName);
let parentDictionaryId = await umbracoApi.dictionary.create(parentDictionaryName);
await umbracoApi.dictionary.create(dictionaryName, [], parentDictionaryId);
await umbracoUi.translation.goToSection(ConstantHelper.sections.translation);

// Act
await umbracoUi.translation.clickActionsMenuForDictionary(parentDictionaryName);
await umbracoUi.translation.clickExportMenu();
const exportData = await umbracoUi.translation.exportDictionary(true);

// Assert
expect(exportData).toEqual(parentDictionaryId + '.udt');
});

test('can import a dictionary item', async ({umbracoApi, umbracoUi}) => {
// Arrange
const udtFilePath = './fixtures/dictionary/TestSingleDictionary.udt';
// This variable must not be changed as it is declared in the file TestDictionary.udt
const importDictionaryName = 'TestImportDictionary';
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
await umbracoApi.dictionary.create(dictionaryName);
await umbracoUi.translation.goToSection(ConstantHelper.sections.translation);

// Act
await umbracoUi.translation.clickActionsMenuForDictionary(dictionaryName);
await umbracoUi.translation.clickImportMenu();
await umbracoUi.translation.importDictionary(udtFilePath);

// Assert
// Verify the imported dictionary item displays in the tree
await umbracoUi.translation.reloadTree(dictionaryName);
await umbracoUi.translation.isDictionaryTreeItemVisible(importDictionaryName);
// TODO: Uncomment this when the front-end is ready. Currently the dictionary list is not updated immediately.
// Verify the imported dictionary item displays in the list
//expect(await umbracoUi.translation.doesDictionaryListHaveText(importDictionaryName)).toBeTruthy();
});

test('can import a dictionary item with descendants @smoke', async ({umbracoApi, umbracoUi}) => {
// Arrange
const udtFilePath = './fixtures/dictionary/TestDictionaryWithDescendants.udt';
// This variable must not be changed as it is declared in the file TestDictionaryWithDescendants.udt
const importParentDictionaryName = 'TestImportParent';
const importChildDictionaryName = 'TestImportChild';
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
await umbracoApi.dictionary.create(dictionaryName);
await umbracoUi.translation.goToSection(ConstantHelper.sections.translation);

// Act
await umbracoUi.translation.clickActionsMenuForDictionary(dictionaryName);
await umbracoUi.translation.clickImportMenu();
await umbracoUi.translation.importDictionary(udtFilePath);

// Assert
// Verify the imported dictionary items display in the tree
await umbracoUi.translation.reloadTree(dictionaryName);
await umbracoUi.translation.isDictionaryTreeItemVisible(importParentDictionaryName);
await umbracoUi.translation.reloadTree(importParentDictionaryName);
await umbracoUi.translation.isDictionaryTreeItemVisible(importChildDictionaryName);
// TODO: Uncomment this when the front-end is ready. Currently the dictionary list is not updated immediately.
// Verify the imported dictionary items display in the list
//expect(await umbracoUi.translation.doesDictionaryListHaveText(importParentDictionaryName)).toBeTruthy();
//expect(await umbracoUi.translation.doesDictionaryListHaveText(importChildDictionaryName)).toBeTruthy();
});

// Skip this test as the search function is removed
test.skip('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.translation.goToSection(ConstantHelper.sections.translation);

// Act
await umbracoUi.translation.enterSearchKeywordAndPressEnter(dictionaryName);

// Assert
expect(await umbracoUi.translation.doesDictionaryListHaveText(dictionaryName)).toBeTruthy();
});

// Skip this test as the search function is removed
test.skip('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.translation.goToSection(ConstantHelper.sections.translation);

// Act
await umbracoUi.translation.enterSearchKeywordAndPressEnter('xyz');

// Assert
await umbracoUi.translation.isSearchResultMessageDisplayEmpty(emptySearchResultMessage);
});
});
Loading