Skip to content

Commit

Permalink
test(e2e): update sidebar e2e test (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope authored Jan 30, 2024
1 parent 049da22 commit f99d448
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 57 deletions.
10 changes: 5 additions & 5 deletions e2e/docs/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ export default defineUserConfig({

sidebar: {
'/': ['/sidebar/'],
'/sidebar/': [
'/sidebar/heading/': 'heading',
'/sidebar/config/': [
{
text: 'Sidebar',
link: '/sidebar/',
link: '/sidebar/config/',
children: [
{ text: 'sidebar 1', link: '/sidebar/1.html' },
{ text: 'sidebar 2', link: '/sidebar/2.html' },
{ text: 'sidebar 1', link: '/sidebar/config/1.html' },
{ text: 'sidebar 2', link: '/sidebar/config/2.html' },
],
},
],
'/heading-sidebar/': 'heading',
},
}),
}) as UserConfig
7 changes: 0 additions & 7 deletions e2e/docs/heading-sidebar/README.md

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions e2e/docs/sidebar/heading/1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Sidebar 1

## Sidebar 1 Heading 1

## Sidebar 1 Heading 2
5 changes: 5 additions & 0 deletions e2e/docs/sidebar/heading/2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Sidebar 2

## Sidebar 2 Heading 1

## Sidebar 2 Heading 2
37 changes: 0 additions & 37 deletions e2e/tests/theme-default/composables/useSidebarItems.cy.ts

This file was deleted.

47 changes: 39 additions & 8 deletions e2e/tests/theme-default/sidebar.cy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,46 @@
it('has heading sidebar', () => {
cy.visit('/sidebar/')
cy.get('.theme-default-content').then((el) => {
cy.wrap(el)
.get('a.sidebar-item')
.should('contain', 'Sidebar Heading 1')
.should('contain', 'Sidebar Heading 2')
describe('has heading sidebar', () => {
it('frontmatter', () => {
cy.visit('/sidebar/auto.html')
cy.get('.theme-default-content').then((el) => {
cy.wrap(el)
.get('a.sidebar-item')
.should('contain', 'Sidebar Heading 1')
.should('contain', 'Sidebar Heading 2')
})
})

it('config', () => {
cy.visit('/sidebar/heading/1.html')

cy.get('.theme-default-content').then((el) => {
cy.wrap(el)
.get('h1')
.invoke('text')
.should('be.not.empty')
.then((text) => {
cy.get('.sidebar-heading')
.invoke('text')
.should('contain', text.replace('#', '').trim())
})

cy.wrap(el)
.get('h2')
.each((header) => {
cy.wrap(header)
.invoke('text')
.should('be.not.empty')
.then((headerText) => {
cy.get('a.sidebar-item').contains(
headerText.replace('#', '').trim(),
)
})
})
})
})
})

it('has configured sidebar', () => {
cy.visit('/sidebar/1.html')
cy.visit('/sidebar/config/1.html')
cy.get('.theme-default-content').then((el) => {
cy.wrap(el)
.get('a.sidebar-item')
Expand Down

0 comments on commit f99d448

Please sign in to comment.