This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from Galooshi/pre-cropped-screenshots
Pre cropped screenshots
- Loading branch information
Showing
20 changed files
with
243 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"presets": [ | ||
"airbnb" | ||
], | ||
"plugins": [ | ||
"transform-object-rest-spread" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6.9.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
SCREENSHOT_BOX_ID: 'happo-screenshot-box', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
jest.mock('child_process'); | ||
const childProcess = require('child_process'); | ||
|
||
jest.mock('../config'); | ||
const config = require('../config'); | ||
|
||
const checkBrowserVersion = require('../checkBrowserVersion'); | ||
|
||
beforeEach(() => { | ||
config.driver = 'firefox'; | ||
}); | ||
|
||
describe('when firefox is new enough', () => { | ||
beforeEach(() => { | ||
childProcess.exec = (_, cb) => cb(null, 'Mozilla Firefox 50.0'); | ||
}); | ||
|
||
it('resolves', () => | ||
checkBrowserVersion().then(() => { | ||
expect(true).toBe(true); | ||
})); | ||
}); | ||
|
||
describe('when firefox is too old', () => { | ||
beforeEach(() => { | ||
childProcess.exec = (_, cb) => cb(null, 'Mozilla Firefox 47.0'); | ||
}); | ||
|
||
it('rejects', () => | ||
checkBrowserVersion().catch((error) => { | ||
expect(error.message).toEqual( | ||
'Happo requires Firefox version 50 or later. You are using Mozilla Firefox 47.0'); | ||
})); | ||
}); | ||
|
||
describe('when the version string is unrecognized', () => { | ||
beforeEach(() => { | ||
childProcess.exec = (_, cb) => cb(null, 'Godzilla Firefox 47.0'); | ||
}); | ||
|
||
it('rejects', () => | ||
checkBrowserVersion().catch((error) => { | ||
expect(error.message).toEqual( | ||
'Failed to parse Firefox version string "Godzilla Firefox 47.0"'); | ||
})); | ||
}); | ||
|
||
describe('when using a different driver', () => { | ||
beforeEach(() => { | ||
config.driver = 'chrome'; | ||
|
||
// Just to make sure that we're not falsely succeeding because of normal | ||
// handling, we also mock an old version of Firefox. | ||
childProcess.exec = (_, cb) => cb(null, 'Mozilla Firefox 47.0'); | ||
}); | ||
|
||
it('resolves', () => | ||
checkBrowserVersion().then(() => { | ||
expect(true).toBe(true); | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const path = require('path'); | ||
|
||
const { platform, arch } = process; | ||
|
||
const geckodriverFolder = path.join(__dirname, | ||
`../../geckodriver/${platform}-${arch}/`); | ||
|
||
process.env.PATH += path.delimiter + geckodriverFolder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const childProcess = require('child_process'); | ||
|
||
const firefox = require('selenium-webdriver/firefox'); | ||
|
||
const config = require('./config'); | ||
|
||
const MINIMUM_FIREFOX_VERSION = 50.0; | ||
const FIREFOX_VERSION_MATCHER = /Mozilla Firefox ([0-9.]+)/; | ||
|
||
module.exports = function checkBrowserVersion() { | ||
if (config.driver !== 'firefox') { | ||
// Our main browser target is Firefox. If you are using something else, you | ||
// must know what you are doing. :) | ||
return Promise.resolve(); | ||
} | ||
|
||
return new Promise((resolve, reject) => { | ||
new firefox.Binary().locate().then((pathToExecutable) => { | ||
childProcess.exec(`${pathToExecutable} --version`, (error, stdout) => { | ||
if (error) { | ||
reject(new Error(`Failed to check Firefox version: ${error}`)); | ||
return; | ||
} | ||
const match = stdout.match(FIREFOX_VERSION_MATCHER); | ||
if (!match) { | ||
reject(new Error(`Failed to parse Firefox version string "${stdout}"`)); | ||
} else if (parseFloat(match[1]) < MINIMUM_FIREFOX_VERSION) { | ||
reject(new Error( | ||
`Happo requires Firefox version ${MINIMUM_FIREFOX_VERSION} or later. ` + | ||
`You are using ${stdout}`)); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.