mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-24 16:08:33 -05:00
docs: Update tests/write new tests
- SRY - I know tests are much slower: Am going to refactor next - Fix failing spec for editing a doc - Update cy.visit() to instead use cy.request() to make tests run faster - Check all content of api pages - Check toc on FAQ
This commit is contained in:
@@ -0,0 +1,169 @@
|
||||
YAML = require('yamljs')
|
||||
_ = require('lodash')
|
||||
|
||||
API_PATH = "/api/welcome/api"
|
||||
API_HTML = API_PATH + '.html'
|
||||
|
||||
FIRST_PAGE = "api.html"
|
||||
NEXT_PAGE = "and.html"
|
||||
|
||||
MAILTO_REGEX = /mailto:/
|
||||
|
||||
# Cypress.isHeadless = true
|
||||
# window.top.$Cypress.isHeadless = true
|
||||
|
||||
describe "API", ->
|
||||
context "Main Menu", ->
|
||||
it "Menu goes straight to 'API' homepage", ->
|
||||
cy.visit('/')
|
||||
|
||||
cy.contains('API')
|
||||
.click()
|
||||
.contains('h1', "API")
|
||||
|
||||
cy.url()
|
||||
.should('match', new RegExp(API_HTML))
|
||||
|
||||
context "Header", ->
|
||||
beforeEach ->
|
||||
cy.visit(API_PATH + ".html")
|
||||
|
||||
it "should have link to edit doc", ->
|
||||
cy.contains("a", "Improve this doc").as("editLink")
|
||||
# cy.get("@editLink").should("have.attr", "href")
|
||||
# .and("include", API_PATH + ".md")
|
||||
cy.get("@editLink").should("have.attr", "href")
|
||||
.and("include", "https://github.com/cypress-io/cypress/issues/new")
|
||||
|
||||
context "Sidebar", ->
|
||||
beforeEach ->
|
||||
cy.visit(API_PATH + ".html")
|
||||
|
||||
cy.readFile("source/_data/sidebar.yml").then (yamlString) ->
|
||||
@sidebar = YAML.parse(yamlString)
|
||||
@sidebarTitles = _.keys(@sidebar.api)
|
||||
|
||||
@sidebarLinkNames = _.reduce @sidebar.api, (memo, nestedObj, key) ->
|
||||
memo.concat(_.keys(nestedObj))
|
||||
, []
|
||||
|
||||
@sidebarLinks = _.reduce @sidebar.api, (memo, nestedObj, key) ->
|
||||
memo.concat(_.values(nestedObj))
|
||||
, []
|
||||
|
||||
cy.readFile("themes/cypress/languages/en.yml").then (yamlString) ->
|
||||
@english = YAML.parse(yamlString)
|
||||
|
||||
it "displays current page as highlighted", ->
|
||||
cy
|
||||
.get("#sidebar").find(".current")
|
||||
.should("have.attr", "href").and("include", "api.html")
|
||||
|
||||
it "displays English titles in sidebar", ->
|
||||
cy
|
||||
.get("#sidebar")
|
||||
.find(".sidebar-title").each (displayedTitle, i) ->
|
||||
englishTitle = @english.sidebar.api[@sidebarTitles[i]]
|
||||
expect(displayedTitle.text()).to.eq(englishTitle)
|
||||
|
||||
it "displays English link names in sidebar", ->
|
||||
cy
|
||||
.get("#sidebar")
|
||||
.find(".sidebar-link").first(5).each (displayedLink, i) ->
|
||||
englishLink = @english.sidebar.api[@sidebarLinkNames[i]]
|
||||
expect(displayedLink.text().trim()).to.eq(englishLink)
|
||||
|
||||
it "displays English links in sidebar", ->
|
||||
cy
|
||||
.get("#sidebar")
|
||||
.find(".sidebar-link").each (displayedLink, i) ->
|
||||
sidebarLink = @sidebarLinks[i]
|
||||
expect(displayedLink.attr('href')).to.include(sidebarLink)
|
||||
|
||||
## This is running too slow to include for now
|
||||
## Issue #431 Needs to be fixed first
|
||||
## https://github.com/cypress-io/cypress/issues/431
|
||||
context.skip "Table of Contents", ->
|
||||
beforeEach ->
|
||||
cy.visit(API_PATH + ".html")
|
||||
|
||||
it "displays toc", ->
|
||||
cy.get('.sidebar-link').each (linkElement) ->
|
||||
cy.request(linkElement[0].href).its('body').then (body) ->
|
||||
|
||||
$body = Cypress.$(body)
|
||||
|
||||
$h1s = $body.find('.article h1').not('.article-title')
|
||||
$h2s = $body.find('.article h2')
|
||||
|
||||
$h1links = $body.find('.toc-level-1>.toc-link')
|
||||
$h2links = $body.find('.toc-level-2>.toc-link')
|
||||
|
||||
$h1s.each (i, el) ->
|
||||
$h1 = Cypress.$(el)
|
||||
$link = $h1links.eq(i)
|
||||
|
||||
expect($link.text()).to.eq($h1.text())
|
||||
expect($link.attr('href')).to.eq('#' + $h1.attr('id'))
|
||||
|
||||
$h2s.each (i, el) ->
|
||||
$h2 = Cypress.$(el)
|
||||
$link = $h2links.eq(i)
|
||||
|
||||
expect($link.text()).to.eq($h2.text())
|
||||
expect($link.attr('href')).to.eq('#' + $h2.attr('id'))
|
||||
|
||||
context "Pagination", ->
|
||||
beforeEach ->
|
||||
cy.visit(API_PATH + ".html")
|
||||
|
||||
it "does not display Prev link on first page", ->
|
||||
cy.get(".article-footer-prev").should("not.exist")
|
||||
|
||||
it "displays Next link", ->
|
||||
cy.get(".article-footer-next").should("have.attr", "href").and("include", NEXT_PAGE)
|
||||
|
||||
describe "click on Next page", ->
|
||||
beforeEach ->
|
||||
cy.get(".article-footer-next").click()
|
||||
cy.url().should("contain", NEXT_PAGE)
|
||||
|
||||
it "should display Prev link", ->
|
||||
cy.get(".article-footer-prev").should("be.visible")
|
||||
|
||||
it "clicking on Prev link should go back to original page", ->
|
||||
cy.get(".article-footer-prev").click()
|
||||
cy.url().should("contain", FIRST_PAGE)
|
||||
|
||||
context "Comments", ->
|
||||
it "displays comments section", ->
|
||||
cy.get("#comments")
|
||||
|
||||
context "Content", ->
|
||||
it "all section & body links work", ->
|
||||
filterMailtos = (urlsToFilter) ->
|
||||
Cypress._.filter(urlsToFilter, (url) -> not url.match(MAILTO_REGEX))
|
||||
|
||||
alreadySeen = []
|
||||
cullAlreadySeenUrls = (urlsToCull) ->
|
||||
# difference is what to return
|
||||
urlsToVisit = Cypress._.difference(urlsToCull, alreadySeen)
|
||||
# union is what to persist
|
||||
alreadySeen = Cypress._.union(urlsToCull, alreadySeen)
|
||||
|
||||
return urlsToVisit
|
||||
|
||||
# SPIDER ALL THE THINGS
|
||||
cy.visit(API_HTML)
|
||||
|
||||
cy.get('.sidebar-link')
|
||||
.each (linkElement) ->
|
||||
cy.request(linkElement[0].href).its('body').then (body) ->
|
||||
elements = Cypress.$(body).find('a').not('.sidebar-link, .toc-link, .main-nav-link, .mobile-nav-link, .article-edit-link, .article-anchor, #article-toc-top, #mobile-nav-toggle, .article-footer-next, .article-footer-prev, .headerlink, #logo, .footer-link')
|
||||
|
||||
withoutMailtos = filterMailtos(Cypress._.map(elements, "href"))
|
||||
|
||||
urls = cullAlreadySeenUrls(withoutMailtos)
|
||||
|
||||
cy.wrap(urls).each (url) ->
|
||||
cy.request(url)
|
||||
@@ -0,0 +1,25 @@
|
||||
YAML = require('yamljs')
|
||||
_ = require('lodash')
|
||||
|
||||
FAQ_PATH = "/faq/index"
|
||||
|
||||
describe "FAQ", ->
|
||||
beforeEach ->
|
||||
cy.server()
|
||||
cy.visit(FAQ_PATH + ".html")
|
||||
|
||||
context "Table of Contents", ->
|
||||
it "displays toc headers", ->
|
||||
cy.get('.toc-level-1>.toc-link').as('tocHeaders')
|
||||
|
||||
cy.get('.faq h1').not('.article-title').each ($h1, i) =>
|
||||
cy.get('@tocHeaders').eq(i).then ($link) =>
|
||||
expect($link.text()).to.eq($h1.text())
|
||||
|
||||
it "displays toc links", ->
|
||||
cy.get('.toc-level-2>.toc-link').as('tocLinks')
|
||||
|
||||
cy.get('.faq h2').not('.article-title').each ($h2, i) =>
|
||||
cy.get('@tocLinks').eq(i).then ($link) =>
|
||||
expect($link.text()).to.eq($h2.text())
|
||||
expect($link.attr('href')).to.eq('#' + $h2.attr('id'))
|
||||
@@ -1,42 +1,169 @@
|
||||
GUIDES_PATH = '/guides/getting-started/why-cypress.html'
|
||||
YAML = require('yamljs')
|
||||
_ = require('lodash')
|
||||
|
||||
GUIDES_PATH = '/guides/getting-started/why-cypress'
|
||||
GUIDES_HTML = GUIDES_PATH + '.html'
|
||||
|
||||
FIRST_PAGE = "why-cypress.html"
|
||||
NEXT_PAGE = "installing-cypress.html"
|
||||
|
||||
MAILTO_REGEX = /mailto:/
|
||||
|
||||
Cypress.isHeadless = true
|
||||
window.top.$Cypress.isHeadless = true
|
||||
|
||||
describe "Guides", ->
|
||||
it "main menu item goes straight to 'Why Cypress?'", ->
|
||||
cy.visit('/')
|
||||
context "Main Menu", ->
|
||||
it "Menu goes straight to 'Why Cypress?'", ->
|
||||
cy.visit('/')
|
||||
|
||||
cy.contains('Guides')
|
||||
.click()
|
||||
.contains('h1', "Why Cypress?")
|
||||
cy.contains('Guides')
|
||||
.click()
|
||||
.contains('h1', "Why Cypress?")
|
||||
|
||||
cy.url()
|
||||
.should('match', new RegExp(GUIDES_PATH))
|
||||
cy.url()
|
||||
.should('match', new RegExp(GUIDES_HTML))
|
||||
|
||||
xit "all section & body links work", ->
|
||||
filterMailtos = (urlsToFilter) ->
|
||||
Cypress._.filter(urlsToFilter, (url) -> not url.match(/mailto:/))
|
||||
context "Header", ->
|
||||
beforeEach ->
|
||||
cy.visit(GUIDES_PATH + ".html")
|
||||
|
||||
alreadySeen = []
|
||||
cullAlreadySeenUrls = (urlsToCull) ->
|
||||
# difference is what to return
|
||||
urlsToVisit = Cypress._.difference(urlsToCull, alreadySeen)
|
||||
# union is what to persist
|
||||
alreadySeen = Cypress._.union(urlsToCull, alreadySeen)
|
||||
it "should have link to edit doc", ->
|
||||
cy.contains("a", "Improve this doc").as("editLink")
|
||||
# cy.get("@editLink").should("have.attr", "href")
|
||||
# .and("include", GUIDES_PATH + ".md")
|
||||
cy.get("@editLink").should("have.attr", "href")
|
||||
.and("include", "https://github.com/cypress-io/cypress/issues/new")
|
||||
|
||||
return urlsToVisit
|
||||
context "Sidebar", ->
|
||||
beforeEach ->
|
||||
cy.visit(GUIDES_PATH + ".html")
|
||||
|
||||
# SPIDER ALL THE THINGS
|
||||
cy.visit(GUIDES_PATH)
|
||||
cy.readFile("source/_data/sidebar.yml").then (yamlString) ->
|
||||
@sidebar = YAML.parse(yamlString)
|
||||
@sidebarTitles = _.keys(@sidebar.guides)
|
||||
|
||||
cy.get('.sidebar-link')
|
||||
.each (linkElement) ->
|
||||
# .first()
|
||||
# .then (linkElement) ->
|
||||
cy.visit linkElement[0].href
|
||||
@sidebarLinkNames = _.reduce @sidebar.guides, (memo, nestedObj, key) ->
|
||||
memo.concat(_.keys(nestedObj))
|
||||
, []
|
||||
|
||||
@sidebarLinks = _.reduce @sidebar.guides, (memo, nestedObj, key) ->
|
||||
memo.concat(_.values(nestedObj))
|
||||
, []
|
||||
|
||||
cy.readFile("themes/cypress/languages/en.yml").then (yamlString) ->
|
||||
@english = YAML.parse(yamlString)
|
||||
|
||||
it "displays current page as highlighted", ->
|
||||
cy
|
||||
.get("#sidebar").find(".current")
|
||||
.should("have.attr", "href").and("include", "why-cypress.html")
|
||||
|
||||
it "displays English titles in sidebar", ->
|
||||
cy
|
||||
.get("#sidebar")
|
||||
.find(".sidebar-title").each (displayedTitle, i) ->
|
||||
englishTitle = @english.sidebar.guides[@sidebarTitles[i]]
|
||||
expect(displayedTitle.text()).to.eq(englishTitle)
|
||||
|
||||
it "displays English link names in sidebar", ->
|
||||
cy
|
||||
.get("#sidebar")
|
||||
.find(".sidebar-link").first(5).each (displayedLink, i) ->
|
||||
englishLink = @english.sidebar.guides[@sidebarLinkNames[i]]
|
||||
expect(displayedLink.text().trim()).to.eq(englishLink)
|
||||
|
||||
it "displays English links in sidebar", ->
|
||||
cy
|
||||
.get("#sidebar")
|
||||
.find(".sidebar-link").each (displayedLink, i) ->
|
||||
sidebarLink = @sidebarLinks[i]
|
||||
expect(displayedLink.attr('href')).to.include(sidebarLink)
|
||||
|
||||
## This is running too slow to include for now
|
||||
## Issue #431 Needs to be fixed first
|
||||
## https://github.com/cypress-io/cypress/issues/431
|
||||
context.skip "Table of Contents", ->
|
||||
before ->
|
||||
cy.visit(GUIDES_PATH + ".html")
|
||||
|
||||
it "displays toc", ->
|
||||
cy.get('.sidebar-link').each (linkElement) ->
|
||||
cy.request(linkElement[0].href).its('body').then (body) ->
|
||||
|
||||
$body = Cypress.$(body)
|
||||
|
||||
$h1s = $body.find('.article h1').not('.article-title')
|
||||
$h2s = $body.find('.article h2')
|
||||
|
||||
$h1links = $body.find('.toc-level-1>.toc-link')
|
||||
$h2links = $body.find('.toc-level-2>.toc-link')
|
||||
|
||||
$h1s.each (i, el) ->
|
||||
$h1 = Cypress.$(el)
|
||||
$link = $h1links.eq(i)
|
||||
|
||||
expect($link.text()).to.eq($h1.text())
|
||||
expect($link.attr('href')).to.eq('#' + $h1.attr('id'))
|
||||
|
||||
$h2s.each (i, el) ->
|
||||
$h2 = Cypress.$(el)
|
||||
$link = $h2links.eq(i)
|
||||
|
||||
expect($link.text()).to.eq($h2.text())
|
||||
expect($link.attr('href')).to.eq('#' + $h2.attr('id'))
|
||||
|
||||
context "Pagination", ->
|
||||
beforeEach ->
|
||||
cy.visit(GUIDES_PATH + ".html")
|
||||
|
||||
it "does not display Prev link on first page", ->
|
||||
cy.get(".article-footer-prev").should("not.exist")
|
||||
|
||||
it "displays Next link", ->
|
||||
cy.get(".article-footer-next").should("have.attr", "href").and("include", NEXT_PAGE)
|
||||
|
||||
describe "click on Next page", ->
|
||||
beforeEach ->
|
||||
cy.get(".article-footer-next").click()
|
||||
cy.url().should("contain", NEXT_PAGE)
|
||||
|
||||
it "should display Prev link", ->
|
||||
cy.get(".article-footer-prev").should("be.visible")
|
||||
|
||||
it "clicking on Prev link should go back to original page", ->
|
||||
cy.get(".article-footer-prev").click()
|
||||
cy.url().should("contain", FIRST_PAGE)
|
||||
|
||||
context "Comments", ->
|
||||
it "displays comments section", ->
|
||||
cy.get("#comments")
|
||||
|
||||
context "Content", ->
|
||||
it "all section & body links work", ->
|
||||
filterMailtos = (urlsToFilter) ->
|
||||
Cypress._.filter(urlsToFilter, (url) -> not url.match(MAILTO_REGEX))
|
||||
|
||||
alreadySeen = []
|
||||
cullAlreadySeenUrls = (urlsToCull) ->
|
||||
# difference is what to return
|
||||
urlsToVisit = Cypress._.difference(urlsToCull, alreadySeen)
|
||||
# union is what to persist
|
||||
alreadySeen = Cypress._.union(urlsToCull, alreadySeen)
|
||||
|
||||
return urlsToVisit
|
||||
|
||||
# SPIDER ALL THE THINGS
|
||||
cy.visit(GUIDES_HTML)
|
||||
|
||||
cy.get('.sidebar-link')
|
||||
.each (linkElement) ->
|
||||
cy.request(linkElement[0].href).its('body').then (body) ->
|
||||
elements = Cypress.$(body).find('a').not('.sidebar-link, .toc-link, .main-nav-link, .mobile-nav-link, .article-edit-link, .article-anchor, #article-toc-top, #mobile-nav-toggle, .article-footer-next, .article-footer-prev, .headerlink, #logo, #footer')
|
||||
|
||||
cy.get('a')
|
||||
.not('.sidebar-link, .toc-link, .main-nav-link, .mobile-nav-link, .article-edit-link, .article-anchor, #article-toc-top, #mobile-nav-toggle, .article-footer-next, .headerlink, #logo')
|
||||
.then (elements) ->
|
||||
withoutMailtos = filterMailtos(Cypress._.map(elements, "href"))
|
||||
return cullAlreadySeenUrls(withoutMailtos)
|
||||
.each (url) ->
|
||||
cy.request(url)
|
||||
|
||||
urls = cullAlreadySeenUrls(withoutMailtos)
|
||||
|
||||
cy.wrap(urls).each (url) ->
|
||||
cy.request(url)
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
YAML = require('yamljs')
|
||||
_ = require('lodash')
|
||||
|
||||
GUIDES_PATH = "/guides/getting-started/why-cypress"
|
||||
API_PATH = "/api/welcome/api"
|
||||
ECO_PATH = "/ecosystem/index"
|
||||
FAQ_PATH = "/faq/index"
|
||||
|
||||
describe "Documentation", ->
|
||||
beforeEach ->
|
||||
cy.server()
|
||||
@mainGuides = "/guides/getting-started/why-cypress"
|
||||
@mainAPI = "/api/welcome/api"
|
||||
@mainEco = "/ecosystem/index"
|
||||
@mainFAQ = "/faq/index"
|
||||
|
||||
context "Pages", ->
|
||||
describe "404", ->
|
||||
@@ -23,165 +24,73 @@ describe "Documentation", ->
|
||||
it "displays", ->
|
||||
cy.contains("Homepage")
|
||||
|
||||
describe "Navigation", ->
|
||||
beforeEach ->
|
||||
cy.visit("/")
|
||||
context "Navigation", ->
|
||||
beforeEach ->
|
||||
cy.visit("/")
|
||||
|
||||
it "displays links to pages", ->
|
||||
cy.contains(".main-nav-link", "Guides")
|
||||
.should("have.attr", "href").and("include", @mainGuides)
|
||||
it "displays links to pages", ->
|
||||
cy.contains(".main-nav-link", "Guides")
|
||||
.should("have.attr", "href").and("include", GUIDES_PATH)
|
||||
|
||||
cy.contains(".main-nav-link", "API")
|
||||
.should("have.attr", "href").and("include", @mainAPI)
|
||||
cy.contains(".main-nav-link", "API")
|
||||
.should("have.attr", "href").and("include", API_PATH)
|
||||
|
||||
cy.contains(".main-nav-link", "Ecosystem")
|
||||
.should("have.attr", "href").and("include", @mainEco)
|
||||
cy.contains(".main-nav-link", "Ecosystem")
|
||||
.should("have.attr", "href").and("include", ECO_PATH)
|
||||
|
||||
cy.contains(".main-nav-link", "FAQ")
|
||||
.should("have.attr", "href").and("include", @mainFAQ)
|
||||
cy.contains(".main-nav-link", "FAQ")
|
||||
.should("have.attr", "href").and("include", FAQ_PATH)
|
||||
|
||||
it "displays link to github repo", ->
|
||||
it "displays link to github repo", ->
|
||||
cy
|
||||
.get(".main-nav-link").find(".fa-github").parent()
|
||||
.should("have.attr", "href")
|
||||
.and("eq", "https://github.com/cypress-io/cypress")
|
||||
|
||||
it "displays language dropdown", ->
|
||||
cy.contains("select", "English").find("option").contains("English")
|
||||
|
||||
describe "active nav", ->
|
||||
it "higlights guides when on a guides page", ->
|
||||
cy
|
||||
.get(".main-nav-link").find(".fa-github").parent()
|
||||
.should("have.attr", "href")
|
||||
.and("eq", "https://github.com/cypress-io/cypress")
|
||||
.visit(GUIDES_PATH + ".html")
|
||||
.contains(".main-nav-link", "Guides")
|
||||
.should("have.class", "active")
|
||||
|
||||
it "displays language dropdown", ->
|
||||
cy.contains("select", "English").find("option").contains("English")
|
||||
|
||||
describe "active nav", ->
|
||||
it "higlights guides when on a guides page", ->
|
||||
cy
|
||||
.visit(@mainGuides + ".html")
|
||||
.contains(".main-nav-link", "Guides")
|
||||
.should("have.class", "active")
|
||||
|
||||
it "higlights api when on a api page", ->
|
||||
cy
|
||||
.visit(@mainAPI + ".html")
|
||||
.contains(".main-nav-link", "API")
|
||||
.should("have.class", "active")
|
||||
|
||||
it "higlights eco when on a eco page", ->
|
||||
cy
|
||||
.visit(@mainEco + ".html")
|
||||
.contains(".main-nav-link", "Ecosystem")
|
||||
.should("have.class", "active")
|
||||
|
||||
it "higlights FAQ when on a FAQ page", ->
|
||||
cy
|
||||
.visit(@mainFAQ + ".html")
|
||||
.contains(".main-nav-link", "FAQ")
|
||||
.should("have.class", "active")
|
||||
|
||||
describe "Search", ->
|
||||
beforeEach ->
|
||||
cy.visit("/")
|
||||
|
||||
it "posts to Algolia api with correct index on search", ->
|
||||
it "higlights api when on a api page", ->
|
||||
cy
|
||||
.route({
|
||||
method: "POST",
|
||||
url: /algolia/
|
||||
}).as("postAlgolia")
|
||||
.get("#search-input").type("g")
|
||||
.wait("@postAlgolia").then (xhr) ->
|
||||
expect(xhr.requestBody.requests[0].indexName).to.eq("cypress")
|
||||
.visit(API_PATH + ".html")
|
||||
.contains(".main-nav-link", "API")
|
||||
.should("have.class", "active")
|
||||
|
||||
it "displays algolia dropdown on search", ->
|
||||
it "higlights eco when on a eco page", ->
|
||||
cy
|
||||
.get(".ds-dropdown-menu").should("not.be.visible")
|
||||
.get("#search-input").type("g")
|
||||
.get(".ds-dropdown-menu").should("be.visible")
|
||||
.visit(ECO_PATH + ".html")
|
||||
.contains(".main-nav-link", "Ecosystem")
|
||||
.should("have.class", "active")
|
||||
|
||||
describe "Guides", ->
|
||||
beforeEach ->
|
||||
cy.visit(@mainGuides + ".html")
|
||||
it "higlights FAQ when on a FAQ page", ->
|
||||
cy
|
||||
.visit(FAQ_PATH + ".html")
|
||||
.contains(".main-nav-link", "FAQ")
|
||||
.should("have.class", "active")
|
||||
|
||||
context "Header", ->
|
||||
it.skip "should display capitalized title of doc", ->
|
||||
cy
|
||||
.contains("h1", "Guides")
|
||||
context "Search", ->
|
||||
beforeEach ->
|
||||
cy.visit("/")
|
||||
|
||||
it "should have link to edit doc", ->
|
||||
cy
|
||||
.contains("a", "Improve this doc").as("editLink")
|
||||
.get("@editLink").should("have.attr", "href")
|
||||
.and("include", @mainGuides + ".md")
|
||||
.get("@editLink").should("have.attr", "href")
|
||||
.and("include", "https://github.com/cypress-io/cypress-documentation/edit/master/source/")
|
||||
it "posts to Algolia api with correct index on search", ->
|
||||
cy
|
||||
.route({
|
||||
method: "POST",
|
||||
url: /algolia/
|
||||
}).as("postAlgolia")
|
||||
.get("#search-input").type("g")
|
||||
.wait("@postAlgolia").then (xhr) ->
|
||||
expect(xhr.requestBody.requests[0].indexName).to.eq("cypress")
|
||||
|
||||
context "Sidebar", ->
|
||||
beforeEach ->
|
||||
cy.readFile("source/_data/sidebar.yml").then (yamlString) ->
|
||||
@sidebar = YAML.parse(yamlString)
|
||||
@sidebarTitles = _.keys(@sidebar.guides)
|
||||
|
||||
@sidebarLinkNames = _.reduce @sidebar.guides, (memo, nestedObj, key) ->
|
||||
memo.concat(_.keys(nestedObj))
|
||||
, []
|
||||
|
||||
@sidebarLinks = _.reduce @sidebar.guides, (memo, nestedObj, key) ->
|
||||
memo.concat(_.values(nestedObj))
|
||||
, []
|
||||
|
||||
cy.readFile("themes/cypress/languages/en.yml").then (yamlString) ->
|
||||
@english = YAML.parse(yamlString)
|
||||
|
||||
it "displays current page as highlighted", ->
|
||||
cy
|
||||
.get("#sidebar").find(".current")
|
||||
.should("have.attr", "href").and("include", "why-cypress.html")
|
||||
|
||||
it "displays English titles in sidebar", ->
|
||||
cy
|
||||
.get("#sidebar")
|
||||
.find(".sidebar-title").each (displayedTitle, i) ->
|
||||
englishTitle = @english.sidebar.guides[@sidebarTitles[i]]
|
||||
|
||||
expect(displayedTitle.text()).to.eq(englishTitle)
|
||||
|
||||
it "displays English link names in sidebar", ->
|
||||
cy
|
||||
.get("#sidebar")
|
||||
.find(".sidebar-link").first(5).each (displayedLink, i) ->
|
||||
englishLink = @english.sidebar.guides[@sidebarLinkNames[i]]
|
||||
|
||||
expect(displayedLink.text().trim()).to.eq(englishLink)
|
||||
|
||||
it "displays English links in sidebar", ->
|
||||
cy
|
||||
.get("#sidebar")
|
||||
.find(".sidebar-link").each (displayedLink, i) ->
|
||||
sidebarLink = @sidebarLinks[i]
|
||||
|
||||
expect(displayedLink.attr('href')).to.include(sidebarLink)
|
||||
|
||||
context.skip "Table of Contents", ->
|
||||
|
||||
context "Pagination", ->
|
||||
beforeEach ->
|
||||
@firstPage = "why-cypress.html"
|
||||
@nextPage = "installing-cypress.html"
|
||||
|
||||
it "does not display Prev link on first page", ->
|
||||
cy.get(".article-footer-prev").should("not.exist")
|
||||
|
||||
it "displays Next link", ->
|
||||
cy.get(".article-footer-next").should("have.attr", "href").and("include", @nextPage)
|
||||
|
||||
describe "click on Next page", ->
|
||||
beforeEach ->
|
||||
cy.get(".article-footer-next").click()
|
||||
cy.url().should("contain", @nextPage)
|
||||
|
||||
it "should display Prev link", ->
|
||||
cy.get(".article-footer-prev").should("be.visible")
|
||||
|
||||
it "clicking on Prev link should go back to original page", ->
|
||||
cy.get(".article-footer-prev").click()
|
||||
cy.url().should("contain", @firstPage)
|
||||
|
||||
context "Comments", ->
|
||||
it "displays comments section", ->
|
||||
cy.get("#comments").should("be.visible")
|
||||
it "displays algolia dropdown on search", ->
|
||||
cy
|
||||
.get(".ds-dropdown-menu").should("not.be.visible")
|
||||
.get("#search-input").type("g")
|
||||
.get(".ds-dropdown-menu").should("be.visible")
|
||||
|
||||
Reference in New Issue
Block a user