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

New: Adding functional test base #305

Merged
merged 3 commits into from
Aug 17, 2017
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
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
language: node_js
node_js:
- "6"
- '6'
addons:
sauce_connect:
username: box-content-preview
jwt:
secure: EPjmiionirVVkbFbp9r4DjMLMcfmdj9Sq8UiMcIGGf5gQk0cV5sgJpDHUDlKhFL3na8FkYf27qadaaJHG9Lr7o1V6IN1tsLamD9kdQjeG1pUSZbyMoMbja9i8CY0/MnQPaPL8UBXbcPrJoBwPNp6PphZ1PtBW68oXale3Xdfd7JMyTtm8f6G40pxpDl50dKI2VZHKKrfWakFkK2DMM73vJScxCrlyJEDc+wSJi2Mr/lrZc/QYy3ug3BGq1S6vV6wsOCk/4Jx+W1hvqK0QBgIytv1XzypqDFJ0OiTiOccsbwvEUHOepQl0EQxBZtM9PO//SBMFc2TqAhldta37JFrEcOEtqrsHwqVELzRMJm9lDSSD+TSj/tri6Kevy311gboZsJh2T3Znkq2h5Zpx8ImbgZCKvQyn8bTSp9MOkb9bGt1tUkZ1LEk3Pj0PUEjFZMnAsT/fLg2EGdXRQWb1W/ZyknoNPfvsU5Po8obQ/AOlKMqaMM7YiGQWruL7Esml0XaiL9H1TSUwmtyAnAU+Q1eYv7II7SnQmVxcgILX7D7nAO82/jP2f12fszEOlgivLr0AS9iAMLcNsrTfSO2p60MESmc/2ZVGjIagNEaGohfb9AI5d0tezU6+GWijuRijVqn1x2rLbSXOV7c3G9yrJpGTru9WD3n/ekgVvg/0nanBpU=
before_script:
- python -m SimpleHTTPServer &
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we still using python or is it node now?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all JS, but we're running a python simple server so that we can serve the distribution version of preview to Sauce Labs.

- sleep 2
script: yarn run ci
cache: yarn
39 changes: 39 additions & 0 deletions functional-tests/base-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const webdriver = require('selenium-webdriver');
const expect = require('chai').expect;

describe('Base Test', () => {
before(() => {
if (process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY) {
this.browser = new webdriver.Builder()
.usingServer(`http://${process.env.SAUCE_USERNAME}:${process.env.SAUCE_ACCESS_KEY}@ondemand.saucelabs.com:80/wd/hub`)
.withCapabilities({
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
build: process.env.TRAVIS_BUILD_NUMBER,
username: process.env.SAUCE_USERNAME,
accessKey: process.env.SAUCE_ACCESS_KEY,
browserName: 'chrome'
}).build();
} else {
this.browser = new webdriver.Builder()
.withCapabilities({
browserName: 'chrome'
}).build();
}
});

beforeEach(() => {
return this.browser.get('http://localhost:8000/functional-tests/index.html');
});

after(() => {
return this.browser.quit();
});

it('should load a file', () => {
return this.browser.wait(webdriver.until.elementLocated(webdriver.By.className('bp-loaded')), 5000).then((element) => {
this.browser.wait(webdriver.until.elementIsVisible(element), 5000).then((el) => {
expect(el).to.not.equal(undefined);
});
});
});
});
27 changes: 27 additions & 0 deletions functional-tests/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<head>
<style>
.preview-container {
border: 1px solid #eee;
height: 490px;
width: 100%;
}
</style>
<link rel="stylesheet" type="text/css" href="../dist/dev/en-US/preview.css">
<script src="../dist/dev/en-US/preview.js"></script>

</head>

<body>
<div class="preview-container"></div>
<script>
var ACCESS_TOKEN = 'EqFyi1Yq1tD9mxY8F38sxDfp73pFd7FP';

var FILE_ID_DOC = '93392244621';

var preview = new Box.Preview();
preview.show(FILE_ID_DOC, ACCESS_TOKEN, {
container: '.preview-container',
showDownload: true,
});
</script>
</body>
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"react-dom": "^15.6.1",
"react-virtualized": "^9.9.0",
"sass-loader": "^6.0.6",
"selenium-webdriver": "^3.5.0",
"sinon": "1.17.7",
"sinon-chai": "2.8.0",
"sinon-stub-promise": "^4.0.0",
Expand All @@ -101,11 +102,12 @@
"build": "yarn run clean && yarn run build-rb && yarn run lint && yarn run dev",
"build-ci": "./node_modules/.bin/webpack --progress --colors --config build/webpack.config.js",
"build-rb": "mojito-rb-gen -s src/i18n -o src/i18n/json -b en-US.properties",
"ci": "yarn run clean && yarn run build-rb && yarn run lint && yarn run test && yarn run build-ci",
"ci": "yarn run clean && yarn run build-rb && yarn run lint && yarn run test && yarn run build-ci && yarn run functional-tests",
"clean": "rm -rf dist && rm -rf reports/coverage && rm -rf src/i18n/json",
"commitmsg": "conventional-changelog-lint -e",
"debug": "NODE_ENV=test ./node_modules/.bin/karma start build/karma.conf.js --no-single-run --auto-watch",
"dev": "BABEL_ENV=dev NODE_ENV=dev ./node_modules/.bin/webpack --progress --colors --config build/webpack.config.js",
"functional-tests": "node ./node_modules/mocha/bin/mocha ./functional-tests/ --timeout 10000",
"lint": "NODE_ENV=dev ./node_modules/.bin/eslint src/lib && ./node_modules/.bin/stylelint 'src/lib/**/*.scss'",
"precommit": "lint-staged",
"prepush": "yarn run lint",
Expand Down