V11/feature/flaky test work (#13513) (#13527)

* Removed all the DeleteAllContent since I delete the doctypes in the before and after each functions which also deletes the content.

* fixed the test so it selects the specific button!

* I was dumb and forgot to remove the out commented code

* Added additional timeout so the pipeline has more time

* Removed language in settings because it was a duplicate of languages / languages

* Fixed the tests so they now check if each individual language that was created actually exists instead of checking for how many languages there are which could be flaky if another test touching the languages failed

* Bumped version

* Added a better locator for the buttons and increased timeouts

Signed-off-by: Zeegaan <nge@umbraco.dk>

Signed-off-by: Zeegaan <nge@umbraco.dk>
Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com>
This commit is contained in:
Nikolaj Geisle
2022-12-06 11:32:23 +01:00
committed by GitHub
parent 248a0c4f19
commit caed5bcb13
9 changed files with 528 additions and 93 deletions

View File

@@ -8,7 +8,7 @@
"hasInstallScript": true,
"dependencies": {
"@umbraco/json-models-builders": "^1.0.2",
"@umbraco/playwright-testhelpers": "^1.0.19",
"@umbraco/playwright-testhelpers": "^1.0.20",
"camelize": "^1.0.0",
"dotenv": "^16.0.2",
"faker": "^4.1.0",
@@ -101,9 +101,9 @@
}
},
"node_modules/@umbraco/playwright-testhelpers": {
"version": "1.0.19",
"resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-1.0.19.tgz",
"integrity": "sha512-NLZHRrWkfjzLoBc6RagQkbggT1awYARlmHNw50Aih566o+BnzkZ3usW0J8bvU4rW+8BbkClvOqUDCOP5vSYbVA==",
"version": "1.0.20",
"resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-1.0.20.tgz",
"integrity": "sha512-V+0ZmaFmvWicHaZFkGako8FjDA6UvwOkKpHwCIy0xLAEuhLLTEb6yCH61WydAn2BqY7Ft0xUPMvbKMURYddkjA==",
"dependencies": {
"@umbraco/json-models-builders": "^1.0.2",
"camelize": "^1.0.0",
@@ -906,9 +906,9 @@
}
},
"@umbraco/playwright-testhelpers": {
"version": "1.0.19",
"resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-1.0.19.tgz",
"integrity": "sha512-NLZHRrWkfjzLoBc6RagQkbggT1awYARlmHNw50Aih566o+BnzkZ3usW0J8bvU4rW+8BbkClvOqUDCOP5vSYbVA==",
"version": "1.0.20",
"resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-1.0.20.tgz",
"integrity": "sha512-V+0ZmaFmvWicHaZFkGako8FjDA6UvwOkKpHwCIy0xLAEuhLLTEb6yCH61WydAn2BqY7Ft0xUPMvbKMURYddkjA==",
"requires": {
"@umbraco/json-models-builders": "^1.0.2",
"camelize": "^1.0.0",

View File

@@ -19,7 +19,7 @@
},
"dependencies": {
"@umbraco/json-models-builders": "^1.0.2",
"@umbraco/playwright-testhelpers": "^1.0.19",
"@umbraco/playwright-testhelpers": "^1.0.20",
"camelize": "^1.0.0",
"faker": "^4.1.0",
"form-data": "^4.0.0",

View File

@@ -0,0 +1,484 @@
import {AliasHelper, ConstantHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";
import {ContentBuilder, DocumentTypeBuilder, PartialViewBuilder} from "@umbraco/json-models-builders";
import {BlockListDataTypeBuilder} from "@umbraco/json-models-builders/dist/lib/builders/dataTypes";
test.describe('BlockListEditorContent', () => {
const documentName = 'DocumentTestName';
const blockListName = 'BlockListTest';
const elementName = 'TestElement';
const documentAlias = AliasHelper.toAlias(documentName);
const blockListAlias = AliasHelper.toAlias(blockListName);
// Won't work if I use the to alias for the elementAlias
const elementAlias = 'testElement';
test.beforeEach(async ({page, umbracoApi, umbracoUi}, testInfo) => {
await umbracoApi.report.report(testInfo);
await umbracoApi.login();
await umbracoApi.documentTypes.ensureNameNotExists(documentName);
await umbracoApi.documentTypes.ensureNameNotExists(elementName);
await umbracoApi.dataTypes.ensureNameNotExists(blockListName);
});
test.afterEach(async ({page, umbracoApi, umbracoUi}) => {
await umbracoApi.documentTypes.ensureNameNotExists(documentName);
await umbracoApi.documentTypes.ensureNameNotExists(elementName);
await umbracoApi.dataTypes.ensureNameNotExists(blockListName);
});
async function createDefaultBlockList(umbracoApi, blockListName, element){
const dataTypeBlockList = new BlockListDataTypeBuilder()
.withName(blockListName)
.addBlock()
.withContentElementTypeKey(element['key'])
.withSettingsElementTypeKey(element['key'])
.done()
.build();
return await umbracoApi.dataTypes.save(dataTypeBlockList);
}
async function createDocumentWithOneBlockListEditor(umbracoApi, element, dataType){
if(element == null) {
element = await umbracoApi.documentTypes.createDefaultElementType(elementName, elementAlias);
}
if(dataType == null) {
dataType = await createDefaultBlockList(umbracoApi, blockListName, element);
}
const docType = new DocumentTypeBuilder()
.withName(documentName)
.withAlias(documentAlias)
.withAllowAsRoot(true)
.addGroup()
.withName('BlockListGroup')
.addCustomProperty(dataType['id'])
.withAlias(blockListAlias)
.done()
.done()
.build();
await umbracoApi.documentTypes.save(docType);
return element;
}
async function createContentWithOneBlockListEditor(umbracoApi, element) {
if(element == null) {
element = await createDocumentWithOneBlockListEditor(umbracoApi, null, null);
}
const rootContentNode = new ContentBuilder()
.withContentTypeAlias(documentAlias)
.withAction(ConstantHelper.actions.save)
.addVariant()
.withName(blockListName)
.withSave(true)
.addProperty()
.withAlias(blockListAlias)
.addBlockListValue()
.addBlockListEntry()
.withContentTypeKey(element['key'])
.appendContentProperties(element.groups[0].properties[0].alias, "aliasTest")
.done()
.done()
.done()
.done()
.build();
await umbracoApi.content.save(rootContentNode);
return element;
}
test('can create content with a block list editor', async ({page, umbracoApi, umbracoUi}) => {
await createDocumentWithOneBlockListEditor(umbracoApi, null, null);
const rootContentNode = new ContentBuilder()
.withContentTypeAlias(documentAlias)
.withAction(ConstantHelper.actions.save)
.addVariant()
.withName(blockListName)
.withSave(true)
.done()
.build();
await umbracoApi.content.save(rootContentNode);
await umbracoUi.goToSection(ConstantHelper.sections.content);
await umbracoUi.refreshContentTree();
// Opens the content with the block list editor
await umbracoUi.clickDataElementByElementName('tree-item-' + blockListName);
// Adds TestElement
await page.locator('[key="blockEditor_addThis"]', {hasText: elementName}).click();
await page.locator('[id="sub-view-0"]').locator('[id="title"]').fill('Testing...');
await page.locator('[label="Create"]').click();
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.saveAndPublish));
// Assert
await umbracoUi.isSuccessNotificationVisible();
// Checks if the content was created
await expect(page.locator('.umb-block-list__block--view')).toHaveCount(1);
await expect(page.locator('.umb-block-list__block--view').nth(0)).toHaveText(elementName);
});
test('can update content with a block list editor', async ({page, umbracoApi, umbracoUi}) => {
await createContentWithOneBlockListEditor(umbracoApi, null);
await umbracoUi.goToSection(ConstantHelper.sections.content);
await umbracoUi.refreshContentTree();
// Opens the content with the block list editor
await umbracoUi.clickDataElementByElementName('tree-item-' + blockListName);
// Updates the block list editor inside of the content
await page.locator('[ui-sortable="vm.sortableOptions"]').nth(0).click();
// Updates content
await page.locator('[id="sub-view-0"]').locator('[id="title"]').fill('ContentTest');
await umbracoUi.clickDataElementByElementName('sub-view-settings');
// Adds text to the setting element
await page.locator('[id="sub-view-1"]').locator('[id="title"]').fill('SettingTest');
await page.locator('[label="Submit"]').click();
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.saveAndPublish));
// Assert
await umbracoUi.isSuccessNotificationVisible();
});
test('can delete a block list editor in content', async ({page, umbracoApi, umbracoUi}) => {
await createContentWithOneBlockListEditor(umbracoApi, null);
await umbracoUi.goToSection(ConstantHelper.sections.content);
await umbracoUi.refreshContentTree();
// Opens the content with the block list editor
await umbracoUi.clickDataElementByElementName('tree-item-' + blockListName);
// Deletes the block list editor inside of the content
await page.locator('[title="Delete"]').click();
// Can't use our constant helper because the action for delete does not contain an s. The correct way is 'action-delete'
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey('actions_delete'));
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.saveAndPublish));
// Assert
await umbracoUi.isSuccessNotificationVisible();
// Checks if the content is actually deleted
await expect(page.locator('[ui-sortable="vm.sortableOptions"]').nth(0)).not.toBeVisible();
});
test('can copy block list content and paste it', async ({page, umbracoApi, umbracoUi}) => {
await createContentWithOneBlockListEditor(umbracoApi, null);
await umbracoUi.goToSection(ConstantHelper.sections.content);
await umbracoUi.refreshContentTree();
// Opens the content with the block list editor
await umbracoUi.clickDataElementByElementName('tree-item-' + blockListName);
// Checks to make sure that there is only one item
await expect(page.locator('.umb-block-list__block--view')).toHaveCount(1);
// Copies block list content
await page.locator('[title="Copy"]').click();
await expect(page.locator('.alert-success', {hasText: 'Copied to clipboard'})).toBeVisible();
// Pastes block list content
await page.locator('[title="Clipboard"]').click();
await page.locator('umb-block-card', {hasText: elementName}).click();
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.saveAndPublish));
// Assert
await expect(page.locator('.umb-block-list__block--view')).toHaveCount(2);
await page.locator('.umb-block-list__block--view').nth(1).click();
await expect(page.locator('[id="sub-view-0"] >> [name="textbox"]')).toHaveValue('aliasTest');
});
test('can copy block list content and paste it into another group with the same block list editor', async ({page, umbracoApi, umbracoUi}) => {
const element = await umbracoApi.documentTypes.createDefaultElementType(elementName, elementAlias);
const dataType = await createDefaultBlockList(umbracoApi, blockListName, element);
const docType = new DocumentTypeBuilder()
.withName(documentName)
.withAlias(documentAlias)
.withAllowAsRoot(true)
.addGroup()
.withName('BlockListGroup')
.addCustomProperty(dataType['id'])
.withAlias(blockListAlias)
.done()
.done()
.addGroup()
.withName('TheBlockListGroupTheSecond')
.addCustomProperty(dataType['id'])
.withAlias('theBlockListAliasTheSecond')
.done()
.done()
.build();
await umbracoApi.documentTypes.save(docType);
await createContentWithOneBlockListEditor(umbracoApi, element);
await umbracoUi.goToSection(ConstantHelper.sections.content);
await umbracoUi.refreshContentTree();
// Opens the content with the block list editor
await umbracoUi.clickDataElementByElementName('tree-item-' + blockListName);
// Checks to make sure that there is only one item in the first group
await expect(page.locator('[data-element="group-aBlockListGroup"] >> .umb-block-list__block--view')).toHaveCount(1);
// Checks to make sure that there is no items in the second group
await expect(page.locator('[data-element="group-aTheBlockListGroupTheSecond"] >> .umb-block-list__block--view')).toHaveCount(0);
// Copies block list content from the first group
await page.locator('[title="Copy"]').click();
await expect(page.locator('.alert-success', {hasText: 'Copied to clipboard'})).toBeVisible();
// Pastes into the second group
await page.locator('[title="Clipboard"]').nth(1).click();
await page.locator('umb-block-card', {hasText: elementName}).click();
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.saveAndPublish));
await expect(page.locator('.alert-success', {hasText: 'Content Published'})).toBeVisible();
// Assert
await expect(page.locator('[data-element="group-aBlockListGroup"] >> .umb-block-list__block--view')).toHaveCount(1);
await expect(page.locator('[data-element="group-aTheBlockListGroupTheSecond"] >> .umb-block-list__block--view')).toHaveCount(1);
await page.locator('[data-element="group-aTheBlockListGroupTheSecond"] >> .umb-block-list__block--view').click();
await expect(page.locator('[id="sub-view-0"] >> [name="textbox"]')).toHaveValue('aliasTest');
});
test('can set a minimum of required blocks in content with a block list editor', async ({page, umbracoApi, umbracoUi}) => {
const element = await umbracoApi.documentTypes.createDefaultElementType(elementName, elementAlias);
const dataTypeBlockList = new BlockListDataTypeBuilder()
.withName(blockListName)
.withMin(2)
.addBlock()
.withContentElementTypeKey(element['key'])
.done()
.build();
const dataType = await umbracoApi.dataTypes.save(dataTypeBlockList);
await createDocumentWithOneBlockListEditor(umbracoApi, element, dataType);
await createContentWithOneBlockListEditor(umbracoApi, element);
await umbracoUi.goToSection(ConstantHelper.sections.content);
await umbracoUi.refreshContentTree();
// Opens the content with the block list editor
await umbracoUi.clickDataElementByElementName('tree-item-' + blockListName);
// Checks if there is validation for needing 2 entries or more
await expect(page.locator('[key="validation_entriesShort"]')).toContainText('Minimum 2 entries');
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.saveAndPublish));
// Checks if a validation error is thrown when trying to save when there is not enough blocks
await expect(page.locator('.alert-error')).toBeVisible();
// Adds another block
await page.locator('[id="' + blockListAlias + '"]').click();
await page.locator('[label="Create"]').click();
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.saveAndPublish));
// Assert
await umbracoUi.getSuccessNotification();
});
test('can set a maximum of required blocks in content with a block list editor', async ({page, umbracoApi, umbracoUi}) => {
const element = await umbracoApi.documentTypes.createDefaultElementType(elementName, elementAlias);
const dataTypeBlockList = new BlockListDataTypeBuilder()
.withName(blockListName)
.withMax(2)
.addBlock()
.withContentElementTypeKey(element['key'])
.done()
.build();
const dataType = await umbracoApi.dataTypes.save(dataTypeBlockList);
await createDocumentWithOneBlockListEditor(umbracoApi, element, dataType);
const rootContentNode = new ContentBuilder()
.withContentTypeAlias(documentAlias)
.withAction(ConstantHelper.actions.save)
.addVariant()
.withName(blockListName)
.withSave(true)
.addProperty()
.withAlias(blockListAlias)
.addBlockListValue()
.addBlockListEntry()
.withContentTypeKey(element['key'])
.appendContentProperties(element.groups[0].properties[0].alias, "aliasTest")
.done()
.addBlockListEntry()
.withContentTypeKey(element['key'])
.appendContentProperties(element.groups[0].properties[0].alias, "aliasTests")
.done()
.addBlockListEntry()
.withContentTypeKey(element['key'])
.appendContentProperties(element.groups[0].properties[0].alias, "aliasTester")
.done()
.done()
.done()
.done()
.build();
await umbracoApi.content.save(rootContentNode);
await umbracoUi.goToSection(ConstantHelper.sections.content);
await umbracoUi.refreshContentTree();
// Opens the content with the block list editor
await umbracoUi.clickDataElementByElementName('tree-item-' + blockListName);
// Checks if there is validation
await expect(page.locator('[key="validation_entriesExceed"]')).toContainText('Maximum 2 entries');
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.saveAndPublish));
// Checks if a validation error is thrown when trying to save when there is too many blocks
await expect(page.locator('.alert-error')).toBeVisible();
// Deletes a block
await page.locator('[title="Delete"]').nth(2).click();
// Can't use our constant helper because the action for delete does not contain an s. The correct way is 'action-delete'
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey('actions_delete'));
// Assert
await umbracoUi.getSuccessNotification();
});
test('can use inline editing mode in content with a block list editor', async ({page, umbracoApi, umbracoUi}) => {
const element = await umbracoApi.documentTypes.createDefaultElementType(elementName, elementAlias);
const dataTypeBlockList = new BlockListDataTypeBuilder()
.withName(blockListName)
.withUseInlineEditingAsDefault(true)
.addBlock()
.withContentElementTypeKey(element['key'])
.done()
.build();
const dataType = await umbracoApi.dataTypes.save(dataTypeBlockList);
await createDocumentWithOneBlockListEditor(umbracoApi, element, dataType);
await createContentWithOneBlockListEditor(umbracoApi, element);
await umbracoUi.goToSection(ConstantHelper.sections.content);
await umbracoUi.refreshContentTree();
// Opens the content with the block list editor
await umbracoUi.clickDataElementByElementName('tree-item-' + blockListName);
// Opens the block in content
await page.locator('[ui-sortable="vm.sortableOptions"]').nth(0).click();
// Assert
await expect(page.locator('[ui-sortable="vm.sortableOptions"]').nth(0).locator('[data-element="property-title"]')).toBeVisible();
});
test('can see rendered content with a block list editor', async ({page, umbracoApi, umbracoUi}) => {
await umbracoApi.templates.ensureNameNotExists(documentName);
await umbracoApi.partialViews.ensureNameNotExists(elementName + '.cshtml');
const element = new DocumentTypeBuilder()
.withName(elementName)
.withAlias(elementAlias)
.AsElementType()
.addGroup()
.withName("TestString")
.withAlias('testString')
.addTextBoxProperty()
.withLabel("Title")
.withAlias("title")
.done()
.addRichTextProperty()
.withLabel('Body')
.withAlias('body')
.done()
.done()
.build();
await umbracoApi.documentTypes.save(element);
const dataType = await createDefaultBlockList(umbracoApi, blockListName, element);
const docType = new DocumentTypeBuilder()
.withName(documentName)
.withAlias('documentTestName')
.withDefaultTemplate('documentTestName')
.withAllowAsRoot(true)
.addGroup()
.withName('BlockListGroup')
.addCustomProperty(dataType['id'])
.withAlias(elementAlias)
.done()
.done()
.build();
await umbracoApi.documentTypes.save(docType);
await umbracoApi.templates.edit(documentName, '@using Umbraco.Cms.Web.Common.PublishedModels;\n' +
'@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.' + documentName + '>\n' +
'@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;' +
'\n@{' +
'\n Layout = null;' +
'\n}' +
'\n' +
'@Html.GetBlockListHtml(Model.' + elementName + ')');
const partialView = new PartialViewBuilder()
.withName(elementAlias)
.withContent("@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockListItem>;\n" +
"@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;\n" +
"@{\n" +
"var content = (ContentModels." + elementName + ")Model.Content;\n" +
"var settings = (ContentModels." + elementName + ")Model.Settings;\n" +
"}\n" +
"\n" +
"<h1>@content.Title</h1>" +
"<p>@content.Body</p>" +
"\n" +
"<h1>@settings.Title</h1>" +
"<p>@settings.Body</p>")
.build();
partialView.virtualPath = "/Views/Partials/blocklist/Components/";
await umbracoApi.partialViews.save(partialView);
const rootContentNode = new ContentBuilder()
.withContentTypeAlias(documentAlias)
.withAction(ConstantHelper.actions.publish)
.addVariant()
.withName('BlockListContent')
.withSave(true)
.withPublish(true)
.addProperty()
.withAlias(elementAlias)
.addBlockListValue()
.addBlockListEntry()
.withContentTypeKey(element['key'])
.appendContentProperties(element.groups[0].properties[0].alias, "ContentTest")
.appendContentProperties(element.groups[0].properties[1].alias, "RTEContent")
.withSettingsTypeKey(element['key'])
.appendSettingsProperties(element.groups[0].properties[0].alias, "SettingTest")
.appendSettingsProperties(element.groups[0].properties[1].alias, "RTESetting")
.done()
.done()
.done()
.done()
.build();
await umbracoApi.content.save(rootContentNode);
// Assert
// Ensure that the view gets rendered correctly
const expected = `<divclass="umb-block-list"><h1>ContentTest</h1><p>RTEContent</p><h1>SettingTest</h1><p>RTESetting</p></div>`;
await expect(await umbracoApi.content.verifyRenderedContent('/', expected, true)).toBeTruthy();
// Clean
await umbracoApi.templates.ensureNameNotExists(documentName);
await umbracoApi.partialViews.ensureNameNotExists(elementAlias + '.cshtml');
});
});

