From 5584969c4a159f91759df75b21c5d48720976dd1 Mon Sep 17 00:00:00 2001 From: Waldemar Mazurek Date: Thu, 10 Oct 2024 10:35:29 +0200 Subject: [PATCH] Adds e2e tests for linkManager chain requests (#3979) --- .../compound/wc-compound-container.cy.js | 13 ++++++++++++ .../e2e/test-app/wc/wc-container.cy.js | 13 ++++++++++++ container/test-app/compound/helloWorldWC.js | 21 ++++++++++++++----- container/test-app/wc/helloWorldWC.js | 21 ++++++++++++++----- 4 files changed, 58 insertions(+), 10 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 494d7788cd..37d0cb97f1 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 @@ -204,6 +204,19 @@ describe('Compound Container Tests', () => { cy.get('#defer-init-flag').should('exist'); }); + it('linkManagerChainRequests for navigation', () => { + cy.on('window:alert', stub); + + cy.get(containerSelector) + .shadow() + .get('#linkManagerChainRequests') + .click() + .then(() => { + expect(stub.getCall(0)).to.be.calledWith('LuigiClient.linkManager().navigate()'); + cy.hash().should('eq', '#hello-world-wc'); + }); + }); + it('LuigiClient API publishEvent', () => { cy.on('window:alert', stub); 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 a6e4916d65..f8c4e78b4c 100644 --- a/container/cypress/e2e/test-app/wc/wc-container.cy.js +++ b/container/cypress/e2e/test-app/wc/wc-container.cy.js @@ -145,6 +145,19 @@ describe('Web Container Test', () => { .should('have.text', 'Received Custom Message: cool custom Message'); }); + it('linkManagerChainRequests for navigation', () => { + cy.on('window:alert', stub); + + cy.get(containerSelector) + .shadow() + .get('#linkManagerChainRequests') + .click() + .then(() => { + expect(stub.getCall(0)).to.be.calledWith('LuigiClient.linkManager().navigate()'); + cy.hash().should('eq', '#hello-world-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 422d1270f5..0bd8936510 100644 --- a/container/test-app/compound/helloWorldWC.js +++ b/container/test-app/compound/helloWorldWC.js @@ -281,18 +281,29 @@ export default class extends HTMLElement { this.$linkManagerChainRequests = this._shadowRoot.querySelector('#linkManagerChainRequests'); this.$linkManagerChainRequests.addEventListener('click', () => { + const path = 'hello-world-wc'; + const ctx = { ctx: 123 }; + this.LuigiClient.linkManager() - .fromContext({ ctx: 123 }) - .navigate('hello-world-wc'); + .fromContext(ctx) + .navigate(); this.LuigiClient.linkManager() .fromClosestContext() - .navigate('hello-world-wc'); + .navigate(path); this.LuigiClient.linkManager() .fromVirtualTreeRoot() - .navigate('hello-world-wc'); + .navigate(path); + this.LuigiClient.linkManager() + .fromParent(ctx) + .navigate(path); this.LuigiClient.linkManager() .withParams('my-params') - .navigate('hello-world-wc'); + .navigate(path); + this.LuigiClient.linkManager().navigate(path); + this.LuigiClient.uxManager().showAlert({ + text: 'LuigiClient.linkManager().navigate()', + type: 'info' + }); }); this.$linkManagerOpenAsRequests = this._shadowRoot.querySelector('#linkManagerOpenAsRequests'); diff --git a/container/test-app/wc/helloWorldWC.js b/container/test-app/wc/helloWorldWC.js index be7ba2d12f..2ecaa8d9fb 100644 --- a/container/test-app/wc/helloWorldWC.js +++ b/container/test-app/wc/helloWorldWC.js @@ -248,18 +248,29 @@ export default class extends HTMLElement { this.$linkManagerChainRequests = this._shadowRoot.querySelector('#linkManagerChainRequests'); this.$linkManagerChainRequests.addEventListener('click', () => { + const path = 'hello-world-wc'; + const ctx = { ctx: 123 }; + this.LuigiClient.linkManager() - .fromContext({ ctx: 123 }) - .navigate('hello-world-wc'); + .fromContext(ctx) + .navigate(); this.LuigiClient.linkManager() .fromClosestContext() - .navigate('hello-world-wc'); + .navigate(path); this.LuigiClient.linkManager() .fromVirtualTreeRoot() - .navigate('hello-world-wc'); + .navigate(path); + this.LuigiClient.linkManager() + .fromParent(ctx) + .navigate(path); this.LuigiClient.linkManager() .withParams('my-params') - .navigate('hello-world-wc'); + .navigate(path); + this.LuigiClient.linkManager().navigate(path); + this.LuigiClient.uxManager().showAlert({ + text: 'LuigiClient.linkManager().navigate()', + type: 'info' + }); }); this.$linkManagerOpenAsRequests = this._shadowRoot.querySelector('#linkManagerOpenAsRequests');