V14 QA Added missing tests for Partial View, Stylesheet, Script, Template (#16059)

* Removed hard waits

* Updated tests for Template and Partial View - not done

* Added insert section tests

* Used defaultTemplateContent to avoid duplicate code

* Added insert section tests

* Added missing tests for Partial View

* Added missing tests for Scripts

* Added missing tests for Stylesheet

* Added missing tests for Template

* Changed method's name due to test helper changes

* Added skip tests

* Bumped version of test helper

* Reversed waits

* Changed createThreeDotsButton to createButton due to UI changes

* Removed List View - Members tests as the UI changes

* Added more waits

* Removed unnecessary waits
This commit is contained in:
Nhu Dinh
2024-04-16 17:12:09 +07:00
committed by GitHub
parent 9f6af970b4
commit 0988f4a7be
13 changed files with 544 additions and 213 deletions

View File

@@ -7,8 +7,8 @@
"name": "acceptancetest",
"hasInstallScript": true,
"dependencies": {
"@umbraco/json-models-builders": "^2.0.4",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.28",
"@umbraco/json-models-builders": "^2.0.5",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.33",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"faker": "^4.1.0",
@@ -132,9 +132,9 @@
}
},
"node_modules/@umbraco/json-models-builders": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@umbraco/json-models-builders/-/json-models-builders-2.0.4.tgz",
"integrity": "sha512-h+9ABeHNeFC2LWZbnJaOQFQitIhg82axxSnvWfg2+4TknDQyBCECq2bO7eizlLzHtU1uGGxShTueCDz04asFGQ==",
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/@umbraco/json-models-builders/-/json-models-builders-2.0.5.tgz",
"integrity": "sha512-Q9re+2yawW8/rkKiEdm2k3VKr1nlCWUhs17n5xOMBlsaFVVps0ZsmliSbIddf1OOWKuYU/uN0SKA3pn/GxV2fA==",
"dependencies": {
"camelize": "^1.0.1",
"faker": "^6.6.6"
@@ -146,11 +146,11 @@
"integrity": "sha512-9tCqYEDHI5RYFQigXFwF1hnCwcWCOJl/hmll0lr5D2Ljjb0o4wphb69wikeJDz5qCEzXCoPvG6ss5SDP6IfOdg=="
},
"node_modules/@umbraco/playwright-testhelpers": {
"version": "2.0.0-beta.28",
"resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-2.0.0-beta.28.tgz",
"integrity": "sha512-GL+N0VtGMYRE6IoOFPPxTodf7wpjoZ3MhZsfNE905vpMpOxokMpkBf2BiZ5q+owYhNx27gYCfxvTMTa6Y4B1dw==",
"version": "2.0.0-beta.33",
"resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-2.0.0-beta.33.tgz",
"integrity": "sha512-fGG/tSlIzzN4thhtYTTvIoXFsfEcKjtdtSkGVUVx1S/FanvI8EyUTlBzqV/6hIq0/wytsPMEvBsmy3AUunKvUQ==",
"dependencies": {
"@umbraco/json-models-builders": "2.0.4",
"@umbraco/json-models-builders": "2.0.5",
"camelize": "^1.0.0",
"faker": "^4.1.0",
"form-data": "^4.0.0",

View File

@@ -20,8 +20,8 @@
"wait-on": "^7.2.0"
},
"dependencies": {
"@umbraco/json-models-builders": "^2.0.4",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.28",
"@umbraco/json-models-builders": "^2.0.5",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.33",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"faker": "^4.1.0",

View File

@@ -18,7 +18,7 @@ test.describe('Data Types basic functionalities tests', () => {
test('can create a data type', async ({umbracoApi, umbracoUi}) => {
// Act
await umbracoUi.dataType.clickActionsMenuAtRoot();
await umbracoUi.dataType.clickCreateThreeDotsButton();
await umbracoUi.dataType.clickCreateButton();
await umbracoUi.dataType.clickNewDataTypeThreeDotsButton();
await umbracoUi.dataType.enterDataTypeName(dataTypeName);
await umbracoUi.dataType.clickSaveButton();

View File

@@ -19,7 +19,7 @@ test.describe('Data Types Folder tests', () => {
test('can create a data type folder', async ({umbracoApi, umbracoUi}) => {
// Act
await umbracoUi.dataType.clickActionsMenuAtRoot();
await umbracoUi.dataType.clickCreateThreeDotsButton();
await umbracoUi.dataType.clickCreateButton();
await umbracoUi.dataType.clickNewDataTypeFolderButton();
await umbracoUi.dataType.enterFolderName(dataTypeFolderName);
await umbracoUi.dataType.clickCreateFolderButton();
@@ -28,7 +28,8 @@ test.describe('Data Types Folder tests', () => {
expect(await umbracoApi.dataType.doesNameExist(dataTypeFolderName)).toBeTruthy();
});
test('can rename a data type folder', async ({umbracoApi, umbracoUi}) => {
// TODO: Remove skip due to the front-end changes. Need to update the rename folder locator.
test.skip('can rename a data type folder', async ({umbracoApi, umbracoUi}) => {
// Arrange
const wrongDataTypeFolderName = 'Wrong Folder';
await umbracoApi.dataType.ensureNameNotExists(wrongDataTypeFolderName);
@@ -68,7 +69,7 @@ test.describe('Data Types Folder tests', () => {
// Act
await umbracoUi.dataType.clickRootFolderCaretButton();
await umbracoUi.dataType.clickActionsMenuForDataType(dataTypeFolderName);
await umbracoUi.dataType.clickCreateThreeDotsButton();
await umbracoUi.dataType.clickCreateButton();
await umbracoUi.dataType.clickNewDataTypeThreeDotsButton();
await umbracoUi.dataType.enterDataTypeName(dataTypeName);
await umbracoUi.dataType.clickSaveButton();
@@ -90,7 +91,7 @@ test.describe('Data Types Folder tests', () => {
// Act
await umbracoUi.dataType.clickRootFolderCaretButton();
await umbracoUi.dataType.clickActionsMenuForDataType(dataTypeFolderName);
await umbracoUi.dataType.clickCreateThreeDotsButton();
await umbracoUi.dataType.clickCreateButton();
await umbracoUi.dataType.clickNewDataTypeFolderButton();
await umbracoUi.dataType.enterFolderName(childFolderName);
await umbracoUi.dataType.clickCreateFolderButton();

View File

@@ -1,7 +1,9 @@
import { test } from "@umbraco/playwright-testhelpers";
import { expect } from "@playwright/test";
const listViewTypes = ['List View - Content', 'List View - Media', 'List View - Members'];
// TODO: Added List View - Members to the list when the front-end is ready
//const listViewTypes = ['List View - Content', 'List View - Media', 'List View - Members'];
const listViewTypes = ['List View - Content', 'List View - Media'];
for (const listViewType of listViewTypes) {
test.describe(`${listViewType} tests`, () => {
let dataTypeDefaultData = null;

View File

@@ -5,6 +5,7 @@ test.describe('Partial View tests', () => {
const partialViewName = 'TestPartialView';
const partialViewFileName = partialViewName + '.cshtml';
const dictionaryName = 'TestDictionaryPartialView';
const defaultPartialViewContent = '@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n';
test.beforeEach(async ({umbracoUi, umbracoApi}) => {
await umbracoApi.partialView.ensureNameNotExists(partialViewFileName);
@@ -20,7 +21,7 @@ test.describe('Partial View tests', () => {
test('can create an empty partial view', async ({umbracoApi, umbracoUi}) => {
// Act
await umbracoUi.partialView.clickActionsMenuAtRoot();
await umbracoUi.partialView.clickCreateThreeDotsButton();
await umbracoUi.partialView.clickCreateButton();
await umbracoUi.partialView.clickNewEmptyPartialViewButton();
await umbracoUi.partialView.enterPartialViewName(partialViewName);
await umbracoUi.partialView.clickSaveButton();
@@ -30,7 +31,7 @@ test.describe('Partial View tests', () => {
expect(await umbracoApi.partialView.doesNameExist(partialViewFileName)).toBeTruthy();
// Verify the new partial view is displayed under the Partial Views section
await umbracoUi.partialView.clickRootFolderCaretButton();
await expect(umbracoUi.partialView.checkItemNameUnderPartialViewTree(partialViewFileName)).toBeVisible();
await umbracoUi.partialView.isPartialViewTreeItemVisibile(partialViewFileName);
})
test('can create a partial view from snippet', async ({umbracoApi, umbracoUi}) => {
@@ -40,11 +41,10 @@ test.describe('Partial View tests', () => {
// Act
await umbracoUi.partialView.clickActionsMenuAtRoot();
await umbracoUi.partialView.clickCreateThreeDotsButton();
await umbracoUi.partialView.clickCreateButton();
await umbracoUi.partialView.clickNewPartialViewFromSnippetButton();
await umbracoUi.partialView.clickBreadcrumbButton();
await umbracoUi.partialView.enterPartialViewName(partialViewName);
await umbracoUi.waitForTimeout(1000);
await umbracoUi.partialView.clickSaveButton();
// Assert
@@ -65,16 +65,16 @@ test.describe('Partial View tests', () => {
// Verify the new partial view is displayed under the Partial Views section
await umbracoUi.partialView.clickRootFolderCaretButton();
await expect(umbracoUi.partialView.checkItemNameUnderPartialViewTree(partialViewFileName)).toBeVisible();
await umbracoUi.partialView.isPartialViewTreeItemVisibile(partialViewFileName);
});
test.skip('can update a partial view name', async ({umbracoApi, umbracoUi}) => {
test('can rename a partial view', async ({umbracoApi, umbracoUi}) => {
// Arrange
const wrongPartialViewName = 'WrongName';
const wrongPartialViewFileName = wrongPartialViewName + '.cshtml';
await umbracoApi.partialView.ensureNameNotExists(wrongPartialViewFileName);
await umbracoApi.partialView.create(wrongPartialViewFileName, "@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n", "/");
await umbracoApi.partialView.create(wrongPartialViewFileName, defaultPartialViewContent, '/');
expect(await umbracoApi.partialView.doesExist(wrongPartialViewFileName)).toBeTruthy();
//Act
@@ -87,21 +87,20 @@ test.describe('Partial View tests', () => {
expect(await umbracoApi.partialView.doesNameExist(partialViewFileName)).toBeTruthy();
expect(await umbracoApi.partialView.doesNameExist(wrongPartialViewFileName)).toBeFalsy();
// Verify the old partial view is NOT displayed under the Partial Views section
await expect(umbracoUi.partialView.checkItemNameUnderPartialViewTree(wrongPartialViewFileName)).not.toBeVisible();
await umbracoUi.partialView.isPartialViewTreeItemVisibile(wrongPartialViewFileName, false);
// Verify the new partial view is displayed under the Partial Views section
await expect(umbracoUi.partialView.checkItemNameUnderPartialViewTree(partialViewFileName)).toBeVisible();
await umbracoUi.partialView.isPartialViewTreeItemVisibile(partialViewFileName);
});
test('can update a partial view content', async ({umbracoApi, umbracoUi}) => {
// Arrange
const updatedPartialViewContent = '@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n' +
const updatedPartialViewContent = defaultPartialViewContent +
'@{\r\n' +
'\tLayout = null;\r\n' +
'}\r\n' +
'<p>AcceptanceTests</p>';
await umbracoApi.partialView.create(partialViewFileName, "@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n", "/");
await umbracoApi.partialView.create(partialViewFileName, defaultPartialViewContent, '/');
expect(await umbracoApi.partialView.doesExist(partialViewFileName)).toBeTruthy();
//Act
@@ -110,18 +109,20 @@ test.describe('Partial View tests', () => {
await umbracoUi.partialView.clickSaveButton();
// Assert
await umbracoUi.partialView.isSuccessNotificationVisible();
const updatedPartialView = await umbracoApi.partialView.getByName(partialViewFileName);
expect(updatedPartialView.content).toBe(updatedPartialViewContent);
});
test('can use query builder with Order By statement for a partial view', async ({umbracoApi, umbracoUi}) => {
// Remove skip when the front-end is ready. Currently this function is not stable, sometimes the shown code is not updated after choosing Order By
test.skip('can use query builder with Order By statement for a partial view', async ({umbracoApi, umbracoUi}) => {
//Arrange
const propertyAliasValue = 'UpdateDate';
const isAscending = false;
const isAscending = true;
const expectedCode = 'Umbraco.ContentAtRoot().FirstOrDefault()\r\n' +
' .Children()\r\n' +
' .Where(x => x.IsVisible())\r\n' +
' .OrderByDescending(x => x.' + propertyAliasValue + ')';
' .OrderBy(x => x.' + propertyAliasValue + ')';
const expectedTemplateContent = '\r\n' +
'@{\r\n' +
'\tvar selection = ' + expectedCode + ';\r\n' +
@@ -134,16 +135,13 @@ test.describe('Partial View tests', () => {
'\t\t</li>\r\n' +
'\t}\r\n' +
'</ul>\r\n' +
'\r\n' +
'@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n';
'\r\n' + defaultPartialViewContent;
await umbracoApi.partialView.create(partialViewFileName, "@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n", "/");
await umbracoApi.partialView.create(partialViewFileName, defaultPartialViewContent, '/');
expect(await umbracoApi.partialView.doesExist(partialViewFileName)).toBeTruthy();
// Act
await umbracoUi.partialView.openPartialViewAtRoot(partialViewFileName);
// Wait for the partial view to open
await umbracoUi.waitForTimeout(1000);
await umbracoUi.partialView.addQueryBuilderWithOrderByStatement(propertyAliasValue, isAscending);
// Verify that the code is shown
await umbracoUi.partialView.isQueryBuilderCodeShown(expectedCode);
@@ -151,11 +149,12 @@ test.describe('Partial View tests', () => {
await umbracoUi.partialView.clickSaveButton();
// Assert
await umbracoUi.partialView.isSuccessNotificationVisible();
const updatedPartialView = await umbracoApi.partialView.getByName(partialViewFileName);
expect(updatedPartialView.content).toBe(expectedTemplateContent);
});
test.skip('can use query builder with Where statement for a partial view', async ({umbracoApi, umbracoUi}) => {
test('can use query builder with Where statement for a partial view', async ({umbracoApi, umbracoUi}) => {
//Arrange
const propertyAliasValue = 'Name';
const operatorValue = 'is';
@@ -176,16 +175,13 @@ test.describe('Partial View tests', () => {
'\t\t</li>\r\n' +
'\t}\r\n' +
'</ul>\r\n' +
'\r\n' +
'@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n';
'\r\n' + defaultPartialViewContent;
await umbracoApi.partialView.create(partialViewFileName, "@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n", "/");
await umbracoApi.partialView.create(partialViewFileName, defaultPartialViewContent, '/');
expect(await umbracoApi.partialView.doesExist(partialViewFileName)).toBeTruthy();
// Act
await umbracoUi.partialView.openPartialViewAtRoot(partialViewFileName);
// Wait for the partial view to open
await umbracoUi.waitForTimeout(1000);
await umbracoUi.partialView.addQueryBuilderWithWhereStatement(propertyAliasValue, operatorValue, constrainValue);
// Verify that the code is shown
await umbracoUi.partialView.isQueryBuilderCodeShown(expectedCode);
@@ -193,47 +189,95 @@ test.describe('Partial View tests', () => {
await umbracoUi.partialView.clickSaveButton();
// Assert
await umbracoUi.partialView.isSuccessNotificationVisible();
const updatedPartialView = await umbracoApi.partialView.getByName(partialViewFileName);
expect(updatedPartialView.content).toBe(expectedTemplateContent);
});
test('can insert dictionaryItem into a partial view', async ({umbracoApi, umbracoUi}) => {
test('can insert dictionary item into a partial view', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.partialView.create(partialViewFileName, "@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n", "/");
await umbracoApi.partialView.create(partialViewFileName, defaultPartialViewContent, '/');
expect(await umbracoApi.partialView.doesExist(partialViewFileName)).toBeTruthy();
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
await umbracoApi.dictionary.create(dictionaryName);
const partialViewContent = '@Umbraco.GetDictionaryValue("' + dictionaryName + '")@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n';
const partialViewContent = '@Umbraco.GetDictionaryValue("' + dictionaryName + '")' + defaultPartialViewContent;
// Act
await umbracoUi.partialView.openPartialViewAtRoot(partialViewFileName);
// Wait for the partial view to open
await umbracoUi.waitForTimeout(1000);
await umbracoUi.partialView.insertDictionaryByName(dictionaryName);
await umbracoUi.partialView.insertDictionaryItem(dictionaryName);
await umbracoUi.partialView.clickSaveButton();
// Assert
await umbracoUi.partialView.isSuccessNotificationVisible();
const partialViewData = await umbracoApi.partialView.getByName(partialViewFileName);
expect(partialViewData.content).toBe(partialViewContent);
});
test('can insert value into a partial view', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.partialView.create(partialViewFileName, defaultPartialViewContent, '/');
expect(await umbracoApi.partialView.doesExist(partialViewFileName)).toBeTruthy();
const systemFieldValue = 'createDate';
const partialViewContent = '@Model.Value("' + systemFieldValue + '")' + defaultPartialViewContent;
// Act
await umbracoUi.partialView.openPartialViewAtRoot(partialViewFileName);
await umbracoUi.waitForTimeout(1000);
await umbracoUi.template.insertSystemFieldValue(systemFieldValue);
await umbracoUi.template.clickSaveButton();
// Assert
await umbracoUi.partialView.isSuccessNotificationVisible();
const partialViewData = await umbracoApi.partialView.getByName(partialViewFileName);
expect(partialViewData.content).toBe(partialViewContent);
});
test('can delete a partial view', async ({umbracoApi, umbracoUi}) => {
//Arrange
await umbracoApi.partialView.create(partialViewFileName, "@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n", "/");
await umbracoApi.partialView.create(partialViewFileName, partialViewFileName, '/');
expect(await umbracoApi.partialView.doesExist(partialViewFileName)).toBeTruthy();
//Act
await umbracoUi.partialView.clickRootFolderCaretButton();
await umbracoUi.partialView.clickActionsMenuForPartialView(partialViewFileName);
await umbracoUi.partialView.deletePartialView();
await umbracoUi.partialView.clickDeleteAndConfirmButton();
// Assert
await umbracoUi.partialView.isSuccessNotificationVisible();
expect(await umbracoApi.partialView.doesExist(partialViewFileName)).toBeFalsy();
// Verify the partial view is NOT displayed under the Partial Views section
await umbracoUi.partialView.clickRootFolderCaretButton();
await expect(umbracoUi.partialView.checkItemNameUnderPartialViewTree(partialViewFileName)).not.toBeVisible();
await umbracoUi.partialView.isPartialViewTreeItemVisibile(partialViewFileName, false);
});
// TODO: Remove skip when the front-end is ready. Currently the returned items count is not updated after choosing the root content.
test.skip('can show returned items in query builder ', async ({umbracoApi, umbracoUi}) => {
//Arrange
// Create content at root with a child
const documentTypeName = 'ParentDocumentType';
const childDocumentTypeName = 'ChildDocumentType';
const contentName = 'ContentName';
const childContentName = 'ChildContentName';
const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(childDocumentTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNode(documentTypeName, childDocumentTypeId);
const contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
// Create partial view
await umbracoApi.partialView.create(partialViewFileName, partialViewFileName, '/');
expect(await umbracoApi.partialView.doesExist(partialViewFileName)).toBeTruthy();
//Act
await umbracoUi.partialView.openPartialViewAtRoot(partialViewFileName);
await umbracoUi.partialView.clickQueryBuilderButton();
await umbracoUi.partialView.chooseRootContentInQueryBuilder('(' + contentName + ')');
// Assert
await umbracoUi.partialView.doesReturnedItemsHaveCount(1);
await umbracoUi.partialView.doesQueryResultHaveContentName(childContentName);
// Clean
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
});
});

View File

@@ -26,7 +26,7 @@ test.describe('Partial View Folder tests', () => {
expect(await umbracoApi.partialView.doesFolderExist(folderName)).toBeTruthy();
// Verify the partial view folder is displayed under the Partial Views section
await umbracoUi.partialView.clickRootFolderCaretButton();
await expect(umbracoUi.partialView.checkItemNameUnderPartialViewTree(folderName)).toBeVisible();
await umbracoUi.partialView.isPartialViewTreeItemVisibile(folderName);
});
test('can delete a folder', async ({umbracoApi, umbracoUi}) => {
@@ -44,7 +44,7 @@ test.describe('Partial View Folder tests', () => {
expect(await umbracoApi.partialView.doesFolderExist(folderName)).toBeFalsy();
// Verify the partial view folder is NOT displayed under the Partial Views section
await umbracoUi.partialView.clickRootFolderCaretButton();
await expect(umbracoUi.partialView.checkItemNameUnderPartialViewTree(folderName)).not.toBeVisible();
await umbracoUi.partialView.isPartialViewTreeItemVisibile(folderName, false);
});
test('can place a partial view into folder', async ({umbracoApi, umbracoUi}) => {
@@ -56,7 +56,7 @@ test.describe('Partial View Folder tests', () => {
// Act
await umbracoUi.partialView.clickRootFolderCaretButton();
await umbracoUi.partialView.clickActionsMenuForPartialView(folderName);
await umbracoUi.partialView.clickCreateThreeDotsButton();
await umbracoUi.partialView.clickCreateButton();
await umbracoUi.partialView.clickNewEmptyPartialViewButton();
await umbracoUi.partialView.enterPartialViewName(partialViewName);
await umbracoUi.partialView.clickSaveButton();
@@ -66,8 +66,49 @@ test.describe('Partial View Folder tests', () => {
const childrenData = await umbracoApi.partialView.getChildren(folderPath);
expect(childrenData[0].name).toEqual(partialViewFileName);
// Verify the partial view is displayed in the folder under the Partial Views section
await expect(umbracoUi.partialView.checkItemNameUnderPartialViewTree(partialViewFileName)).not.toBeVisible();
await umbracoUi.partialView.isPartialViewTreeItemVisibile(partialViewFileName, false);
await umbracoUi.partialView.clickCaretButtonForName(folderName);
await expect(umbracoUi.partialView.checkItemNameUnderPartialViewTree(partialViewFileName)).toBeVisible();
await umbracoUi.partialView.isPartialViewTreeItemVisibile(partialViewFileName);
});
test('can create a folder in a folder', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.partialView.createFolder(folderName);
const childFolderName = 'childFolderName';
// Act
await umbracoUi.partialView.clickRootFolderCaretButton();
await umbracoUi.partialView.clickActionsMenuForPartialView(folderName);
await umbracoUi.partialView.createFolder(childFolderName);
// Assert
await umbracoUi.partialView.isSuccessNotificationVisible();
expect(await umbracoApi.partialView.doesNameExist(childFolderName)).toBeTruthy();
const partialViewChildren = await umbracoApi.partialView.getChildren('/' + folderName);
expect(partialViewChildren[0].path).toBe('/' + folderName + '/' + childFolderName);
await umbracoUi.partialView.clickCaretButtonForName(folderName);
await umbracoUi.partialView.isPartialViewTreeItemVisibile(childFolderName);
});
test('can create a folder in a folder in a folder', async ({umbracoApi, umbracoUi}) => {
// Arrange
const childFolderName = 'ChildFolderName';
const childOfChildFolderName = 'ChildOfChildFolderName';
await umbracoApi.partialView.createFolder(folderName);
await umbracoApi.partialView.createFolder(childFolderName, folderName);
// Act
await umbracoUi.partialView.clickRootFolderCaretButton();
await umbracoUi.partialView.clickCaretButtonForName(folderName);
await umbracoUi.partialView.clickActionsMenuForPartialView(childFolderName);
await umbracoUi.partialView.createFolder(childOfChildFolderName);
// Assert
await umbracoUi.partialView.isSuccessNotificationVisible();
expect(await umbracoApi.partialView.doesNameExist(childOfChildFolderName)).toBeTruthy();
const partialViewChildren = await umbracoApi.partialView.getChildren('/' + folderName + '/' + childFolderName);
expect(partialViewChildren[0].path).toBe('/' + folderName + '/' + childFolderName + '/' + childOfChildFolderName);
await umbracoUi.partialView.clickCaretButtonForName(childFolderName);
await umbracoUi.partialView.isPartialViewTreeItemVisibile(childOfChildFolderName);
});
});

View File

@@ -18,18 +18,16 @@ test.describe('Script tests', () => {
test('can create a empty script', async ({umbracoApi, umbracoUi}) => {
// Act
await umbracoUi.script.clickActionsMenuAtRoot();
await umbracoUi.script.clickCreateThreeDotsButton();
await umbracoUi.script.clickCreateButton();
await umbracoUi.script.clickNewJavascriptFileButton();
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.script.enterScriptName(scriptName);
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.script.clickSaveButton();
// Assert
await umbracoUi.script.isSuccessNotificationVisible();
expect(await umbracoApi.script.doesNameExist(scriptName)).toBeTruthy();
await umbracoUi.script.clickRootFolderCaretButton();
await umbracoUi.script.isScriptTreeItemVisibile(scriptName);
});
test('can create a script with content', async ({umbracoApi, umbracoUi}) => {
@@ -38,14 +36,10 @@ test.describe('Script tests', () => {
// Act
await umbracoUi.script.clickActionsMenuAtRoot();
await umbracoUi.script.clickCreateThreeDotsButton();
await umbracoUi.script.clickCreateButton();
await umbracoUi.script.clickNewJavascriptFileButton();
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.script.enterScriptName(scriptName);
await umbracoUi.script.enterScriptContent(scriptContent);
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.script.clickSaveButton();
// Assert
@@ -53,6 +47,8 @@ test.describe('Script tests', () => {
expect(await umbracoApi.script.doesNameExist(scriptName)).toBeTruthy();
const scriptData = await umbracoApi.script.getByName(scriptName);
expect(scriptData.content).toBe(scriptContent);
await umbracoUi.script.clickRootFolderCaretButton();
await umbracoUi.script.isScriptTreeItemVisibile(scriptName);
});
test('can update a script', async ({umbracoApi, umbracoUi}) => {
@@ -62,16 +58,11 @@ test.describe('Script tests', () => {
// Act
await umbracoUi.script.openScriptAtRoot(scriptName);
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.script.enterScriptContent(updatedScriptContent);
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.script.clickSaveButton();
// Assert
// TODO: Uncomment when the notification is visible. Currently there is no notification after you update a script
// await umbracoUi.script.isSuccessNotificationVisible();
await umbracoUi.script.isSuccessNotificationVisible();
const updatedScript = await umbracoApi.script.get(scriptPath);
expect(updatedScript.content).toBe(updatedScriptContent);
});
@@ -83,10 +74,27 @@ test.describe('Script tests', () => {
// Act
await umbracoUi.script.clickRootFolderCaretButton();
await umbracoUi.script.clickActionsMenuForScript(scriptName);
await umbracoUi.script.deleteScript();
await umbracoUi.script.clickDeleteAndConfirmButton();
// Assert
await umbracoUi.script.isSuccessNotificationVisible();
expect(await umbracoApi.script.doesNameExist(scriptName)).toBeFalsy();
await umbracoUi.script.isScriptTreeItemVisibile(scriptName, false);
});
test('can rename a script', async ({umbracoApi, umbracoUi}) => {
// Arrange
const wrongScriptName = 'WrongTestScript.js';
await umbracoApi.script.create(wrongScriptName, '');
// Act
await umbracoUi.script.clickRootFolderCaretButton();
await umbracoUi.script.clickActionsMenuForScript(wrongScriptName);
await umbracoUi.script.rename(scriptName);
// Assert
await umbracoUi.script.isSuccessNotificationVisible();
expect(await umbracoApi.script.doesNameExist(scriptName)).toBeTruthy();
expect(await umbracoApi.script.doesNameExist(wrongScriptName)).toBeFalsy();
});
});

View File

@@ -23,6 +23,8 @@ test.describe('Script tests', () => {
// Assert
await umbracoUi.script.isSuccessNotificationVisible();
expect(await umbracoApi.script.doesFolderExist(scriptFolderName)).toBeTruthy();
await umbracoUi.script.clickRootFolderCaretButton();
await umbracoUi.script.isScriptTreeItemVisibile(scriptFolderName);
});
test('can delete a folder', async ({umbracoApi, umbracoUi}) => {
@@ -37,6 +39,7 @@ test.describe('Script tests', () => {
// Assert
await umbracoUi.script.isSuccessNotificationVisible();
expect(await umbracoApi.script.doesFolderExist(scriptFolderName)).toBeFalsy();
await umbracoUi.script.isScriptTreeItemVisibile(scriptFolderName, false);
});
test('can create a script in a folder', async ({umbracoApi, umbracoUi}) => {
@@ -47,24 +50,21 @@ test.describe('Script tests', () => {
// Act
await umbracoUi.script.clickRootFolderCaretButton();
await umbracoUi.script.clickActionsMenuForScript(scriptFolderName);
await umbracoUi.script.clickCreateThreeDotsButton();
await umbracoUi.script.clickCreateButton();
await umbracoUi.script.clickNewJavascriptFileButton();
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.script.enterScriptName(scriptName);
await umbracoUi.script.enterScriptContent(scriptContent);
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.script.clickSaveButton();
// Assert
await umbracoUi.script.isSuccessNotificationVisible();
// TODO: Check if the script was created correctly in the UI when the refresh button is implemented
expect(await umbracoApi.script.doesNameExist(scriptName)).toBeTruthy();
const scriptChildren = await umbracoApi.script.getChildren('/' + scriptFolderName);
expect(scriptChildren[0].path).toBe('/' + scriptFolderName + '/' + scriptName);
const scriptData = await umbracoApi.script.get(scriptChildren[0].path);
expect(scriptData.content).toBe(scriptContent);
await umbracoUi.stylesheet.clickCaretButtonForName(scriptFolderName);
await umbracoUi.script.isScriptTreeItemVisibile(scriptName);
});
test('can create a folder in a folder', async ({umbracoApi, umbracoUi}) => {
@@ -79,10 +79,11 @@ test.describe('Script tests', () => {
// Assert
await umbracoUi.script.isSuccessNotificationVisible();
// TODO: Check if the folder was created correctly in the UI when the refresh button is implemented
expect(await umbracoApi.script.doesNameExist(childFolderName)).toBeTruthy();
const scriptChildren = await umbracoApi.script.getChildren('/' + scriptFolderName);
expect(scriptChildren[0].path).toBe('/' + scriptFolderName + '/' + childFolderName);
await umbracoUi.stylesheet.clickCaretButtonForName(scriptFolderName);
await umbracoUi.script.isScriptTreeItemVisibile(childFolderName);
});
test('can create a folder in a folder in a folder', async ({umbracoApi, umbracoUi}) => {
@@ -100,10 +101,11 @@ test.describe('Script tests', () => {
// Assert
await umbracoUi.script.isSuccessNotificationVisible();
// TODO: Check if the folder was created correctly in the UI when the refresh button is implemented
expect(await umbracoApi.script.doesNameExist(childOfChildFolderName)).toBeTruthy();
const scriptChildren = await umbracoApi.script.getChildren('/' + scriptFolderName + '/' + childFolderName);
expect(scriptChildren[0].path).toBe('/' + scriptFolderName + '/' + childFolderName + '/' + childOfChildFolderName);
await umbracoUi.stylesheet.clickCaretButtonForName(childFolderName);
await umbracoUi.script.isScriptTreeItemVisibile(childOfChildFolderName);
});
test('can create a script in a folder in a folder', async ({umbracoApi, umbracoUi}) => {
@@ -116,21 +118,17 @@ test.describe('Script tests', () => {
await umbracoUi.script.clickRootFolderCaretButton();
await umbracoUi.script.clickCaretButtonForName(scriptFolderName);
await umbracoUi.script.clickActionsMenuForScript(childFolderName);
await umbracoUi.script.clickCreateThreeDotsButton();
await umbracoUi.script.clickCreateButton();
await umbracoUi.script.clickNewJavascriptFileButton();
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.script.enterScriptName(scriptName);
await umbracoUi.script.enterScriptName(scriptName);
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.script.clickSaveButton();
// Assert
await umbracoUi.script.isSuccessNotificationVisible();
// TODO: Check if the script was created correctly in the UI when the refresh button is implemented
expect(await umbracoApi.script.doesNameExist(scriptName)).toBeTruthy();
const scriptChildren = await umbracoApi.script.getChildren('/' + scriptFolderName + '/' + childFolderName);
expect(scriptChildren[0].path).toBe('/' + scriptFolderName + '/' + childFolderName + '/' + scriptName);
await umbracoUi.stylesheet.clickCaretButtonForName(childFolderName);
await umbracoUi.script.isScriptTreeItemVisibile(scriptName);
});
});

View File

@@ -3,7 +3,9 @@ import {expect} from '@playwright/test';
test.describe('Stylesheets tests', () => {
const stylesheetName = 'TestStyleSheetFile.css';
const ruleName = 'TestRuleName';
const styleName = 'TestStyleName';
const styleSelector = 'h1';
const styleStyles = 'color:red';
test.beforeEach(async ({umbracoUi,umbracoApi}) => {
await umbracoUi.goToBackOffice();
@@ -18,19 +20,16 @@ test.describe('Stylesheets tests', () => {
test('can create a empty stylesheet', async ({umbracoApi, umbracoUi}) => {
// Act
await umbracoUi.stylesheet.clickActionsMenuAtRoot();
await umbracoUi.stylesheet.clickCreateThreeDotsButton();
await umbracoUi.stylesheet.clickCreateButton();
await umbracoUi.stylesheet.clickNewStylesheetButton();
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.stylesheet.enterStylesheetName(stylesheetName);
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.stylesheet.clickSaveButton();
// Assert
await umbracoUi.stylesheet.isSuccessNotificationVisible();
expect(await umbracoApi.stylesheet.doesNameExist(stylesheetName)).toBeTruthy();
// TODO: when frontend is ready, verify the new stylesheet is displayed under the Stylesheets section
await umbracoUi.stylesheet.clickRootFolderCaretButton();
await umbracoUi.stylesheet.isStylesheetTreeItemVisibile(stylesheetName);
});
test('can create a stylesheet with content', async ({umbracoApi, umbracoUi}) => {
@@ -39,61 +38,57 @@ test.describe('Stylesheets tests', () => {
//Act
await umbracoUi.stylesheet.clickActionsMenuAtRoot();
await umbracoUi.stylesheet.clickCreateThreeDotsButton();
await umbracoUi.stylesheet.clickCreateButton();
await umbracoUi.stylesheet.clickNewStylesheetButton();
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.stylesheet.enterStylesheetName(stylesheetName);
await umbracoUi.stylesheet.enterStylesheetContent(stylesheetContent);
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.stylesheet.clickSaveButton();
// Assert
await umbracoUi.stylesheet.isSuccessNotificationVisible();
expect(await umbracoApi.stylesheet.doesNameExist(stylesheetName)).toBeTruthy();
// TODO: when frontend is ready, verify the new stylesheet is displayed under the Stylesheets section
const stylesheetData = await umbracoApi.stylesheet.getByName(stylesheetName);
expect(stylesheetData.content).toEqual(stylesheetContent);
await umbracoUi.stylesheet.clickRootFolderCaretButton();
await umbracoUi.stylesheet.isStylesheetTreeItemVisibile(stylesheetName);
});
// We are not able to create stylesheet with RTE styles.
test.skip('can create a new Rich Text Editor stylesheet file', async ({umbracoApi, umbracoUi}) => {
test('can create a new Rich Text Editor stylesheet file', async ({umbracoApi, umbracoUi}) => {
// Arrange
const stylesheetContent = '/**umb_name:' + styleName + '*/\n' + styleSelector + ' {\n\t' + styleStyles + '\n}';
//Act
await umbracoUi.stylesheet.clickActionsMenuAtRoot();
await umbracoUi.stylesheet.clickCreateThreeDotsButton();
await umbracoUi.stylesheet.clickCreateButton();
await umbracoUi.stylesheet.clickNewRichTextEditorStylesheetButton();
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.stylesheet.enterStylesheetName(stylesheetName);
await umbracoUi.stylesheet.addNewRule(ruleName, 'h1', 'color:red');
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.stylesheet.addRTEStyle(styleName, styleSelector, styleStyles);
await umbracoUi.stylesheet.clickSaveButton();
// Assert
await umbracoUi.stylesheet.isSuccessNotificationVisible();
expect(await umbracoApi.stylesheet.doesExist(stylesheetName)).toBeTruthy();
expect(await umbracoApi.stylesheet.doesRuleNameExist(stylesheetName, ruleName)).toBeTruthy();
// TODO: when frontend is ready, verify the new stylesheet is displayed under the Stylesheets section
const stylesheetData = await umbracoApi.stylesheet.getByName(stylesheetName);
expect(stylesheetData.content).toEqual(stylesheetContent);
await umbracoUi.stylesheet.clickRootFolderCaretButton();
await umbracoUi.stylesheet.isStylesheetTreeItemVisibile(stylesheetName);
});
// We are not able to update a stylesheet with RTE styles.
test.skip('can update a stylesheet', async ({umbracoApi, umbracoUi}) => {
test('can update a stylesheet', async ({umbracoApi, umbracoUi}) => {
// Arrange
const stylesheetContent = '/**umb_name:' + styleName + '*/\n' + styleSelector + ' {\n\t' + styleStyles + '\n}';
await umbracoApi.stylesheet.create(stylesheetName, '', '/');
expect(await umbracoApi.stylesheet.doesExist(stylesheetName)).toBeTruthy();
//Act
await umbracoUi.stylesheet.openStylesheetByNameAtRoot(stylesheetName);
await umbracoUi.stylesheet.addNewRule(ruleName, 'h1', 'color:red');
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.stylesheet.addRTEStyle(styleName, styleSelector, styleStyles);
await umbracoUi.stylesheet.clickSaveButton();
// Assert
// await umbracoUi.stylesheet.isSuccessNotificationVisible();
expect(await umbracoApi.stylesheet.doesRuleNameExist(stylesheetName, ruleName)).toBeTruthy();
// TODO: when frontend is ready, verify the notification displays
await umbracoUi.stylesheet.isSuccessNotificationVisible();
const stylesheetData = await umbracoApi.stylesheet.getByName(stylesheetName);
expect(stylesheetData.content).toEqual(stylesheetContent);
});
test('can delete a stylesheet', async ({umbracoApi, umbracoUi}) => {
@@ -103,12 +98,65 @@ test.describe('Stylesheets tests', () => {
//Act
await umbracoUi.stylesheet.clickRootFolderCaretButton();
await umbracoUi.stylesheet.clickActionsMenuForStylesheet(stylesheetName);
await umbracoUi.stylesheet.deleteStylesheet();
await umbracoUi.stylesheet.clickDeleteAndConfirmButton();
// Assert
await umbracoUi.stylesheet.isSuccessNotificationVisible();
expect(await umbracoApi.stylesheet.doesNameExist(stylesheetName)).toBeFalsy();
// TODO: when frontend is ready, verify the new stylesheet is NOT displayed under the Stylesheets section
// TODO: when frontend is ready, verify the notification displays
await umbracoUi.stylesheet.isStylesheetTreeItemVisibile(stylesheetName, false);
});
test('can rename a stylesheet', async ({umbracoApi, umbracoUi}) => {
// Arrange
const wrongStylesheetName = 'WrongStylesheetName.css';
await umbracoApi.stylesheet.create(wrongStylesheetName, '', '/');
//Act
await umbracoUi.stylesheet.clickRootFolderCaretButton();
await umbracoUi.stylesheet.clickActionsMenuForStylesheet(wrongStylesheetName);
await umbracoUi.stylesheet.rename(stylesheetName);
// Assert
await umbracoUi.stylesheet.isSuccessNotificationVisible();
expect(await umbracoApi.stylesheet.doesNameExist(stylesheetName)).toBeTruthy();
expect(await umbracoApi.stylesheet.doesNameExist(wrongStylesheetName)).toBeFalsy();
});
test('can edit rich text editor styles', async ({umbracoApi, umbracoUi}) => {
// Arrange
const newStyleName = 'TestNewStyleName';
const newStyleSelector = 'h2';
const newStyleStyles = 'color: white';
const newStylesheetContent = '/**umb_name:' + newStyleName + '*/\n' + newStyleSelector + ' {\n\t' + newStyleStyles + '\n}';
const stylesheetContent = '/**umb_name:' + styleName + '*/\n' + styleSelector + ' {\n\t' + styleStyles + '\n}';
await umbracoApi.stylesheet.create(stylesheetName, stylesheetContent, '/');
expect(await umbracoApi.stylesheet.doesExist(stylesheetName)).toBeTruthy();
//Act
await umbracoUi.stylesheet.openStylesheetByNameAtRoot(stylesheetName);
await umbracoUi.stylesheet.editRTEStyle(styleName, newStyleName, newStyleSelector, newStyleStyles);
await umbracoUi.stylesheet.clickSaveButton();
// Assert
await umbracoUi.stylesheet.isSuccessNotificationVisible();
const stylesheetData = await umbracoApi.stylesheet.getByName(stylesheetName);
expect(stylesheetData.content).toEqual(newStylesheetContent);
});
test('can remove rich text editor styles', async ({umbracoApi, umbracoUi}) => {
// Arrange
const stylesheetContent = '/**umb_name:' + styleName + '*/\n' + styleSelector + ' {\n\t' + styleStyles + '\n}';
await umbracoApi.stylesheet.create(stylesheetName, stylesheetContent, '/');
expect(await umbracoApi.stylesheet.doesExist(stylesheetName)).toBeTruthy();
//Act
await umbracoUi.stylesheet.openStylesheetByNameAtRoot(stylesheetName);
await umbracoUi.stylesheet.removeRTEStyle(styleName);
await umbracoUi.stylesheet.clickSaveButton();
// Assert
await umbracoUi.stylesheet.isSuccessNotificationVisible();
const stylesheetData = await umbracoApi.stylesheet.getByName(stylesheetName);
expect(stylesheetData.content).toEqual('');
});
});

View File

@@ -23,7 +23,8 @@ test.describe('Stylesheets tests', () => {
// Assert
await umbracoUi.stylesheet.isSuccessNotificationVisible();
expect(await umbracoApi.stylesheet.doesFolderExist(stylesheetFolderName)).toBeTruthy();
// TODO: when frontend is ready, verify the new folder is displayed under the Stylesheets section
await umbracoUi.stylesheet.clickRootFolderCaretButton();
await umbracoUi.stylesheet.isStylesheetTreeItemVisibile(stylesheetFolderName);
});
test('can delete a folder', async ({umbracoApi, umbracoUi}) => {
@@ -38,7 +39,7 @@ test.describe('Stylesheets tests', () => {
// Assert
await umbracoUi.stylesheet.isSuccessNotificationVisible();
expect(await umbracoApi.stylesheet.doesFolderExist(stylesheetFolderName)).toBeFalsy();
// TODO: when frontend is ready, verify the removed folder is NOT displayed under the Stylesheets section
await umbracoUi.stylesheet.isStylesheetTreeItemVisibile(stylesheetFolderName, false);
});
test('can create a folder in a folder', async ({umbracoApi, umbracoUi}) => {
@@ -56,7 +57,8 @@ test.describe('Stylesheets tests', () => {
expect(await umbracoApi.stylesheet.doesNameExist(childFolderName)).toBeTruthy();
const styleChildren = await umbracoApi.stylesheet.getChildren('/' + stylesheetFolderName);
expect(styleChildren[0].path).toBe('/' + stylesheetFolderName + '/' + childFolderName);
// TODO: when frontend is ready, verify the new folder is displayed under the Stylesheets section
await umbracoUi.stylesheet.clickCaretButtonForName(stylesheetFolderName);
await umbracoUi.stylesheet.isStylesheetTreeItemVisibile(childFolderName);
});
test('can create a folder in a folder in a folder', async ({umbracoApi, umbracoUi}) => {
@@ -77,7 +79,8 @@ test.describe('Stylesheets tests', () => {
expect(await umbracoApi.stylesheet.doesNameExist(childOfChildFolderName)).toBeTruthy();
const styleChildren = await umbracoApi.stylesheet.getChildren('/' + stylesheetFolderName + '/' + childFolderName);
expect(styleChildren[0].path).toBe('/' + stylesheetFolderName + '/' + childFolderName + '/' + childOfChildFolderName);
// TODO: when frontend is ready, verify the new folder is displayed under the Stylesheets section
await umbracoUi.stylesheet.clickCaretButtonForName(childFolderName);
await umbracoUi.stylesheet.isStylesheetTreeItemVisibile(childOfChildFolderName);
});
test('can create a stylesheet in a folder', async ({umbracoApi, umbracoUi}) => {
@@ -88,25 +91,21 @@ test.describe('Stylesheets tests', () => {
//Act
await umbracoUi.stylesheet.clickRootFolderCaretButton();
await umbracoUi.stylesheet.clickActionsMenuForStylesheet(stylesheetFolderName);
await umbracoUi.stylesheet.clickCreateThreeDotsButton();
await umbracoUi.stylesheet.clickCreateButton();
await umbracoUi.stylesheet.clickNewStylesheetButton();
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.stylesheet.enterStylesheetName(stylesheetName);
await umbracoUi.stylesheet.enterStylesheetContent(stylesheetContent);
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.stylesheet.clickSaveButton();
// Assert
await umbracoUi.stylesheet.isSuccessNotificationVisible();
expect(await umbracoApi.stylesheet.doesNameExist(stylesheetName)).toBeTruthy();
// TODO: when frontend is ready, verify the new stylesheet is displayed under the Stylesheets section
expect(await umbracoApi.stylesheet.doesNameExist(stylesheetName)).toBeTruthy();
const stylesheetChildren = await umbracoApi.stylesheet.getChildren('/' + stylesheetFolderName);
expect(stylesheetChildren[0].path).toBe('/' + stylesheetFolderName + '/' + stylesheetName);
const stylesheetData = await umbracoApi.stylesheet.get(stylesheetChildren[0].path);
expect(stylesheetData.content).toBe(stylesheetContent);
await umbracoUi.stylesheet.clickCaretButtonForName(stylesheetFolderName);
await umbracoUi.stylesheet.isStylesheetTreeItemVisibile(stylesheetName);
});
test('can create a stylesheet in a folder in a folder', async ({umbracoApi, umbracoUi}) => {
@@ -120,24 +119,20 @@ test.describe('Stylesheets tests', () => {
await umbracoUi.stylesheet.clickRootFolderCaretButton();
await umbracoUi.stylesheet.clickCaretButtonForName(stylesheetFolderName);
await umbracoUi.stylesheet.clickActionsMenuForStylesheet(childFolderName);
await umbracoUi.stylesheet.clickCreateThreeDotsButton();
await umbracoUi.stylesheet.clickCreateButton();
await umbracoUi.stylesheet.clickNewStylesheetButton();
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.stylesheet.enterStylesheetName(stylesheetName);
await umbracoUi.stylesheet.enterStylesheetContent(stylesheetContent);
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(500);
await umbracoUi.stylesheet.clickSaveButton();
// Assert
await umbracoUi.stylesheet.isSuccessNotificationVisible();
expect(await umbracoApi.stylesheet.doesNameExist(stylesheetName)).toBeTruthy();
// TODO: when frontend is ready, verify the new stylesheet is displayed under the Stylesheets section
expect(await umbracoApi.stylesheet.doesNameExist(stylesheetName)).toBeTruthy();
const stylesheetChildren = await umbracoApi.stylesheet.getChildren('/' + stylesheetFolderName + '/' + childFolderName);
expect(stylesheetChildren[0].path).toBe('/' + stylesheetFolderName + '/' + childFolderName + '/' + stylesheetName);
const stylesheetData = await umbracoApi.stylesheet.get(stylesheetChildren[0].path);
expect(stylesheetData.content).toBe(stylesheetContent);
await umbracoUi.stylesheet.clickCaretButtonForName(childFolderName);
await umbracoUi.stylesheet.isStylesheetTreeItemVisibile(stylesheetName);
});
});

View File

@@ -3,6 +3,7 @@ import {expect} from "@playwright/test";
test.describe('Template tests', () => {
const templateName = 'TestTemplate';
const defaultTemplateContent = '@using Umbraco.Cms.Web.Common.PublishedModels;\r\n@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n@{\r\n\tLayout = null;\r\n}';
test.beforeEach(async ({umbracoUi, umbracoApi}) => {
await umbracoApi.template.ensureNameNotExists(templateName);
@@ -14,31 +15,26 @@ test.describe('Template tests', () => {
await umbracoApi.template.ensureNameNotExists(templateName);
});
test.skip('can create a template', async ({umbracoApi, umbracoUi}) => {
test('can create a template', async ({umbracoApi, umbracoUi}) => {
// Act
await umbracoUi.template.clickActionsMenuAtRoot();
await umbracoUi.template.clickNewTemplateButton();
await umbracoUi.template.clickCreateButton();
await umbracoUi.template.enterTemplateName(templateName);
// TODO: Remove this timeout when frontend validation is implemented
await umbracoUi.waitForTimeout(1000);
await umbracoUi.template.clickSaveButton();
// Assert
await umbracoUi.template.isSuccessNotificationVisible();
expect(await umbracoApi.template.doesNameExist(templateName)).toBeTruthy();
await umbracoUi.template.clickRootFolderCaretButton();
await umbracoUi.template.isTemplateTreeItemVisibile(templateName);
});
test('can update a template', async ({umbracoApi, umbracoUi}) => {
test('can update content of a template', async ({umbracoApi, umbracoUi}) => {
// Arrange
const templateAlias = AliasHelper.toAlias(templateName);
const updatedTemplateContent = '@using Umbraco.Cms.Web.Common.PublishedModels;\r\n' +
'@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n' +
'@{\r\n' +
'\tLayout = null;\r\n' +
'}\r\n' +
'<p>AcceptanceTests</p>';
const updatedTemplateContent =
defaultTemplateContent + '\r\n' + '<p>AcceptanceTests</p>';
await umbracoApi.template.create(templateName, templateAlias, '');
await umbracoApi.template.createDefaultTemplate(templateName);
// Act
await umbracoUi.template.goToTemplate(templateName);
@@ -52,59 +48,122 @@ test.describe('Template tests', () => {
expect(updatedTemplate.content).toBe(updatedTemplateContent);
});
test('can delete a template', async ({umbracoApi, umbracoUi}) => {
test('can rename a template', async ({umbracoApi, umbracoUi}) => {
// Arrange
const templateAlias = AliasHelper.toAlias(templateName);
await umbracoApi.template.create(templateName, templateAlias, '');
const wrongTemplateName = 'WrongTemplateName';
const templateAlias = AliasHelper.toAlias(wrongTemplateName);
await umbracoApi.template.ensureNameNotExists(wrongTemplateName);
const templateId = await umbracoApi.template.create(wrongTemplateName, templateAlias, '');
expect(await umbracoApi.template.doesNameExist(wrongTemplateName)).toBeTruthy();
// Act
await umbracoUi.template.clickRootFolderCaretButton();
await umbracoUi.template.clickActionsMenuForTemplate(templateName);
await umbracoUi.template.deleteTemplate();
// Assert
await umbracoUi.template.isSuccessNotificationVisible();
expect(await umbracoApi.template.doesNameExist(templateName)).toBeFalsy();
});
test.skip('can set a template as master template', async ({umbracoApi, umbracoUi}) => {
// Arrange
const templateAlias = AliasHelper.toAlias(templateName);
const childTemplateName = 'ChildTemplate';
const childTemplateAlias = AliasHelper.toAlias(childTemplateName);
await umbracoApi.template.ensureNameNotExists(childTemplateName);
await umbracoApi.template.create(templateName, templateAlias, '');
await umbracoApi.template.create(childTemplateName, childTemplateAlias, '');
// Act
await umbracoUi.template.goToTemplate(childTemplateName);
await umbracoUi.template.clickChangeMasterTemplateButton();
await umbracoUi.template.clickCaretDictionaryButton();
await umbracoUi.template.clickButtonWithName(templateName);
await umbracoUi.template.clickSubmitButton();
await umbracoUi.template.goToTemplate(wrongTemplateName);
await umbracoUi.template.enterTemplateName(templateName);
await umbracoUi.template.clickSaveButton();
// Assert
await umbracoUi.template.isSuccessNotificationVisible();
expect(await umbracoUi.template.isMasterTemplateNameVisible(templateName)).toBeTruthy();
const templateData = await umbracoApi.template.get(templateId);
expect(templateData.name).toBe(templateName);
});
test('can delete a template', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.template.createDefaultTemplate(templateName);
// Act
await umbracoUi.template.clickRootFolderCaretButton();
await umbracoUi.template.clickActionsMenuForTemplate(templateName);
await umbracoUi.template.clickDeleteAndConfirmButton();
// Assert
await umbracoUi.template.isSuccessNotificationVisible();
expect(await umbracoApi.template.doesNameExist(templateName)).toBeFalsy();
await umbracoUi.template.isTemplateTreeItemVisibile(templateName, false);
});
test('can set a template as master template', async ({umbracoApi, umbracoUi}) => {
// Arrange
const childTemplateName = 'ChildTemplate';
await umbracoApi.template.ensureNameNotExists(childTemplateName);
await umbracoApi.template.createDefaultTemplate(templateName);
await umbracoApi.template.createDefaultTemplate(childTemplateName);
// Act
await umbracoUi.template.goToTemplate(childTemplateName);
await umbracoUi.template.clickChangeMasterTemplateButton();
await umbracoUi.template.clickButtonWithName(templateName);
await umbracoUi.template.clickChooseButton();
await umbracoUi.template.clickSaveButton();
// Assert
await umbracoUi.template.isSuccessNotificationVisible();
await umbracoUi.template.isMasterTemplateNameVisible(templateName);
// Checks if the childTemplate has the masterTemplate set
const childTemplate = await umbracoApi.template.getByName(childTemplateName);
const masterTemplate = await umbracoApi.template.getByName(templateName);
expect(childTemplate.masterTemplateId).toBe(masterTemplate.id);
const childTemplateData = await umbracoApi.template.getByName(childTemplateName);
const masterTemplateData = await umbracoApi.template.getByName(templateName);
expect(childTemplateData.masterTemplate.id).toBe(masterTemplateData.id);
// Clean
await umbracoApi.template.ensureNameNotExists(childTemplateName);
});
test.skip('can use query builder for a template', async ({umbracoApi, umbracoUi}) => {
test('can remove a master template', async ({umbracoApi, umbracoUi}) => {
// Arrange
const childTemplateName = 'ChildTemplate';
const templateAlias = AliasHelper.toAlias(templateName);
const childTemplateAlias = AliasHelper.toAlias(childTemplateName);
const childTemplateContent = '@{\n\tLayout = \"' + templateAlias + '.cshtml\";\n}\n';
await umbracoApi.template.ensureNameNotExists(childTemplateName);
await umbracoApi.template.create(templateName, templateAlias, '');
const expectedTemplateContent = '\r\n@{\r\n\tvar selection = Umbraco.ContentAtRoot().FirstOrDefault()\r\n .Children()\r\n .Where(x =\u003E x.IsVisible())\r\n .OrderBy(x =\u003E x.CreateDate);\r\n}\r\n\u003Cul\u003E\r\n\t@foreach (var item in selection)\r\n\t{\r\n\t\t\u003Cli\u003E\r\n\t\t\t\u003Ca href=\u0022@item.Url()\u0022\u003E@item.Name()\u003C/a\u003E\r\n\t\t\u003C/li\u003E\r\n\t}\r\n\u003C/ul\u003E\r\n\r\n@using Umbraco.Cms.Web.Common.PublishedModels;\r\n@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n@{\r\n\tLayout = null;\r\n}';
await umbracoApi.template.create(childTemplateName, childTemplateAlias, childTemplateContent);
// Act
await umbracoUi.template.goToTemplate(templateName, childTemplateName);
await umbracoUi.template.clickRemoveMasterTemplateButton();
await umbracoUi.template.clickSaveButton();
// Assert
await umbracoUi.template.isSuccessNotificationVisible();
await umbracoUi.template.isMasterTemplateNameVisible('No master');
const childTemplate = await umbracoApi.template.getByName(childTemplateName);
expect(childTemplate.masterTemplate).toBe(null);
// Clean
await umbracoApi.template.ensureNameNotExists(childTemplateName);
});
// Remove skip when the front-end is ready. Currently this function is not stable, sometimes the shown code is not updated after choosing Order By
test.skip('can use query builder with Order By statement for a template', async ({umbracoApi, umbracoUi}) => {
// Arrange
const propertyAliasValue = 'UpdateDate';
const isAscending = true;
const expectedCode = 'Umbraco.ContentAtRoot().FirstOrDefault()\r\n' +
' .Children()\r\n' +
' .Where(x => x.IsVisible())\r\n' +
' .OrderBy(x => x.' + propertyAliasValue + ')';
const expectedTemplateContent = '\r\n' +
'@{\r\n' +
'\tvar selection = ' + expectedCode + ';\r\n' +
'}\r\n' +
'<ul>\r\n' +
'\t@foreach (var item in selection)\r\n' +
'\t{\r\n' +
'\t\t<li>\r\n' +
'\t\t\t<a href="@item.Url()">@item.Name()</a>\r\n' +
'\t\t</li>\r\n' +
'\t}\r\n' +
'</ul>\r\n' +
'\r\n' + defaultTemplateContent;
await umbracoApi.template.createDefaultTemplate(templateName);
// Act
await umbracoUi.template.goToTemplate(templateName);
await umbracoUi.template.addQueryBuilderWithOrderByStatement('CreateDate', true);
await umbracoUi.waitForTimeout(1000);
await umbracoUi.template.addQueryBuilderWithOrderByStatement(propertyAliasValue, isAscending);
// Verify that the code is shown
await umbracoUi.template.isQueryBuilderCodeShown(expectedCode);
await umbracoUi.template.clickSubmitButton();
await umbracoUi.template.clickSaveButton();
@@ -114,45 +173,118 @@ test.describe('Template tests', () => {
expect(templateData.content).toBe(expectedTemplateContent);
});
test('can insert sections into a template', async ({umbracoApi, umbracoUi}) => {
test('can use query builder with Where statement for a template', async ({umbracoApi, umbracoUi}) => {
// Arrange
const templateAlias = AliasHelper.toAlias(templateName);
await umbracoApi.template.create(templateName, templateAlias, '');
const templateContent = '@RenderBody()@using Umbraco.Cms.Web.Common.PublishedModels;\r\n' +
'@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n' +
//Arrange
const propertyAliasValue = 'Name';
const operatorValue = 'is';
const constrainValue = 'Test Content';
const expectedCode = 'Umbraco.ContentAtRoot().FirstOrDefault()\r\n' +
' .Children()\r\n' +
' .Where(x => (x.' + propertyAliasValue + ' == "' + constrainValue + '"))\r\n' +
' .Where(x => x.IsVisible())';
const expectedTemplateContent = '\r\n' +
'@{\r\n' +
'\tLayout = null;\r\n' +
'}';
'\tvar selection = ' + expectedCode + ';\r\n' +
'}\r\n' +
'<ul>\r\n' +
'\t@foreach (var item in selection)\r\n' +
'\t{\r\n' +
'\t\t<li>\r\n' +
'\t\t\t<a href="@item.Url()">@item.Name()</a>\r\n' +
'\t\t</li>\r\n' +
'\t}\r\n' +
'</ul>\r\n' +
'\r\n' + defaultTemplateContent;
await umbracoApi.template.createDefaultTemplate(templateName);
// Act
await umbracoUi.template.goToTemplate(templateName);
await umbracoUi.template.clickSectionsButton();
await umbracoUi.waitForTimeout(1000);
await umbracoUi.template.addQueryBuilderWithWhereStatement(propertyAliasValue, operatorValue, constrainValue);
// Verify that the code is shown
await umbracoUi.template.isQueryBuilderCodeShown(expectedCode);
await umbracoUi.template.clickSubmitButton();
await umbracoUi.template.clickSaveButton();
// Assert
await umbracoUi.template.isSuccessNotificationVisible();
const templateData = await umbracoApi.template.getByName(templateName);
expect(templateData.content).toBe(expectedTemplateContent);
});
test('can insert sections - render child template into a template', async ({umbracoApi, umbracoUi}) => {
// Arrange
const sectionType = 'Render child template';
const insertedContent = '@RenderBody()';
await umbracoApi.template.createDefaultTemplate(templateName);
const templateContent = insertedContent + defaultTemplateContent;
// Act
await umbracoUi.template.goToTemplate(templateName);
await umbracoUi.waitForTimeout(1000);
await umbracoUi.template.insertSection(sectionType);
await umbracoUi.template.clickSaveButton();
// Assert
await umbracoUi.template.isSuccessNotificationVisible();
const templateData = await umbracoApi.template.getByName(templateName);
expect(templateData.content).toBe(templateContent);
});
test('can insert dictionaryItem into a template', async ({umbracoApi, umbracoUi}) => {
test('can insert sections - render a named section into a template', async ({umbracoApi, umbracoUi}) => {
// Arrange
const templateAlias = AliasHelper.toAlias(templateName);
await umbracoApi.template.create(templateName, templateAlias, '');
const dictionaryName = 'TestDictionary';
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
await umbracoApi.dictionary.create(dictionaryName);
const templateContent = '@Umbraco.GetDictionaryValue("TestDictionary")@using Umbraco.Cms.Web.Common.PublishedModels;\r\n' +
'@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\r\n' +
'@{\r\n' +
'\tLayout = null;\r\n' +
'}';
const sectionType = 'Render a named section';
const sectionName = 'TestSectionName';
const insertedContent = '@RenderSection("' + sectionName + '", false)';
await umbracoApi.template.createDefaultTemplate(templateName);
const templateContent = insertedContent + defaultTemplateContent;
// Act
await umbracoUi.template.goToTemplate(templateName);
await umbracoUi.template.insertDictionaryByName(dictionaryName);
await umbracoUi.waitForTimeout(1000);
await umbracoUi.template.insertSection(sectionType, sectionName);
await umbracoUi.template.clickSaveButton();
// Assert
await umbracoUi.template.isSuccessNotificationVisible();
const templateData = await umbracoApi.template.getByName(templateName);
expect(templateData.content).toBe(templateContent);
});
test('can insert sections - define a named section into a template', async ({umbracoApi, umbracoUi}) => {
// Arrange
const sectionType = 'Define a named section';
const sectionName = 'TestSectionName';
const insertedContent = '@section ' + sectionName + '\r\n{\r\n\r\n\r\n\r\n}';
await umbracoApi.template.createDefaultTemplate(templateName);
const templateContent = insertedContent + defaultTemplateContent;
// Act
await umbracoUi.template.goToTemplate(templateName);
await umbracoUi.waitForTimeout(1000);
await umbracoUi.template.insertSection(sectionType, sectionName);
await umbracoUi.template.clickSaveButton();
// Assert
await umbracoUi.template.isSuccessNotificationVisible();
const templateData = await umbracoApi.template.getByName(templateName);
expect(templateData.content).toBe(templateContent);
});
test('can insert dictionary item into a template', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.template.createDefaultTemplate(templateName);
const dictionaryName = 'TestDictionary';
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
await umbracoApi.dictionary.create(dictionaryName);
const templateContent = '@Umbraco.GetDictionaryValue("' + dictionaryName + '")' + defaultTemplateContent;
// Act
await umbracoUi.template.goToTemplate(templateName);
await umbracoUi.waitForTimeout(1000);
await umbracoUi.template.insertDictionaryItem(dictionaryName);
await umbracoUi.template.clickSaveButton();
// Assert
@@ -163,4 +295,71 @@ test.describe('Template tests', () => {
// Clean
await umbracoApi.dictionary.ensureNameNotExists(dictionaryName);
});
test('can insert partial view into a template', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.template.createDefaultTemplate(templateName);
const partialViewName = 'TestPartialView';
const partialViewFileName = partialViewName + '.cshtml';
await umbracoApi.partialView.ensureNameNotExists(partialViewFileName);
await umbracoApi.partialView.createDefaultPartialView(partialViewFileName);
const templateContent = '@await Html.PartialAsync("' + partialViewName + '")' + defaultTemplateContent;
// Act
await umbracoUi.template.goToTemplate(templateName);
await umbracoUi.waitForTimeout(1000);
await umbracoUi.template.insertPartialView(partialViewFileName);
await umbracoUi.template.clickSaveButton();
// Assert
await umbracoUi.template.isSuccessNotificationVisible();
const templateData = await umbracoApi.template.getByName(templateName);
expect(templateData.content).toBe(templateContent);
});
test('can insert value into a template', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.template.createDefaultTemplate(templateName);
const systemFieldValue = 'createDate';
const templateContent = '@Model.Value("' + systemFieldValue + '")' + defaultTemplateContent;
// Act
await umbracoUi.template.goToTemplate(templateName);
await umbracoUi.waitForTimeout(1000);
await umbracoUi.template.insertSystemFieldValue(systemFieldValue);
await umbracoUi.template.clickSaveButton();
// Assert
await umbracoUi.template.isSuccessNotificationVisible();
const templateData = await umbracoApi.template.getByName(templateName);
expect(templateData.content).toBe(templateContent);
});
// TODO: Remove skip when the front-end is ready. Currently the returned items count is not updated after choosing the root content.
test.skip('can show returned items in query builder ', async ({umbracoApi, umbracoUi}) => {
//Arrange
// Create content at root with a child
const documentTypeName = 'ParentDocumentType';
const childDocumentTypeName = 'ChildDocumentType';
const contentName = 'ContentName';
const childContentName = 'ChildContentName';
const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(childDocumentTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNode(documentTypeName, childDocumentTypeId);
const contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
// Create template
await umbracoApi.template.createDefaultTemplate(templateName);
//Act
await umbracoUi.template.goToTemplate(templateName);
await umbracoUi.template.clickQueryBuilderButton();
await umbracoUi.template.chooseRootContentInQueryBuilder('(' + contentName + ')');
// Assert
await umbracoUi.template.doesReturnedItemsHaveCount(1);
await umbracoUi.template.doesQueryResultHaveContentName(childContentName);
// Clean
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
});
});

View File

@@ -9,11 +9,6 @@ setup('authenticate', async ({page}) => {
await umbracoUi.login.enterEmail(process.env.UMBRACO_USER_LOGIN);
await umbracoUi.login.enterPassword(process.env.UMBRACO_USER_PASSWORD);
await umbracoUi.login.clickLoginButton();
// Assert
//await expect(page.locator('uui-tab-group').locator('[label="Settings"]')).toBeVisible({timeout: 10000});
// DELETE LATER
await umbracoUi.waitForTimeout(20000);
await umbracoUi.login.goToSection(ConstantHelper.sections.settings);
await page.context().storageState({path: STORAGE_STATE});
});