Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: converted environment to lowercase on initialization #1670

Merged
merged 3 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cold-mails-shout.md
Original file line number Diff line number Diff line change
@@ -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.
16 changes: 16 additions & 0 deletions packages/internet-header/cypress/e2e/environment.cy.ts
Original file line number Diff line number Diff line change
@@ -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');
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script
src="../../../dist/swisspost-internet-header/swisspost-internet-header.esm.js"
type="module"
></script>
</head>
<body>
<swisspost-internet-header project="ekp" environment="INT01"></swisspost-internet-header>
<h1>Fixtures - uppercase environment</h1>
</body>
</html>
4 changes: 4 additions & 0 deletions packages/internet-header/src/assets/js/klp-login-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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,
Expand Down
Loading