From 299259c16c8b606da94d26c0d74ce1a0373b9046 Mon Sep 17 00:00:00 2001 From: tparisi Date: Thu, 31 Oct 2024 15:28:51 +0100 Subject: [PATCH 1/2] bug fix. ExternalViews where not deserialized correctly on client side --- src/client/deserializers/customization.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/deserializers/customization.ts b/src/client/deserializers/customization.ts index 3d09dd1ff..95b90e168 100644 --- a/src/client/deserializers/customization.ts +++ b/src/client/deserializers/customization.ts @@ -17,13 +17,14 @@ import { Timezone } from "chronoshift"; import { ClientCustomization, SerializedCustomization } from "../../common/models/customization/customization"; import { deserialize as deserializeLocale } from "../../common/models/locale/locale"; +import { ExternalView } from "../../common/models/external-view/external-view"; export function deserialize(customization: SerializedCustomization): ClientCustomization { const { headerBackground, messages, locale, customLogoSvg, timezones, externalViews, hasUrlShortener, sentryDSN, visualizationColors } = customization; return { headerBackground, customLogoSvg, - externalViews, + externalViews: externalViews.map(ExternalView.fromJS), hasUrlShortener, sentryDSN, messages, From f6d5583ab537db935a33a6abf33600ba84a19eca Mon Sep 17 00:00:00 2001 From: tparisi Date: Fri, 1 Nov 2024 23:14:29 +0100 Subject: [PATCH 2/2] Added test as requested in PR review --- config-examples.yaml | 6 ++++++ cypress/e2e/externalview.cy.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 cypress/e2e/externalview.cy.ts diff --git a/config-examples.yaml b/config-examples.yaml index 2c1248cca..dd718d4fa 100644 --- a/config-examples.yaml +++ b/config-examples.yaml @@ -635,3 +635,9 @@ customization: urlShortener: | // also available: context.clientIp return request.get('http://tinyurl.com/api-create.php?url=' + encodeURIComponent(url)) + externalViews: + - title: Example externalView + linkGenerator: > + { + return 'http://www.example.com'; + } diff --git a/cypress/e2e/externalview.cy.ts b/cypress/e2e/externalview.cy.ts new file mode 100644 index 000000000..bd093c56d --- /dev/null +++ b/cypress/e2e/externalview.cy.ts @@ -0,0 +1,27 @@ +/* + * Copyright 2017-2022 Allegro.pl + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +describe('ExternalView', () => { + it('open share menu and find example externalView', () => { + cy.visit('http://localhost:9090/#covid19/4/N4IgbglgzgrghgGwgLzgFwgewHYgFwhqZqJQgA0408SqGOAygKZobYDmZe2MCClGALZNkOJvhABRNAGMA9AFUAKgGEKIAGYQEaJgCcuAbVBoAngAdxBIeMp6mGiTfU2ACvqwATI6E8w96Fi4BK4AjACa6lC65vgAtKECFlYgCOhM0SAAvgC6uZRQ5khoRjkFHhn4xiD2GvpM2DIpMnBQlZQamHqC6PgmyRKeDnC8aOpgiDAp2UmWEsKt/uJZ5KC19Y0pQ+gAFmQdXT1jeP1zBEMaIzrjk9MrhAMEC7D2M2sOG01OGSXqnd29E4PM4gC5XMaUCYIKYSGbAlLPJZvGofeybCQTGQyCDYQI4faaQ6A05bYajG7Qu6zBFMRavfIgcw47BMTwAEQgwmwUCCRlSmBa9FwZUZzNZDC6xxALTaZCyQA=') + + cy.get('div.icon-button:nth-child(3)').click() + cy.contains('Example externalView') + }) +}) + + +