Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: flaky tests and logo url #48

Merged
merged 1 commit into from
May 8, 2022
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
41 changes: 21 additions & 20 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
{
"baseUrl": "http://localhost:1313",
"baseUrl": "http://localhost:1313/",
"viewportWidth": 1920,
"viewportHeight": 1080,
"screenshotOnRunFailure": false,
"video": false,
"env": {
"404_URL" : "/404.html",
"404_PATH" : "404.html",
"SITEMAP_XML_PATH" : "sitemap.xml",
"FRENCH_URL_PREFIX" : "/fr",
"FUNC_TOC_URL" : "/functionalities/toc/",
"FUNC_BANNER_URLS" : ["/functionalities/banner/global/","/functionalities/banner/single/"],
"FUNC_MERMAID_URL" : "/functionalities/mermaid/",
"HOMEPAGE_URL" : "/",
"FUNC_TOC_PATH" : "functionalities/toc/",
"FUNC_BANNER_PATHS" : ["functionalities/banner/global/","functionalities/banner/single/"],
"FUNC_MERMAID_PATH" : "functionalities/mermaid/",
"HOMEPAGE_URL" : "http://localhost:1313/",
"NULL_STRING" : "bnVsbFN0cmluZw==",
"SEARCH_TEST_INPUT" : "theme",
"SC_URL" : "/shortcodes/",
"SC_ALERT_URL" : "/alert/",
"SC_BLOCKQUOTE_URL" : "/blockquote/",
"SC_COLLAPSIBLE_URL" : "/collapsible/",
"SC_INTRO_URL" : "/intro/",
"SC_OPENAPI_URL" : "/openapi/",
"SC_PAGEBREAK_URL" : "/pagebreak/",
"SC_PARAMETER_URL" : "/parameter/",
"SC_SNIPPET_URL" : "/snippet/",
"SC_TREEVIEW_URL" : "/treeview/",
"SITEMAP_URL" : "/sitemap/",
"TAXONOMY_URL" : "/categories/",
"TERM_URL" : "/categories/markdown/",
"THEME_URL" : "/theme/",
"SC_PATH" : "shortcodes/",
"SC_ALERT_PATH" : "alert/",
"SC_BLOCKQUOTE_PATH" : "blockquote/",
"SC_COLLAPSIBLE_PATH" : "collapsible/",
"SC_INTRO_PATH" : "intro/",
"SC_OPENAPI_PATH" : "openapi/",
"SC_PAGEBREAK_PATH" : "pagebreak/",
"SC_PARAMETER_PATH" : "parameter/",
"SC_SNIPPET_PATH" : "snippet/",
"SC_TREEVIEW_PATH" : "treeview/",
"SITEMAP_PATH" : "sitemap/",
"TAXONOMY_PATH" : "categories/",
"TERM_PATH" : "categories/markdown/",
"THEME_PATH" : "theme/",
"VIEWPORT_COMMON_HEIGHT" : 1080,
"VIEWPORT_DESKTOP_MAXWIDTH" : 1920,
"VIEWPORT_DESKTOP_MINWIDTH" : 1024,
Expand Down
8 changes: 5 additions & 3 deletions cypress/integration/global/404Tests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('for: 404 page', () => {
beforeEach(() => {
cy.visit(Cypress.env('404_URL'))
cy.visit(Cypress.env('404_PATH'))
})
it('link back to homepage should be displayed', () => {
cy.get('#footer404')
Expand All @@ -9,7 +9,9 @@ describe('for: 404 page', () => {
it('link back to homepage should redirect to homepage', () => {
cy.get('#footer404')
.click()
cy.location('pathname')
.should('eq', Cypress.env('HOMEPAGE_URL'))
cy.location()
.should((loc) => {
expect(loc.toString()).to.eq(Cypress.env('HOMEPAGE_URL'))
})
})
})
2 changes: 1 addition & 1 deletion cypress/integration/global/bannerTests.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
for (const bannerUrl of Cypress.env('FUNC_BANNER_URLS')) {
for (const bannerUrl of Cypress.env('FUNC_BANNER_PATHS')) {
describe('for: table of content of ' + bannerUrl, () => {
beforeEach(() => {
cy.visit(bannerUrl)
Expand Down
9 changes: 3 additions & 6 deletions cypress/integration/global/contentTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('for: content', () => {
beforeEach(() => {
cy.visit(Cypress.env('FUNC_TOC_URL'))
cy.visit(Cypress.env('FUNC_TOC_PATH'))
})
it('all titles should have anchors', () => {
cy.get('#content')
Expand All @@ -19,11 +19,8 @@ describe('for: content', () => {
.children('a[href="#' + encodeURI($title[0].id).toLowerCase() + '"]')
.should('have.class', 'anchor')
.click({force:true})
cy.location()
.should((loc) => {
expect(loc.hash).to.eq('#' + encodeURI($title[0].id).toLowerCase())
expect(loc.pathname).to.eq(Cypress.env('FUNC_TOC_URL'))
})
cy.location('href')
.should('eq', Cypress.env('HOMEPAGE_URL') + Cypress.env('FUNC_TOC_PATH') + '#' + encodeURI($title[0].id).toLowerCase())
})
})
})
4 changes: 2 additions & 2 deletions cypress/integration/global/logoTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('for: logo', () => {
beforeEach(() => {
cy.visit(Cypress.env('SITEMAP_URL'))
cy.visit(Cypress.env('SITEMAP_PATH'))
})
it('logo should be displayed', () => {
cy.get('#globalLogo')
Expand All @@ -9,7 +9,7 @@ describe('for: logo', () => {
it('logo should redirect to homepage', () => {
cy.get('#globalLogo')
.click()
cy.location('pathname')
cy.location('href')
.should('eq', Cypress.env('HOMEPAGE_URL'))
})
})
2 changes: 1 addition & 1 deletion cypress/integration/global/mermaidTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('for: mermaid', () => {
beforeEach(() => {
cy.visit(Cypress.env('FUNC_MERMAID_URL'))
cy.visit(Cypress.env('FUNC_MERMAID_PATH'))
})
it('one mermaid should be displayed', () => {
cy.get('#content .sc-mermaid-wrapper > .sc-mermaid-container')
Expand Down
61 changes: 32 additions & 29 deletions cypress/integration/global/multilingualTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,40 @@ describe('for: multilingual', () => {
beforeEach(() => {
cy.visit(Cypress.env('HOMEPAGE_URL'))
})
it('all entries in the sidebar should have its corresponding traduction', () => {
let pathsMap = [];
cy.get('#sidebarContainer .menu .is-expandable .card-header-title[href]')
.each(($elem) => {
let href = $elem[0].getAttribute("href");
if (href) { pathsMap.push(href) }
})
cy.wrap(pathsMap)
.each(($path) => {
cy.visit($path)
.location('pathname')
.should('eq', $path)
cy.visit(Cypress.env('FRENCH_URL_PREFIX') + $path)
.location('pathname')
.should('eq', Cypress.env('FRENCH_URL_PREFIX') + $path)
it('sitemap.xml should have 2 entries', () => {
cy.request(Cypress.env('SITEMAP_XML_PATH'))
.its('body')
.then((sitemapindex) => {
const parser = new DOMParser();
const xmlSitemapindex = parser.parseFromString(sitemapindex,"text/xml");
expect(xmlSitemapindex.getElementsByTagName('sitemap')).to.have.length(2)
})
})
it('all entries in the sidebar should be set properly active when visited', () => {
let pathsMap = [];
cy.get('#sidebarContainer .menu .is-expandable .card-header-title[href]')
.each(($elem) => {
let href = $elem[0].getAttribute("href");
if (href) { pathsMap.push(href) }
})
cy.wrap(pathsMap)
.each(($path) => {
cy.visit($path)
.location('pathname')
.should('eq', $path)
.get('#sidebarActiveEntry .card-header-title[href]')
.should('have.attr', 'href', $path)
it('languages sitemap.xml should have the same number of url', () => {
cy.request(Cypress.env('SITEMAP_XML_PATH'))
.its('body')
.then((sitemapindex) => {
const parser = new DOMParser();
const sitemaps = parser.parseFromString(sitemapindex,"text/xml").getElementsByTagName('sitemap');
console.log(sitemaps)
cy.request(sitemaps[0].getElementsByTagName('loc')[0].childNodes[0].nodeValue)
.its('body')
.then((urlset) => parser.parseFromString(urlset,"text/xml").getElementsByTagName('url').length)
.then((urlCount) => {
for (let sitemap of sitemaps) {
cy.request(sitemap.getElementsByTagName('loc')[0].childNodes[0].nodeValue)
.its('body')
.then((urlset) => parser.parseFromString(urlset,"text/xml").getElementsByTagName('url'))
.should((urlset) => {
expect(urlset.length).to.equal(urlCount)
})
.then((urlset) => {
for (let url of urlset) {
cy.request(url.getElementsByTagName('loc')[0].childNodes[0].nodeValue)
}
})
}
})
})
})
})
8 changes: 5 additions & 3 deletions cypress/integration/global/shortcutsTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('for: shortcuts', () => {
beforeEach(() => {
cy.visit(Cypress.env('SITEMAP_URL'))
cy.visit(Cypress.env('SITEMAP_PATH'))
})
it('[shift+i] should open website information panel', () => {
cy.window().its('scShowInfo')
Expand All @@ -18,8 +18,10 @@ describe('for: shortcuts', () => {
cy.window().its('scGoHome')
cy.get('body')
.type('{shift+h}', {delay:0})
cy.location('pathname')
.should('eq', Cypress.env('HOMEPAGE_URL'))
cy.location()
.should((loc) => {
expect(loc.toString()).to.eq(Cypress.env('HOMEPAGE_URL'))
})
})
it('[shift+f] should focus on search', () => {
cy.window().its('scGoSearch')
Expand Down
6 changes: 3 additions & 3 deletions cypress/integration/global/tocTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('for: table of content', () => {
beforeEach(() => {
cy.visit(Cypress.env('FUNC_TOC_URL'))
cy.visit(Cypress.env('FUNC_TOC_PATH'))
})
it('toc should be displayed on desktop', () => {
cy.viewportDesktop()
Expand All @@ -23,12 +23,12 @@ describe('for: table of content', () => {
.should('not.exist')
})
it('toc should not be displayed on term pages', () => {
cy.visit(Cypress.env('TERM_URL'))
cy.visit(Cypress.env('TERM_PATH'))
cy.get('#tocContainer')
.should('not.exist')
})
it('toc should not be displayed on taxonomy pages', () => {
cy.visit(Cypress.env('TAXONOMY_URL'))
cy.visit(Cypress.env('TAXONOMY_PATH'))
cy.get('#tocContainer')
.should('not.exist')
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/shortcodes/alertTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('for: alert shortcode', () => {
beforeEach(() => {
cy.visit(Cypress.env('SC_URL') + Cypress.env('SC_ALERT_URL'))
cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_ALERT_PATH'))
})
it('two info alerts should be displayed', () => {
cy.get('#content .sc-alert.sc-alert-info')
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/shortcodes/blockquoteTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('for: blockquote shortcode', () => {
beforeEach(() => {
cy.visit(Cypress.env('SC_URL') + Cypress.env('SC_BLOCKQUOTE_URL'))
cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_BLOCKQUOTE_PATH'))
})
it('two blockquotes should be displayed', () => {
cy.get('#content .sc-blockquote')
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/shortcodes/collapsibleTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('for: collapsible shortcode', () => {
beforeEach(() => {
cy.visit(Cypress.env('SC_URL') + Cypress.env('SC_COLLAPSIBLE_URL'))
cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_COLLAPSIBLE_PATH'))
})
it('two collapsibles should be displayed', () => {
cy.get('#content .sc-collapsible-container')
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/shortcodes/introTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('for: intro shortcode', () => {
beforeEach(() => {
cy.visit(Cypress.env('SC_URL') + Cypress.env('SC_INTRO_URL'))
cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_INTRO_PATH'))
})
it('one intro should be displayed', () => {
cy.get('#content #introTest')
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/shortcodes/openapiTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('for: openapi shortcode', () => {
beforeEach(() => {
cy.visit(Cypress.env('SC_URL') + Cypress.env('SC_OPENAPI_URL'))
cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_OPENAPI_PATH'))
})
it('two openapi should be displayed', () => {
cy.get('#content .sc-openapi-wrapper > .sc-openapi-container')
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/shortcodes/pagebreakTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('for: pagebreak shortcode', () => {
beforeEach(() => {
cy.visit(Cypress.env('SC_URL') + Cypress.env('SC_PAGEBREAK_URL'))
cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_PAGEBREAK_PATH'))
})
it('one pagebreak should be set in the page', () => {
cy.get('#content .sc-pagebreak')
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/shortcodes/parameterTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('for: parameter shortcode', () => {
beforeEach(() => {
cy.visit(Cypress.env('SC_URL') + Cypress.env('SC_PARAMETER_URL'))
cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_PARAMETER_PATH'))
})
it('seven parameters should be displayed', () => {
cy.get('#content .sc-parameter')
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/shortcodes/snippetTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('for: snippet shortcode', () => {
beforeEach(() => {
cy.visit(Cypress.env('SC_URL') + Cypress.env('SC_SNIPPET_URL'))
cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_SNIPPET_PATH'))
})
it('ten snippets wrapper should be displayed', () => {
cy.get('#content .sc-snippet-wrapper')
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/shortcodes/treeviewTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('for: treeview shortcode', () => {
beforeEach(() => {
cy.visit(Cypress.env('SC_URL') + Cypress.env('SC_TREEVIEW_URL'))
cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_TREEVIEW_PATH'))
})
it('six treeviews should be displayed', () => {
cy.get('#content .sc-treeview')
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/global/shortcutsCommands.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Cypress.Commands.add('desktopShortcutsBeforeEach', () => {
cy.visit(Cypress.env('SITEMAP_URL'))
cy.visit(Cypress.env('SITEMAP_PATH'))
cy.viewportDesktop()
})
7 changes: 2 additions & 5 deletions exampleSite/content/english/theme/beyond.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
weight: 1030
linkTitle: "To infinity and beyond!"
title: "Setup: To infinity and beyond!"
description: "Everything needed to know about the theme."
title: "To infinity and beyond!"
description: "What will come next in the theme."
categories: ["Theme"]
---

Expand All @@ -22,6 +22,3 @@ categories: ["Theme"]

### Technical website improvements
* Use of purgeCSS in PostCSS

# Contributing
---
25 changes: 25 additions & 0 deletions exampleSite/content/english/theme/contribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
weight: 1040
linkTitle: "Contribute"
title: "Contributing guide"
description: "How to contribute to the theme?"
categories: ["Theme"]
---

# Find a bug?
---

If you find any bug within the theme, don't hesitate to [raise and report a new issue](https://github.com/jgazeau/shadocs/issues/new).

# Want to contribute?
---

If you want to contribute directly to the project, don't hesitate do fork the project and raise a Pull Request to submit your modifications. All ideas are welcomed and I'll be glad to check them.

# Want to run the documentation website locally?
---

To run the current website locally, run the following command:
```sh
hugo -s exampleSite/ serve
```
7 changes: 2 additions & 5 deletions exampleSite/content/french/theme/beyond.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
weight: 1030
linkTitle: "Vers l'infini et au-delà !"
title: "Installation: Vers l'infini et au-delà !"
description: "Tout ce qu'il faut savoir sur le thème."
title: "Vers l'infini et au-delà !"
description: "Ce qui est prévu par la suite dans le thème."
categories: ["Thème"]
---

Expand All @@ -22,6 +22,3 @@ categories: ["Thème"]

### Optimisations techniques du site
* Utilisation de purgeCSS en PostCSS

# Contribuer
---
Loading