mirror of
https://github.com/openstf/stf
synced 2025-10-03 09:49:17 +02:00
parent
8bba7f4558
commit
7d593cdb51
8 changed files with 220 additions and 16 deletions
|
@ -41,7 +41,6 @@ Test results can be found in:
|
|||
|
||||
---
|
||||
|
||||
===
|
||||
## Multiple Browsers Local STF with a specific suite
|
||||
- Connect a device
|
||||
- Run stf
|
||||
|
|
|
@ -7,14 +7,21 @@ describe('Control Page', function() {
|
|||
this.get = function() {
|
||||
browser.get(localhost + 'control')
|
||||
}
|
||||
this.kickDeviceButton = element.all(by.css('.kick-device')).first()
|
||||
|
||||
this.kickDeviceButton = element.all(by.css('.kick-device'))
|
||||
this.devicesDropDown = element(by.css('.device-name-text'))
|
||||
|
||||
this.openDevicesDropDown = function() {
|
||||
return this.devicesDropDown.click()
|
||||
}
|
||||
|
||||
this.getFirstKickDeviceButton = function() {
|
||||
return this.kickDeviceButton.first()
|
||||
}
|
||||
|
||||
this.kickDevice = function() {
|
||||
this.openDevicesDropDown()
|
||||
this.kickDeviceButton.click()
|
||||
}
|
||||
this.devicesDropDown = element(by.css('.device-name-text'))
|
||||
this.openDevicesDropDown = function() {
|
||||
this.devicesDropDown.click()
|
||||
this.getFirstKickDeviceButton().click()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,12 @@ describe('Device Page', function() {
|
|||
var DeviceListPage = require('./')
|
||||
var deviceListPage = new DeviceListPage()
|
||||
|
||||
var LoginPage = require('../login')
|
||||
var loginPage = new LoginPage()
|
||||
|
||||
var WidgetContainerPage = require('../widget-container')
|
||||
var widgetContainerObj = new WidgetContainerPage()
|
||||
|
||||
it('should go to Devices List page', function() {
|
||||
deviceListPage.get()
|
||||
browser.getCurrentUrl().then(function(newUrl) {
|
||||
|
@ -20,6 +26,18 @@ describe('Device Page', function() {
|
|||
expect(deviceListPage.searchInput.getAttribute('value')).toBe('state: "available"')
|
||||
})
|
||||
|
||||
it('should not display used device if filter is set to - state using', function() {
|
||||
deviceListPage.get()
|
||||
deviceListPage.filterUsingDevices()
|
||||
deviceListPage.getNumberOfFilteredOutDevices().then(function(amount) {
|
||||
var filteredOut = amount
|
||||
deviceListPage.numberOfDevices().then(function(amount) {
|
||||
var notFiltered = amount
|
||||
expect(notFiltered - filteredOut).toBe(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('should have more than 1 device available', function() {
|
||||
expect(deviceListPage.devicesUsable.count()).toBeGreaterThan(0)
|
||||
})
|
||||
|
@ -28,6 +46,66 @@ describe('Device Page', function() {
|
|||
expect(deviceListPage.availableDevice().getAttribute('class')).toMatch('state-available')
|
||||
})
|
||||
|
||||
it('should be able to unassign used device', function() {
|
||||
deviceListPage.get()
|
||||
deviceListPage.controlAvailableDevice()
|
||||
deviceListPage.get()
|
||||
deviceListPage.unassignDevice()
|
||||
browser.getCurrentUrl().then(function(newUrl) {
|
||||
expect(newUrl).toBe(browser.baseUrl + 'devices')
|
||||
})
|
||||
})
|
||||
|
||||
it('should be able to reuse assign device', function() {
|
||||
// Test for issue #1076
|
||||
|
||||
deviceListPage.get()
|
||||
deviceListPage.controlAvailableDevice()
|
||||
deviceListPage.get()
|
||||
deviceListPage.selectAssignedDevice()
|
||||
browser.getCurrentUrl().then(function(newUrl) {
|
||||
expect(newUrl).toContain(browser.baseUrl + 'control/')
|
||||
})
|
||||
})
|
||||
|
||||
it('should one device be marked as busy as is used by another user', function() {
|
||||
deviceListPage.get()
|
||||
deviceListPage.controlAvailableDevice()
|
||||
|
||||
loginPage.doFreshLogin('tester', 'test_user2@login.com')
|
||||
deviceListPage.get()
|
||||
expect(deviceListPage.getNumberOfBusyDevices()).toBe(1)
|
||||
})
|
||||
|
||||
it('should not be able to pick up device marked as busy', function() {
|
||||
deviceListPage.get()
|
||||
deviceListPage.controlAvailableDevice()
|
||||
|
||||
loginPage.doFreshLogin('tester', 'test_user2@login.com')
|
||||
deviceListPage.get()
|
||||
deviceListPage.selectBusyDevice()
|
||||
browser.getCurrentUrl().then(function(newUrl) {
|
||||
expect(newUrl).toContain(browser.baseUrl + 'devices')
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
// Relogin to test account if don't use standard test account
|
||||
deviceListPage.get()
|
||||
widgetContainerObj.getUserNameFromWidget().then(function(userName) {
|
||||
if (userName.toLowerCase() !== loginPage.getUserName().toLowerCase()) {
|
||||
loginPage.doFreshLogin()
|
||||
}
|
||||
})
|
||||
|
||||
// Unassign element if is assigned
|
||||
deviceListPage.get()
|
||||
deviceListPage.deviceStopUsingBtn.count().then(function(elements) {
|
||||
if (elements > 0) {
|
||||
deviceListPage.unassignDevice()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('List View', function() {
|
||||
|
|
|
@ -1,22 +1,70 @@
|
|||
module.exports = function DeviceListPage() {
|
||||
|
||||
this.get = function() {
|
||||
// TODO: Let's get rid off the login first
|
||||
browser.get(browser.baseUrl + 'devices')
|
||||
browser.wait(waitUrl(/devices/), 5000)
|
||||
}
|
||||
|
||||
this.devices = element(by.model('tracker.devices'))
|
||||
this.deviceStopUsingBtn = element.all(by.css('.state-using'))
|
||||
this.devicesByCss = element.all(by.css('ul.devices-icon-view > li'))
|
||||
this.devicesUsable = element.all(by.css('.state-available'))
|
||||
this.devicesBusy = element.all(by.css('.state-busy'))
|
||||
this.searchInput = element(by.model('search.deviceFilter'))
|
||||
this.devicesFilteredOut = element.all(by.xpath('//*[contains(@class, "filter-out")]'))
|
||||
|
||||
this.filterAvailableDevices = function() {
|
||||
return this.searchInput.sendKeys('state: "available"')
|
||||
}
|
||||
this.numberOfDevices = function() {
|
||||
return this.devicesByCss.count()
|
||||
|
||||
this.filterUsingDevices = function() {
|
||||
return this.searchInput.sendKeys('state: "using"')
|
||||
}
|
||||
|
||||
this.numberOfDevices = function() {
|
||||
return this.devicesByCss.count().then(function(amount) {
|
||||
return amount
|
||||
})
|
||||
}
|
||||
|
||||
this.getNumberOfFilteredOutDevices = function() {
|
||||
return this.devicesFilteredOut.count().then(function(amount) {
|
||||
return amount
|
||||
})
|
||||
}
|
||||
|
||||
this.getNumberOfBusyDevices = function() {
|
||||
return this.devicesBusy.count().then(function(amount) {
|
||||
return amount
|
||||
})
|
||||
}
|
||||
|
||||
this.availableDevice = function() {
|
||||
return this.devicesUsable.first()
|
||||
}
|
||||
|
||||
this.controlAvailableDevice = function() {
|
||||
return this.availableDevice().click()
|
||||
this.availableDevice().click()
|
||||
browser.wait(waitUrl(/control/), 5000)
|
||||
}
|
||||
|
||||
this.assignedDevice = function() {
|
||||
return this.deviceStopUsingBtn.first()
|
||||
}
|
||||
|
||||
this.getFirstBusyDevice = function() {
|
||||
return this.devicesBusy.first()
|
||||
}
|
||||
|
||||
this.unassignDevice = function() {
|
||||
return this.assignedDevice().click()
|
||||
}
|
||||
|
||||
this.selectAssignedDevice = function() {
|
||||
return this.assignedDevice().element(by.xpath('..')).click()
|
||||
}
|
||||
|
||||
this.selectBusyDevice = function() {
|
||||
return this.getFirstBusyDevice().element(by.xpath('..')).click()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,16 +30,24 @@ module.exports = function LoginPage() {
|
|||
return this.username.submit()
|
||||
}
|
||||
|
||||
this.doLogin = function() {
|
||||
this.getUserName = function() {
|
||||
return this.login.username
|
||||
}
|
||||
|
||||
this.doLogin = function(userName, email, password) {
|
||||
var EC = protractor.ExpectedConditions
|
||||
var timeout = 15000
|
||||
var loginName = (typeof userName !== 'undefined') ? userName : this.login.username
|
||||
var loginEmail = (typeof email !== 'undefined') ? email : this.login.email
|
||||
var loginPassword = (typeof password !== 'undefined') ? email : this.login.password
|
||||
|
||||
this.get()
|
||||
browser.wait(EC.presenceOf(element(by.css('[value="Log In"]'))), timeout)
|
||||
this.setName(this.login.username)
|
||||
this.setName(loginName)
|
||||
if (this.login.method === 'ldap') {
|
||||
this.setPassword(this.login.password)
|
||||
this.setPassword(loginPassword)
|
||||
} else {
|
||||
this.setEmail(this.login.email)
|
||||
this.setEmail(loginEmail)
|
||||
}
|
||||
|
||||
this.submit()
|
||||
|
@ -51,6 +59,16 @@ module.exports = function LoginPage() {
|
|||
})
|
||||
}
|
||||
|
||||
this.doFreshLogin = function(userName, email, password) {
|
||||
// Clean up cookies
|
||||
browser.executeScript('window.localStorage.clear();')
|
||||
browser.executeScript('window.sessionStorage.clear();')
|
||||
browser.driver.manage().deleteAllCookies()
|
||||
|
||||
// Procced again through login process
|
||||
this.doLogin(userName, email, password)
|
||||
}
|
||||
|
||||
this.cleanUp = function() {
|
||||
this.username = null
|
||||
this.password = null
|
||||
|
|
18
res/test/e2e/widget-container/index.js
Normal file
18
res/test/e2e/widget-container/index.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
module.exports = function WidgetContainerPage() {
|
||||
|
||||
this.get = function() {
|
||||
browser.get(browser.baseUrl + 'devices')
|
||||
browser.wait(waitUrl(/devices/), 5000)
|
||||
}
|
||||
|
||||
this.userName = element(by.binding('currentUser.name'))
|
||||
this.amountOfAssignedToUserDevices = element(by.xpath('//*[@class="number color-orange"]/span'))
|
||||
|
||||
this.getUserNameFromWidget = function() {
|
||||
return this.userName.getText()
|
||||
}
|
||||
|
||||
this.getAmountOfAssignedToUserDevices = function() {
|
||||
return this.amountOfAssignedToUserDevices.getText()
|
||||
}
|
||||
}
|
36
res/test/e2e/widget-container/widget-container-spec.js
Normal file
36
res/test/e2e/widget-container/widget-container-spec.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
describe('Widget Container Page', function() {
|
||||
|
||||
var DeviceListPage = require('../devices')
|
||||
var deviceListPage = new DeviceListPage()
|
||||
|
||||
var WidgetContainerPage = require('./')
|
||||
var widgetContainerObj = new WidgetContainerPage()
|
||||
|
||||
var LoginPage = require('../login')
|
||||
var loginPage = new LoginPage()
|
||||
|
||||
it('should display amount of devices used by the user', function() {
|
||||
deviceListPage.get()
|
||||
deviceListPage.controlAvailableDevice()
|
||||
deviceListPage.get()
|
||||
widgetContainerObj.getAmountOfAssignedToUserDevices().then(function(amount) {
|
||||
expect(amount).toBe('1')
|
||||
})
|
||||
})
|
||||
|
||||
it('should display user name after login on widget', function() {
|
||||
widgetContainerObj.getUserNameFromWidget().then(function(userName) {
|
||||
expect(userName.toLowerCase()).toBe(loginPage.getUserName().toLowerCase())
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
// Unassign element if is assigned
|
||||
deviceListPage.get()
|
||||
deviceListPage.deviceStopUsingBtn.count().then(function(elements) {
|
||||
if (elements > 0) {
|
||||
deviceListPage.unassignDevice()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
|
@ -95,7 +95,7 @@ module.exports.config = {
|
|||
reportTitle: 'Protractor Test Execution Report',
|
||||
outputPath: dashboardReportDirectory,
|
||||
outputFilename: 'index',
|
||||
screenshotPath: './',
|
||||
screenshotPath: '.',
|
||||
testBrowser: browserName,
|
||||
browserVersion: browserVersion,
|
||||
modifiedSuiteName: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue