Skip to content

Commit

Permalink
Add a test for the WIP language banner link change (github#17480)
Browse files Browse the repository at this point in the history
* Add a test

* Try adding de

* Let's try all languages
  • Loading branch information
JasonEtco authored Jan 27, 2021
1 parent 612ec76 commit 4a76141
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"test": "jest && eslint . && prettier -c \"**/*.{yml,yaml}\" && npm run check-deps",
"prebrowser-test": "npm run build",
"browser-test": "start-server-and-test browser-test-server 4001 browser-test-tests",
"browser-test-server": "cross-env NODE_ENV=production ENABLED_LANGUAGES='en,ja' PORT=4001 node server.js",
"browser-test-server": "cross-env NODE_ENV=production PORT=4001 node server.js",
"browser-test-tests": "cross-env BROWSER=1 jest tests/browser/browser.js",
"sync-search": "start-server-and-test sync-search-server 4002 sync-search-indices",
"sync-search-dry-run": "DRY_RUN=1 npm run sync-search",
Expand Down
17 changes: 17 additions & 0 deletions tests/browser/browser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* global page, browser */
const sleep = require('await-sleep')
const { latest } = require('../../lib/enterprise-server-releases')
const languages = require('../../lib/languages')

describe('homepage', () => {
jest.setTimeout(60 * 1000)
Expand Down Expand Up @@ -264,3 +265,19 @@ describe('card filters', () => {
expect(noResultsClasses).not.toContain('d-none')
})
})

describe('language banner', () => {
it('directs user to the English version of the article', async () => {
const wipLanguageKey = Object.keys(languages).find(key => languages[key].wip)

// This kinda sucks, but if we don't have a WIP language, we currently can't
// run a reliable test. But hey, on the bright side, if we don't have a WIP
// language then this code will never run anyway!
if (wipLanguageKey) {
const res = await page.goto(`http://localhost:4001/${wipLanguageKey}/actions`)
expect(res.ok()).toBe(true)
const href = await page.$eval('a#to-english-doc', el => el.href)
expect(href.endsWith('/en/actions')).toBe(true)
}
})
})

0 comments on commit 4a76141

Please sign in to comment.