-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: functional test framework using CodeceptJS (#628)
- Loading branch information
1 parent
93fc1d4
commit 8cab696
Showing
11 changed files
with
463 additions
and
77 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 |
---|---|---|
|
@@ -9,3 +9,4 @@ reports | |
dist | ||
src/i18n/json | ||
jsconfig.json | ||
functional-tests/output |
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,6 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- '6' | ||
- '8' | ||
stages: | ||
- ci | ||
- name: sauce-labs | ||
|
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,63 @@ | ||
const DEFAULT_WAIT_TIME = 10000; // 10 seconds | ||
const { | ||
SAUCE_USERNAME, | ||
SAUCE_ACCESS_KEY, | ||
TRAVIS_JOB_NUMBER, | ||
CI, | ||
BROWSER_NAME = 'chrome', | ||
BROWSER_VERSION = 'latest', | ||
BROWSER_PLATFORM | ||
} = process.env; | ||
|
||
// Local selenium config | ||
const webDriverIOlocal = { | ||
url: 'http://localhost:8000', | ||
browser: 'chrome', | ||
smartWait: DEFAULT_WAIT_TIME, | ||
restart: false, | ||
waitForTimeout: DEFAULT_WAIT_TIME | ||
}; | ||
|
||
// CI saucelabs config | ||
let WebDriverIO; | ||
if (typeof SAUCE_USERNAME === 'undefined') { | ||
WebDriverIO = webDriverIOlocal; | ||
} else { | ||
WebDriverIO = Object.assign({}, webDriverIOlocal, { | ||
host: 'ondemand.saucelabs.com', | ||
port: 80, | ||
user: SAUCE_USERNAME, | ||
key: SAUCE_ACCESS_KEY, | ||
desiredCapabilities: { | ||
'tunnel-identifier': TRAVIS_JOB_NUMBER, | ||
browserName: BROWSER_NAME, | ||
version: BROWSER_VERSION, | ||
platform: BROWSER_PLATFORM, | ||
chromeOptions: { | ||
args: ['--disable-web-security'] | ||
} | ||
} | ||
}); | ||
|
||
if (!CI) { | ||
// Local saucelabs config | ||
Object.assign(WebDriverIO, { | ||
host: 'localhost', | ||
port: 4445 | ||
}); | ||
} | ||
} | ||
|
||
exports.config = { | ||
tests: './functional-tests/*_test.js', | ||
timeout: DEFAULT_WAIT_TIME, | ||
output: './functional-tests/output', | ||
helpers: { | ||
WebDriverIO, | ||
Filesystem: {} | ||
}, | ||
include: {}, | ||
bootstrap: false, | ||
mocha: {}, | ||
name: 'box-content-preview' | ||
}; |
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,12 @@ | ||
{ | ||
"extends": ["../.eslintrc"], | ||
"globals": { | ||
"Feature": false, | ||
"Before": false, | ||
"Scenario": false | ||
}, | ||
"rules": { | ||
"func-names": ["off"], | ||
"no-unused-expressions" : ["off"] | ||
} | ||
} |
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,11 @@ | ||
# Running tests locally | ||
|
||
## Saucelabs | ||
1) Download the [saucelabs proxy](https://wiki.saucelabs.com/display/DOCS/Sauce+Connect+Proxy) | ||
2) Run ```yarn functional-tests``` to start a local server on localhost:8000 | ||
3) Run the proxy ```./bin/sc -u SAUCELABS_USER_NAME -k SAUCELABS_ACCESS_KEY -N -i test``` to allow saucelabs to access your localhost | ||
4) Run the tests | ||
```SAUCE_USERNAME=SAUCELABS_USER_NAME SAUCE_ACCESS_KEY=SAUCELABS_ACCESS_KEY TRAVIS_JOB_NUMBER=TUNNEL_ID node ./node_modules/codeceptjs/bin/codecept.js run --verbose``` where SAUCE_USERNAME, SAUCELABS_ACCESS_KEY can be found in saucelabs website. TUNNEL_ID is a unique identifier such as your username. | ||
|
||
## local selenium and browser testing (without saucelabs) | ||
Make sure selenium webdriver is running and run ```node ./node_modules/codeceptjs/bin/codecept.js run --verbose``` |
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
// Unfortunately node doesnt support native imports (yet) | ||
|
||
exports.SELECTOR_BOX_PREVIEW_BTN_DOWNLOAD = '.bp-btn-download'; | ||
exports.SELECTOR_DOWNLOAD_IFRAME = '#downloadiframe'; |
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,17 @@ | ||
const { SELECTOR_BOX_PREVIEW_BTN_DOWNLOAD, SELECTOR_DOWNLOAD_IFRAME } = require('./constants'); | ||
const { expect } = require('chai'); | ||
|
||
Feature('Header'); | ||
|
||
Before((I) => { | ||
I.amOnPage('/functional-tests/index.html'); | ||
}); | ||
|
||
Scenario('Download the file @ci', function*(I) { | ||
I.waitForVisible(SELECTOR_BOX_PREVIEW_BTN_DOWNLOAD, 5000); | ||
I.click(SELECTOR_BOX_PREVIEW_BTN_DOWNLOAD); | ||
I.waitForElement(SELECTOR_DOWNLOAD_IFRAME); | ||
const src = yield I.grabAttributeFrom(SELECTOR_DOWNLOAD_IFRAME, 'src'); | ||
const urlRegex = /https:\/\/dl[0-9]*\.boxcloud\.com.+\/download/; | ||
expect(urlRegex.test(src)).to.be.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Feature('Sanity'); | ||
const bpLoaded = '.bp-loaded'; | ||
|
||
Before((I) => { | ||
I.amOnPage('/functional-tests/index.html'); | ||
}); | ||
|
||
Scenario('Sanity test @ci', (I) => { | ||
I.waitForElement(bpLoaded); | ||
I.waitForVisible(bpLoaded); | ||
I.waitForText('The Content Platform for Your Apps'); | ||
}); |
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.