diff --git a/packages/main/src/components/ObjectPage/ObjectPage.cy.tsx b/packages/main/src/components/ObjectPage/ObjectPage.cy.tsx index 0ac7d1137aa..3bdb7bbd548 100644 --- a/packages/main/src/components/ObjectPage/ObjectPage.cy.tsx +++ b/packages/main/src/components/ObjectPage/ObjectPage.cy.tsx @@ -7,7 +7,7 @@ import TitleLevel from '@ui5/webcomponents/dist/types/TitleLevel.js'; import ValueState from '@ui5/webcomponents-base/dist/types/ValueState.js'; import IllustrationMessageType from '@ui5/webcomponents-fiori/dist/types/IllustrationMessageType.js'; import type { CSSProperties } from 'react'; -import { useEffect, useLayoutEffect, useReducer, useRef, useState } from 'react'; +import { useEffect, useLayoutEffect, useReducer, useRef, useState, version as reactVersion } from 'react'; import type { ObjectPagePropTypes } from '../..'; import { CheckBox, @@ -114,7 +114,7 @@ describe('ObjectPage', () => { cy.get('[ui5-tabcontainer]').findUi5TabByText('Section 15').should('have.attr', 'aria-selected', 'true'); if (mode === ObjectPageMode.Default) { - cy.findByTestId('op').scrollTo(0, 4750); + cy.findByTestId('op').scrollTo(0, 4858); cy.findByText('Content 7').should('be.visible'); cy.get('[ui5-tabcontainer]').findUi5TabByText('Section 7').should('have.attr', 'aria-selected', 'true'); @@ -124,7 +124,7 @@ describe('ObjectPage', () => { for (let i = 0; i < 15; i++) { cy.findByText('Add').click(); } - cy.findByTestId('op').scrollTo(0, 4750); + cy.findByTestId('op').scrollTo(0, 4858); cy.findByText('Content 7').should('be.visible'); cy.get('[ui5-tabcontainer]').findUi5TabByText('Section 7').should('have.attr', 'aria-selected', 'true'); @@ -374,12 +374,6 @@ describe('ObjectPage', () => { ); cy.wait(200); - // first titleText should never be displayed (not.be.visible doesn't work here - only invisible for sighted users) - cy.findByText('Goals') - .parent() - .should('have.css', 'width', '1px') - .and('have.css', 'margin', '-1px') - .and('have.css', 'position', 'absolute'); cy.findByText('Employment').should('not.be.visible'); cy.findByText('Test').should('be.visible'); @@ -712,19 +706,19 @@ describe('ObjectPage', () => { }; cy.mount(); cy.findByText('Update Heights').click(); - cy.findByText('{"offset":1080,"scroll":2290}').should('exist'); + cy.findByText('{"offset":1080,"scroll":2330}').should('exist'); cy.findByTestId('op').scrollTo('bottom'); cy.findByText('Update Heights').click({ force: true }); - cy.findByText('{"offset":1080,"scroll":2290}').should('exist'); + cy.findByText('{"offset":1080,"scroll":2330}').should('exist'); cy.mount(); cy.findByText('Update Heights').click(); - cy.findByText('{"offset":1080,"scroll":2330}').should('exist'); + cy.findByText('{"offset":1080,"scroll":2370}').should('exist'); cy.findByTestId('op').scrollTo('bottom'); cy.findByText('Update Heights').click({ force: true }); - cy.findByText('{"offset":1080,"scroll":2330}').should('exist'); + cy.findByText('{"offset":1080,"scroll":2370}').should('exist'); cy.mount(); cy.findByText('Update Heights').click(); @@ -923,12 +917,6 @@ describe('ObjectPage', () => { cy.get('[ui5-tabcontainer]').findUi5TabByText('Goals').click(); cy.findByText('Custom Header Section One').should('be.visible'); cy.findByText('toggle titleText1').click({ scrollBehavior: false, force: true }); - // first titleText should never be displayed (not.be.visible doesn't work here - only invisible for sighted users) - cy.findByText('Goals') - .parent() - .should('have.css', 'width', '1px') - .and('have.css', 'margin', '-1px') - .and('have.css', 'position', 'absolute'); cy.findByText('Custom Header Section One').should('be.visible'); cy.get('[ui5-tabcontainer]').findUi5TabByText('Personal').click(); @@ -1843,6 +1831,61 @@ describe('ObjectPage', () => { } cy.focused().should('be.visible').and('have.attr', 'ui5-table-row'); }); + + it('sticky headers', () => { + cy.mount( + + {OPContent} + {OPContentWithCustomHeaderSections} + , + ); + + cy.findByText('Goals').should('not.be.visible'); + cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').click(); + cy.findByText('Employment').should('not.be.visible'); + cy.findByText('Employee Details').parent().should('have.css', 'position', 'sticky'); + + cy.mount( + + {OPContent} + {OPContentWithCustomHeaderSections} + , + ); + + cy.findByText('Goals').should('be.visible').parent().should('have.css', 'position', 'sticky'); + cy.findByTestId('op').scrollTo(0, 500); + cy.findByText('Goals').should('be.visible'); + cy.get('[ui5-tabcontainer]').findUi5TabByText('Personal').click(); + // has subsections -> only subsection headers are sticky + cy.findByText('Personal').should('be.visible').parent().should('have.css', 'position', 'static'); + cy.findByText('Connect').should('be.visible').parent().should('have.css', 'position', 'sticky'); + cy.findByTestId('op').scrollTo(0, 2500); + cy.findByText('Goals').should('not.be.visible'); + cy.findByText('Payment Information').should('be.visible'); + cy.get('[ui5-tabcontainer]').findUi5TabByText('Custom Header Section One').click(); + cy.findByText('Custom Header Section One').should('be.visible').parent().should('have.css', 'position', 'sticky'); + cy.findByTestId('op').scrollTo(0, 3500); + cy.findByText('Custom Header Section One').should('be.visible'); + cy.get('[ui5-tabcontainer]').findUi5TabByText('Custom Header Section Two').click(); + // has subsections -> only subsection headers are sticky + cy.findByText('Custom Header Section Two').should('be.visible').parent().should('have.css', 'position', 'static'); + cy.findByText('Subsection1').should('be.visible').parent().should('have.css', 'position', 'sticky'); + cy.findByTestId('op').scrollTo(0, 4000); + cy.findByText('Custom Header Section Two').should('not.be.visible'); + cy.findByText('Subsection1').should('be.visible'); + }); }); const DPTitle = ( @@ -1942,6 +1985,44 @@ const OPContent = [ , ]; +const OPContentWithCustomHeaderSections = [ + Custom Header Section One} + > +
+ , + Custom Header Section Two} + > + + + +