From a856755d96e18667730abcdc63d790c411549371 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Tue, 9 May 2023 22:29:58 +0200 Subject: [PATCH] Add new footer element to switch to the correct footer Relates to MS-714 --- client/cypress/support/component.ts | 4 +- client/src/helpers/app-flavor.constants.ts | 4 + client/src/helpers/flavor.stubabble.js | 15 +++ client/src/helpers/types.ts | 1 + client/src/layouts/MyKVFooter.cy.js | 21 +++ client/src/layouts/MyKVFooter.vue | 139 ++++++++++++++++++++ client/src/layouts/SimpleFooter.cy.js | 45 +++++++ client/src/layouts/SimpleFooter.vue | 54 +++----- client/src/layouts/SimpleLayout.vue | 45 ++++--- client/src/layouts/SkillboxSimpleFooter.vue | 40 ++++++ 10 files changed, 311 insertions(+), 57 deletions(-) create mode 100644 client/src/helpers/flavor.stubabble.js create mode 100644 client/src/layouts/MyKVFooter.cy.js create mode 100644 client/src/layouts/MyKVFooter.vue create mode 100644 client/src/layouts/SimpleFooter.cy.js create mode 100644 client/src/layouts/SkillboxSimpleFooter.vue diff --git a/client/cypress/support/component.ts b/client/cypress/support/component.ts index 5accb9c6..2efd8572 100644 --- a/client/cypress/support/component.ts +++ b/client/cypress/support/component.ts @@ -34,7 +34,9 @@ declare global { } } -Cypress.Commands.add('mount', mount); +Cypress.Commands.add('mount', (component, ...args) => { + return mount(component, ...args); +}); // Example use: // cy.mount(MyComponent) diff --git a/client/src/helpers/app-flavor.constants.ts b/client/src/helpers/app-flavor.constants.ts index 82f2d49b..aa569843 100644 --- a/client/src/helpers/app-flavor.constants.ts +++ b/client/src/helpers/app-flavor.constants.ts @@ -4,6 +4,7 @@ export const defaultFlavorValues: FlavorValues = { appFlavor: 'skillbox', appLogo: '/static/logo.png', supportLink: 'https://myskillbox.ch/support', + baseUrl: 'myskillbox.ch', // mySkillbox texts textAppName: 'mySkillbox', @@ -28,6 +29,7 @@ export const myKvValues: FlavorValues = { appFlavor: 'my-kv', appLogo: 'https://skillbox-my-kv-prod.s3-eu-west-1.amazonaws.com/mykv-logo.png', supportLink: 'https://www.mykv.ch/support', + baseUrl: 'mykv.ch', // myKV texts textAppName: 'myKV', @@ -50,12 +52,14 @@ export const myKvValues: FlavorValues = { export const dhfValues: FlavorValues = Object.assign({}, myKvValues, { appFlavor: 'my-dhf', + baseUrl: 'mydetailhandel.ch', appLogo: 'https://skillbox-my-detailhandel-dhf-prod.s3.eu-central-1.amazonaws.com/myDHF-logo.png', textAppName: 'myDHF', helloIllustration: 'HelloMyDHFIllustration', }); export const dhaValues: FlavorValues = Object.assign({}, myKvValues, { appFlavor: 'my-dha', + baseUrl: 'mydetailhandel.ch', appLogo: 'https://skillbox-my-detailhandel-dha-prod.s3.eu-central-1.amazonaws.com/myDHA-logo.png', textAppName: 'myDHA', helloIllustration: 'HelloMyDHAIllustration', diff --git a/client/src/helpers/flavor.stubabble.js b/client/src/helpers/flavor.stubabble.js new file mode 100644 index 00000000..e377ac06 --- /dev/null +++ b/client/src/helpers/flavor.stubabble.js @@ -0,0 +1,15 @@ +import flavor from './app-flavor'; + +const getFlavor = () => { + return flavor; +}; + +/* + * We have to do this like this, so we're able to stub the method `getFlavor`, + * otherwise we get a `ESModules can't be stubbed` error from cypress + * + * see: https://github.com/cypress-io/cypress/issues/22355#issuecomment-1485716724 + */ +export const Flavor = { + getFlavor, +}; diff --git a/client/src/helpers/types.ts b/client/src/helpers/types.ts index 3e8dd3fe..c67e1a8e 100644 --- a/client/src/helpers/types.ts +++ b/client/src/helpers/types.ts @@ -2,6 +2,7 @@ export interface FlavorValues { appFlavor: string; appLogo: string; supportLink: string; + baseUrl: string; textAppName: string; textTopic: string; textTopics: string; diff --git a/client/src/layouts/MyKVFooter.cy.js b/client/src/layouts/MyKVFooter.cy.js new file mode 100644 index 00000000..69f0887d --- /dev/null +++ b/client/src/layouts/MyKVFooter.cy.js @@ -0,0 +1,21 @@ +import MyKVFooter from './MyKVFooter.vue' + +describe('', () => { + it('renders', () => { + // see: https://on.cypress.io/mounting-vue + cy.mount(MyKVFooter, { + global: { + config: { + globalProperties: { + $flavor: {} + } + } + } + }) + cy.viewport('macbook-15'); + cy.get('a').eq(0).should('contain', 'Datenschutz'); + cy.get('a').eq(1).should('contain', 'Impressum'); + cy.get('a').eq(2).should('contain', 'AGB'); + cy.get('a').eq(3).should('contain', 'Support'); + }) +}) diff --git a/client/src/layouts/MyKVFooter.vue b/client/src/layouts/MyKVFooter.vue new file mode 100644 index 00000000..9961d64a --- /dev/null +++ b/client/src/layouts/MyKVFooter.vue @@ -0,0 +1,139 @@ + + + + + diff --git a/client/src/layouts/SimpleFooter.cy.js b/client/src/layouts/SimpleFooter.cy.js new file mode 100644 index 00000000..bfc7e61e --- /dev/null +++ b/client/src/layouts/SimpleFooter.cy.js @@ -0,0 +1,45 @@ +import SimpleFooter from './SimpleFooter.vue'; +import { Flavor } from '@/helpers/flavor.stubabble'; +import { defaultFlavorValues, dhaValues, dhfValues, myKvValues } from '@/helpers/app-flavor.constants'; + +const checkLinks = (baseUrl) => { + cy.mount(SimpleFooter); + cy.viewport('macbook-15'); + cy.get('a') + .eq(0) + .should('contain', 'Datenschutz') + .and('have.attr', 'href') + .and('include', `https://${baseUrl}/datenschutz`); + cy.get('a') + .eq(1) + .should('contain', 'Impressum') + .and('have.attr', 'href') + .and('include', `https://${baseUrl}/impressum`); + cy.get('a').eq(2).should('contain', 'AGB').and('have.attr', 'href').and('include', `https://${baseUrl}/agb`); + cy.get('a').eq(3).should('contain', 'Support').and('have.attr', 'href').and('include', `https://${baseUrl}/support`); +}; + +describe('', () => { + it('renders for MySkillbox', () => { + // see: https://on.cypress.io/mounting-vue + cy.stub(Flavor, 'getFlavor').returns(defaultFlavorValues); + cy.mount(SimpleFooter); + cy.viewport('macbook-15'); + cy.get('p').eq(0).should('contain', 'Copyright'); + }); + it('renders for MyKV', () => { + // see: https://on.cypress.io/mounting-vue + cy.stub(Flavor, 'getFlavor').returns(myKvValues); + checkLinks('mykv.ch'); + }); + it('renders for MyDHA', () => { + // see: https://on.cypress.io/mounting-vue + cy.stub(Flavor, 'getFlavor').returns(dhaValues); + checkLinks('mydetailhandel.ch'); + }); + it('renders for MyDHF', () => { + // see: https://on.cypress.io/mounting-vue + cy.stub(Flavor, 'getFlavor').returns(dhfValues); + checkLinks('mydetailhandel.ch'); + }); +}); diff --git a/client/src/layouts/SimpleFooter.vue b/client/src/layouts/SimpleFooter.vue index e60990e4..b0192c8b 100644 --- a/client/src/layouts/SimpleFooter.vue +++ b/client/src/layouts/SimpleFooter.vue @@ -1,40 +1,24 @@ - +}); + diff --git a/client/src/layouts/SimpleLayout.vue b/client/src/layouts/SimpleLayout.vue index 630632dc..cf44875b 100644 --- a/client/src/layouts/SimpleLayout.vue +++ b/client/src/layouts/SimpleLayout.vue @@ -10,38 +10,41 @@ - - diff --git a/client/src/layouts/SkillboxSimpleFooter.vue b/client/src/layouts/SkillboxSimpleFooter.vue new file mode 100644 index 00000000..e60990e4 --- /dev/null +++ b/client/src/layouts/SkillboxSimpleFooter.vue @@ -0,0 +1,40 @@ + + +