diff --git a/e2e/docs/.vuepress/config.ts b/e2e/docs/.vuepress/config.ts index 582b872082..cd3321b268 100644 --- a/e2e/docs/.vuepress/config.ts +++ b/e2e/docs/.vuepress/config.ts @@ -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 diff --git a/e2e/docs/heading-sidebar/README.md b/e2e/docs/heading-sidebar/README.md deleted file mode 100644 index 9f4faac20a..0000000000 --- a/e2e/docs/heading-sidebar/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# heading-sidebar - -## header 1 - -## header 2 - -## header 3 diff --git a/e2e/docs/sidebar/README.md b/e2e/docs/sidebar/auto.md similarity index 100% rename from e2e/docs/sidebar/README.md rename to e2e/docs/sidebar/auto.md diff --git a/e2e/docs/sidebar/1.md b/e2e/docs/sidebar/config/1.md similarity index 100% rename from e2e/docs/sidebar/1.md rename to e2e/docs/sidebar/config/1.md diff --git a/e2e/docs/sidebar/2.md b/e2e/docs/sidebar/config/2.md similarity index 100% rename from e2e/docs/sidebar/2.md rename to e2e/docs/sidebar/config/2.md diff --git a/e2e/docs/sidebar/heading/1.md b/e2e/docs/sidebar/heading/1.md new file mode 100644 index 0000000000..b587f0e562 --- /dev/null +++ b/e2e/docs/sidebar/heading/1.md @@ -0,0 +1,5 @@ +# Sidebar 1 + +## Sidebar 1 Heading 1 + +## Sidebar 1 Heading 2 diff --git a/e2e/docs/sidebar/heading/2.md b/e2e/docs/sidebar/heading/2.md new file mode 100644 index 0000000000..038eb26091 --- /dev/null +++ b/e2e/docs/sidebar/heading/2.md @@ -0,0 +1,5 @@ +# Sidebar 2 + +## Sidebar 2 Heading 1 + +## Sidebar 2 Heading 2 diff --git a/e2e/tests/theme-default/composables/useSidebarItems.cy.ts b/e2e/tests/theme-default/composables/useSidebarItems.cy.ts deleted file mode 100644 index 459539adf6..0000000000 --- a/e2e/tests/theme-default/composables/useSidebarItems.cy.ts +++ /dev/null @@ -1,37 +0,0 @@ -it("route has 'heading' sidebar", () => { - cy.visit('/heading-sidebar/') - 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('route has custom sidebar', () => { - cy.visit('/sidebar/') - cy.get('.theme-default-content').then((el) => { - cy.wrap(el).get('.sidebar-heading').should('contain', 'Sidebar') - cy.wrap(el) - .get('a.sidebar-item') - .should('contain', 'Sidebar Heading 1') - .should('contain', 'Sidebar Heading 2') - }) -}) diff --git a/e2e/tests/theme-default/sidebar.cy.ts b/e2e/tests/theme-default/sidebar.cy.ts index 281ebddd36..a11d17e98b 100644 --- a/e2e/tests/theme-default/sidebar.cy.ts +++ b/e2e/tests/theme-default/sidebar.cy.ts @@ -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')