Skip to content

Commit

Permalink
fix(canary-react): icpaginationbar itemsperpage fix all option when t…
Browse files Browse the repository at this point in the history
…he items per page options vary

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

fix mi6#2843
  • Loading branch information
dn55533 committed Jan 3, 2025
1 parent 77eaed0 commit 334c0f7
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 334c0f7

Please sign in to comment.