Skip to content

Commit

Permalink
fix: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TechAkayy committed Jan 22, 2025
1 parent 41b3a69 commit 9750632
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
41 changes: 22 additions & 19 deletions docs/cypress/e2e/sidebar.cypress.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { visit, navigateTo, goBackHome, assertPage, waitForHydration } from './helpers'
import { visit, visitHome, navigateTo, goBackHome, assertPage, waitForHydration } from './helpers'

describe('Sidebar Toggle', () => {
const sidebar = () =>
Expand All @@ -24,23 +24,26 @@ describe('Sidebar Toggle', () => {
sidebarToggle().should('not.be.visible')
})

test.skipIf(process.env.CI)('can open in mobile', () => {
visitHome()
cy.viewport(500, 720)
visit('/guide/frameworks')
openSidebar()
closeSidebar()

// Ensure Turbo reactivates the islands.
openSidebar()
sidebar().contains('Config').click()

// Give Turbo time to replace the body.
waitForHydration()
assertPage({ title: 'Config' })
sidebar().should('not.be.visible')

openSidebar()
closeSidebar()
it('can open in mobile', () => {
cy.skipIf(process.env.CI)
it('can open in mobile', () => {
visitHome()
cy.viewport(500, 720)
visit('/guide/frameworks')
openSidebar()
closeSidebar()

// Ensure Turbo reactivates the islands.
openSidebar()
sidebar().contains('Config').click()

// Give Turbo time to replace the body.
waitForHydration()
assertPage({ title: 'Config' })
sidebar().should('not.be.visible')

openSidebar()
closeSidebar()
})
})
})
7 changes: 7 additions & 0 deletions docs/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

Cypress.Commands.add(
'skipIf',
(expression) => {
if (expression) context.skip.bind(context)();
}
);

0 comments on commit 9750632

Please sign in to comment.