From ba6085791b068ab42fb478f05d1db281b22b34ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20=C3=96ller?= Date: Tue, 29 Oct 2024 18:20:56 +0100 Subject: [PATCH 1/5] added container cypress tests for openAsModal, Drawer and Splitview --- .../compound/wc-compound-container.cy.js | 34 +++++++ .../test-app/iframe/iframe-container.cy.js | 54 +++++++++++ .../e2e/test-app/wc/wc-container.cy.js | 34 +++++++ container/test-app/compound/helloWorldWC.js | 40 ++++++-- .../test-app/iframe/iframeContainer.html | 9 +- container/test-app/iframe/microfrontend.html | 25 +++++ container/test-app/wc/clientAPI.html | 6 +- container/test-app/wc/helloWorldWC.js | 91 +++++++++++++++---- 8 files changed, 264 insertions(+), 29 deletions(-) diff --git a/container/cypress/e2e/test-app/compound/wc-compound-container.cy.js b/container/cypress/e2e/test-app/compound/wc-compound-container.cy.js index 9de337f9ff..942216cfec 100644 --- a/container/cypress/e2e/test-app/compound/wc-compound-container.cy.js +++ b/container/cypress/e2e/test-app/compound/wc-compound-container.cy.js @@ -217,6 +217,40 @@ describe('Compound Container Tests', () => { }); }); + it('openAsModal webcomponent container', () => { + cy.on('window:alert', stub); + + cy.get(containerSelector) + .shadow() + .get('#openAsModalBtn') + .click() + .then(() => { + cy.hash().should('eq', '#openAsModal-wc'); + }); + }); + it('openAsDrawer webcomponent container', () => { + cy.on('window:alert', stub); + + cy.get(containerSelector) + .shadow() + .get('#openAsDrawerBtn') + .click() + .then(() => { + cy.hash().should('eq', '#openAsDrawer-wc'); + }); + }); + it('openAsSplitview webcomponent container', () => { + cy.on('window:alert', stub); + + cy.get(containerSelector) + .shadow() + .get('#openAsSplitviewBtn') + .click() + .then(() => { + cy.hash().should('eq', '#openAsSplitview-wc'); + }); + }); + it('LuigiClient API publishEvent', () => { cy.on('window:alert', stub); diff --git a/container/cypress/e2e/test-app/iframe/iframe-container.cy.js b/container/cypress/e2e/test-app/iframe/iframe-container.cy.js index 0b6b5013e1..c59ca51920 100644 --- a/container/cypress/e2e/test-app/iframe/iframe-container.cy.js +++ b/container/cypress/e2e/test-app/iframe/iframe-container.cy.js @@ -115,4 +115,58 @@ describe('Iframe Container Test', () => { }); }); }); + + it('openAsModal', () => { + cy.on('window:confirm', () => false); + + cy.get(containerSelector) + .shadow() + .get('iframe') + .then(iframe => { + const $body = iframe.contents().find('body'); + cy.wrap($body) + .contains('test openAsModal()') + .click(); + + cy.location().should(loc => { + expect(loc.href).to.eq('http://localhost:8080/iframe/iframeContainer.html#openAsModal-iframe'); + }); + }); + }); + + it('openAsDrawer', () => { + cy.on('window:confirm', () => false); + + cy.get(containerSelector) + .shadow() + .get('iframe') + .then(iframe => { + const $body = iframe.contents().find('body'); + cy.wrap($body) + .contains('test openAsDrawer') + .click(); + + cy.location().should(loc => { + expect(loc.href).to.eq('http://localhost:8080/iframe/iframeContainer.html#openAsDrawer-iframe'); + }); + }); + }); + + it('openAsSplitview', () => { + cy.on('window:confirm', () => false); + + cy.get(containerSelector) + .shadow() + .get('iframe') + .then(iframe => { + const $body = iframe.contents().find('body'); + cy.wrap($body) + .contains('test openAsSplitview') + .click(); + + cy.location().should(loc => { + expect(loc.href).to.eq('http://localhost:8080/iframe/iframeContainer.html#openAsSplitview-iframe'); + }); + }); + }); }); diff --git a/container/cypress/e2e/test-app/wc/wc-container.cy.js b/container/cypress/e2e/test-app/wc/wc-container.cy.js index 65833119de..5550e977c2 100644 --- a/container/cypress/e2e/test-app/wc/wc-container.cy.js +++ b/container/cypress/e2e/test-app/wc/wc-container.cy.js @@ -158,6 +158,40 @@ describe('Web Container Test', () => { }); }); + it('openAsModal webcomponent container', () => { + cy.on('window:alert', stub); + + cy.get(containerSelector) + .shadow() + .get('#openAsModalBtn') + .click() + .then(() => { + cy.hash().should('eq', '#openAsModal-wc'); + }); + }); + it('openAsDrawer webcomponent container', () => { + cy.on('window:alert', stub); + + cy.get(containerSelector) + .shadow() + .get('#openAsDrawerBtn') + .click() + .then(() => { + cy.hash().should('eq', '#openAsDrawer-wc'); + }); + }); + it('openAsSplitview webcomponent container', () => { + cy.on('window:alert', stub); + + cy.get(containerSelector) + .shadow() + .get('#openAsSplitviewBtn') + .click() + .then(() => { + cy.hash().should('eq', '#openAsSplitview-wc'); + }); + }); + it('pathExists', () => { cy.on('window:alert', stub); diff --git a/container/test-app/compound/helloWorldWC.js b/container/test-app/compound/helloWorldWC.js index 0bd8936510..59271f5b07 100644 --- a/container/test-app/compound/helloWorldWC.js +++ b/container/test-app/compound/helloWorldWC.js @@ -79,12 +79,22 @@ export default class extends HTMLElement { withParams().navigate() `; + /* const linkManagerOpenAsRequestsBtn = document.createElement('template'); linkManagerOpenAsRequestsBtn.innerHTML = ``; + */ + const openAsModalBtn = document.createElement('template'); + openAsModalBtn.innerHTML = ''; + + const openAsDrawerBtn = document.createElement('template'); + openAsDrawerBtn.innerHTML = ''; + + const openAsSplitviewBtn = document.createElement('template'); + openAsSplitviewBtn.innerHTML = ''; const linkManagerUpdateTopPathExistsBackBtn = document.createElement('template'); linkManagerUpdateTopPathExistsBackBtn.innerHTML = ` + + + + +