View File

@@ -53,7 +53,7 @@ test.describe('DataTypes', () => {
// Assert
const expected = `<p style="color:000000" > Lorem ipsum dolor sit amet </p>`;
await expect(umbracoApi.content.verifyRenderedContent('/', expected, true)).toBeTruthy();
await expect(await page.locator('.umb-button__overlay')).not.toBeVisible();
await expect(await page.locator('.umb-button__overlay')).not.toBeVisible({timeout: 10000});
// Pick another colour to verify both work
await page.locator('.btn-FF0000').click();
@@ -61,7 +61,7 @@ test.describe('DataTypes', () => {
// Save
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.saveAndPublish));
await umbracoUi.isSuccessNotificationVisible();
await expect(await page.locator('.umb-button__overlay')).not.toBeVisible();
await expect(await page.locator('.umb-button__overlay')).not.toBeVisible({timeout: 10000});
// Assert
const expected2 = '<p style="color:FF0000">Lorem ipsum dolor sit amet</p>';
@@ -173,7 +173,7 @@ test.describe('DataTypes', () => {
// Assert
await expect(await umbracoUi.getErrorNotification()).not.toBeVisible();
// Testing if the edits match the expected results
const expected = '<a href="/">UrlPickerContent</a>';
await expect(await umbracoApi.content.verifyRenderedContent('/', expected, true)).toBeTruthy();

View File

@@ -97,7 +97,7 @@ test.describe('Vary by culture for TextBox', () => {
// Assert
await page.locator('.umb-variant-switcher__toggle').click();
await page.locator('.umb-variant-switcher__name-wrapper', {hasText: "English (United States)"}).hover();
await page.locator('[role="button"]', {hasText: "Open in split view"}).click();
await page.locator('[role="menuitem"]', {hasText:'English'}).locator('[role="button"]', {hasText: "Open in split view"}).click();
await expect(page.locator('[name="textbox"]').first()).toHaveValue(daValue);
await expect(page.locator('[name="textbox"]').nth(1)).toHaveValue(enValue);

View File

@@ -23,7 +23,11 @@ test.describe('Languages', () => {
// Save and assert success
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.save));
await umbracoUi.isSuccessNotificationVisible();
// await expect(umbracoApi.languages.exists(culture)).toBe(true);
const doesExistDA = await umbracoApi.languages.exists(culture);
await expect(doesExistDA).toBe(true);
// Cleanup
await umbracoApi.languages.ensureCultureNotExists(culture);
});
@@ -44,17 +48,27 @@ test.describe('Languages', () => {
// Enter language tree and select the language we just created
await umbracoUi.clickElement(umbracoUi.getTreeItem('settings', ['languages']));
// Assert there are 3 languages
await expect(await page.locator('tbody > tr')).toHaveCount(3);
// Assert that the 2 languages exists
// DA
let doesExistDA = await umbracoApi.languages.exists(language1);
await expect(doesExistDA).toBe(true);
// EN
let doesExistEN = await umbracoApi.languages.exists(language2);
await expect(doesExistEN).toBe(true);
// Delete UK Language
await page.locator('umb-button[label-key="general_delete"]').last().click();
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey('contentTypeEditor_yesDelete'));
// Assert there is only 2 languages
await expect(await page.locator('tbody > tr')).toHaveCount(2);
// Assert the da language still exists and that the uk is deleted
// DA
doesExistDA = await umbracoApi.languages.exists(language1);
await expect(doesExistDA).toBe(true);
// EN
doesExistEN = await umbracoApi.languages.exists(language2);
await expect(doesExistEN).toBe(false);
// Cleanup
await umbracoApi.languages.ensureCultureNotExists(language1);
await umbracoApi.languages.ensureCultureNotExists(language2);

View File

@@ -1,64 +0,0 @@
import {test, ApiHelpers, UiHelpers, ConstantHelper} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";
test.describe('Languages', () => {
test.beforeEach(async ({ page, umbracoApi }) => {
await umbracoApi.login();
});
test('Can add language', async ({ page, umbracoApi, umbracoUi }) => {
// For some reason the languages to chose from seems to be translated differently than normal, as an example:
// My system is set to EN (US), but most languages are translated into Danish for some reason
// Aghem seems untranslated though?
const name = "Aghem"; // Must be an option in the select box
await umbracoApi.languages.ensureNameNotExists(name);
await umbracoUi.goToSection(ConstantHelper.sections.settings);
await umbracoUi.waitForTreeLoad(ConstantHelper.sections.settings);
await umbracoUi.clickElement(umbracoUi.getTreeItem("settings", ["Languages"]));
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey("languages_addLanguage"));
await page.locator('select[name="newLang"]').selectOption({label: name});
await page.locator('.btn-success').click();
await umbracoUi.isSuccessNotificationVisible();
await umbracoApi.languages.ensureNameNotExists(name);
});
test('Deletes language', async ({ page, umbracoApi, umbracoUi }) => {
// Setup
const language1 = 'da';
const language2 = 'en-GB';
await umbracoApi.languages.ensureCultureNotExists(language1);
await umbracoApi.languages.ensureCultureNotExists(language2);
await umbracoApi.languages.createLanguage(language1, true, 1);
await umbracoApi.languages.createLanguage(language2, true, 1);
//Enter settings section and wait for everything to load
await umbracoUi.goToSection(ConstantHelper.sections.settings);
await umbracoUi.waitForTreeLoad(ConstantHelper.sections.settings);
// Enter language tree and select the language we just created
await umbracoUi.clickElement(umbracoUi.getTreeItem('settings', ['Languages']));
// Assert there are 3 languages
let languages = page.locator('tbody > tr');
await expect(languages).toHaveCount(3);
// Delete UK Language
await page.locator('umb-button[label-key="general_delete"]').last().click();
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey('contentTypeEditor_yesDelete'));
// Assert there is only 2 languages
await expect(page.locator('tbody > tr')).toHaveCount(2);
// Cleanup
await umbracoApi.languages.ensureCultureNotExists(language1);
await umbracoApi.languages.ensureCultureNotExists(language2);
});
});

View File

@@ -34,10 +34,10 @@ test.describe('Partial View Macro Files', () => {
await umbracoUi.setEditorHeaderName(name);
//Save
await page.locator('.btn-success').click();
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.save));
//Assert
await umbracoUi.isSuccessNotificationVisible();
await umbracoUi.isSuccessNotificationVisible({timeout:10000});
//Clean up
await cleanup(umbracoApi, name);
@@ -54,12 +54,12 @@ test.describe('Partial View Macro Files', () => {
// Type name
await umbracoUi.setEditorHeaderName(name);
// Save
await page.locator('.btn-success').click();
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.save));
// Assert
await umbracoUi.isSuccessNotificationVisible();
await umbracoUi.isSuccessNotificationVisible({timeout:10000});
// Clean
await cleanup(umbracoApi, name);
@@ -81,10 +81,10 @@ test.describe('Partial View Macro Files', () => {
await umbracoUi.setEditorHeaderName(name);
// Save
await page.locator('.btn-success').click();
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.save));
// Assert
await umbracoUi.isSuccessNotificationVisible();
await umbracoUi.isSuccessNotificationVisible({timeout:10000});
// Clean
await cleanup(umbracoApi, name);
@@ -144,7 +144,7 @@ test.describe('Partial View Macro Files', () => {
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.save));
// Assert
await umbracoUi.isSuccessNotificationVisible();
await umbracoUi.isSuccessNotificationVisible({timeout:10000});
await cleanup(umbracoApi, name);
});

View File

@@ -36,7 +36,7 @@ test.describe('Partial Views', () => {
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.save));
//Assert
await umbracoUi.isSuccessNotificationVisible();
await umbracoUi.isSuccessNotificationVisible({timeout:10000});
//Clean up
await umbracoApi.partialViews.ensureNameNotExists(fileName);
@@ -62,7 +62,7 @@ test.describe('Partial Views', () => {
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.save));
// Assert
await umbracoUi.isSuccessNotificationVisible();
await umbracoUi.isSuccessNotificationVisible({timeout:10000});
// Clean up
await umbracoApi.partialViews.ensureNameNotExists(fileName);
@@ -134,7 +134,8 @@ test.describe('Partial Views', () => {
await umbracoUi.clickElement(umbracoUi.getButtonByLabelKey(ConstantHelper.buttons.save));
// Assert
await umbracoUi.isSuccessNotificationVisible();
await umbracoUi.isSuccessNotificationVisible({timeout:10000});
// Clean
await umbracoApi.partialViews.ensureNameNotExists(fileName);
});