From ad166921a8d4d900d196901ca623993fccadd94d Mon Sep 17 00:00:00 2001 From: Elitsa Marinovska Date: Tue, 11 Aug 2020 22:42:26 +0200 Subject: [PATCH 1/6] Updates Cypress to future latest --- 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 3b4177ce3f..376984b3b8 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", - "ncp": "^2.0.0", "cypress": "^4.9.0", - "umbraco-cypress-testhelpers": "1.0.0-beta-44" + "ncp": "^2.0.0", + "umbraco-cypress-testhelpers": "^1.0.0-beta-47" }, "dependencies": { "typescript": "^3.9.2" From 52500cce3891064d3d2ed09a67358fa53924b025 Mon Sep 17 00:00:00 2001 From: Elitsa Marinovska Date: Tue, 11 Aug 2020 22:43:16 +0200 Subject: [PATCH 2/6] Creates tests for content --- .../cypress/integration/Content/content.ts | 418 ++++++++++++++++++ 1 file changed, 418 insertions(+) create mode 100644 src/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts new file mode 100644 index 0000000000..deeb21a4a9 --- /dev/null +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts @@ -0,0 +1,418 @@ +/// +import { DocumentTypeBuilder } from 'umbraco-cypress-testhelpers'; +context('Content', () => { + + beforeEach(() => { + cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); + }); + + it('Copy content', () => { + const rootdocTypeName = "Test document type"; + const childDocTypeName = "Child test document type"; + const nodeName = "1) Home"; + const childNodeName = "1) Child"; + const anotherNodeName = "2) Home"; + + const childDocType = new DocumentTypeBuilder() + .withName(childDocTypeName) + .build(); + + cy.deleteAllContent(); + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(childDocTypeName); + + cy.saveDocumentType(childDocType).then((generatedDocType) => + { + const rootDocType = new DocumentTypeBuilder() + .withName(rootdocTypeName) + .withAllowAsRoot(true) + .withAllowedContentTypes(generatedDocType["id"]) + .build(); + + cy.saveDocumentType(rootDocType); + }); + + cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); + + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').first().click(); + + // Type name + cy.umbracoEditorHeaderName(nodeName); + + // Save + cy.get('.btn-info').click(); + cy.umbracoSuccessNotification().should('be.visible'); + + // Add an item under root node + cy.umbracoTreeItem("content", [nodeName]).rightclick(); + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.umb-actions').first().click(); + cy.umbracoEditorHeaderName(childNodeName); + cy.get('.btn-info').click(); + + // Add second root node + cy.get('li .umb-tree-root:contains("Content")').rightclick(); + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').first().click(); + cy.umbracoEditorHeaderName(anotherNodeName); + cy.get('.btn-info').click(); + + // Copy node + cy.umbracoTreeItem("content", [nodeName, childNodeName]).rightclick({force:true}); + cy.umbracoContextMenuAction("action-copy").click(); + cy.get('.umb-pane [data-element="tree-item-' + anotherNodeName + '"]').click(); + cy.get('.umb-dialog-footer > .btn-primary').click(); + + // Assert + cy.get('.alert-success').should('exist'); + + // Clean up (content is automatically deleted when document types are gone) + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(childDocTypeName); + }); + + it('Move content', () => { + const rootdocTypeName = "Test document type"; + const childDocTypeName = "Child test document type"; + const nodeName = "1) Home"; + const childNodeName = "1) Child"; + const anotherNodeName = "2) Home"; + + const childDocType = new DocumentTypeBuilder() + .withName(childDocTypeName) + .build(); + + cy.deleteAllContent(); + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(childDocTypeName); + + cy.saveDocumentType(childDocType).then((generatedDocType) => + { + const rootDocType = new DocumentTypeBuilder() + .withName(rootdocTypeName) + .withAllowAsRoot(true) + .withAllowedContentTypes(generatedDocType["id"]) + .build(); + + cy.saveDocumentType(rootDocType); + }); + + cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); + + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').first().click(); + + // Type name + cy.umbracoEditorHeaderName(nodeName); + + // Save + cy.get('.btn-info').click(); + cy.umbracoSuccessNotification().should('be.visible'); + + // Add an item under root node + cy.umbracoTreeItem("content", [nodeName]).rightclick(); + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.umb-actions').first().click(); + cy.umbracoEditorHeaderName(childNodeName); + cy.get('.btn-info').click(); + + // Add second root node + cy.get('li .umb-tree-root:contains("Content")').rightclick(); + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').first().click(); + cy.umbracoEditorHeaderName(anotherNodeName); + cy.get('.btn-info').click(); + + // Move node + cy.umbracoTreeItem("content", [nodeName, childNodeName]).rightclick({force:true}); + cy.umbracoContextMenuAction("action-move").click(); + cy.get('.umb-pane [data-element="tree-item-' + anotherNodeName + '"]').click(); + cy.get('.umb-dialog-footer > .btn-primary').click(); + + // Assert + cy.get('.alert-success').should('exist'); + + // Clean up (content is automatically deleted when document types are gone) + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(childDocTypeName); + }); + + it('Sort content', () => { + const rootdocTypeName = "Test document type"; + const childDocTypeName = "Child test document type"; + const nodeName = "1) Home"; + const firstChildNodeName = "1) Child"; + const secondChildNodeName = "2) Child"; + + const childDocType = new DocumentTypeBuilder() + .withName(childDocTypeName) + .build(); + + cy.deleteAllContent(); + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(childDocTypeName); + + cy.saveDocumentType(childDocType).then((generatedDocType) => { + const rootDocType = new DocumentTypeBuilder() + .withName(rootdocTypeName) + .withAllowAsRoot(true) + .withAllowedContentTypes(generatedDocType["id"]) + .build(); + + cy.saveDocumentType(rootDocType); + }); + + cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); + + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').first().click(); + + // Type name + cy.umbracoEditorHeaderName(nodeName); + + // Save + cy.get('.btn-info').click(); + cy.umbracoSuccessNotification().should('be.visible'); + + // Add an item under root node + cy.umbracoTreeItem("content", [nodeName]).rightclick(); + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.umb-actions').first().click(); + cy.umbracoEditorHeaderName(firstChildNodeName); + cy.get('.btn-info').click(); + + // Add an item under root node + cy.umbracoTreeItem("content", [nodeName]).rightclick(); + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.umb-actions').first().click(); + cy.umbracoEditorHeaderName(secondChildNodeName); + cy.get('.btn-info').click(); + + // Sort nodes + cy.umbracoTreeItem("content", [nodeName]).rightclick({ force: true }); + cy.umbracoContextMenuAction("action-sort").click(); + + const offsetFirstElm = cy.get('.ui-sortable .ui-sortable-handle :nth-child(2)').eq(0).then($el => $el.offset()); + offsetFirstElm.then((offsetFirstElm) => { + const pageYFirst = Math.round(offsetFirstElm.top); + + const offsetSecondElm = cy.get('.ui-sortable .ui-sortable-handle :nth-child(2)').eq(1).then($el => $el.offset()); + offsetSecondElm.then((offset) => { + const pageX = Math.round(offset.left); + const pageY = Math.round(offset.top); + + cy.get('.table-sortable').find('tbody :nth-child(1)').eq(0) + .trigger('mousedown', { which: 1, pageX: pageX, pageY: pageYFirst }) + .trigger('mousemove', { which: 1, pageX: pageX, pageY: pageY }) + .trigger('mouseup'); + }) + }); + + // Save and close dialog + cy.get('.umb-modalcolumn .btn-success').click(); + cy.get('.umb-modalcolumn .btn-link').click(); + + // Assert + cy.get('.umb-tree-item [node="child"]').eq(0).should('contain.text', secondChildNodeName); + cy.get('.umb-tree-item [node="child"]').eq(1).should('contain.text', firstChildNodeName); + + // Clean up (content is automatically deleted when document types are gone) + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(childDocTypeName); + }); + + it('Rollback content', () => { + const rootdocTypeName = "Test document type"; + const initialNodeName = "Home node"; + const nodeName = "Home"; + + const rootDocType = new DocumentTypeBuilder() + .withName(rootdocTypeName) + .withAllowAsRoot(true) + .build(); + + cy.deleteAllContent(); + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.saveDocumentType(rootDocType); + + cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); + + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').first().click(); + + // Type name + cy.umbracoEditorHeaderName(initialNodeName); + + // Save and publish + cy.get('.btn-success').first().click(); + cy.umbracoSuccessNotification().should('be.visible'); + + // Edit header + cy.get('#headerName').clear(); + cy.umbracoEditorHeaderName(nodeName); + + // Save and publish + cy.get('.btn-success').first().click(); + + // Rollback + cy.get('.umb-box-header :button').click(); + + cy.get('.umb-box-content > .ng-scope > .input-block-level') + .find('option[label*=' + new Date().getDate() + ']') + .then(elements => { + const option = elements[elements.length - 1].getAttribute('value'); + cy.get('.umb-box-content > .ng-scope > .input-block-level') + .select(option); + }); + + cy.get('.umb-editor-footer-content__right-side > [button-style="success"] > .umb-button > .btn-success').click(); + + // Assert + cy.get('.history').find('.umb-badge').eq(0).should('contain.text',"Save"); + cy.get('.history').find('.umb-badge').eq(1).should('contain.text',"Rollback"); + cy.get('#headerName').should('have.value', initialNodeName); + + // Clean up (content is automatically deleted when document types are gone) + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName).wait(100); + }); + + it('View audit trail', () => { + const rootdocTypeName = "Test document type"; + const nodeName = "Home"; + const labelName = "Name"; + + const rootDocType = new DocumentTypeBuilder() + .withName(rootdocTypeName) + .withAllowAsRoot(true) + .addGroup() + .addTextBoxProperty() + .withLabel(labelName) + .done() + .done() + .build(); + + cy.deleteAllContent(); + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.saveDocumentType(rootDocType); + + cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); + + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').first().click(); + + // Type name + cy.umbracoEditorHeaderName(nodeName); + + // Save and publish + cy.get('.btn-success').first().click(); + cy.umbracoSuccessNotification().should('be.visible'); + + // Navigate to Info app + cy.get(':nth-child(2) > [ng-show="navItem.alias !== \'more\'"]').click(); + + // Assert + cy.get('.history').should('exist'); + + // Clean up (content is automatically deleted when document types are gone) + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + }); + + it('Save draft', () => { + const rootdocTypeName = "Test document type"; + const nodeName = "Home"; + + const rootDocType = new DocumentTypeBuilder() + .withName(rootdocTypeName) + .withAllowAsRoot(true) + .build(); + + cy.deleteAllContent(); + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.saveDocumentType(rootDocType); + + cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); + + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').first().click(); + + // Type name + cy.umbracoEditorHeaderName(nodeName); + + // Save + cy.get('.btn-info').click(); + cy.umbracoSuccessNotification().should('be.visible'); + + // Assert + cy.get('[data-element="node-info-status"]').find('.umb-badge').should('contain.text',"Draft"); + + // Clean up (content is automatically deleted when document types are gone) + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + }); + + it('Preview draft', () => { + const rootdocTypeName = "Test document type"; + const nodeName = "Home"; + + const rootDocType = new DocumentTypeBuilder() + .withName(rootdocTypeName) + .withAllowAsRoot(true) + .build(); + + cy.deleteAllContent(); + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.saveDocumentType(rootDocType); + + cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); + + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').first().click(); + + // Type name + cy.umbracoEditorHeaderName(nodeName); + + // Save + cy.get('.btn-info').click(); + + // Preview + cy.get('[alias="preview"]').should('be.visible').click(); + + // Assert + cy.umbracoSuccessNotification({ multiple: true }).should('be.visible'); + + // Clean up (content is automatically deleted when document types are gone) + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + }); + + it('Publish draft', () => { + const rootdocTypeName = "Test document type"; + const nodeName = "Home"; + + const rootDocType = new DocumentTypeBuilder() + .withName(rootdocTypeName) + .withAllowAsRoot(true) + .build(); + + cy.deleteAllContent(); + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.saveDocumentType(rootDocType); + + cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); + + cy.umbracoContextMenuAction("action-create").click(); + cy.get('.menu-label').first().click(); + + // Type name + cy.umbracoEditorHeaderName(nodeName); + + // Save and publish + cy.get('.btn-success').first().click(); + cy.umbracoSuccessNotification().should('be.visible'); + + // Assert + cy.get('[data-element="node-info-status"]').find('.umb-badge').should('contain.text',"Published"); + + // Clean up (content is automatically deleted when document types are gone) + cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + }); +}); From cab6bbb44df63d88be2436b4a170547f63d37eda Mon Sep 17 00:00:00 2001 From: Elitsa Marinovska Date: Sun, 6 Sep 2020 17:00:50 +0200 Subject: [PATCH 3/6] Refactoring for using API for saving content --- .../cypress/integration/Content/content.ts | 462 +++++++++++------- 1 file changed, 279 insertions(+), 183 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts index deeb21a4a9..6b14a380b8 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts @@ -1,5 +1,5 @@ /// -import { DocumentTypeBuilder } from 'umbraco-cypress-testhelpers'; +import { DocumentTypeBuilder, ContentBuilder } from 'umbraco-cypress-testhelpers'; context('Content', () => { beforeEach(() => { @@ -7,139 +7,177 @@ context('Content', () => { }); it('Copy content', () => { - const rootdocTypeName = "Test document type"; + const rootDocTypeName = "Test document type"; const childDocTypeName = "Child test document type"; const nodeName = "1) Home"; const childNodeName = "1) Child"; const anotherNodeName = "2) Home"; const childDocType = new DocumentTypeBuilder() - .withName(childDocTypeName) - .build(); + .withName(childDocTypeName) + .build(); cy.deleteAllContent(); - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); cy.umbracoEnsureDocumentTypeNameNotExists(childDocTypeName); - cy.saveDocumentType(childDocType).then((generatedDocType) => - { + cy.saveDocumentType(childDocType).then((generatedChildDocType) => { + const rootDocTypeAlias; + const createdChildDocType = generatedChildDocType; + + cy.get('li .umb-tree-root:contains("Content")').should("be.visible"); + const rootDocType = new DocumentTypeBuilder() - .withName(rootdocTypeName) + .withName(rootDocTypeName) .withAllowAsRoot(true) - .withAllowedContentTypes(generatedDocType["id"]) + .withAllowedContentTypes(createdChildDocType["id"]) .build(); - cy.saveDocumentType(rootDocType); + cy.saveDocumentType(rootDocType).then((generatedRootDocType) => { + rootDocTypeAlias = generatedRootDocType["alias"]; + + const rootContentNode = new ContentBuilder() + .withContentTypeAlias(rootDocTypeAlias) + .withAction("saveNew") + .addVariant() + .withName(nodeName) + .withSave(true) + .done() + .build(); + + cy.saveContent(rootContentNode).then((contentNode) => { + // Add an item under root node + const childContentNode = new ContentBuilder() + .withContentTypeAlias(createdChildDocType["alias"]) + .withAction("saveNew") + .withParent(contentNode["id"]) + .addVariant() + .withName(childNodeName) + .withSave(true) + .done() + .build(); + + cy.saveContent(childContentNode); + }); + + const anotherRootContentNode = new ContentBuilder() + .withContentTypeAlias(rootDocTypeAlias) + .withAction("saveNew") + .addVariant() + .withName(anotherNodeName) + .withSave(true) + .done() + .build(); + + cy.saveContent(anotherRootContentNode); + }); }); + // Refresh to update the tree cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); - - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.menu-label').first().click(); - - // Type name - cy.umbracoEditorHeaderName(nodeName); - - // Save - cy.get('.btn-info').click(); - cy.umbracoSuccessNotification().should('be.visible'); - - // Add an item under root node - cy.umbracoTreeItem("content", [nodeName]).rightclick(); - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.umb-actions').first().click(); - cy.umbracoEditorHeaderName(childNodeName); - cy.get('.btn-info').click(); - - // Add second root node - cy.get('li .umb-tree-root:contains("Content")').rightclick(); - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.menu-label').first().click(); - cy.umbracoEditorHeaderName(anotherNodeName); - cy.get('.btn-info').click(); + cy.umbracoContextMenuAction("action-refreshNode").click(); // Copy node - cy.umbracoTreeItem("content", [nodeName, childNodeName]).rightclick({force:true}); + cy.umbracoTreeItem("content", [nodeName, childNodeName]).rightclick({ force: true }); cy.umbracoContextMenuAction("action-copy").click(); cy.get('.umb-pane [data-element="tree-item-' + anotherNodeName + '"]').click(); cy.get('.umb-dialog-footer > .btn-primary').click(); - + // Assert cy.get('.alert-success').should('exist'); // Clean up (content is automatically deleted when document types are gone) - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); cy.umbracoEnsureDocumentTypeNameNotExists(childDocTypeName); }); it('Move content', () => { - const rootdocTypeName = "Test document type"; + const rootDocTypeName = "Test document type"; const childDocTypeName = "Child test document type"; const nodeName = "1) Home"; const childNodeName = "1) Child"; const anotherNodeName = "2) Home"; const childDocType = new DocumentTypeBuilder() - .withName(childDocTypeName) - .build(); + .withName(childDocTypeName) + .build(); cy.deleteAllContent(); - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); cy.umbracoEnsureDocumentTypeNameNotExists(childDocTypeName); - cy.saveDocumentType(childDocType).then((generatedDocType) => - { + cy.saveDocumentType(childDocType).then((generatedChildDocType) => { + const rootDocTypeAlias; + const createdChildDocType = generatedChildDocType; + + cy.get('li .umb-tree-root:contains("Content")').should("be.visible"); + const rootDocType = new DocumentTypeBuilder() - .withName(rootdocTypeName) + .withName(rootDocTypeName) .withAllowAsRoot(true) - .withAllowedContentTypes(generatedDocType["id"]) + .withAllowedContentTypes(createdChildDocType["id"]) .build(); - cy.saveDocumentType(rootDocType); + cy.saveDocumentType(rootDocType).then((generatedRootDocType) => { + rootDocTypeAlias = generatedRootDocType["alias"]; + + const rootContentNode = new ContentBuilder() + .withContentTypeAlias(rootDocTypeAlias) + .withAction("saveNew") + .addVariant() + .withName(nodeName) + .withSave(true) + .done() + .build(); + + cy.saveContent(rootContentNode).then((contentNode) => { + // Add an item under root node + const childContentNode = new ContentBuilder() + .withContentTypeAlias(createdChildDocType["alias"]) + .withAction("saveNew") + .withParent(contentNode["id"]) + .addVariant() + .withName(childNodeName) + .withSave(true) + .done() + .build(); + + cy.saveContent(childContentNode); + }); + + const anotherRootContentNode = new ContentBuilder() + .withContentTypeAlias(rootDocTypeAlias) + .withAction("saveNew") + .addVariant() + .withName(anotherNodeName) + .withSave(true) + .done() + .build(); + + cy.saveContent(anotherRootContentNode); + }); }); + // Refresh to update the tree cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); - - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.menu-label').first().click(); - - // Type name - cy.umbracoEditorHeaderName(nodeName); - - // Save - cy.get('.btn-info').click(); - cy.umbracoSuccessNotification().should('be.visible'); - - // Add an item under root node - cy.umbracoTreeItem("content", [nodeName]).rightclick(); - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.umb-actions').first().click(); - cy.umbracoEditorHeaderName(childNodeName); - cy.get('.btn-info').click(); - - // Add second root node - cy.get('li .umb-tree-root:contains("Content")').rightclick(); - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.menu-label').first().click(); - cy.umbracoEditorHeaderName(anotherNodeName); - cy.get('.btn-info').click(); + cy.umbracoContextMenuAction("action-refreshNode").click(); // Move node - cy.umbracoTreeItem("content", [nodeName, childNodeName]).rightclick({force:true}); + cy.umbracoTreeItem("content", [nodeName, childNodeName]).rightclick({ force: true }); cy.umbracoContextMenuAction("action-move").click(); cy.get('.umb-pane [data-element="tree-item-' + anotherNodeName + '"]').click(); cy.get('.umb-dialog-footer > .btn-primary').click(); - + // Assert cy.get('.alert-success').should('exist'); // Clean up (content is automatically deleted when document types are gone) - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); cy.umbracoEnsureDocumentTypeNameNotExists(childDocTypeName); }); it('Sort content', () => { - const rootdocTypeName = "Test document type"; + const rootDocTypeName = "Test document type"; const childDocTypeName = "Child test document type"; const nodeName = "1) Home"; const firstChildNodeName = "1) Child"; @@ -150,49 +188,72 @@ context('Content', () => { .build(); cy.deleteAllContent(); - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); cy.umbracoEnsureDocumentTypeNameNotExists(childDocTypeName); - cy.saveDocumentType(childDocType).then((generatedDocType) => { + cy.saveDocumentType(childDocType).then((generatedChildDocType) => { + const createdChildDocType = generatedChildDocType; + + cy.get('li .umb-tree-root:contains("Content")').should("be.visible"); + const rootDocType = new DocumentTypeBuilder() - .withName(rootdocTypeName) + .withName(rootDocTypeName) .withAllowAsRoot(true) - .withAllowedContentTypes(generatedDocType["id"]) + .withAllowedContentTypes(createdChildDocType["id"]) .build(); - cy.saveDocumentType(rootDocType); + cy.saveDocumentType(rootDocType).then((generatedRootDocType) => { + const parentId; + + const rootContentNode = new ContentBuilder() + .withContentTypeAlias(generatedRootDocType["alias"]) + .withAction("saveNew") + .addVariant() + .withName(nodeName) + .withSave(true) + .done() + .build(); + + cy.saveContent(rootContentNode).then((contentNode) => { + parentId = contentNode["id"]; + + // Add an item under root node + const firstChildContentNode = new ContentBuilder() + .withContentTypeAlias(createdChildDocType["alias"]) + .withAction("saveNew") + .withParent(parentId) + .addVariant() + .withName(firstChildNodeName) + .withSave(true) + .done() + .build(); + + cy.saveContent(firstChildContentNode); + + // Add a second item under root node + const secondChildContentNode = new ContentBuilder() + .withContentTypeAlias(createdChildDocType["alias"]) + .withAction("saveNew") + .withParent(parentId) + .addVariant() + .withName(secondChildNodeName) + .withSave(true) + .done() + .build(); + + cy.saveContent(secondChildContentNode); + }); + }); }); + // Refresh to update the tree cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); - - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.menu-label').first().click(); - - // Type name - cy.umbracoEditorHeaderName(nodeName); - - // Save - cy.get('.btn-info').click(); - cy.umbracoSuccessNotification().should('be.visible'); - - // Add an item under root node - cy.umbracoTreeItem("content", [nodeName]).rightclick(); - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.umb-actions').first().click(); - cy.umbracoEditorHeaderName(firstChildNodeName); - cy.get('.btn-info').click(); - - // Add an item under root node - cy.umbracoTreeItem("content", [nodeName]).rightclick(); - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.umb-actions').first().click(); - cy.umbracoEditorHeaderName(secondChildNodeName); - cy.get('.btn-info').click(); + cy.umbracoContextMenuAction("action-refreshNode").click(); // Sort nodes cy.umbracoTreeItem("content", [nodeName]).rightclick({ force: true }); cy.umbracoContextMenuAction("action-sort").click(); - + const offsetFirstElm = cy.get('.ui-sortable .ui-sortable-handle :nth-child(2)').eq(0).then($el => $el.offset()); offsetFirstElm.then((offsetFirstElm) => { const pageYFirst = Math.round(offsetFirstElm.top); @@ -218,35 +279,41 @@ context('Content', () => { cy.get('.umb-tree-item [node="child"]').eq(1).should('contain.text', firstChildNodeName); // Clean up (content is automatically deleted when document types are gone) - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); cy.umbracoEnsureDocumentTypeNameNotExists(childDocTypeName); }); it('Rollback content', () => { - const rootdocTypeName = "Test document type"; + const rootDocTypeName = "Test document type"; const initialNodeName = "Home node"; const nodeName = "Home"; const rootDocType = new DocumentTypeBuilder() - .withName(rootdocTypeName) + .withName(rootDocTypeName) .withAllowAsRoot(true) .build(); cy.deleteAllContent(); - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); - cy.saveDocumentType(rootDocType); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); + cy.saveDocumentType(rootDocType).then((generatedRootDocType) => { + const rootContentNode = new ContentBuilder() + .withContentTypeAlias(generatedRootDocType["alias"]) + .addVariant() + .withName(initialNodeName) + .withSave(true) + .done() + .build(); + + cy.saveContent(rootContentNode) + }); + + // Refresh to update the tree cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); + cy.umbracoContextMenuAction("action-refreshNode").click(); - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.menu-label').first().click(); - - // Type name - cy.umbracoEditorHeaderName(initialNodeName); - - // Save and publish - cy.get('.btn-success').first().click(); - cy.umbracoSuccessNotification().should('be.visible'); + // Access node + cy.umbracoTreeItem("content", [initialNodeName]).click(); // Edit header cy.get('#headerName').clear(); @@ -261,52 +328,60 @@ context('Content', () => { cy.get('.umb-box-content > .ng-scope > .input-block-level') .find('option[label*=' + new Date().getDate() + ']') .then(elements => { - const option = elements[elements.length - 1].getAttribute('value'); + const option = elements[[elements.length - 1]].getAttribute('value'); cy.get('.umb-box-content > .ng-scope > .input-block-level') .select(option); }); cy.get('.umb-editor-footer-content__right-side > [button-style="success"] > .umb-button > .btn-success').click(); - + + cy.reload(); + // Assert - cy.get('.history').find('.umb-badge').eq(0).should('contain.text',"Save"); - cy.get('.history').find('.umb-badge').eq(1).should('contain.text',"Rollback"); + cy.get('.history').find('.umb-badge').eq(0).should('contain.text', "Save"); + cy.get('.history').find('.umb-badge').eq(1).should('contain.text', "Rollback"); cy.get('#headerName').should('have.value', initialNodeName); // Clean up (content is automatically deleted when document types are gone) - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName).wait(100); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); }); it('View audit trail', () => { - const rootdocTypeName = "Test document type"; + const rootDocTypeName = "Test document type"; const nodeName = "Home"; const labelName = "Name"; const rootDocType = new DocumentTypeBuilder() - .withName(rootdocTypeName) + .withName(rootDocTypeName) .withAllowAsRoot(true) .addGroup() - .addTextBoxProperty() - .withLabel(labelName) - .done() + .addTextBoxProperty() + .withLabel(labelName) + .done() .done() .build(); cy.deleteAllContent(); - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); - cy.saveDocumentType(rootDocType); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); + cy.saveDocumentType(rootDocType).then((generatedRootDocType) => { + const rootContentNode = new ContentBuilder() + .withContentTypeAlias(generatedRootDocType["alias"]) + .addVariant() + .withName(nodeName) + .withSave(true) + .done() + .build(); + + cy.saveContent(rootContentNode) + }); + + // Refresh to update the tree cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); + cy.umbracoContextMenuAction("action-refreshNode").click(); - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.menu-label').first().click(); - - // Type name - cy.umbracoEditorHeaderName(nodeName); - - // Save and publish - cy.get('.btn-success').first().click(); - cy.umbracoSuccessNotification().should('be.visible'); + // Access node + cy.umbracoTreeItem("content", [nodeName]).click(); // Navigate to Info app cy.get(':nth-child(2) > [ng-show="navItem.alias !== \'more\'"]').click(); @@ -315,64 +390,79 @@ context('Content', () => { cy.get('.history').should('exist'); // Clean up (content is automatically deleted when document types are gone) - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); }); it('Save draft', () => { - const rootdocTypeName = "Test document type"; + const rootDocTypeName = "Test document type"; const nodeName = "Home"; const rootDocType = new DocumentTypeBuilder() - .withName(rootdocTypeName) + .withName(rootDocTypeName) .withAllowAsRoot(true) .build(); cy.deleteAllContent(); - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); - cy.saveDocumentType(rootDocType); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); + cy.saveDocumentType(rootDocType).then((generatedRootDocType) => { + const rootContentNode = new ContentBuilder() + .withContentTypeAlias(generatedRootDocType["alias"]) + .withAction("saveNew") + .addVariant() + .withName(nodeName) + .withSave(true) + .done() + .build(); + + cy.saveContent(rootContentNode) + }); + + // Refresh to update the tree cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); + cy.umbracoContextMenuAction("action-refreshNode").click(); - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.menu-label').first().click(); + // Access node + cy.umbracoTreeItem("content", [nodeName]).click(); - // Type name - cy.umbracoEditorHeaderName(nodeName); - - // Save - cy.get('.btn-info').click(); - cy.umbracoSuccessNotification().should('be.visible'); - // Assert - cy.get('[data-element="node-info-status"]').find('.umb-badge').should('contain.text',"Draft"); + cy.get('[data-element="node-info-status"]').find('.umb-badge').should('contain.text', "Draft"); // Clean up (content is automatically deleted when document types are gone) - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); }); it('Preview draft', () => { - const rootdocTypeName = "Test document type"; + const rootDocTypeName = "Test document type"; const nodeName = "Home"; const rootDocType = new DocumentTypeBuilder() - .withName(rootdocTypeName) + .withName(rootDocTypeName) .withAllowAsRoot(true) .build(); cy.deleteAllContent(); - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); - cy.saveDocumentType(rootDocType); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); + cy.saveDocumentType(rootDocType).then((generatedRootDocType) => { + const rootContentNode = new ContentBuilder() + .withContentTypeAlias(generatedRootDocType["alias"]) + .withAction("saveNew") + .addVariant() + .withName(nodeName) + .withSave(true) + .done() + .build(); + + cy.saveContent(rootContentNode) + }); + + // Refresh to update the tree cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); + cy.umbracoContextMenuAction("action-refreshNode").click(); - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.menu-label').first().click(); - - // Type name - cy.umbracoEditorHeaderName(nodeName); - - // Save - cy.get('.btn-info').click(); + // Access node + cy.umbracoTreeItem("content", [nodeName]).click(); // Preview cy.get('[alias="preview"]').should('be.visible').click(); @@ -381,38 +471,44 @@ context('Content', () => { cy.umbracoSuccessNotification({ multiple: true }).should('be.visible'); // Clean up (content is automatically deleted when document types are gone) - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); }); it('Publish draft', () => { - const rootdocTypeName = "Test document type"; + const rootDocTypeName = "Test document type"; const nodeName = "Home"; const rootDocType = new DocumentTypeBuilder() - .withName(rootdocTypeName) + .withName(rootDocTypeName) .withAllowAsRoot(true) .build(); cy.deleteAllContent(); - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); - cy.saveDocumentType(rootDocType); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); + cy.saveDocumentType(rootDocType).then((generatedRootDocType) => { + const rootContentNode = new ContentBuilder() + .withContentTypeAlias(generatedRootDocType["alias"]) + .addVariant() + .withName(nodeName) + .withSave(true) + .done() + .build(); + + cy.saveContent(rootContentNode) + }); + + // Refresh to update the tree cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick(); + cy.umbracoContextMenuAction("action-refreshNode").click(); - cy.umbracoContextMenuAction("action-create").click(); - cy.get('.menu-label').first().click(); + // Access node + cy.umbracoTreeItem("content", [nodeName]).click(); - // Type name - cy.umbracoEditorHeaderName(nodeName); - - // Save and publish - cy.get('.btn-success').first().click(); - cy.umbracoSuccessNotification().should('be.visible'); - // Assert - cy.get('[data-element="node-info-status"]').find('.umb-badge').should('contain.text',"Published"); + cy.get('[data-element="node-info-status"]').find('.umb-badge').should('contain.text', "Published"); // Clean up (content is automatically deleted when document types are gone) - cy.umbracoEnsureDocumentTypeNameNotExists(rootdocTypeName); + cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName); }); }); From d8732e55a6e87790a6d28f20812619da0aa92586 Mon Sep 17 00:00:00 2001 From: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com> Date: Sun, 6 Sep 2020 17:08:36 +0200 Subject: [PATCH 4/6] Updates package to future latest with necessary changes --- src/Umbraco.Tests.AcceptanceTest/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/package.json b/src/Umbraco.Tests.AcceptanceTest/package.json index 867b7f5cf3..2aea85b6aa 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.1", "ncp": "^2.0.0", - "umbraco-cypress-testhelpers": "^1.0.0-beta-48" + "umbraco-cypress-testhelpers": "^1.0.0-beta-49" }, "dependencies": { "typescript": "^3.9.2" From b4b7bb438d9bd8da567671562bcb385397346822 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Wed, 9 Sep 2020 07:51:05 +0200 Subject: [PATCH 5/6] updated version of testhelpers --- 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 2aea85b6aa..2017142d1e 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.1", + "cypress": "^5.1.0", "ncp": "^2.0.0", - "umbraco-cypress-testhelpers": "^1.0.0-beta-49" + "umbraco-cypress-testhelpers": "^1.0.0-beta-50" }, "dependencies": { "typescript": "^3.9.2" From 6e2588580410c3b5c3b4ea4681c964b8518e13f2 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Wed, 9 Sep 2020 10:29:41 +0200 Subject: [PATCH 6/6] Simplified the drag and drop --- .../cypress/integration/Content/content.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts index 6b14a380b8..23e97043b0 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts @@ -254,21 +254,9 @@ context('Content', () => { cy.umbracoTreeItem("content", [nodeName]).rightclick({ force: true }); cy.umbracoContextMenuAction("action-sort").click(); - const offsetFirstElm = cy.get('.ui-sortable .ui-sortable-handle :nth-child(2)').eq(0).then($el => $el.offset()); - offsetFirstElm.then((offsetFirstElm) => { - const pageYFirst = Math.round(offsetFirstElm.top); - - const offsetSecondElm = cy.get('.ui-sortable .ui-sortable-handle :nth-child(2)').eq(1).then($el => $el.offset()); - offsetSecondElm.then((offset) => { - const pageX = Math.round(offset.left); - const pageY = Math.round(offset.top); - - cy.get('.table-sortable').find('tbody :nth-child(1)').eq(0) - .trigger('mousedown', { which: 1, pageX: pageX, pageY: pageYFirst }) - .trigger('mousemove', { which: 1, pageX: pageX, pageY: pageY }) - .trigger('mouseup'); - }) - }); + //Drag and drop + cy.get('.ui-sortable .ui-sortable-handle :nth-child(2)').eq(0).trigger('mousedown', { which: 1 }) + cy.get('.ui-sortable .ui-sortable-handle :nth-child(2)').eq(1).trigger("mousemove").trigger("mouseup") // Save and close dialog cy.get('.umb-modalcolumn .btn-success').click();