const SIDEBAR = './content/_data/sidebar.json'
const SIDEBAR_EN = './content/_data/en.json'

describe('Guides', () => {
  beforeEach(() => {
    cy.viewport('macbook-15')
    cy.visit('/')
  })

  it('contains a sidebar', () => {
    cy.readFile(SIDEBAR).then(({ guides: sidebarGuides }) => {
      cy.readFile(SIDEBAR_EN).then(({ sidebar: { guides } }) => {
        const sidebarCategories = Object.keys(sidebarGuides)

        cy.wrap(sidebarCategories).each((category) => {
          const pages = Object.keys(sidebarGuides[category])

          cy.get('.app-sidebar').contains(guides[category])

          cy.wrap(pages).each((page) => {
            const pageTitle = guides[page]

            if (page === 'component-testing-introduction') {
              // for now, bypass an error thrown on this page by vue-meta
              return
            }

            cy.contains(
              `.app-sidebar [data-test="${category}"] a`,
              pageTitle
            ).click({ force: true })

            const redirects = {
              'dashboard-introduction': '/guides/dashboard/introduction',
              'continuous-integration-introduction':
                '/guides/continuous-integration/introduction',
            }

            cy.location('pathname').should(
              'equal',
              redirects[page] || `/guides/${category}/${page}`
            )

            cy.contains(
              `.app-sidebar [data-test="${category}"] a`,
              pageTitle
            ).should(
              'have.class',
              'nuxt-link-exact-active nuxt-link-active active-sidebar-link'
            )

            cy.title().should('equal', pageTitle)

            cy.get('.main-content-title').contains(pageTitle)

            cy.visualSnapshot(`/guides/${category}/${page}`)
          })

          cy.visit('/')
        })
      })
    })
  })
})

@@ -651,195 +651,806 @@
     
-const pageTitle = guides%5Bpage%5D%0A%0A            if (page === 'component-testing-introduction') %7B%0A              // for now, bypass an error thrown on this page by vue-meta%0A              return
+/**%0A             * The %60title%60 in the front matter is _usually_ the same as the%0A             * %60en.json%60 data for that key. However, some exceptions exist%0A             * which use a front matter %60title%60 that does not match.%0A             */%0A            const titleMismatches = %7B%0A              'dashboard-introduction': 'Dashboard',%0A            %7D%0A%0A            const pageTitle = titleMismatches%5Bpage%5D %7C%7C guides%5Bpage%5D%0A%0A            if (page === 'component-testing-introduction') %7B%0A              // for now, bypass an error thrown on this page by vue-meta%0A              return%0A            %7D%0A%0A            // Title on /guides/dashboard/introduction is %22Dashboard%22 whereas the sidebar%0A            // item is %22Introduction%22%0A            const sidebarItemMismatches = %7B%0A              Dashboard: 'Introduction',
 %0A   
@@ -1549,32 +1549,68 @@
 %60,%0A             
+ sidebarItemMismatches%5BpageTitle%5D %7C%7C
  pageTitle%0A     
@@ -2120,16 +2120,52 @@
         
+ sidebarItemMismatches%5BpageTitle%5D %7C%7C
  pageTit

update tests after updating dashboard introduction title