Skip to content

Commit

Permalink
Get fixtures from e2e repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Buck committed Jun 29, 2018
1 parent 16e99ea commit 0c8dd8d
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ lerna-debug.log

dist/
out/
e2e/urls.json
e2e/fixtures.json
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ before_script:
- git diff --exit-code # make sure that yarn.lock didn't change
- ./packages/blob-reader/scripts/update-fixtures.sh
- yarn package
after_script:
- yarn e2e
script:
- travis_retry yarn test
- yarn e2e
deploy:
- provider: releases
api_key: "$GH_DEPLOY"
Expand Down
41 changes: 13 additions & 28 deletions e2e/automated.test.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,25 @@
const urls = require('./urls.json'); // eslint-disable-line import/no-unresolved
const fixtures = require('./fixtures.json'); // eslint-disable-line import/no-unresolved

async function insertResolveUrlsIntoDom() {
return page.evaluate(() => {
document.querySelectorAll('.octolinker-link').forEach(node => {
const resolveto = node
.closest('tr')
.previousElementSibling.textContent.trim()
.replace('// Should resolve to: ', '');
node.dataset.e2eResult = resolveto;
});
});
}
async function executeTest(url, lineNumber, targetUrl) {
const selector = `#LC${lineNumber} .octolinker-link`;

async function goto(url) {
await page.goto(url);
await page.waitForSelector('.octolinker-link');

await insertResolveUrlsIntoDom();
await page.waitForSelector(selector);

await page.click('.octolinker-link');
const result = await page.$eval(
'.octolinker-link',
el => el.dataset.e2eResult,
);
await page.waitForNavigation();
await Promise.all([
page.waitForNavigation(),
// page.click(selector), for some reason page.click is not working
page.$eval(selector, el => el.click()),
]);

// TODO remove double slash fix
await expect(page.url().replace(/\/\//g, '/')).toEqual(
expect.stringMatching(result.replace('<root>', '')),
);
await expect(page.url()).toEqual(expect.stringMatching(targetUrl));
}

describe('End to End tests', () => {
urls.forEach(url => {
it(`resolves ${url}`, async () => {
await goto(url);
fixtures.forEach(({ url, content, lineNumber, targetUrl }) => {
it(`resolves ${content} to ${targetUrl}`, async () => {
await executeTest(url, lineNumber, targetUrl);
});
});
});
14 changes: 0 additions & 14 deletions e2e/example.test.js

This file was deleted.

21 changes: 0 additions & 21 deletions e2e/scrape-repo.js

This file was deleted.

1 change: 1 addition & 0 deletions jest-puppeteer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
dumpio: true,
headless: false,
args: [
'--no-sandbox',
`--disable-extensions-except=${extPath}`,
`--load-extension=${extPath}`,
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint": "eslint .",
"pretest": "yarn lint",
"test": "jest",
"e2e": "node e2e/scrape-repo.js && jest --config=e2e/jest-e2e.config.js",
"e2e": "curl https://raw.githubusercontent.com/OctoLinker/e2e/master/resource.json > e2e/fixtures.json && jest --config=e2e/jest-e2e.config.js",
"postinstall": "yarn lerna bootstrap",
"test:watch": "jest --watch",
"version": "json -I -f assets/manifest.json -e \"this.version='`json -f package.json version`'\" && git add assets/manifest.json",
Expand Down

0 comments on commit 0c8dd8d

Please sign in to comment.