Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions packages/fiori/cypress/specs/SideNavigation.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -939,33 +939,39 @@ describe("Side Navigation interaction", () => {
</SideNavigation>
);

cy.get("#parentItem").realClick();
[
const cases: Array<{ selector: () => Cypress.Chainable, expectedCallCount: number }> = [
{
element: cy.get("#sideNav").shadow().find("[ui5-responsive-popover] [ui5-side-navigation-item][text='2']").shadow()
.find(".ui5-sn-item"),
selector: () => cy.get("#sideNav").shadow().find("[ui5-responsive-popover] [ui5-side-navigation-item][text='2']").shadow().find(".ui5-sn-item"),
expectedCallCount: 1,
},
{
element: cy.get("#sideNav").shadow().find("[ui5-responsive-popover] [ui5-side-navigation-sub-item][text='2.1']"),
selector: () => cy.get("#sideNav").shadow().find("[ui5-responsive-popover] [ui5-side-navigation-sub-item][text='2.1']"),
expectedCallCount: 1,
},
{
element: cy.get("#sideNav").shadow().find("[ui5-responsive-popover] [ui5-side-navigation-sub-item][text='2.2']"),
selector: () => cy.get("#sideNav").shadow().find("[ui5-responsive-popover] [ui5-side-navigation-sub-item][text='2.2']"),
expectedCallCount: 0,
},
].forEach(({ element, expectedCallCount }) => {
];

cases.forEach(({ selector, expectedCallCount }) => {
cy.get("#sideNav")
.then(sideNav => {
sideNav.get(0).addEventListener("ui5-selection-change", cy.stub().as("selectionChangeHandler"));
});

// act
// open the popover fresh each iteration
cy.get("#parentItem").realClick();
element.realClick();
cy.get("#sideNav").shadow().find("[ui5-responsive-popover]").should("be.visible");

// act
selector().realClick();

// assert
cy.get("@selectionChangeHandler", { timeout: 1000 }).should("have.callCount", expectedCallCount);
cy.get("@selectionChangeHandler").should("have.callCount", expectedCallCount);

// close popover before next iteration (click outside)
cy.get("body").click(0, 0);
});
});

Expand All @@ -978,6 +984,8 @@ describe("Side Navigation interaction", () => {
);

cy.get("#item").realClick();
// wait for first selection to settle before clicking again
cy.get("@selectionChangeHandler").should("have.been.calledOnce");
cy.get("#item").realClick();

cy.get("@selectionChangeHandler").should("have.been.calledOnce");
Expand Down Expand Up @@ -1021,14 +1029,17 @@ describe("Side Navigation interaction", () => {
.realClick();

cy.get("@overflowMenu")
.should("be.not.visible");
.should("not.be.visible");

cy.get("[ui5-side-navigation-item][text='Home 6']")
.should("be.focused");

cy.get("@itemOverflow")
.realClick();

cy.get("@overflowMenu")
.should("be.visible");

cy.get("@overflowMenu")
.find("[ui5-navigation-menu-item][text='Home 7']")
.realClick();
Expand Down
Loading
Loading