Skip to content

Commit

Permalink
fix(canary-react): Fix the All option of the items per page dropdown …
Browse files Browse the repository at this point in the history
…in the IcPaginationBar when there are fewer items than available options

include the all option when there are fewer items than the available options

fix mi6#2843
  • Loading branch information
dn55533 committed Jan 6, 2025
1 parent c7bbf0c commit 449391c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,36 @@ describe("IcPaginationBar visual regression and a11y tests", () => {
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD),
});
});

it("should render with 'All' visible from items per page dropdown when there are fewer items than the available options", () => {
mount(<PaginationBarItemsPerPage totalItems={5} hideAllFromItemsPerPage />);

cy.checkHydrated(PAGINATION_BAR);

cy.findShadowEl(PAGINATION_BAR, ".items-per-page-input").click();

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "hide-all-option-still-visible",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD),
});
});

it("should render with 'All' visible in the items per page dropdown when the number of items matches the upper bound of the lowest available option", () => {
mount(
<PaginationBarItemsPerPage totalItems={20} hideAllFromItemsPerPage />
);

cy.checkHydrated(PAGINATION_BAR);

cy.findShadowEl(PAGINATION_BAR, ".items-per-page-input").click();

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "hide-all-option-still-visible-due-to-matching-item-upper-bound",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD),
});
});
});

describe("IcPaginationBar visual regression tests in high contrast mode", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ export const defaultArgs = {
showGoToPageControl: false,
totalItems: 100,
type: "simple",
hideAllFromItemsPerPage: false
};

<Canvas withSource="none">
Expand Down Expand Up @@ -548,6 +549,7 @@ export const defaultArgs = {
showGoToPageControl={args.showGoToPageControl}
totalItems={args.totalItems}
type={args.type}
hideAllFromItemsPerPage={args.hideAllFromItemsPerPage}
onIcPageChange={updatePageNum}
>
</IcPaginationBar>
Expand Down

0 comments on commit 449391c

Please sign in to comment.