Skip to content

Commit

Permalink
Merge branch 'header-tweaks' of github.com:steemit/condenser into hea…
Browse files Browse the repository at this point in the history
…der-tweaks
  • Loading branch information
gl2748 committed Mar 9, 2018
2 parents 2ad1eff + 3ee5377 commit 190d70a
Show file tree
Hide file tree
Showing 11 changed files with 1,291 additions and 12 deletions.
65 changes: 65 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
version: 2
jobs:
build:
docker:
- image: docker:17-git
steps:
- checkout
- setup_remote_docker
- run:
name: Build Docker image
command: docker build -t condenser .
- run:
name: Save Docker image
command: docker save -o condenser.tar condenser
- persist_to_workspace:
root: .
paths:
- condenser.tar
build-blackboxtest:
docker:
- image: docker:17-git
steps:
- checkout
- setup_remote_docker
- run:
name: Build Docker image
command: docker build -t condenser-blackboxtest blackboxtest/
- run:
name: Save Docker image
command: docker save -o condenser-blackboxtest.tar condenser-blackboxtest
- persist_to_workspace:
root: .
paths:
- condenser-blackboxtest.tar
run-blackboxtest:
docker:
- image: docker:17-git
steps:
- checkout
- setup_remote_docker
- attach_workspace:
at: /tmp/workspace
- run:
name: Load Docker images
command: |
docker load -i /tmp/workspace/condenser.tar
docker load -i /tmp/workspace/condenser-blackboxtest.tar
- run:
name: Start condenser
command: |
docker run -ditp 8080:8080 --name condenser condenser
sleep 10 # let condenser start
- run:
name: Run tests
command: docker run --network container:condenser condenser-blackboxtest
workflows:
version: 2
condenser:
jobs:
- build
- build-blackboxtest
- run-blackboxtest:
requires:
- build
- build-blackboxtest
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@ OFFLINE_SSR_TEST=true SDC_DATABASE_URL="mysql://[email protected]/steemit_dev" NODE

This will read data from the blobs in `api_mockdata` directory. If you want to use another set of mock data, create a similar directory to that one and add an argument `OFFLINE_SSR_TEST_DATA_DIR` pointing to your new directory.

### Run blackbox tests using nightwatch

To run a Selenium test suite, start the condenser docker image with a name `condenser` (like `docker run --name condenser -itp 8080:8080 steemit/condenser:latest`) and then run the blackboxtest image attached to the condneser image's network:

```
docker build -t=steemit/condenser-blackboxtest blackboxtest/
docker run --network container:condenser steemit/condenser-blackboxtest:latest
```

## Issues

To report a non-critical issue, please file an issue on this GitHub project.
Expand Down
14 changes: 14 additions & 0 deletions blackboxtest/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM circleci/openjdk:jdk-node-browsers

WORKDIR /home/circleci
COPY package.json yarn.lock /home/circleci/
RUN yarn install --non-interactive --frozen-lockfile
RUN curl -s https://selenium-release.storage.googleapis.com/3.9/selenium-server-standalone-3.9.1.jar > /home/circleci/selenium-server-standalone.jar
RUN curl -s https://chromedriver.storage.googleapis.com/2.36/chromedriver_linux64.zip | funzip > /home/circleci/chromedriver && chmod +x /home/circleci/chromedriver

COPY . /home/circleci/


CMD [ "yarn", "start" ]


21 changes: 21 additions & 0 deletions blackboxtest/nightwatch-tests/homepage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
'Ensure homepage loads without strange errors': browser => {
browser
.url('http://localhost:8080')
.pause(300)
//.assert.containsText('h1.articles__h1', 'Trending: All tags')
.assert.containsText('a.Header__login-link', 'Login')
.getLog('browser', function(result) {
this.assert.ok(
reasonableErrorLog(result),
'error log is reasonable'
);
})
.end();
},
};

function reasonableErrorLog(logs) {
const logsMinusNetworkErrors = logs.filter(log => log.source !== 'network');
return logsMinusNetworkErrors.length === 0;
}
48 changes: 48 additions & 0 deletions blackboxtest/nightwatch-tests/ssr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const http = require('http');

module.exports = {
'Ensure all of the standard routes return HTTP 200': (browser) => {
browser.end(); // Not needed.
[
'/',
'/trending',
'/created',
'/hot',
'/promoted',
'/about.html',
'/faq.html',
'/login.html',
'/privacy.html',
'/support.html',
'/tos.html',
'/change_password',
'/create_account',
'/approval',
'/recover_account_step_1',
'/recover_account_step_2',
'/waiting_list.html',
'/market',
'/~witnesses',
'/submit.html',
].forEach(path => testHttpGet('localhost', 8080, path, browser));
},
};

const testHttpGet = (host, port, path, browser) => {
http
.request({
host,
port,
path,
method: 'GET'
}, function(res) {
browser.assert.equal(res.statusCode, 200, `Response for ${path} is 200`);
})
.setTimeout(30000, function() {
browser.assert.equal(true, false, `request for ${path} took more than 30 seconds`);
})
.on('error', function (err) {
browser.assert.equal(true, false, err);
})
.end();
};
44 changes: 44 additions & 0 deletions blackboxtest/nightwatch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"src_folders" : ["./nightwatch-tests"],
"output_folder" : "./nightwatch-reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",

"selenium" : {
"start_process" : true,
"server_path" : "./selenium-server-standalone.jar",
"log_path" : "",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "./chromedriver"
}
},

"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
},

"chrome" : {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
13 changes: 13 additions & 0 deletions blackboxtest/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "condenser-blackboxtest",
"version": "1.0.0",
"main": false,
"scripts": {
"start": "nightwatch --config nightwatch.json"
},
"license": "MIT",
"dependencies": {
"nightwatch": "0.9.19",
"phantomjs-prebuilt": "2.1.16"
}
}
Loading

0 comments on commit 190d70a

Please sign in to comment.