-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1077 from lukzeg/fix/enable_reopening_device_view
#1076 - Fix/enable reopening device view
- Loading branch information
Showing
9 changed files
with
224 additions
and
18 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
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
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
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
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,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.filterUsingDevices = function() { | ||
return this.searchInput.sendKeys('state: "using"') | ||
} | ||
|
||
this.numberOfDevices = function() { | ||
return this.devicesByCss.count() | ||
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() | ||
} | ||
} |
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
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,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() | ||
} | ||
} |
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,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() | ||
} | ||
}) | ||
}) | ||
}) |
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