From 894bbfb9d459c1c0cf4719e888f6fb5c2ea06bdd Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Tue, 4 Aug 2020 11:54:19 +0200 Subject: [PATCH] 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 83fa2830da..0dc99ee32a 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); }); });