From 768d79b010c40dccbe95a71427a1ddb48b9cebbb Mon Sep 17 00:00:00 2001 From: Ndricim Rrapi Date: Tue, 24 Sep 2024 18:13:11 +0200 Subject: [PATCH] Add tests and update docu --- .../compound/wc-compound-container.cy.js | 12 ++++++++++++ .../test-app/compound/compoundClientAPI.html | 1 + container/test-app/compound/helloWorldWC.js | 16 ++++++++++++++++ .../typings/LuigiCompoundContainer.svelte.d.ts | 2 +- docs/luigi-compound-container-api.md | 2 +- 5 files changed, 31 insertions(+), 2 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 a8f824c24d..3fca178d08 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 @@ -32,6 +32,18 @@ describe('Compound Container Tests', () => { }); }); + it('LuigiClient API - getCurrentLocale', () => { + cy.on('window:alert', stub); + + cy.get(containerSelector) + .shadow() + .contains('getCurrentLocale') + .click() + .then(() => { + expect(stub.getCall(0)).to.be.calledWith('LuigiClient.getCurrentLocale()=en'); + }); + }); + it('LuigiClient API - getDirtyStatus', () => { cy.on('window:alert', stub); diff --git a/container/test-app/compound/compoundClientAPI.html b/container/test-app/compound/compoundClientAPI.html index 85eefa9a37..df52da4a2a 100644 --- a/container/test-app/compound/compoundClientAPI.html +++ b/container/test-app/compound/compoundClientAPI.html @@ -37,6 +37,7 @@

defer-init="false" webcomponent="true" theme="sap_fiori_3" + locale="en" > diff --git a/container/test-app/compound/helloWorldWC.js b/container/test-app/compound/helloWorldWC.js index 0598bdd4df..a5ab9b3183 100644 --- a/container/test-app/compound/helloWorldWC.js +++ b/container/test-app/compound/helloWorldWC.js @@ -13,6 +13,9 @@ export default class extends HTMLElement { const templateBtn = document.createElement('template'); templateBtn.innerHTML = ''; + const current_locale = document.createElement('template'); + current_locale.innerHTML = ''; + const templateBtn2 = document.createElement('template'); templateBtn2.innerHTML = ''; @@ -112,10 +115,23 @@ export default class extends HTMLElement { this._shadowRoot.appendChild(linkManagerOpenAsRequestsBtn.content.cloneNode(true)); this._shadowRoot.appendChild(linkManagerUpdateTopPathExistsBackBtn.content.cloneNode(true)); this._shadowRoot.appendChild(setViewGroupDataBtn.content.cloneNode(true)); + this._shadowRoot.appendChild(current_locale.content.cloneNode(true)); + this._shadowRoot.appendChild(empty.content.cloneNode(true)); + this.$currentLocaleButton = this._shadowRoot.querySelector('#current_locale'); + this.$currentLocaleButton.addEventListener('click', () => { + if (this.LuigiClient) { + this.LuigiClient.uxManager().showAlert({ + text: 'LuigiClient.getCurrentLocale()=' + this.LuigiClient.getCurrentLocale(), + type: 'info' + }); + } + }); + this.$paragraph = this._shadowRoot.querySelector('p'); + this.$button = this._shadowRoot.querySelector('#aButton'); this.$button.addEventListener('click', () => { if (this.LuigiClient) { diff --git a/container/typings/LuigiCompoundContainer.svelte.d.ts b/container/typings/LuigiCompoundContainer.svelte.d.ts index ee033a1dec..8f8217364f 100644 --- a/container/typings/LuigiCompoundContainer.svelte.d.ts +++ b/container/typings/LuigiCompoundContainer.svelte.d.ts @@ -26,7 +26,7 @@ export default class LuigiCompoundContainer extends HTMLElement { /** * - * The locale to be passed to the compound micro frontend + * The locale to be passed to the compound micro frontend. * @since NEXT_RELEASE_CONTAINER */ locale: string; diff --git a/docs/luigi-compound-container-api.md b/docs/luigi-compound-container-api.md index a4afa50e52..613404f32d 100644 --- a/docs/luigi-compound-container-api.md +++ b/docs/luigi-compound-container-api.md @@ -51,7 +51,7 @@ Type: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Glob ### locale -The locale to be passed to the compound micro frontend +The locale to be passed to the compound micro frontend. Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)