From 771055f19e8b646a345d20e205221f9a6cb3d301 Mon Sep 17 00:00:00 2001 From: akarmanov Date: Tue, 5 Nov 2024 15:28:49 -0500 Subject: [PATCH 1/8] BACKLOG-23358 Add highlight test --- tests/cypress/e2e/jcontent/preview.cy.ts | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/cypress/e2e/jcontent/preview.cy.ts b/tests/cypress/e2e/jcontent/preview.cy.ts index 639fa393e..25693b19d 100644 --- a/tests/cypress/e2e/jcontent/preview.cy.ts +++ b/tests/cypress/e2e/jcontent/preview.cy.ts @@ -1,6 +1,20 @@ import {JContent} from '../../page-object'; +import gql from 'graphql-tag'; describe('JContent preview tests', () => { + const addContent = gql`mutation MyMutation { + jcr { + addNode( + name: "addedNode" + parentPathOrId: "/sites/jcontentSite/home/area-main" + primaryNodeType: "jnt:bigText" + properties: { name: "text", language: "en", value: "test added" } + ) { + uuid + } + } +}`; + beforeEach(() => { cy.executeGroovy('jcontent/createSite.groovy', {SITEKEY: 'jcontentSite'}); cy.apollo({mutationFile: 'jcontent/createContent.graphql'}); @@ -39,6 +53,23 @@ describe('JContent preview tests', () => { .should('be.visible'); }); + it('should highlight changes staging vs live', () => { + cy.apollo({mutation: addContent}); + JContent.visit('jcontentSite', 'en', 'pages/home#(jcontent:(compareDialog:(open:!t,path:/sites/jcontentSite/home)))'); + cy.get('h1').contains('Compare staging vs live version').should('exist'); + cy.get('button[data-sel-role="highlight"]').should('be.visible').click(); + cy.get('iframe[data-sel-role="staging-frame"]') + .its('0.contentDocument.body') + .should('be.visible') + .contains('span[class="diff-html-added"]'); + cy.get('button[data-sel-role="highlight"]').should('be.visible').click(); + cy.get('iframe[data-sel-role="staging-frame"]') + .its('0.contentDocument.body') + .should('be.visible') + .contains('span[class="diff-html-added"]') + .should('not.exist'); + }); + afterEach(() => { cy.logout(); cy.executeGroovy('jcontent/deleteSite.groovy', {SITEKEY: 'jcontentSite'}); From 4e0c698c53a04d9f300a025e10d3991192a95982 Mon Sep 17 00:00:00 2001 From: akarmanov Date: Wed, 6 Nov 2024 07:31:44 -0500 Subject: [PATCH 2/8] BACKLOG-23358 Refactor tests --- .../JContent/CompareDialog/CompareDialog.jsx | 4 +- .../e2e/jcontent/compareStagingLive.cy.ts | 60 +++++++++++++++++++ tests/cypress/e2e/jcontent/preview.cy.ts | 42 ------------- tests/cypress/page-object/compareDialog.ts | 35 +++++++++++ tests/cypress/page-object/jcontent.ts | 5 ++ 5 files changed, 102 insertions(+), 44 deletions(-) create mode 100644 tests/cypress/e2e/jcontent/compareStagingLive.cy.ts create mode 100644 tests/cypress/page-object/compareDialog.ts diff --git a/src/javascript/JContent/CompareDialog/CompareDialog.jsx b/src/javascript/JContent/CompareDialog/CompareDialog.jsx index dd4a7811c..2a57969b5 100644 --- a/src/javascript/JContent/CompareDialog/CompareDialog.jsx +++ b/src/javascript/JContent/CompareDialog/CompareDialog.jsx @@ -43,14 +43,14 @@ const CompareDialog = () => { } return ( - +