-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optionally scroll to the top after paginating
- Loading branch information
1 parent
567eafe
commit c495914
Showing
3 changed files
with
130 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
describe("Pagination", () => { | ||
describe("with scrolling", () => { | ||
beforeEach(() => { | ||
cy.renderFromStorybook("pagination--scroll-after-pagination"); | ||
}); | ||
|
||
it("does not scroll after pagination by default", () => { | ||
cy.get('[aria-label="scroll target"]').contains("None").click(); | ||
|
||
cy.get('[aria-label="Pagination navigation"]').contains("Next").click(); | ||
cy.isNotInViewport('[data-testid="page-heading"'); | ||
}); | ||
|
||
it("scrolls to the top of the page after pagination when scrollToTopAfterPagination is true", () => { | ||
cy.get('[aria-label="scroll target"]').contains("Top of page").click(); | ||
|
||
cy.get('[aria-label="Pagination navigation"]').contains("Next").click(); | ||
cy.get('[aria-label="Pagination navigation"]').contains("Previous").click(); | ||
cy.isInViewport('[data-testid="page-heading"'); | ||
}); | ||
|
||
it("scrolls to the top of the target element when scrollToTopAfterPagination is true and a scrollTargetRef is present", () => { | ||
cy.get('[aria-label="scroll target"]').contains("Top of section").click(); | ||
|
||
cy.get('[aria-label="Pagination navigation"]').contains("7").click(); | ||
cy.isNotInViewport('[data-testid="page-heading"'); | ||
cy.isInViewport('[data-testid="section-heading"'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters