Skip to content

Test page titles #1800

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 5 commits into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions cypress/integration/i18n_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ describe('i18n', () => {
cy.url().should('contain', 'why-cypress')
})

it('uses English in Command Line guide', () => {
cy.visit('/guides/guides/command-line.html')
cy.document().its('documentElement.lang').should('equal', 'en')
cy.get('meta[property="og:title"]').invoke('attr', 'content').should('equal', 'Command Line')
cy.contains('h1', 'Command Line')
})

context('language select', () => {
it('selects English by default', () => {
cy.get('#lang-select').find('option')
Expand Down
52 changes: 52 additions & 0 deletions cypress/integration/page_header_spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,60 @@
const YAML = require('yamljs')
const _ = require('lodash')

describe('Page Header', () => {
beforeEach(() => {
cy.server()
})

it('displays correct page title', function () {
cy.wrap(this.langValues).each(function (lang) {
let sidebarYaml = 'source/_data/sidebar.yml'
let visitUrlPrefix = ''

if (lang !== 'en') {
sidebarYaml = `source/${lang}/_data/sidebar.yml`
visitUrlPrefix = lang
}

cy.wrap(this.MAIN_NAV).each((nav) => {
// the Plugin docs doesn't have a sidebar
// the API docs don't really need translations (since it's all commands)
if (nav.name === 'Plugins' || nav.name === 'API') return

cy.readFile(sidebarYaml)
.then(function (yamlString) {
this.navName = _.toLower(nav.name)

this.sidebar = YAML.parse(yamlString)
this.sidebarTitles = _.keys(this.sidebar[this.navName])

this.sidebarLinkNames = _.reduce(this.sidebar[this.navName], (memo, nestedObj) => memo.concat(_.keys(nestedObj))
, [])

this.sidebarLinks = _.reduce(this.sidebar[this.navName], (memo, nestedObj) => memo.concat(_.values(nestedObj))
, [])

cy.visit(`${visitUrlPrefix}${nav.path}.html`)

cy.get('.sidebar-link')
.each(($linkElement) => {
cy.request(`${$linkElement[0].href}`).its('body')
.then((body) => {
const page = _.last($linkElement[0].href.split('/'))

if (page !== 'assertions.html') {
const $body = Cypress.$(body)
const $h1 = $body.find('h1.article-title')

expect($h1.text(), `Page title '${$h1.text()}' in ${page} matches translated title in ${lang}.yml`).to.eq($linkElement.text().trim())
}
})
})
})
})
})
})

it('should have link to edit doc', function () {
cy.wrap(this.MAIN_NAV).each((nav) => {
let path = `${nav.path}.html`
Expand Down
6 changes: 0 additions & 6 deletions cypress/integration/sidebar_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ context('Sidebar', () => {
})

context('Titles and links', () => {
beforeEach(() => {

})

it('displays titles and links in sidebar', function () {
cy.wrap(this.langValues).each(function (lang) {
let sidebarYaml = 'source/_data/sidebar.yml'
Expand Down Expand Up @@ -71,8 +67,6 @@ context('Sidebar', () => {
})
})
})


})
})
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/table_of_contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const GUIDES_PATH = '/guides/overview/why-cypress.html'
const API_PATH = '/api/api/table-of-contents'

describe('Table of Contents', () => {
beforeEach(() => {
beforeEach(function () {
//# skip running this test if we are in interactive mode
if (Cypress.config('isInteractive')) {
this.skip()
Expand Down
Loading