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

Feature/add brave tests to ci pipeline #376

Merged
merged 8 commits into from
Apr 1, 2019
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
22 changes: 22 additions & 0 deletions .circleci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM circleci/node:8-browsers

# hardcode ubuntu version for circleci's debian-9 based image
ENV UBUNTU_CODENAME=cosmic
ENV BRAVE_CHROMEDRIVER_VER=2.33
RUN /bin/bash -c 'set -e; \
sudo apt-get install apt-transport-https; \
curl -s https://brave-browser-apt-release.s3.brave.com/brave-core.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-release.gpg add -a; \
echo "deb [arch=amd64] https://brave-browser-apt-release.s3.brave.com/ $UBUNTU_CODENAME main" | sudo tee /etc/apt/sources.list.d/brave-browser-release-${UBUNTU_CODENAME}.list; \
sudo apt update; \
sudo apt install brave-keyring brave-browser'

# add chromedriver tho it's not configurable on selenium-webdriver
RUN /bin/bash -c 'set -e; \
BRAVE_VERSION=$(apt-cache policy brave-browser|grep -i installed | awk "{print \$NF}"); \
cd /tmp; \
curl -o chromedriver_linux64.zip -L https://github.com/brave/brave-browser/releases/download/v${BRAVE_VERSION}/chromedriver-v${BRAVE_CHROMEDRIVER_VER}-linux-x64.zip; \
unzip chromedriver_linux64.zip; \
rm -rf chromedriver_linux64.zip; \
sudo mv chromedriver /usr/local/bin/chromedriver; \
sudo chmod +x /usr/local/bin/chromedriver; \
chromedriver --version'
17 changes: 17 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ jobs:
root: ~/repo
paths: .

test-brave:
working_directory: ~/repo
docker:
- image: emurgo/circleci-node-8-browsers:latest

steps:
- checkout
- *attach_workspace
- run: npm run test-e2e-brave

test-chrome:
working_directory: ~/repo
docker:
Expand Down Expand Up @@ -95,6 +105,13 @@ workflows:
build-deploy:
jobs:
- build-setup
- test-brave:
filters:
branches:
only:
- master
requires:
- build-setup
- test-chrome:
requires:
- build-setup
Expand Down
41 changes: 35 additions & 6 deletions features/support/webdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ const fs = require('fs');
const firefoxExtensionId = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa';
const firefoxUuidMapping = `{"{530f7c6c-6077-4703-8f71-cb368c663e35}":"${firefoxExtensionId}"}`;

function getBraveBuilder() {
return new seleniumWebdriver.Builder()
.withCapabilities({
chromeOptions: {
args: [
'start-maximized'
]
}
})
.forBrowser('chrome')
.setChromeOptions(new chrome.Options()
.setChromeBinaryPath('/usr/bin/brave-browser')
.addArguments('--start-maximized', '--disable-setuid-sandbox', '--no-sandbox')
.addExtensions(path.resolve(__dirname, '../../yoroi-test.crx')));
}

function getChromeBuilder() {
return new seleniumWebdriver.Builder()
.withCapabilities({
Expand Down Expand Up @@ -67,19 +83,32 @@ function getFirefoxBuilder() {

type WorldInput = {
parameters: {
browser: 'chrome' | 'firefox'
browser: 'brave' | 'chrome' | 'firefox'
}
};

// TODO: We should add methods to `this.driver` object, instead of use `this` directly
function CustomWorld(cmdInput: WorldInput) {
const builder = cmdInput.parameters.browser === 'chrome'
? getChromeBuilder()
: getFirefoxBuilder();
this.driver = builder.build();
switch (cmdInput.parameters.browser) {
case 'brave': {
const braveBuilder = getBraveBuilder();
this.driver = braveBuilder.build();
break;
}
case 'firefox': {
const firefoxBuilder = getFirefoxBuilder();
this.driver = firefoxBuilder.build();
break;
}
default: {
const chromeBuilder = getChromeBuilder();
this.driver = chromeBuilder.build();
break;
}
}

this.getExtensionUrl = (): string => {
if (cmdInput.parameters.browser === 'chrome') {
if (cmdInput.parameters.browser === 'chrome' || cmdInput.parameters.browser === 'brave') {
/**
* Extension id is determinisitically calculated based on pubKey used to generate the crx file
* so we can just hardcode this value if we keep e2etest-key.pem file
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"test-e2e-chrome": "npm run test-common -- --world-parameters '{\"browser\":\"chrome\"}' features/*.feature",
"test-by-tag-chrome": "npm run test-common -- --world-parameters '{\"browser\":\"chrome\"}' features/*.feature --tags",
"test-by-feature-chrome": "npm run test-common -- --world-parameters '{\"browser\":\"chrome\"}'",
"test-e2e-brave": "npm run test-common -- --world-parameters '{\"browser\":\"brave\"}' features/*.feature",
"test-by-tag-brave": "npm run test-common -- --world-parameters '{\"browser\":\"brave\"}' features/*.feature --tags",
"test-by-feature-brave": "npm run test-common -- --world-parameters '{\"browser\":\"brave\"}'",
"test-e2e-firefox": "npm run test-common -- --world-parameters '{\"browser\":\"firefox\"}' features/*.feature",
"test-by-tag-firefox": "npm run test-common -- --world-parameters '{\"browser\":\"firefox\"}' features/*.feature --tags",
"test-by-feature-firefox": "npm run test-common -- --world-parameters '{\"browser\":\"firefox\"}'",
Expand Down