From 8c593d0ea6cfb60e0e5c36a91fb69b52546353d1 Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Tue, 4 Aug 2020 11:04:09 +0200 Subject: [PATCH 01/13] Add test for macro without macro --- .../Settings/partialsViewMacroFiles.ts | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts index f4c976de08f7..8a6b35807863 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts @@ -32,6 +32,35 @@ context('Partial View Macro Files', () => { //Clean up cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); cy.umbracoEnsureMacroNameNotExists(name); - }); + }); + + it('Create new partial view macro without macro', () => { + const name = "TestPartialMacrolessMacro"; + const fileName = name + ".cshtml"; + + cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); + cy.umbracoEnsureMacroNameNotExists(fileName); + + 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(); + cy.get('.menu-label').eq(1).click(); + + // Type name + cy.umbracoEditorHeaderName(name); + + // Save + cy.get('.btn-success').click(); + + // Assert + cy.umbracoSuccessNotification().should('be.visible'); + + // Clean + cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); + cy.umbracoEnsureMacroNameNotExists(name); + }); }); From 82b3416d429cb2003ed06b6d5187ccf16f2ecc54 Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Tue, 4 Aug 2020 11:20:06 +0200 Subject: [PATCH 02/13] Test partial view macro from snippet --- .../Settings/partialsViewMacroFiles.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts index 8a6b35807863..6cd0152a8ab8 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts @@ -63,4 +63,36 @@ context('Partial View Macro Files', () => { cy.umbracoEnsureMacroNameNotExists(name); }); + it('Create new partial view macro from snippet', () => { + const name = "TestPartialFromSnippet"; + const fileName = name + ".cshtml"; + + cy.umbracoEnsureMacroNameNotExists(fileName); + cy.umbracoEnsureMacroNameNotExists(fileName); + + 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(); + cy.get('.menu-label').eq(2).click(); + + // Select snippet + cy.get('.menu-label').eq(1).click(); + + // Type name + cy.umbracoEditorHeaderName(name); + + // Save + cy.get('.btn-success').click(); + + // Assert + cy.umbracoSuccessNotification().should('be.visible'); + + // Clean + cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); + cy.umbracoEnsureMacroNameNotExists(name); + }); + }); From 7d045fd0b3206f1e2c79068d9f67e1743dc174be Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Tue, 4 Aug 2020 11:23:22 +0200 Subject: [PATCH 03/13] Fix spaces --- .../Settings/partialsViewMacroFiles.ts | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts index 6cd0152a8ab8..988691ce99ed 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts @@ -64,35 +64,35 @@ context('Partial View Macro Files', () => { }); it('Create new partial view macro from snippet', () => { - const name = "TestPartialFromSnippet"; - const fileName = name + ".cshtml"; + const name = "TestPartialFromSnippet"; + const fileName = name + ".cshtml"; - cy.umbracoEnsureMacroNameNotExists(fileName); - cy.umbracoEnsureMacroNameNotExists(fileName); + cy.umbracoEnsureMacroNameNotExists(fileName); + cy.umbracoEnsureMacroNameNotExists(fileName); - cy.umbracoSection('settings'); - cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); + cy.umbracoSection('settings'); + cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); - cy.umbracoTreeItem("settings", ["Partial View Macro Files"]).rightclick(); + cy.umbracoTreeItem("settings", ["Partial View Macro Files"]).rightclick(); - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.menu-label').eq(2).click(); + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').eq(2).click(); - // Select snippet - cy.get('.menu-label').eq(1).click(); + // Select snippet + cy.get('.menu-label').eq(1).click(); - // Type name - cy.umbracoEditorHeaderName(name); + // Type name + cy.umbracoEditorHeaderName(name); - // Save - cy.get('.btn-success').click(); + // Save + cy.get('.btn-success').click(); - // Assert - cy.umbracoSuccessNotification().should('be.visible'); + // Assert + cy.umbracoSuccessNotification().should('be.visible'); - // Clean - cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); - cy.umbracoEnsureMacroNameNotExists(name); + // Clean + cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); + cy.umbracoEnsureMacroNameNotExists(name); }); }); From 60791fb96f462811db71f8ed8fe9a4b6f8046100 Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Tue, 4 Aug 2020 11:35:12 +0200 Subject: [PATCH 04/13] Wrap intital navigation in method --- .../Settings/partialsViewMacroFiles.ts | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts index 988691ce99ed..83fa2830daf9 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts @@ -5,19 +5,24 @@ context('Partial View Macro Files', () => { cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); }); + function navigateToSettings() { + cy.umbracoSection('settings'); + cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); + + cy.umbracoTreeItem("settings", ["Partial View Macro Files"]).rightclick(); + } + it('Create new partial view macro', () => { const name = "TestPartialViewMacro"; const fileName = name + ".cshtml"; - cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); - cy.umbracoEnsureMacroNameNotExists(name); - - cy.umbracoSection('settings'); - cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); + cy.umbracoEnsureMacroNameNotExists(name); + cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); - cy.umbracoTreeItem("settings", ["Partial View Macro Files"]).rightclick(); + navigateToSettings(); cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').first().click(); // TODO: Fucked we cant use something like cy.umbracoContextMenuAction("action-label").click(); //Type name @@ -39,14 +44,12 @@ context('Partial View Macro Files', () => { const fileName = name + ".cshtml"; cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); - cy.umbracoEnsureMacroNameNotExists(fileName); - - cy.umbracoSection('settings'); - cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); + cy.umbracoEnsureMacroNameNotExists(name); - cy.umbracoTreeItem("settings", ["Partial View Macro Files"]).rightclick(); + navigateToSettings(); cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').eq(1).click(); // Type name @@ -67,15 +70,13 @@ context('Partial View Macro Files', () => { const name = "TestPartialFromSnippet"; const fileName = name + ".cshtml"; - cy.umbracoEnsureMacroNameNotExists(fileName); - cy.umbracoEnsureMacroNameNotExists(fileName); - - cy.umbracoSection('settings'); - cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); + cy.umbracoEnsureMacroNameNotExists(name); + cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); - cy.umbracoTreeItem("settings", ["Partial View Macro Files"]).rightclick(); + navigateToSettings(); cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').eq(2).click(); // Select snippet From 894bbfb9d459c1c0cf4719e888f6fb5c2ea06bdd Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Tue, 4 Aug 2020 11:54:19 +0200 Subject: [PATCH 05/13] Put cleanup into a function --- .../Settings/partialsViewMacroFiles.ts | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts index 83fa2830daf9..0dc99ee32a12 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts @@ -12,12 +12,17 @@ context('Partial View Macro Files', () => { cy.umbracoTreeItem("settings", ["Partial View Macro Files"]).rightclick(); } - it('Create new partial view macro', () => { - const name = "TestPartialViewMacro"; - const fileName = name + ".cshtml"; + function cleanup(name, extension = ".cshtml") { + fileName = name + extension; cy.umbracoEnsureMacroNameNotExists(name); cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); + } + + it('Create new partial view macro', () => { + const name = "TestPartialViewMacro"; + + cleanup(name); navigateToSettings(); @@ -35,16 +40,13 @@ context('Partial View Macro Files', () => { cy.umbracoSuccessNotification().should('be.visible'); //Clean up - cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); - cy.umbracoEnsureMacroNameNotExists(name); + cleanup(name); }); it('Create new partial view macro without macro', () => { const name = "TestPartialMacrolessMacro"; - const fileName = name + ".cshtml"; - cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); - cy.umbracoEnsureMacroNameNotExists(name); + cleanup(name); navigateToSettings(); @@ -62,19 +64,15 @@ context('Partial View Macro Files', () => { cy.umbracoSuccessNotification().should('be.visible'); // Clean - cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); - cy.umbracoEnsureMacroNameNotExists(name); + cleanup(name); }); it('Create new partial view macro from snippet', () => { const name = "TestPartialFromSnippet"; - const fileName = name + ".cshtml"; - cy.umbracoEnsureMacroNameNotExists(name); - cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); + cleanup(name); navigateToSettings(); - cy.umbracoContextMenuAction("action-create").click(); cy.get('.menu-label').eq(2).click(); @@ -92,8 +90,7 @@ context('Partial View Macro Files', () => { cy.umbracoSuccessNotification().should('be.visible'); // Clean - cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName); - cy.umbracoEnsureMacroNameNotExists(name); + cleanup(name); }); }); From 6a67fd5fabe13794a0c1632e91ebfae04785b5c3 Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Wed, 5 Aug 2020 15:21:54 +0200 Subject: [PATCH 06/13] 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 0dc99ee32a12..c39465a736f5 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 3b4177ce3f8c..be979cb87b20 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" From 355804d4a68a0a2b724853c96c1a4165588d5b3a Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Thu, 6 Aug 2020 08:53:17 +0200 Subject: [PATCH 07/13] Update testhelpers to fix wonky import --- .../cypress/integration/Settings/partialsViewMacroFiles.ts | 2 +- src/Umbraco.Tests.AcceptanceTest/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts index c39465a736f5..0a1fec7bc8b8 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts @@ -1,5 +1,5 @@ /// -import { PartialViewMacroBuilder } from "umbraco-cypress-testhelpers/lib/cms/builders/partialViewMacros/partialViewMacroBuilder"; +import { PartialViewMacroBuilder } from "umbraco-cypress-testhelpers"; context('Partial View Macro Files', () => { diff --git a/src/Umbraco.Tests.AcceptanceTest/package.json b/src/Umbraco.Tests.AcceptanceTest/package.json index be979cb87b20..5840518184b8 100644 --- a/src/Umbraco.Tests.AcceptanceTest/package.json +++ b/src/Umbraco.Tests.AcceptanceTest/package.json @@ -7,7 +7,7 @@ "cross-env": "^7.0.2", "cypress": "^4.12.0", "ncp": "^2.0.0", - "umbraco-cypress-testhelpers": "^1.0.0-beta-45" + "umbraco-cypress-testhelpers": "^1.0.0-beta-46" }, "dependencies": { "typescript": "^3.9.2" From b42bd51392acf2b0f767d5aac878dc25fe382adc Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Thu, 13 Aug 2020 09:02:18 +0200 Subject: [PATCH 08/13] Add partial views tests --- .../integration/Settings/partialsViews.ts | 152 +++++++++++++++--- 1 file changed, 131 insertions(+), 21 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViews.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViews.ts index b644c6642b51..5fa4e151089d 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViews.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViews.ts @@ -1,35 +1,145 @@ /// +import { PartialViewBuilder } from "umbraco-cypress-testhelpers"; + context('Partial Views', () => { - beforeEach(() => { - cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); - }); + beforeEach(() => { + cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); + }); + + function navigateToSettings() { + cy.umbracoSection('settings'); + cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); + } + + function openPartialViewsCreatePanel() { + navigateToSettings(); + cy.umbracoTreeItem("settings", ["Partial Views"]).rightclick(); + } + + it('Create new empty partial view', () => { + const name = "TestPartialView"; + const fileName = name + ".cshtml"; + + cy.umbracoEnsurePartialViewNameNotExists(fileName); + + openPartialViewsCreatePanel(); + + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').first().click(); // TODO: Fucked we cant use something like cy.umbracoContextMenuAction("action-mediaType").click(); + + //Type name + cy.umbracoEditorHeaderName(name); + + //Save + cy.get('.btn-success').click(); + + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.umbracoPartialViewExists(fileName).then(exists => { expect(exists).to.be.true; }); + + //Clean up + cy.umbracoEnsurePartialViewNameNotExists(fileName); + }); + + it('Create partial view from snippet', () => { + const name = "TestPartialViewFromSnippet"; + const fileName = name + ".cshtml"; + + cy.umbracoEnsurePartialViewNameNotExists(fileName); + + openPartialViewsCreatePanel(); + + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').eq(1).click(); + // Select snippet + cy.get('.menu-label').eq(2).click(); + + // Type name + cy.umbracoEditorHeaderName(name); + + // Save + cy.get('.btn-success').click(); + + // Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.umbracoPartialViewExists(fileName).then(exists => { expect(exists).to.be.true; }); + + // Clean up + cy.umbracoEnsurePartialViewNameNotExists(fileName); + }); + + it('Partial view with no name', () => { + openPartialViewsCreatePanel(); + + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').first().click(); + + // The test would fail intermittently, most likely because the editor didn't have time to load + // This should ensure that the editor is loaded and the test should no longer fail unexpectedly. + cy.get('.ace_content', {timeout: 5000}).should('exist'); + + // Click save + cy.get('.btn-success').click(); + + // Asserts + cy.umbracoErrorNotification().should('be.visible'); + }); + + it('Delete partial view', () => { + const name = "TestDeletePartialView"; + const fileName = name + ".cshtml"; + + cy.umbracoEnsurePartialViewNameNotExists(fileName); + + // Build and save partial view + const partialView = new PartialViewBuilder() + .withName(name) + .withContent("@inherits Umbraco.Web.Mvc.UmbracoViewPage") + .build(); + + cy.savePartialView(partialView); + + navigateToSettings(); + + // Delete partial view + cy.umbracoTreeItem("settings", ["Partial Views", fileName]).rightclick(); + cy.umbracoContextMenuAction("action-delete").click(); + cy.umbracoButtonByLabelKey("general_ok").click(); - it('Create new empty partial view', () => { - const name = "TestPartialView"; - const fileName = name + ".cshtml"; + // Assert + cy.contains(fileName).should('not.exist'); + cy.umbracoPartialViewExists(fileName).then(exists => { expect(exists).to.be.false; }); - cy.umbracoEnsurePartialViewNameNotExists(fileName); + // Clean + cy.umbracoEnsurePartialViewNameNotExists(fileName); + }); - cy.umbracoSection('settings'); - cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); + it('Edit partial view', () => { + const name = 'EditPartialView'; + const fileName = name + ".cshtml"; - cy.umbracoTreeItem("settings", ["Partial Views"]).rightclick(); + cy.umbracoEnsurePartialViewNameNotExists(fileName); - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.menu-label').first().click(); // TODO: Fucked we cant use something like cy.umbracoContextMenuAction("action-mediaType").click(); + const partialView = new PartialViewBuilder() + .withName(name) + .withContent("@inherits Umbraco.Web.Mvc.UmbracoViewPage\n") + .build(); - //Type name - cy.umbracoEditorHeaderName(name); + cy.savePartialView(partialView); - //Save - cy.get('.btn-success').click(); + navigateToSettings(); + // Open partial view + cy.umbracoTreeItem("settings", ["Partial Views", fileName]).click(); + // Edit + cy.get('.ace_content').type("var num = 5;"); + cy.get('.btn-success').click(); - //Assert - cy.umbracoSuccessNotification().should('be.visible'); + // Assert + cy.umbracoSuccessNotification().should('be.visible'); + // Clean + cy.umbracoEnsurePartialViewNameNotExists(fileName); + }); - //Clean up - cy.umbracoEnsurePartialViewNameNotExists(fileName); - }); }); From cc696ade1c95ca76a5058781e3109eb58f40c9e5 Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Thu, 13 Aug 2020 09:02:54 +0200 Subject: [PATCH 09/13] Update npm packages --- src/Umbraco.Tests.AcceptanceTest/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/package.json b/src/Umbraco.Tests.AcceptanceTest/package.json index 5840518184b8..867b7f5cf389 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", + "cypress": "^4.12.1", "ncp": "^2.0.0", - "umbraco-cypress-testhelpers": "^1.0.0-beta-46" + "umbraco-cypress-testhelpers": "^1.0.0-beta-48" }, "dependencies": { "typescript": "^3.9.2" From e76ffc865ca0624bbfca994d7fc4cbec8c8be7c7 Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Thu, 13 Aug 2020 09:09:15 +0200 Subject: [PATCH 10/13] Ensure that the template is deleted when creating a new documentType --- .../cypress/integration/Settings/documentTypes.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/documentTypes.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/documentTypes.ts index e0a651731ac8..c40d65d54120 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/documentTypes.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/documentTypes.ts @@ -10,6 +10,7 @@ context('Document Types', () => { const name = "Test document type"; cy.umbracoEnsureDocumentTypeNameNotExists(name); + cy.umbracoEnsureTemplateNameNotExists(name); cy.umbracoSection('settings'); cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); @@ -44,6 +45,7 @@ context('Document Types', () => { //Assert cy.umbracoSuccessNotification().should('be.visible'); + cy.umbracoEnsureTemplateNameNotExists(name); //Clean up cy.umbracoEnsureDocumentTypeNameNotExists(name); From 9a2fb1e0d8b573885fc6789bfeb4f420a50df4bc Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Thu, 13 Aug 2020 09:11:58 +0200 Subject: [PATCH 11/13] Fix javascript test --- .../cypress/integration/Settings/partialsViewMacroFiles.ts | 2 +- .../cypress/integration/Settings/scripts.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts index 0a1fec7bc8b8..bf1c25c16dd9 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts @@ -119,7 +119,7 @@ context('Partial View Macro Files', () => { // Assert cy.contains(fullName).should('not.exist'); - // Clearn + // Clean cleanup(name); }); diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/scripts.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/scripts.ts index 8cffd3e59bea..cce8a45da6af 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/scripts.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/scripts.ts @@ -14,7 +14,7 @@ context('Scripts', () => { cy.umbracoSection('settings'); cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); - cy.umbracoTreeItem("settings", ["Stylesheets"]).rightclick(); + cy.umbracoTreeItem("settings", ["Scripts"]).rightclick(); cy.umbracoContextMenuAction("action-create").click(); cy.get('.menu-label').first().click(); // TODO: Fucked we cant use something like cy.umbracoContextMenuAction("action-mediaType").click(); From 1512496f4f6c82ebc67de0ea1ce34af584ba057c Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Thu, 13 Aug 2020 09:31:28 +0200 Subject: [PATCH 12/13] Add template tests --- .../cypress/integration/Settings/templates.ts | 147 +++++++++++++++--- 1 file changed, 128 insertions(+), 19 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/templates.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/templates.ts index 6871db7ffed2..194419ee8889 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/templates.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/templates.ts @@ -1,57 +1,166 @@ /// -import {DocumentTypeBuilder, TemplateBuilder} from "umbraco-cypress-testhelpers"; +import { TemplateBuilder } from 'umbraco-cypress-testhelpers'; context('Templates', () => { - beforeEach(() => { - cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); - }); - - it('Create template', () => { - const name = "Test template"; - - cy.umbracoEnsureTemplateNameNotExists(name); + beforeEach(() => { + cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); + }); + function navigateToSettings() { cy.umbracoSection('settings'); cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); + } + function createTemplate() { + navigateToSettings(); cy.umbracoTreeItem("settings", ["Templates"]).rightclick(); - cy.umbracoContextMenuAction("action-create").click(); + } + + + it('Create template', () => { + const name = "Test template test"; + cy.umbracoEnsureTemplateNameNotExists(name); + + createTemplate(); //Type name cy.umbracoEditorHeaderName(name); + /* Make an edit, if you don't the file will be create twice, + only happens in testing though, probably because the test is too fast + Certifiably mega wonk regardless */ + cy.get('.ace_content').type("var num = 5;"); //Save - cy.get("form[name='contentForm']").submit(); + cy.get('.btn-success').click(); //Assert cy.umbracoSuccessNotification().should('be.visible'); //Clean up cy.umbracoEnsureTemplateNameNotExists(name); - }); + }); + + it('Unsaved changes stay', () => { + const name = "Templates Unsaved Changes Stay test"; + const edit = "var num = 5;"; + cy.umbracoEnsureTemplateNameNotExists(name); + + const template = new TemplateBuilder() + .withName(name) + .withContent('@inherits Umbraco.Web.Mvc.UmbracoViewPage\n') + .build(); + + cy.saveTemplate(template); + + navigateToSettings(); + + // Open partial view + cy.umbracoTreeItem("settings", ["Templates", name]).click(); + // Edit + cy.get('.ace_content').type(edit); + // Navigate away + cy.umbracoSection('content'); + // Click stay button + cy.get('umb-button[label="Stay"] button:enabled').click(); + + // Assert + // That the same document is open + cy.get('#headerName').should('have.value', name); + cy.get('.ace_content').contains(edit); + + cy.umbracoEnsureTemplateNameNotExists(name); + }); + + it('Discard unsaved changes', () => { + const name = "Discard changes test"; + const edit = "var num = 5;"; - it('Delete template', () => { - const name = "Test template"; cy.umbracoEnsureTemplateNameNotExists(name); const template = new TemplateBuilder() .withName(name) + .withContent('@inherits Umbraco.Web.Mvc.UmbracoViewPage\n') .build(); cy.saveTemplate(template); + navigateToSettings(); + + // Open partial view + cy.umbracoTreeItem("settings", ["Templates", name]).click(); + // Edit + cy.get('.ace_content').type(edit); + // Navigate away + cy.umbracoSection('content'); + // Click discard + cy.get('umb-button[label="Discard changes"] button:enabled').click(); + // Navigate back cy.umbracoSection('settings'); - cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); - cy.umbracoTreeItem("settings", ["Templates", name]).rightclick(); - cy.umbracoContextMenuAction("action-delete").click(); + // Asserts + cy.get('.ace_content').should('not.contain', edit); + // cy.umbracoPartialViewExists(fileName).then(exists => { expect(exists).to.be.false; }); TODO: Switch to template + cy.umbracoEnsureTemplateNameNotExists(name); + }); + + it('Insert macro', () => { + const name = 'InsertMacroTest'; + + cy.umbracoEnsureTemplateNameNotExists(name); + cy.umbracoEnsureMacroNameNotExists(name); + + const template = new TemplateBuilder() + .withName(name) + .withContent('') + .build(); + + cy.saveTemplate(template); + + cy.saveMacro(name); + + navigateToSettings(); + cy.umbracoTreeItem("settings", ["Templates", name]).click(); + // Insert macro + cy.umbracoButtonByLabelKey('general_insert').click(); + cy.get('.umb-insert-code-box__title').contains('Macro').click(); + cy.get('.umb-card-grid-item').contains(name).click(); - cy.umbracoButtonByLabelKey("general_ok").click(); + // Assert + cy.get('.ace_content').contains('@Umbraco.RenderMacro("' + name + '")').should('exist'); - cy.contains(name).should('not.exist'); + // Clean + cy.umbracoEnsureTemplateNameNotExists(name); + cy.umbracoEnsureMacroNameNotExists(name); + }); + + it('Insert value', () => { + const name = 'Insert Value Test'; cy.umbracoEnsureTemplateNameNotExists(name); + + const partialView = new TemplateBuilder() + .withName(name) + .withContent('') + .build(); + + cy.saveTemplate(partialView); + + navigateToSettings(); + cy.umbracoTreeItem("settings", ["Templates", name]).click(); + + // Insert value + cy.umbracoButtonByLabelKey('general_insert').click(); + cy.get('.umb-insert-code-box__title').contains('Value').click(); + cy.get('select').select('umbracoBytes'); + cy.umbracoButtonByLabelKey('general_submit').click(); + + // assert + cy.get('.ace_content').contains('@Model.Value("umbracoBytes")').should('exist'); + + // Clean + cy.umbracoEnsureTemplateNameNotExists(name); }); + }); From 67c25ad39ba5a3cde45e866df706012b11a61ad8 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Thu, 20 Aug 2020 09:42:42 +0200 Subject: [PATCH 13/13] Fixes for ace editor in cypress tests --- .../integration/Settings/partialsViewMacroFiles.ts | 8 ++++---- .../cypress/integration/Settings/partialsViews.ts | 6 +++--- .../cypress/integration/Settings/templates.ts | 10 ++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts index bf1c25c16dd9..563ff77658ef 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViewMacroFiles.ts @@ -104,9 +104,9 @@ context('Partial View Macro Files', () => { .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"); @@ -133,7 +133,7 @@ context('Partial View Macro Files', () => { .withName(name) .withContent("@inherits Umbraco.Web.Macros.PartialViewMacroPage") .build(); - + cy.savePartialViewMacro(partialViewMacro); // Navigate to settings @@ -142,7 +142,7 @@ context('Partial View Macro Files', () => { cy.umbracoTreeItem("settings", ["Partial View Macro Files", fullName]).click(); // Type an edit - cy.get('.ace_content').type(" // test"); + cy.get('.ace_text-input').type(" // test", {force:true} ); // Save cy.get('.btn-success').click(); diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViews.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViews.ts index 5fa4e151089d..068338f8fa14 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViews.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/partialsViews.ts @@ -107,11 +107,11 @@ context('Partial Views', () => { cy.umbracoContextMenuAction("action-delete").click(); cy.umbracoButtonByLabelKey("general_ok").click(); - // Assert + // Assert cy.contains(fileName).should('not.exist'); cy.umbracoPartialViewExists(fileName).then(exists => { expect(exists).to.be.false; }); - // Clean + // Clean cy.umbracoEnsurePartialViewNameNotExists(fileName); }); @@ -132,7 +132,7 @@ context('Partial Views', () => { // Open partial view cy.umbracoTreeItem("settings", ["Partial Views", fileName]).click(); // Edit - cy.get('.ace_content').type("var num = 5;"); + cy.get('.ace_text-input').type("var num = 5;", {force:true} ); cy.get('.btn-success').click(); // Assert diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/templates.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/templates.ts index 194419ee8889..aff1c380935a 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/templates.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/templates.ts @@ -30,7 +30,7 @@ context('Templates', () => { /* Make an edit, if you don't the file will be create twice, only happens in testing though, probably because the test is too fast Certifiably mega wonk regardless */ - cy.get('.ace_content').type("var num = 5;"); + cy.get('.ace_text-input').type("var num = 5;", {force:true} ); //Save cy.get('.btn-success').click(); @@ -59,10 +59,11 @@ context('Templates', () => { // Open partial view cy.umbracoTreeItem("settings", ["Templates", name]).click(); // Edit - cy.get('.ace_content').type(edit); + cy.get('.ace_text-input').type(edit, {force:true} ); + // Navigate away cy.umbracoSection('content'); - // Click stay button + // Click stay button cy.get('umb-button[label="Stay"] button:enabled').click(); // Assert @@ -91,7 +92,8 @@ context('Templates', () => { // Open partial view cy.umbracoTreeItem("settings", ["Templates", name]).click(); // Edit - cy.get('.ace_content').type(edit); + cy.get('.ace_text-input').type(edit, {force:true} ); + // Navigate away cy.umbracoSection('content'); // Click discard