Skip to content

Commit 7f37116

Browse files
committed
tests: back to top test resolved
1 parent 68af97b commit 7f37116

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

components/BackToTop.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const BackToTop = () => {
3636

3737
return (
3838
<button
39+
id='back-to-top'
3940
onClick={scrollToTop}
4041
className={`fixed right-4 bottom-4 z-50 rounded-full bg-blue-500 p-2 text-white shadow-lg ${
4142
isVisible ? 'animate-fade-in opacity-100 hover:cursor-pointer' : 'animate-fade-out opacity-0'

tests/general.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,17 @@ test.describe('General Tests', () => {
2020

2121
test('Back to top button functionality', async ({ page }) => {
2222
// Initially button should not be visible
23-
const backToTopButton = page.getByRole('button', { name: 'Back to top' })
23+
const backToTopButton = page.locator('#back-to-top')
2424
await expect(backToTopButton).not.toBeVisible()
2525

26+
// Click on the category containers to add enough content to scroll
27+
// class category-container
28+
const categoryContainers = page.locator('.category-container')
29+
const containerCount = await categoryContainers.count()
30+
for (let i = 0; i < containerCount; i++) {
31+
await categoryContainers.nth(i).click()
32+
}
33+
2634
// Scroll down to make the button appear
2735
await page.evaluate(() => {
2836
window.scrollTo(0, 1000)

0 commit comments

Comments
 (0)