mirror of
https://github.com/openstf/stf
synced 2025-10-05 02:29:26 +02:00
-Add shell e2e test.
-Add parallel multi browser protractor configuration. -Add screenshot reports. -Add fail fast helper.
This commit is contained in:
parent
755502a28e
commit
b1afa8076c
6 changed files with 100 additions and 6 deletions
|
@ -10,7 +10,6 @@ var gettext = require('gulp-angular-gettext')
|
|||
var jade = require('gulp-jade')
|
||||
var clean = require('gulp-clean')
|
||||
var protractor = require("gulp-protractor")
|
||||
var protractorConfig = './res/test/protractor.conf'
|
||||
var karma = require('karma').server
|
||||
var karmaConfig = '/res/test/karma.conf.js'
|
||||
var stream = require('stream')
|
||||
|
@ -60,6 +59,8 @@ gulp.task('webdriver-update', protractor.webdriver_update)
|
|||
gulp.task('webdriver-standalone', protractor.webdriver_standalone)
|
||||
|
||||
gulp.task('protractor', function (callback) {
|
||||
var protractorConfig = './res/test/protractor.conf'
|
||||
|
||||
var args = []
|
||||
if (typeof gutil.env.suite === 'string') {
|
||||
args.push('--suite')
|
||||
|
@ -70,6 +71,10 @@ gulp.task('protractor', function (callback) {
|
|||
args.push('debug')
|
||||
}
|
||||
|
||||
if (gutil.env.multi) {
|
||||
protractorConfig = './res/test/protractor-multi.conf'
|
||||
}
|
||||
|
||||
gulp.src(["./res/test/e2e/**/*.js"])
|
||||
.pipe(protractor.protractor({
|
||||
configFile: protractorConfig,
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
"Promise": true,
|
||||
"$": false,
|
||||
"$$": false,
|
||||
"protractor": false
|
||||
"protractor": false,
|
||||
"jasmine": false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,48 @@ describe('Control Page', function () {
|
|||
expect(controlPage.kickDeviceButton, true)
|
||||
})
|
||||
|
||||
|
||||
describe('Dashboard', function () {
|
||||
var DashboardTab = function () {
|
||||
this.shellInput = element(by.model('command'))
|
||||
this.shellResults = element.all(by.css('.shell-results')).first()
|
||||
|
||||
this.helloString = 'hello adb'
|
||||
this.echoCommand = 'echo "' + this.helloString + '"'
|
||||
this.clearCommand = 'clear'
|
||||
this.openMenuCommand = 'input keyevent 3'
|
||||
|
||||
this.shellExecute = function (command) {
|
||||
this.shellInput.sendKeys(command)
|
||||
this.shellInput.sendKeys(protractor.Key.ENTER)
|
||||
}
|
||||
}
|
||||
var dashboardTab = new DashboardTab()
|
||||
|
||||
describe('Shell', function () {
|
||||
|
||||
it('should echo "hello adb" to the adb shell', function () {
|
||||
expect(dashboardTab.shellInput.isPresent()).toBe(true)
|
||||
|
||||
dashboardTab.shellExecute(dashboardTab.echoCommand)
|
||||
|
||||
expect(dashboardTab.shellResults.getText()).toBe(dashboardTab.helloString)
|
||||
})
|
||||
|
||||
it('should clear adb shell input', function () {
|
||||
dashboardTab.shellExecute(dashboardTab.clearCommand)
|
||||
expect(dashboardTab.shellResults.getText()).toBeFalsy()
|
||||
})
|
||||
|
||||
it('should open and close the menu button trough adb shell', function () {
|
||||
dashboardTab.shellExecute(dashboardTab.openMenuCommand)
|
||||
dashboardTab.shellExecute(dashboardTab.openMenuCommand)
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
it('should stop controlling an usable device', function () {
|
||||
controlPage.kickDevice()
|
||||
|
||||
|
@ -38,9 +80,5 @@ describe('Control Page', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('Dashboard', function () {
|
||||
describe('Shell', function () {
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
10
res/test/e2e/helpers/fail-fast.js
Normal file
10
res/test/e2e/helpers/fail-fast.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
// https://github.com/angular/protractor/issues/499
|
||||
|
||||
module.exports = function FailFast() {
|
||||
var passed = jasmine.getEnv().currentSpec.results().passed()
|
||||
if (!passed) {
|
||||
jasmine.getEnv().specFilter = function (spec) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
33
res/test/protractor-multi.conf.js
Normal file
33
res/test/protractor-multi.conf.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
var config = require('./protractor.conf').config
|
||||
var HtmlReporter = require('protractor-html-screenshot-reporter')
|
||||
|
||||
config.chromeOnly = false
|
||||
config.capabilities = null
|
||||
config.multiCapabilities = [
|
||||
{
|
||||
browserName: 'chrome',
|
||||
chromeOptions: {
|
||||
args: ['--test-type'] // Prevent security warning bug in ChromeDriver
|
||||
}
|
||||
},
|
||||
{
|
||||
browserName: 'firefox'
|
||||
}
|
||||
//{
|
||||
// browserName: 'safari'
|
||||
//}
|
||||
// add appium/sauce labs
|
||||
]
|
||||
|
||||
config.onPrepare = function () {
|
||||
var loginPage = new LoginPage()
|
||||
loginPage.doLogin()
|
||||
loginPage.cleanUp()
|
||||
|
||||
jasmine.getEnv().addReporter(new HtmlReporter({
|
||||
baseDirectory: './res/test/test_out/screenshots'
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
exports.config = config
|
|
@ -1,6 +1,8 @@
|
|||
// Reference: https://github.com/angular/protractor/blob/master/referenceConf.js
|
||||
var LoginPage = require('./e2e/login')
|
||||
var BrowserLogs = require('./e2e/helpers/browser-logs')
|
||||
var FailFast = require('./e2e/helpers/fail-fast')
|
||||
var HtmlReporter = require('protractor-html-screenshot-reporter')
|
||||
|
||||
exports.config = {
|
||||
baseUrl: process.env.STF_URL || 'http://localhost:7100/#!/',
|
||||
|
@ -40,8 +42,13 @@ exports.config = {
|
|||
loginPage.doLogin()
|
||||
loginPage.cleanUp()
|
||||
|
||||
//jasmine.getEnv().addReporter(new HtmlReporter({
|
||||
// baseDirectory: './res/test/test_out/screenshots'
|
||||
//}))
|
||||
|
||||
afterEach(function () {
|
||||
BrowserLogs({expectNoLogs: true})
|
||||
FailFast()
|
||||
})
|
||||
},
|
||||
onComplete: function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue