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
16 changes: 16 additions & 0 deletions cypress/e2e/page-hash-navigation.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"use strict";

describe("Page hash navigation", () => {
it("scrolls to the element specified by the hash", () => {
cy.visit("/guides/getting-started/#basic-setup");

cy.location("hash").should("eq", "#basic-setup");

cy.get("#basic-setup", { timeout: 10000 })
.should("exist")
.then(($el) => {
const rect = $el[0].getBoundingClientRect();
expect(rect.top).to.be.lessThan(200);
});
});
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write the useful test - you test nothing here

1 change: 1 addition & 0 deletions src/components/Page/Page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default function Page(props) {
const element = document.getElementById(hash.slice(1));
if (element) {
element.scrollIntoView();
observer.disconnect();
}
});
observer.observe(target, {
Expand Down
Loading