diff --git a/packages/main/src/components/ObjectPage/ObjectPage.cy.tsx b/packages/main/src/components/ObjectPage/ObjectPage.cy.tsx index 9346e351627..7f82a618cf3 100644 --- a/packages/main/src/components/ObjectPage/ObjectPage.cy.tsx +++ b/packages/main/src/components/ObjectPage/ObjectPage.cy.tsx @@ -2,6 +2,7 @@ import '@ui5/webcomponents-icons/dist/AllIcons.js'; import '@ui5/webcomponents-fiori/dist/illustrations/NoData.js'; import BarDesign from '@ui5/webcomponents/dist/types/BarDesign.js'; import ButtonDesign from '@ui5/webcomponents/dist/types/ButtonDesign.js'; +import InputType from '@ui5/webcomponents/dist/types/InputType.js'; 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'; @@ -9,6 +10,14 @@ import type { CSSProperties } from 'react'; import { useEffect, useReducer, useRef, useState } from 'react'; import type { ObjectPagePropTypes } from '../..'; import { + CheckBox, + Form, + FormGroup, + FormItem, + Input, + Option, + Select, + TextArea, Avatar, Bar, Breadcrumbs, @@ -38,6 +47,78 @@ import { import { cypressPassThroughTestsFactory } from '@/cypress/support/utils'; describe('ObjectPage', () => { + it('dynamic children selection', () => { + const TestComp = () => { + const [state, setState] = useState(false); + const [sections, add] = useReducer( + (prev) => [ + ...prev, + +
Content {prev.length + 1}
+
+ ], + [] + ); + return ( + <> + + { + setState(!state); + }} + > + {OPContent} + {sections} + + + ); + }; + + cy.mount(); + + cy.wait(100); + cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').realClick(); + cy.findByText('Job Information').should('be.visible'); + + // add 15 sections + for (let i = 0; i < 15; i++) { + cy.findByText('Add').click(); + } + + //TabContainer overflow btn + cy.get('[data-ui5-stable="overflow-end"]').realClick(); + cy.get('[ui5-list]').should('be.visible'); + cy.wait(500); + // select "Section 15" + cy.realPress('PageDown'); + cy.wait(500); + cy.realPress('Enter'); + cy.get('[ui5-list]').should('not.be.visible'); + + cy.findByText('Content 15').should('be.visible'); + cy.wait(100); + cy.get('[ui5-tabcontainer]').findUi5TabByText('Section 15').should('have.attr', 'aria-selected', 'true'); + + cy.findByTestId('op').scrollTo(0, 4660); + + cy.findByText('Content 7').should('be.visible'); + cy.get('[ui5-tabcontainer]').findUi5TabByText('Section 7').should('have.attr', 'aria-selected', 'true'); + + cy.mount(); + // add 15 sections + for (let i = 0; i < 15; i++) { + cy.findByText('Add').click(); + } + cy.findByTestId('op').scrollTo(0, 4660); + + cy.findByText('Content 7').should('be.visible'); + cy.get('[ui5-tabcontainer]').findUi5TabByText('Section 7').should('have.attr', 'aria-selected', 'true'); + }); + it('toggle header', () => { const toggle = cy.spy().as('toggleSpy'); cy.mount( @@ -278,12 +359,9 @@ describe('ObjectPage', () => { cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').focus(); cy.realPress('ArrowDown'); - cy.wait(500); cy.realPress('ArrowDown'); cy.realPress('ArrowDown'); cy.realPress('Enter'); - cy.wait(200); - cy.realPress('Enter'); cy.findByText('Job Relationship').should('be.visible'); cy.mount( @@ -324,6 +402,8 @@ describe('ObjectPage', () => { cy.realPress('ArrowDown'); cy.realPress('ArrowDown'); cy.realPress('Enter'); + // wait for scroll + cy.wait(200); cy.findByText('Job Relationship').should('be.visible'); cy.findByTestId('footer').should('be.visible'); @@ -353,10 +433,12 @@ describe('ObjectPage', () => { cy.findByTestId('section 1').should('be.visible'); cy.get('[ui5-tabcontainer]').findUi5TabOpenPopoverButtonByText('Employment').click(); - cy.wait(500); + cy.get('[ui5-list]').should('be.visible'); + cy.wait(200); cy.realPress('ArrowDown'); cy.realPress('ArrowDown'); cy.realPress('Enter'); + cy.wait(500); cy.findByText('Job Relationship').should('be.visible'); cy.findByText('Job Information').should('not.be.visible'); @@ -923,6 +1005,57 @@ describe('ObjectPage', () => { cy.get('@cb').should('not.been.called'); }); + it('onSelectedSectionChange: React state update', () => { + const TestComp = () => { + const [state, setState] = useState(false); + return ( + { + setState(!state); + }} + > + +
+
Content1
+
+
+ +
+
Content2
+
+
+
+ ); + }; + + cy.mount(); + cy.get('[ui5-tabcontainer]').findUi5TabByText('test2').realClick(); + cy.findByText('Content1').should('not.be.visible'); + cy.findByText('Content2').should('be.visible'); + cy.get('[ui5-tabcontainer]').findUi5TabByText('test2').should('have.attr', 'aria-selected', 'true'); + cy.get('[ui5-tabcontainer]').findUi5TabByText('test1').should('have.attr', 'aria-selected', 'false'); + }); + + it('header spacer', () => { + const TestComp = () => { + return ( + + +
First Content
+
+ {OPContent} +
+ ); + }; + cy.mount(); + cy.findByTestId('op').scrollTo(0, 649); + + cy.wait(500); + cy.findByText('First Content').should('be.visible'); + }); + cypressPassThroughTestsFactory(ObjectPage); }); @@ -1011,6 +1144,68 @@ const OPContent = [ ]; +const HeaderWithLargeForm = ( + +
+ + Name}> + + + Address}> + + + Country}> + + + Additional Comment} className="formAlignLabelStart"> +