);
};
diff --git a/components/SiteLayout.tsx b/components/SiteLayout.tsx
index 7b7f9269c..458618830 100644
--- a/components/SiteLayout.tsx
+++ b/components/SiteLayout.tsx
@@ -1,6 +1,6 @@
import React from 'react';
import Layout from '../components/Layout';
-
+/* istanbul ignore file */
type SiteLayoutProps = {
children?: React.ReactNode;
isDropdown?: boolean;
diff --git a/cypress/components/ScrollButton.cy.tsx b/cypress/components/ScrollButton.cy.tsx
index 44bd7a7cd..965cbee56 100644
--- a/cypress/components/ScrollButton.cy.tsx
+++ b/cypress/components/ScrollButton.cy.tsx
@@ -1,36 +1,166 @@
+/* eslint-disable cypress/no-unnecessary-waiting */
import React from 'react';
import ScrollButton from '~/components/ScrollButton';
describe('ScrollButton Component', () => {
- // Should render and function correctly
- it('should render and function correctly', () => {
- // Mount the ScrollButton component
+ beforeEach(() => {
+ // Mount the ScrollButton component with a tall container
cy.mount(
,
);
+ });
+ it('should render and function correctly', () => {
// Initially, the button should not exist
cy.get('[data-test="scroll-button"]').should('not.exist');
- // when window scrollY is >150 the button should exist
- cy.window().scrollTo(0, 151);
+ // Scroll to trigger button appearance (use a value well above the 150px threshold)
+ cy.window().scrollTo(0, 200);
- // Check if the button is exist
+ // Wait a bit for the scroll event to be processed
+ cy.wait(100);
+
+ // Check if the button exists
cy.get('[data-test="scroll-button"]').should('exist');
// Click the button
cy.get('[data-test="scroll-button"]').click();
- // Check if the window scroll to top
- cy.window().its('scrollY').should('eq', 1);
+ // Wait for smooth scroll to complete
+ cy.wait(500);
+
+ // Check if the window scroll to top (allow for small variations due to browser rounding)
+ cy.window().its('scrollY').should('be.closeTo', 0, 1);
// check again if the button is not exist
cy.get('[data-test="scroll-button"]').should('not.exist');
// when window scrollY is <150 the button should not exist
cy.window().scrollTo(0, 149);
+ cy.wait(100);
cy.get('[data-test="scroll-button"]').should('not.exist');
});
+
+ it('should have circular design', () => {
+ // Scroll to trigger button appearance
+ cy.window().scrollTo(0, 200);
+ cy.wait(100);
+
+ // Check if button exists
+ cy.get('[data-test="scroll-button"]').should('exist');
+
+ // Verify circular design - should have rounded-full class
+ cy.get('[data-test="scroll-button"]').should('have.class', 'rounded-full');
+
+ // Verify the container has equal height and width (12x12)
+ cy.get('[data-test="scroll-button"]').parent().should('have.class', 'h-12');
+ cy.get('[data-test="scroll-button"]').parent().should('have.class', 'w-12');
+ });
+
+ it('should have proper accessibility attributes', () => {
+ // Scroll to trigger button appearance
+ cy.window().scrollTo(0, 200);
+ cy.wait(100);
+
+ // Check if button has proper aria-label
+ cy.get('[data-test="scroll-button"]').should(
+ 'have.attr',
+ 'aria-label',
+ 'Scroll to top',
+ );
+
+ // Check if button is accessible via keyboard (tabindex or role)
+ cy.get('[data-test="scroll-button"]').should('be.visible');
+ cy.get('[data-test="scroll-button"]').should('not.be.disabled');
+ });
+
+ it('should have smooth transitions and hover effects', () => {
+ // Scroll to trigger button appearance
+ cy.window().scrollTo(0, 200);
+ cy.wait(100);
+
+ // Check for transition classes
+ cy.get('[data-test="scroll-button"]').should(
+ 'have.class',
+ 'transition-all',
+ );
+ cy.get('[data-test="scroll-button"]').should('have.class', 'duration-200');
+ cy.get('[data-test="scroll-button"]').should('have.class', 'ease-in-out');
+
+ // Check for hover effect class
+ cy.get('[data-test="scroll-button"]').should(
+ 'have.class',
+ 'hover:-translate-y-1',
+ );
+ });
+
+ it('should support dark mode styling', () => {
+ // Scroll to trigger button appearance
+ cy.window().scrollTo(0, 200);
+ cy.wait(100);
+
+ // Check for dark mode classes
+ cy.get('[data-test="scroll-button"]').should(
+ 'have.class',
+ 'dark:bg-gray-800',
+ );
+ cy.get('[data-test="scroll-button"]').should(
+ 'have.class',
+ 'dark:border-gray-600',
+ );
+ cy.get('[data-test="scroll-button"]').should(
+ 'have.class',
+ 'dark:hover:bg-gray-700',
+ );
+
+ // Check for light mode classes
+ cy.get('[data-test="scroll-button"]').should('have.class', 'bg-white');
+ cy.get('[data-test="scroll-button"]').should(
+ 'have.class',
+ 'border-gray-200',
+ );
+ cy.get('[data-test="scroll-button"]').should(
+ 'have.class',
+ 'hover:bg-gray-50',
+ );
+ });
+
+ it('should have proper icon styling', () => {
+ // Scroll to trigger button appearance
+ cy.window().scrollTo(0, 200);
+ cy.wait(100);
+
+ // Check if arrow icon exists and has proper classes
+ cy.get('[data-test="scroll-button"] svg').should('exist');
+ cy.get('[data-test="scroll-button"] svg').should('have.class', 'h-6');
+ cy.get('[data-test="scroll-button"] svg').should('have.class', 'w-6');
+ cy.get('[data-test="scroll-button"] svg').should(
+ 'have.class',
+ 'text-gray-700',
+ );
+ cy.get('[data-test="scroll-button"] svg').should(
+ 'have.class',
+ 'dark:text-gray-300',
+ );
+ });
+
+ it('should be positioned correctly', () => {
+ // Scroll to trigger button appearance
+ cy.window().scrollTo(0, 200);
+ cy.wait(100);
+
+ // Check positioning classes
+ cy.get('[data-test="scroll-button"]')
+ .parent()
+ .should('have.class', 'fixed');
+ cy.get('[data-test="scroll-button"]')
+ .parent()
+ .should('have.class', 'bottom-14');
+ cy.get('[data-test="scroll-button"]')
+ .parent()
+ .should('have.class', 'right-4');
+ cy.get('[data-test="scroll-button"]').parent().should('have.class', 'z-40');
+ });
});
diff --git a/cypress/components/Sidebar.cy.tsx b/cypress/components/Sidebar.cy.tsx
new file mode 100644
index 000000000..76ddb5554
--- /dev/null
+++ b/cypress/components/Sidebar.cy.tsx
@@ -0,0 +1,609 @@
+/* eslint-disable @typescript-eslint/no-var-requires */
+import React from 'react';
+import { SidebarLayout, DocsNav } from '~/components/Sidebar';
+import mockNextRouter, { MockRouter } from '../plugins/mockNextRouterUtils';
+
+describe('Sidebar Component', () => {
+ let mockRouter: MockRouter;
+
+ beforeEach(() => {
+ mockRouter = mockNextRouter();
+ // Mock the useTheme hook
+ cy.stub(require('next-themes'), 'useTheme').returns({
+ resolvedTheme: 'light',
+ theme: 'light',
+ setTheme: cy.stub(),
+ });
+ });
+
+ describe('SidebarLayout', () => {
+ it('should render the sidebar layout correctly', () => {
+ cy.mount(
+
+
Test Content
+ ,
+ );
+
+ // Check if the layout structure is rendered
+ cy.get('[data-testid="content"]')
+ .should('exist')
+ .and('contain', 'Test Content');
+
+ // Check if the sidebar container exists
+ cy.get('.max-w-\\[1400px\\]').should('exist');
+
+ // Check if the grid layout is applied
+ cy.get('.grid').should('exist');
+ });
+
+ it('should render mobile menu container', () => {
+ cy.mount(
+
+
Test Content
+ ,
+ );
+
+ cy.viewport(768, 1024);
+
+ // Check if mobile menu container exists
+ cy.get('.lg\\:hidden').should('exist');
+
+ // Check if the mobile menu has the correct structure
+ cy.get('.lg\\:hidden > div').should('exist');
+ });
+
+ it('should handle mobile menu toggle correctly', () => {
+ cy.mount(
+
+
Test Content
+ ,
+ );
+
+ // Set viewport to mobile size
+ cy.viewport(768, 1024);
+
+ // Check if mobile menu container exists
+ cy.get('.lg\\:hidden').should('exist');
+
+ // Initially mobile menu should be closed
+ cy.get('.transform.-translate-x-full').should('exist');
+
+ // Click on mobile menu button (the div with onClick handler)
+ cy.get('.lg\\:hidden > div').first().click();
+
+ // Menu should be open
+ cy.get('.transform.-translate-x-0').should('exist');
+ });
+
+ it('should show correct section title based on current path', () => {
+ // Test Introduction section
+ mockRouter.asPath = '/docs';
+ cy.mount(
+
+
Test Content
+ ,
+ );
+ cy.viewport(768, 1024);
+
+ // Check if mobile menu exists and has content
+ cy.get('.lg\\:hidden').should('exist');
+ cy.get('.lg\\:hidden h3').should('exist');
+ cy.get('.lg\\:hidden h3').should('contain', 'Introduction');
+ });
+
+ it('should show Get Started section title', () => {
+ mockRouter.asPath = '/learn';
+ cy.mount(
+
+