diff --git a/.changeset/cold-mails-shout.md b/.changeset/cold-mails-shout.md new file mode 100644 index 0000000000..7267523bef --- /dev/null +++ b/.changeset/cold-mails-shout.md @@ -0,0 +1,5 @@ +--- +'@swisspost/internet-header': patch +--- + +Fixed an issue with uppercase environment strings. Uppercase environment strings caused issues with mapping to datasets throughout the header. Now the property is being converted to lowercase internally. diff --git a/packages/internet-header/cypress/e2e/environment.cy.ts b/packages/internet-header/cypress/e2e/environment.cy.ts new file mode 100644 index 0000000000..e7f098cdd8 --- /dev/null +++ b/packages/internet-header/cypress/e2e/environment.cy.ts @@ -0,0 +1,16 @@ +import testConfiguration from '../fixtures/internet-header/test-configuration.json'; +import mockAuth from '../fixtures/internet-header/auth.json'; + +describe('header attributes', { baseUrl: null }, () => { + beforeEach(() => { + cy.intercept('**/v1/session/subscribe', mockAuth).as('auth'); + cy.intercept('**/api/headerjs/Json?serviceid=*', testConfiguration).as('getConfig'); + }); + + it('should lowercase the environment attribute', () => { + cy.visit('./cypress/fixtures/pages/uppercase-environment.html'); + cy.wait('@getConfig').then(interception => { + expect(interception.request.query['environment']).to.eq('int01'); + }); + }); +}); diff --git a/packages/internet-header/cypress/fixtures/pages/uppercase-environment.html b/packages/internet-header/cypress/fixtures/pages/uppercase-environment.html new file mode 100644 index 0000000000..47be1f5d7e --- /dev/null +++ b/packages/internet-header/cypress/fixtures/pages/uppercase-environment.html @@ -0,0 +1,17 @@ + + + + + + + Document + + + + +

Fixtures - uppercase environment

+ + diff --git a/packages/internet-header/src/assets/js/klp-login-widget.js b/packages/internet-header/src/assets/js/klp-login-widget.js index 3ea3c0389b..e8c854c3f0 100644 --- a/packages/internet-header/src/assets/js/klp-login-widget.js +++ b/packages/internet-header/src/assets/js/klp-login-widget.js @@ -1192,6 +1192,10 @@ const vertx = window.vertx || {}; if (sessionData.userType === 'B2C') { const settingEnvLinks = { + dev01: 'https://serviceint1.post.ch/kvm/app/ui', + dev02: 'https://serviceint1.post.ch/kvm/app/ui', + devs1: 'https://serviceint1.post.ch/kvm/app/ui', + test: 'https://serviceint1.post.ch/kvm/app/ui', int01: 'https://serviceint1.post.ch/kvm/app/ui', int02: 'https://serviceint2.post.ch/kvm/app/ui', prod: 'https://service.post.ch/kvm/app/ui', diff --git a/packages/internet-header/src/components/post-internet-header/post-internet-header.tsx b/packages/internet-header/src/components/post-internet-header/post-internet-header.tsx index b1248e303d..6d6a02aba6 100644 --- a/packages/internet-header/src/components/post-internet-header/post-internet-header.tsx +++ b/packages/internet-header/src/components/post-internet-header/post-internet-header.tsx @@ -167,7 +167,7 @@ export class PostInternetHeader { // Wait for the config to arrive, then render the header try { state.projectId = this.project; - state.environment = this.environment; + state.environment = this.environment.toLocaleLowerCase() as Environment; if (this.language !== undefined) state.currentLanguage = this.language; state.languageSwitchOverrides = typeof this.languageSwitchOverrides === 'string' @@ -187,7 +187,7 @@ export class PostInternetHeader { state.localizedConfig = await getLocalizedConfig({ projectId: this.project, - environment: this.environment, + environment: state.environment, language: this.language, cookieKey: this.languageCookieKey, localStorageKey: this.languageLocalStorageKey,