Skip to content

Commit de799d0

Browse files
committed
test(ObjectPage): fix test in CI
1 parent 0f18cd7 commit de799d0

File tree

3 files changed

+131
-135
lines changed

3 files changed

+131
-135
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
spec:
18-
- base
19-
- charts
20-
- cypress-commands
21-
- main/src/components
22-
- main/src/webComponents
23-
- main/src/internal
24-
- compat
18+
- main/src/components/ObjectPage
2519
react: ['18', '19']
2620
fail-fast: false
2721
steps:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"build:storybook-sitemap": "node ./scripts/create-storybook-sitemap.js --directory .out",
1616
"test:prepare": "rimraf temp && lerna run build",
1717
"test:open": "CYPRESS_COVERAGE=false cypress open --component --browser chrome",
18-
"test": "yarn test:prepare && cypress run --component --browser chrome --spec packages",
18+
"test": "yarn test:prepare && cypress run --component --browser chrome --spec packages/main/src/components/ObjectPage",
1919
"clean": "tsc --build --clean && tsc --build tsconfig.build.json --clean && rimraf temp .out && lerna run clean",
2020
"clean:remove-modules": "yarn clean && rimraf node_modules",
2121
"prettier:all": "prettier --write --config ./prettier.config.js \"**/*\"",

packages/main/src/components/ObjectPage/ObjectPage.cy.tsx

Lines changed: 129 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -365,148 +365,150 @@ describe('ObjectPage', () => {
365365
});
366366
});
367367

