diff --git a/.changeset/sharp-frogs-change.md b/.changeset/sharp-frogs-change.md new file mode 100644 index 0000000000..64c2d53937 --- /dev/null +++ b/.changeset/sharp-frogs-change.md @@ -0,0 +1,5 @@ +--- +'@swisspost/design-system-components': patch +--- + +Fixed issue where the local header behaved inconsistently across different browsers. diff --git a/packages/components/cypress/e2e/header.cy.ts b/packages/components/cypress/e2e/header.cy.ts new file mode 100644 index 0000000000..000a09f1e1 --- /dev/null +++ b/packages/components/cypress/e2e/header.cy.ts @@ -0,0 +1,59 @@ +describe('header', { baseUrl: null, includeShadowDom: true }, () => { + const testFiles = ['post-header', 'post-header-without-title']; + + testFiles.forEach(testFile => { + describe(testFile.replaceAll('-', ' '), () => { + beforeEach(() => { + cy.visit(`./cypress/fixtures/${testFile}.test.html`); + + cy.get('post-header').as('header'); + }); + + function getContentTop() { + return cy.get('main').then($main => Math.round($main.position().top)); + } + + function checkLayoutShift() { + // get the content position before the header is visible + let initialContentTop: number; + getContentTop().then(pos => { + initialContentTop = pos; + cy.get('@header').should('not.be.visible'); + }); + + // check the content position did not change when the header is visible + cy.get('@header') + .should('be.visible') + .then(() => { + getContentTop().should('eq', initialContentTop); + }); + } + + it('should not shift layout on desktop', () => { + checkLayoutShift(); + }); + + it('should not shift layout on mobile', () => { + cy.viewport('ipad-2'); + checkLayoutShift(); + }); + + it('should not shift layout on mobile', () => { + cy.viewport('iphone-6'); + checkLayoutShift(); + }); + }); + }); + + describe('Accessibility', () => { + beforeEach(() => { + cy.visit('./cypress/fixtures/post-header.test.html'); + cy.get('post-header[data-hydrated]').should('be.visible'); + cy.injectAxe(); + }); + + it('Has no detectable a11y violations on load', () => { + cy.checkA11y('post-mainnavigation'); + }); + }); +}); diff --git a/packages/components/cypress/fixtures/post-header-without-title.test.html b/packages/components/cypress/fixtures/post-header-without-title.test.html new file mode 100644 index 0000000000..94a0d43e27 --- /dev/null +++ b/packages/components/cypress/fixtures/post-header-without-title.test.html @@ -0,0 +1,137 @@ + + + + + + Document + + + + + + + + + Homepage + + + + + + + Menu + + + + + + + DE + FR + IT + EN + + + + + + + + + + +

Main Navigation

+ + + Briefe + Pakete + + + + Briefe + + + Schliessen +

Briefe title

+ +

Briefe senden

+ Briefe Schweiz + Kleinwaren Ausland + Waren Ausland + Express und Kurier +
+ +

Schritt für Schritt

+ Pakete Schweiz + Kleinwaren Ausland + Waren Ausland + Express und Kurier +
+
+
+ + Pakete + + + Schliessen +

Pakete title

+ +

Pakete senden

+ Pakete Schweiz + Kleinwaren Ausland + Waren Ausland + Express und Kurier +
+ +

Schritt für Schritt

+ Pakete Schweiz + Kleinwaren Ausland + Waren Ausland + Express und Kurier +
+
+
+
+
+
+ +
+

Page Content

+
+ + diff --git a/packages/components/cypress/fixtures/post-header.test.html b/packages/components/cypress/fixtures/post-header.test.html new file mode 100644 index 0000000000..01e503009b --- /dev/null +++ b/packages/components/cypress/fixtures/post-header.test.html @@ -0,0 +1,140 @@ + + + + + + Document + + + + + + + + + Homepage + + + + + + + Menu + + + + + + + DE + FR + IT + EN + + + +

Application title

+ + + + + + + + + +

Main Navigation

+ + + Briefe + Pakete + + + + Briefe + + + Schliessen +

Briefe title

+ +

Briefe senden

+ Briefe Schweiz + Kleinwaren Ausland + Waren Ausland + Express und Kurier +
+ +

Schritt für Schritt

+ Pakete Schweiz + Kleinwaren Ausland + Waren Ausland + Express und Kurier +
+
+
+ + Pakete + + + Schliessen +

Pakete title

+ +

Pakete senden

+ Pakete Schweiz + Kleinwaren Ausland + Waren Ausland + Express und Kurier +
+ +

Schritt für Schritt

+ Pakete Schweiz + Kleinwaren Ausland + Waren Ausland + Express und Kurier +
+
+
+
+
+
+ +
+

Page Content

+
+ + diff --git a/packages/components/cypress/fixtures/post-mainnavigation-overflow.test.html b/packages/components/cypress/fixtures/post-mainnavigation-overflow.test.html deleted file mode 100644 index 30638c9cf0..0000000000 --- a/packages/components/cypress/fixtures/post-mainnavigation-overflow.test.html +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - Document - - - - - - - - Homepage - - - - - - - Menu - - - - - - - DE - FR - IT - EN - - - -

Application title

- - - - - - - - - -

Main Navigation

- - - Item 1 - - - Schliessen -

Briefe title

- -

Briefe senden

- Briefe Schweiz - Kleinwaren Ausland - Waren Ausland - Express und Kurier -
- -

Schritt für Schritt

- Pakete Schweiz - Kleinwaren Ausland - Waren Ausland - Express und Kurier -
-
-
- - - Item 2 - Item 3 - Item 4 - Item 5 - Item 6 - Item 7 - Item 8 - Item 9 - Item 10 - Item 11 - Item 12 - Item 13 - Item 14 - Item 15 - Item 16 - Item 17 - Item 18 - Item 19 - - - Item 20 - - - Schliessen -

Pakete title

- -

Pakete senden

- Pakete Schweiz - Kleinwaren Ausland - Waren Ausland - Express und Kurier -
- -

Schritt für Schritt

- Pakete Schweiz - Kleinwaren Ausland - Waren Ausland - Express und Kurier -
-
-
-
-
-
- - diff --git a/packages/components/cypress/fixtures/post-mainnavigation.test.html b/packages/components/cypress/fixtures/post-mainnavigation.test.html index 8d254364d9..b4eb7e560d 100644 --- a/packages/components/cypress/fixtures/post-mainnavigation.test.html +++ b/packages/components/cypress/fixtures/post-mainnavigation.test.html @@ -4,6 +4,10 @@ Document + Application title

Main Navigation

- - Briefe - Pakete - - - - Briefe - + + Item 1 +