From caed5bcb13fd34f36e2d8d6622b4211fcd5f1147 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Tue, 6 Dec 2022 11:32:23 +0100 Subject: [PATCH] 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 Signed-off-by: Zeegaan Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com> --- .../package-lock.json | 14 +- .../Umbraco.Tests.AcceptanceTest/package.json | 2 +- .../blockListEditorContent.spec.ts | 484 ++++++++++++++++++ .../DefaultConfig/DataTypes/dataTypes.spec.ts | 6 +- .../DataTypes/textBoxVariation.spec.ts | 2 +- .../DefaultConfig/Languages/languages.spec.ts | 26 +- .../DefaultConfig/Settings/languages.spec.ts | 64 --- .../Settings/partialViewMacroFiles.spec.ts | 16 +- .../Settings/partialViews.spec.ts | 7 +- 9 files changed, 528 insertions(+), 93 deletions(-) create mode 100644 tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/BlockListEditor/blockListEditorContent.spec.ts delete mode 100644 tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/languages.spec.ts diff --git a/tests/Umbraco.Tests.AcceptanceTest/package-lock.json b/tests/Umbraco.Tests.AcceptanceTest/package-lock.json index 14f0a1b670..581bb822f8 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/package-lock.json +++ b/tests/Umbraco.Tests.AcceptanceTest/package-lock.json @@ -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", diff --git a/tests/Umbraco.Tests.AcceptanceTest/package.json b/tests/Umbraco.Tests.AcceptanceTest/package.json index 9390fa5341..6d72a2bd6e 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/package.json +++ b/tests/Umbraco.Tests.AcceptanceTest/package.json @@ -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", diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/BlockListEditor/blockListEditorContent.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/BlockListEditor/blockListEditorContent.spec.ts new file mode 100644 index 0000000000..e44a5cc87d --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/BlockListEditor/blockListEditorContent.spec.ts @@ -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\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;\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" + + "

@content.Title

" + + "

@content.Body

" + + "\n" + + "

@settings.Title

" + + "

@settings.Body

") + .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 = `

ContentTest

RTEContent

SettingTest

RTESetting

`; + await expect(await umbracoApi.content.verifyRenderedContent('/', expected, true)).toBeTruthy(); + + // Clean + await umbracoApi.templates.ensureNameNotExists(documentName); + await umbracoApi.partialViews.ensureNameNotExists(elementAlias + '.cshtml'); + }); +}); \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataTypes/dataTypes.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataTypes/dataTypes.spec.ts index ba6637c693..808858ab01 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataTypes/dataTypes.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataTypes/dataTypes.spec.ts @@ -53,7 +53,7 @@ test.describe('DataTypes', () => { // Assert const expected = `

Lorem ipsum dolor sit amet

`; 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 = '

Lorem ipsum dolor sit amet

'; @@ -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 = 'UrlPickerContent'; await expect(await umbracoApi.content.verifyRenderedContent('/', expected, true)).toBeTruthy(); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataTypes/textBoxVariation.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataTypes/textBoxVariation.spec.ts index 9222301db1..1cd66d12d2 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataTypes/textBoxVariation.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataTypes/textBoxVariation.spec.ts @@ -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); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Languages/languages.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Languages/languages.spec.ts index 6e6c2bf4e0..2d2bd6c6c7 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Languages/languages.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Languages/languages.spec.ts @@ -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); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/languages.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/languages.spec.ts deleted file mode 100644 index 879c696f65..0000000000 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/languages.spec.ts +++ /dev/null @@ -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); - }); -}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/partialViewMacroFiles.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/partialViewMacroFiles.spec.ts index 88939ab10f..94903f0a54 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/partialViewMacroFiles.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/partialViewMacroFiles.spec.ts @@ -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); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/partialViews.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/partialViews.spec.ts index c8dc16b51d..052642bed7 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/partialViews.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/partialViews.spec.ts @@ -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); });