368-
it('scroll to sections - default mode', () => {
369-
document.body.style.margin = '0px';
370-
cy.mount(
371-
<ObjectPage data-testid="op" titleArea={DPTitle} headerArea={DPContent} style={{ height: '100vh' }}>
372-
{OPContent}
373-
</ObjectPage>,
374-
);
375-
cy.wait(200);
368+
for (let i = 0; i < 50; i++) {
369+
it.only('scroll to sections - default mode', () => {
370+
document.body.style.margin = '0px';
371+
cy.mount(
372+
<ObjectPage data-testid="op" titleArea={DPTitle} headerArea={DPContent} style={{ height: '100vh' }}>
373+
{OPContent}
374+
</ObjectPage>,
375+
);
376+
cy.wait(200);
376377

377-
// first titleText should never be displayed (not.be.visible doesn't work here - only invisible for sighted users)
378-
cy.findByText('Goals')
379-
.parent()
380-
.should('have.css', 'width', '1px')
381-
.and('have.css', 'margin', '-1px')
382-
.and('have.css', 'position', 'absolute');
383-
cy.findByText('Employment').should('not.be.visible');
384-
cy.findByText('Test').should('be.visible');
378+
// first titleText should never be displayed (not.be.visible doesn't work here - only invisible for sighted users)
379+
cy.findByText('Goals')
380+
.parent()
381+
.should('have.css', 'width', '1px')
382+
.and('have.css', 'margin', '-1px')
383+
.and('have.css', 'position', 'absolute');
384+
cy.findByText('Employment').should('not.be.visible');
385+
cy.findByText('Test').should('be.visible');
385386

386-
cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').realClick();
387-
cy.get('[data-section-id="test"]').shouldNeverHaveAttribute('selected');
388-
cy.get('[data-section-id="personal"]').shouldNeverHaveAttribute('selected');
389-
cy.get(`[ui5-tab][data-index="3"]`).should('have.attr', 'selected');
390-
cy.findByText('Employment').should('be.visible');
387+
cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').realClick();
388+
cy.get('[data-section-id="test"]').shouldNeverHaveAttribute('selected');
389+
cy.get('[data-section-id="personal"]').shouldNeverHaveAttribute('selected');
390+
cy.get(`[ui5-tab][data-index="3"]`).should('have.attr', 'selected');
391+
cy.findByText('Employment').should('be.visible');
391392

392-
cy.wait(200);
393+
cy.wait(200);
393394

394-
cy.get('[ui5-tabcontainer]').findUi5TabByText('Goals').realClick();
395-
cy.findByText('Test').should('be.visible');
395+
cy.get('[ui5-tabcontainer]').findUi5TabByText('Goals').realClick();
396+
cy.findByText('Test').should('be.visible');
396397

397-
// no scroll when focusing something in the header area
398-
cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').realClick();
399-
cy.findByText('Job Information').should('be.visible');
400-
cy.findByTestId('op').invoke('scrollTop').as('scrollTop');
401-
cy.wait(100);
402-
cy.realPress('ArrowLeft');
403-
cy.get('@scrollTop').then((scrollTop) => {
404-
cy.findByTestId('op').invoke('scrollTop').should('equal', scrollTop);
405-
});
398+
// no scroll when focusing something in the header area
399+
cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').realClick();
400+
cy.findByText('Job Information').should('be.visible');
401+
cy.findByTestId('op').invoke('scrollTop').as('scrollTop');
402+
cy.wait(100);
403+
cy.realPress('ArrowLeft');
404+
cy.get('@scrollTop').then((scrollTop) => {
405+
cy.findByTestId('op').invoke('scrollTop').should('equal', scrollTop);
406+
});
406407

407-
cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').focus();
408-
cy.realPress('ArrowDown');
409-
cy.realPress('ArrowDown');
410-
cy.realPress('ArrowDown');
411-
cy.realPress('Enter');
412-
cy.get('[data-section-id="goals"]').shouldNeverHaveAttribute('selected');
413-
cy.get('[data-section-id="personal"]').shouldNeverHaveAttribute('selected');
414-
cy.findByText('Job Relationship').should('be.visible');
408+
cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').focus();
409+
cy.realPress('ArrowDown');
410+
cy.realPress('ArrowDown');
411+
cy.realPress('ArrowDown');
412+
cy.realPress('Enter');
413+
cy.get('[data-section-id="goals"]').shouldNeverHaveAttribute('selected');
414+
cy.get('[data-section-id="personal"]').shouldNeverHaveAttribute('selected');
415+
cy.findByText('Job Relationship').should('be.visible');
415416

416-
cy.mount(
417-
<ObjectPage
418-
data-testid
419-
titleArea={DPTitle}
420-
headerArea={DPContent}
421-
footerArea={Footer}
422-
style={{ height: '100vh' }}
423-
>
424-
{OPContent}
425-
</ObjectPage>,
426-
);
427-
cy.wait(100);
417+
cy.mount(
418+
<ObjectPage
419+
data-testid
420+
titleArea={DPTitle}
421+
headerArea={DPContent}
422+
footerArea={Footer}
423+
style={{ height: '100vh' }}
424+
>
425+
{OPContent}
426+
</ObjectPage>,
427+
);
428+
cy.wait(100);
428429

429-
cy.findByText('Employment').should('not.be.visible');
430-
cy.findByText('Test').should('be.visible');
431-
cy.findByTestId('footer').should('be.visible');
430+
cy.findByText('Employment').should('not.be.visible');
431+
cy.findByText('Test').should('be.visible');
432+
cy.findByTestId('footer').should('be.visible');
432433

433-
// Select Employment tab
434-
cy.get('[ui5-tabcontainer]').findUi5TabByText('Goals').focus();
435-
cy.get('[ui5-tabcontainer]').realPress('ArrowRight');
436-
cy.get('[ui5-tabcontainer]').realPress('ArrowRight');
437-
cy.get('[ui5-tabcontainer]').realPress('ArrowRight');
438-
cy.get('[ui5-tabcontainer]').realPress('Enter');
434+
// Select Employment tab
435+
cy.get('[ui5-tabcontainer]').findUi5TabByText('Goals').focus();
436+
cy.get('[ui5-tabcontainer]').realPress('ArrowRight');
437+
cy.get('[ui5-tabcontainer]').realPress('ArrowRight');
438+
cy.get('[ui5-tabcontainer]').realPress('ArrowRight');
439+
cy.get('[ui5-tabcontainer]').realPress('Enter');
439440

440-
cy.wait(200);
441-
//fallback click
442-
cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').realClick();
443-
cy.get('[data-section-id="test"]').shouldNeverHaveAttribute('selected');
444-
cy.get('[data-section-id="personal"]').shouldNeverHaveAttribute('selected');
445-
cy.findByTestId('footer').should('be.visible');
446-
cy.findByText('Employment').should('be.visible');
447-
cy.findByText('Job Information').should('be.visible');
441+
cy.wait(200);
442+
//fallback click
443+
cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').realClick();
444+
cy.get('[data-section-id="test"]').shouldNeverHaveAttribute('selected');
445+
cy.get('[data-section-id="personal"]').shouldNeverHaveAttribute('selected');
446+
cy.findByTestId('footer').should('be.visible');
447+
cy.findByText('Employment').should('be.visible');
448+
cy.findByText('Job Information').should('be.visible');
448449

449-
cy.get('[ui5-tabcontainer]').findUi5TabByText('Goals').click();
450-
cy.get('[data-section-id="test"]').shouldNeverHaveAttribute('selected', 300);
451-
cy.get('[data-section-id="personal"]').shouldNeverHaveAttribute('selected');
452-
cy.findByText('Test').should('be.visible');
453-
cy.findByTestId('footer').should('be.visible');
450+
cy.get('[ui5-tabcontainer]').findUi5TabByText('Goals').click();
451+
cy.get('[data-section-id="test"]').shouldNeverHaveAttribute('selected', 300);
452+
cy.get('[data-section-id="personal"]').shouldNeverHaveAttribute('selected');
453+
cy.findByText('Test').should('be.visible');
454+
cy.findByTestId('footer').should('be.visible');
454455

455-
cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').focus();
456-
cy.realPress('ArrowDown');
457-
cy.wait(500);
458-
cy.realPress('ArrowDown');
459-
cy.realPress('ArrowDown');
460-
cy.realPress('Enter');
461-
cy.get('[data-section-id="personal"]').shouldNeverHaveAttribute('selected');
462-
cy.get(`[ui5-tab][data-index="3"]`).should('have.attr', 'selected');
463-
// wait for scroll
464-
cy.wait(200);
465-
cy.findByText('Job Relationship').should('be.visible');
456+
cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').focus();
457+
cy.realPress('ArrowDown');
458+
cy.wait(500);
459+
cy.realPress('ArrowDown');
460+
cy.realPress('ArrowDown');
461+
cy.realPress('Enter');
462+
cy.get('[data-section-id="personal"]').shouldNeverHaveAttribute('selected');
463+
cy.get(`[ui5-tab][data-index="3"]`).should('have.attr', 'selected');
464+
// wait for scroll
465+
cy.wait(200);
466+
cy.findByText('Job Relationship').should('be.visible');
466467

467-
cy.findByTestId('footer').should('be.visible');
468+
cy.findByTestId('footer').should('be.visible');
468469

469-
cy.mount(
470-
<ObjectPage
471-
data-testid
472-
titleArea={DPTitle}
473-
headerArea={DPContent}
474-
footerArea={Footer}
475-
style={{ height: '100vh' }}
476-
>
477-
{OPContent}
478-
<ObjectPageSection aria-label="Long Section" id="long-section" titleText="Long Section">
479-
<ObjectPageSubSection aria-label="Long Subsection 1" id="sub1" titleText="Long Subsection 1">
480-
<FlexBox style={{ height: '2000px' }} direction="Column" justifyContent="SpaceBetween">
481-
<span>Start SubSection1</span>
482-
<span>End SubSection1</span>
483-
</FlexBox>
484-
</ObjectPageSubSection>
485-
<ObjectPageSubSection aria-label="Long Subsection 2" id="sub2" titleText="Long Subsection 2">
486-
<FlexBox style={{ height: '1000px' }} direction="Column" justifyContent="SpaceBetween">
487-
<span>Start SubSection2</span>
488-
<span>End SubSection2</span>
489-
</FlexBox>
490-
</ObjectPageSubSection>
491-
</ObjectPageSection>
492-
</ObjectPage>,
493-
);
494-
cy.wait(100);
470+
cy.mount(
471+
<ObjectPage
472+
data-testid
473+
titleArea={DPTitle}
474+
headerArea={DPContent}
475+
footerArea={Footer}
476+
style={{ height: '100vh' }}
477+
>
478+
{OPContent}
479+
<ObjectPageSection aria-label="Long Section" id="long-section" titleText="Long Section">
480+
<ObjectPageSubSection aria-label="Long Subsection 1" id="sub1" titleText="Long Subsection 1">
481+
<FlexBox style={{ height: '2000px' }} direction="Column" justifyContent="SpaceBetween">
482+
<span>Start SubSection1</span>
483+
<span>End SubSection1</span>
484+
</FlexBox>
485+
</ObjectPageSubSection>
486+
<ObjectPageSubSection aria-label="Long Subsection 2" id="sub2" titleText="Long Subsection 2">
487+
<FlexBox style={{ height: '1000px' }} direction="Column" justifyContent="SpaceBetween">
488+
<span>Start SubSection2</span>
489+
<span>End SubSection2</span>
490+
</FlexBox>
491+
</ObjectPageSubSection>
492+
</ObjectPageSection>
493+
</ObjectPage>,
494+
);
495+
cy.wait(100);
495496

496-
cy.get('[ui5-tabcontainer]').findUi5TabByText('Long Section').focus();
497-
cy.realPress('ArrowDown');
498-
cy.get('[ui5-responsive-popover]').should('be.visible');
499-
cy.realPress('ArrowDown');
500-
cy.wait(50);
501-
cy.realPress('ArrowDown');
502-
cy.realPress('Enter');
503-
cy.get('[data-section-id="test"]').shouldNeverHaveAttribute('selected');
504-
cy.get('[data-section-id="personal"]').shouldNeverHaveAttribute('selected');
505-
cy.get(`[ui5-tab][data-index="3"]`).shouldNeverHaveAttribute('selected');
506-
// wait for scroll
507-
cy.wait(200);
508-
cy.findByText('Start SubSection2').should('be.visible');
509-
});
497+
cy.get('[ui5-tabcontainer]').findUi5TabByText('Long Section').focus();
498+
cy.realPress('ArrowDown');
499+
cy.get('[ui5-responsive-popover]').should('be.visible');
500+
cy.realPress('ArrowDown');
501+
cy.wait(50);
502+
cy.realPress('ArrowDown');
503+
cy.realPress('Enter');
504+
cy.get('[data-section-id="test"]').shouldNeverHaveAttribute('selected');
505+
cy.get('[data-section-id="personal"]').shouldNeverHaveAttribute('selected');
506+
cy.get(`[ui5-tab][data-index="3"]`).shouldNeverHaveAttribute('selected');
507+
// wait for scroll
508+
cy.wait(200);
509+
cy.findByText('Start SubSection2').should('be.visible');
510+
});
511+
}
510512

511513
it('scroll to sections - tab mode', () => {
512514
document.body.style.margin = '0px';

0 commit comments

Comments
 (0)