diff --git a/site/gatsby-site/playwright/e2e/landingPage.spec.ts b/site/gatsby-site/playwright/e2e/landingPage.spec.ts index 40c35ffd22..0e0809aef7 100644 --- a/site/gatsby-site/playwright/e2e/landingPage.spec.ts +++ b/site/gatsby-site/playwright/e2e/landingPage.spec.ts @@ -101,11 +101,11 @@ test.describe('The Landing page', () => { ); test('Loads the random incidents carousel', async ({ page, skipOnEmptyEnvironment }) => { - await page.goto('/'); - await page.locator('[data-cy="random-incidents-carousel"]').scrollIntoViewIfNeeded(); - await expect(page.locator('[data-cy="random-incidents-carousel"]')).toBeVisible(); - await expect(page.locator('[data-cy="random-incidents-carousel-item"]')).toHaveCount(5); - }); + await page.goto('/'); + await page.locator('[data-cy="random-incidents-carousel"]').scrollIntoViewIfNeeded(); + await expect(page.locator('[data-cy="random-incidents-carousel"]')).toBeVisible(); + await expect(page.locator('[data-cy="random-incidents-carousel-item"]')).toHaveCount(5); + }); test('Renders commit sha in the footer', async ({ page }) => { await page.goto('/'); @@ -119,4 +119,30 @@ test.describe('The Landing page', () => { await expect(lis).toBeGreaterThan(0); }); + test('Should collapse sidebar', async ({ page, skipOnEmptyEnvironment }) => { + await page.goto('/'); + const sidebarTree = page.locator('[data-testid="sidebar-desktop"]'); + await sidebarTree.locator('[data-cy="collapse-button"]').click(); + const sidebar = await page.locator('[id="sidebar"]').first(); + let hasClass = await sidebar.evaluate((el, className) => { + return el.classList.contains(className); + }, 'collapsed'); + expect(hasClass).toBe(true); + await sidebarTree.locator('[data-cy="collapse-button"]').click(); + hasClass = await sidebar.evaluate((el, className) => { + return el.classList.contains(className); + }, 'collapsed'); + expect(hasClass).toBe(false); + }); + + test('Should display sidebar tooltip when collapsed', async ({ page, skipOnEmptyEnvironment }) => { + await page.goto('/'); + const sidebarTree = page.locator('[data-testid="sidebar-desktop"]'); + await sidebarTree.locator('[data-cy="collapse-button"]').click(); + // Hovers over a sidebar item + await page.getByTestId('sidebar-desktop').getByTestId("sidebar-welcome").hover(); + await expect(page.getByTestId('sidebar-desktop').locator('[data-testid="flowbite-tooltip"]', { hasText: 'Welcome to the AIID' })) + .toBeVisible(); + + }); }); diff --git a/site/gatsby-site/src/components/sidebar/index.js b/site/gatsby-site/src/components/sidebar/index.js index 814acb8388..09c9f97c8f 100644 --- a/site/gatsby-site/src/components/sidebar/index.js +++ b/site/gatsby-site/src/components/sidebar/index.js @@ -227,7 +227,9 @@ const Sidebar = ({ defaultCollapsed = false, location = null, setNavCollapsed })