From 6a67fd5fabe13794a0c1632e91ebfae04785b5c3 Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Wed, 5 Aug 2020 15:21:54 +0200 Subject: [PATCH] Add additional partialViewMacro tests --- .../Settings/partialsViewMacroFiles.ts | 79 ++++++++++++++++--- src/Umbraco.Tests.AcceptanceTest/package.json | 4 +- 2 files changed, 71 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts index 0dc99ee32a..c39465a736 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts @@ -1,19 +1,22 @@ /// +import { PartialViewMacroBuilder } from "umbraco-cypress-testhelpers/lib/cms/builders/partialViewMacros/partialViewMacroBuilder"; + context('Partial View Macro Files', () => { beforeEach(() => { cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); }); - function navigateToSettings() { + function openPartialViewMacroCreatePanel() { cy.umbracoSection('settings'); cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); cy.umbracoTreeItem("settings", ["Partial View Macro Files"]).rightclick(); + cy.umbracoContextMenuAction("action-create").click(); } function cleanup(name, extension = ".cshtml") { - fileName = name + extension; + const fileName = name + extension; cy.umbracoEnsureMacroNameNotExists(name); cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); @@ -24,9 +27,7 @@ context('Partial View Macro Files', () => { cleanup(name); - navigateToSettings(); - - cy.umbracoContextMenuAction("action-create").click(); + openPartialViewMacroCreatePanel(); cy.get('.menu-label').first().click(); // TODO: Fucked we cant use something like cy.umbracoContextMenuAction("action-label").click(); @@ -38,6 +39,7 @@ context('Partial View Macro Files', () => { //Assert cy.umbracoSuccessNotification().should('be.visible'); + cy.umbracoMacroExists(name).then(exists => { expect(exists).to.be.true; }); //Clean up cleanup(name); @@ -48,9 +50,7 @@ context('Partial View Macro Files', () => { cleanup(name); - navigateToSettings(); - - cy.umbracoContextMenuAction("action-create").click(); + openPartialViewMacroCreatePanel(); cy.get('.menu-label').eq(1).click(); @@ -62,6 +62,7 @@ context('Partial View Macro Files', () => { // Assert cy.umbracoSuccessNotification().should('be.visible'); + cy.umbracoMacroExists(name).then(exists => { expect(exists).to.be.false; }); // Clean cleanup(name); @@ -72,8 +73,7 @@ context('Partial View Macro Files', () => { cleanup(name); - navigateToSettings(); - cy.umbracoContextMenuAction("action-create").click(); + openPartialViewMacroCreatePanel(); cy.get('.menu-label').eq(2).click(); @@ -88,9 +88,68 @@ context('Partial View Macro Files', () => { // Assert cy.umbracoSuccessNotification().should('be.visible'); + cy.umbracoMacroExists(name).then(exists => { expect(exists).to.be.true; }); // Clean cleanup(name); }); + it('Delete partial view macro', () => { + const name = "TestDeletePartialViewMacro"; + const fullName = name + ".cshtml" + + cleanup(name); + + const partialViewMacro = new PartialViewMacroBuilder() + .withName(name) + .withContent("@inherits Umbraco.Web.Macros.PartialViewMacroPage") + .build(); + + cy.savePartialViewMacro(partialViewMacro); + + // Navigate to settings + cy.umbracoSection('settings'); + cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); + + // Delete partialViewMacro + cy.umbracoTreeItem("settings", ["Partial View Macro Files", fullName]).rightclick(); + cy.umbracoContextMenuAction("action-delete").click(); + cy.umbracoButtonByLabelKey("general_ok").click(); + + // Assert + cy.contains(fullName).should('not.exist'); + + // Clearn + cleanup(name); + }); + + it('Edit partial view macro', () => { + const name = "TestPartialViewMacroEditable"; + const fullName = name + ".cshtml"; + + cleanup(name); + + const partialViewMacro = new PartialViewMacroBuilder() + .withName(name) + .withContent("@inherits Umbraco.Web.Macros.PartialViewMacroPage") + .build(); + + cy.savePartialViewMacro(partialViewMacro); + + // Navigate to settings + cy.umbracoSection('settings'); + cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); + cy.umbracoTreeItem("settings", ["Partial View Macro Files", fullName]).click(); + + // Type an edit + cy.get('.ace_content').type(" // test"); + // Save + cy.get('.btn-success').click(); + + // Assert + cy.umbracoSuccessNotification().should('be.visible'); + + cleanup(name); + }); + }); diff --git a/src/Umbraco.Tests.AcceptanceTest/package.json b/src/Umbraco.Tests.AcceptanceTest/package.json index 3b4177ce3f..be979cb87b 100644 --- a/src/Umbraco.Tests.AcceptanceTest/package.json +++ b/src/Umbraco.Tests.AcceptanceTest/package.json @@ -5,9 +5,9 @@ }, "devDependencies": { "cross-env": "^7.0.2", + "cypress": "^4.12.0", "ncp": "^2.0.0", - "cypress": "^4.9.0", - "umbraco-cypress-testhelpers": "1.0.0-beta-44" + "umbraco-cypress-testhelpers": "^1.0.0-beta-45" }, "dependencies": { "typescript": "^3.9.2"