1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 10:19:30 +02:00

Added first real e2e protractor tests. Now it needs a device connected.

This commit is contained in:
Gunther Brunner 2014-08-25 21:25:02 +09:00
parent 6f817a512d
commit 7d9d64ddcb
11 changed files with 171 additions and 105 deletions

View file

@ -10,7 +10,7 @@ var gettext = require('gulp-angular-gettext')
var jade = require('gulp-jade')
var clean = require('gulp-clean')
var protractor = require("gulp-protractor")
var protractorConfig = require('./res/test/protractor.conf')
var protractorConfig = './res/test/protractor.conf'
var karma = require('karma').server
var karmaConfig = '/res/test/karma.conf.js'
var stream = require('stream')
@ -59,8 +59,8 @@ gulp.task('karma', function (done) {
gulp.task('webdriver_update', protractor.webdriver_update)
gulp.task('webdriver_standalone', protractor.webdriver_standalone)
gulp.task('protractor', ['webdriver_update'], function (callback) {
gulp.src(["./res/test/**/*.js"])
gulp.task('protractor', function (callback) {
gulp.src(["./res/test/e2e/**/*.js"])
.pipe(protractor.protractor({
configFile: protractorConfig
}))

View file

@ -37,6 +37,7 @@
"by": false,
"Promise": true,
"$": false,
"$$": false
"$$": false,
"protractor": false
}
}

View file

@ -0,0 +1,41 @@
describe('Control Page', function () {
var DeviceListPage = require('./app-devices')
var deviceListPage = new DeviceListPage()
var ControlPage = function () {
this.get = function () {
browser.get(protractor.getInstance().baseUrl + 'control')
}
this.kickDeviceButton = element.all(by.css('.kick-device')).first()
this.kickDevice = function () {
this.kickDeviceButton.click()
}
}
var controlPage = new ControlPage()
it('should control an usable device', function () {
deviceListPage.controlAvailableDevice()
browser.getLocationAbsUrl().then(function (newUrl) {
expect(newUrl).toMatch(protractor.getInstance().baseUrl + 'control')
})
})
it('should have a kick button', function () {
expect(controlPage.kickDeviceButton, true)
})
//it('should stop controlling an usable device', function () {
// controlPage.kickDevice()
//
// browser.getLocationAbsUrl().then(function (newUrl) {
// expect(newUrl).toBe(protractor.getInstance().baseUrl + 'devices')
// })
//})
describe('Dashboard', function () {
describe('Shell', function () {
})
})
})

View file

@ -0,0 +1,32 @@
describe('Device Page', function () {
describe('List', function () {
var DeviceListPage = require('./app-devices')
var deviceListPage = new DeviceListPage()
it('should go to Devices List page', function () {
deviceListPage.get()
browser.getLocationAbsUrl().then(function (newUrl) {
expect(newUrl).toBe(protractor.getInstance().baseUrl + 'devices')
})
})
it('should have more than 1 device in the list', function () {
expect(deviceListPage.numberOfDevices()).toBeGreaterThan(0)
})
it('should filter available devices', function () {
deviceListPage.filterAvailableDevices()
expect(deviceListPage.searchInput.getAttribute('value')).toBe('state: "available"')
})
it('should have more than 1 device available', function () {
expect(deviceListPage.devicesUsable.count()).toBeGreaterThan(0)
})
it('should have one device usable', function () {
expect(deviceListPage.availableDevice().getText()).toBe('Use')
})
})
})

View file

@ -0,0 +1,23 @@
module.exports = function DeviceListPage() {
this.get = function () {
// TODO: Let's get rid off the login first
browser.get(protractor.getInstance().baseUrl + 'devices')
}
this.devices = element(by.model('tracker.devices'))
this.devicesByCss = element.all(by.css('ul.devices-icon-view > li'))
this.devicesUsable =
element.all(by.css('button.device-status.btn-primary-outline'))
this.searchInput = element(by.model('search.deviceFilter'))
this.filterAvailableDevices = function () {
return this.searchInput.sendKeys('state: "available"')
}
this.numberOfDevices = function () {
return this.devicesByCss.count()
}
this.availableDevice = function () {
return this.devicesUsable.first()
}
this.controlAvailableDevice = function () {
this.availableDevice().click()
}
}

View file

@ -0,0 +1,7 @@
describe('Help Page', function () {
var HelpPage = function () {
this.get = function () {
browser.get(protractor.getInstance().baseUrl + 'help')
}
}
})

View file

@ -0,0 +1,17 @@
describe('Login Page', function () {
var LoginPage = require('./app-login')
var loginPage = new LoginPage()
it('should login with auth-mock', function () {
loginPage.get()
loginPage.setName('test_user')
loginPage.setEmail('test_user@test.local')
loginPage.submit().then(function () {
browser.getLocationAbsUrl().then(function (newUrl) {
expect(newUrl).toBe(protractor.getInstance().baseUrl + 'devices')
})
})
})
})

27
res/test/e2e/app-login.js Normal file
View file

@ -0,0 +1,27 @@
var loginBaseUrl = 'http://localhost:7120'
module.exports = function LoginPage() {
this.get = function () {
return browser.get(loginBaseUrl)
}
this.name = element(by.model('name'))
this.email = element(by.model('email'))
this.setName = function (name) {
return this.name.sendKeys(name)
}
this.setEmail = function (email) {
return this.email.sendKeys(email)
}
this.setPassword = function (password) {
return this.password.sendKeys(password)
}
this.submit = function () {
return this.name.submit()
}
this.login = function () {
this.get()
this.setName('test_user')
this.setEmail('test_user@login.local')
return this.submit()
}
}

View file

@ -0,0 +1,7 @@
describe('Settings Page', function () {
var SettingsPage = function () {
this.get = function () {
browser.get(protractor.getInstance().baseUrl + 'settings')
}
}
})

View file

@ -1,100 +0,0 @@
describe('STF App', function () {
var config = {
baseUrl: 'http://localhost:7100/#!',
loginBaseUrl: 'http://localhost:7120'
}
describe('Login Page', function () {
var LoginPage = function () {
this.get = function () {
return browser.get(config.loginBaseUrl)
}
this.name = element(by.model('name'))
this.email = element(by.model('email'))
this.setName = function (name) {
return this.name.sendKeys(name)
}
this.setEmail = function (email) {
return this.email.sendKeys(email)
}
this.setPassword = function (password) {
return this.password.sendKeys(password)
}
this.submit = function () {
return this.name.submit()
}
this.login = function () {
this.get()
this.setName('test_user')
this.setEmail('test_user@login.local')
return this.submit()
}
}
var loginPage = new LoginPage()
it('should login with auth-mock', function () {
loginPage.get()
loginPage.setName('test_user')
loginPage.setEmail('test_user@test.local')
loginPage.submit().then(function () {
browser.getLocationAbsUrl().then(function (newUrl) {
expect(newUrl).toBe(config.baseUrl + '/devices')
})
})
})
})
describe('Device List Page', function () {
var DeviceListPage = function () {
this.get = function () {
// TODO: Let's get rid off the login first
browser.get(config.baseUrl + '/devices')
}
this.rootClass = $$('.stf-device-list')
this.devices = element(by.model('tracker.devices'))
this.devicesRepeated = element.all(
by.repeater('device in tracker.devices'))
}
var deviceListPage = new DeviceListPage()
it('should show a list of devices', function () {
// console.log(deviceListPage.devices)
// expect(deviceListPage.devices.isPresent()).toBe(true)
})
it('should filter out all the devices', function () {
})
})
describe('Control Page', function () {
var DeviceListPage = function () {
this.get = function () {
browser.get(config.baseUrl + '/control')
}
}
})
describe('Settings Page', function () {
var SettingsPage = function () {
this.get = function () {
browser.get(config.baseUrl + '/settings')
}
}
})
describe('Help Page', function () {
var HelpPage = function () {
this.get = function () {
browser.get(config.baseUrl + '/help')
}
}
})
})

View file

@ -1,9 +1,20 @@
// Reference: https://github.com/angular/protractor/blob/master/referenceConf.js
var LoginPage = require('./e2e/app-login.js')
exports.config = {
specs: ['res/test/e2e/*spec.js'],
chromeOnly: true,
baseUrl: 'http://localhost:7100/#!/',
specs: ['res/test/e2e/**/*-spec.js'],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
},
capabilities: {
browserName: 'chrome'
},
onPrepare: function() {
var loginPage = new LoginPage()
loginPage.login()
//browser.driver.wait(loginPage.login)
}
}