From f1f34811abb1ae894eaa03e9bf41350971a5a272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Tomoaki=20=C3=96ller?= <85555471+VincentUllal@users.noreply.github.com> Date: Thu, 7 Nov 2024 11:40:58 +0100 Subject: [PATCH] add container cypress tests for openAsModal, Drawer and Splitview (#4004) * added container cypress tests for openAsModal, openAsDrawer and openAsSplitview --- .../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 | 4 +- container/test-app/wc/helloWorldWC.js | 91 +++++++++++++++---- 8 files changed, 262 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..fe2b83d177 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.hash).to.eq('#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.hash).to.eq('#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.hash).to.eq('#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 = ` + + + + +