Constructor
new BackEndPage()
Defines a back end page to help writing end to end tests on OpenVeo back end pages.
Do not use this directly but extend it.
- Source:
Example
var BackEndPage = require('@openveo/test').e2e.pages.BackEndPage;
function MyBackEndPage() {
MyBackEndPage.super_.call(this);
this.path = 'be/myBackEndPage';
}
module.exports = MyBackEndPage;
util.inherits(MyBackEndPage, BackEndPage);
var page = new MyBackEndPage();
page.logAsAdmin();
page.load().then(function() {
console.log('Page fully loaded in the first language of the list of languages');
});
Extends
Members
(readonly) alertElements :Object
List of alert elements.
Type:
- Object
- Source:
(readonly) bodyElement :Object
Body element.
Type:
- Object
- Inherited From:
- Source:
(readonly) EC :Object
Protractor expected conditions.
Type:
- Object
- Inherited From:
- Source:
(readonly) flow :Object
Protractor control flow.
Type:
- Object
- Inherited From:
- Source:
(readonly) languageLinkElement :Object
Language link element to open the list of languages.
Type:
- Object
- Source:
(readonly) leftMenuElement :Object
Left menu wrapper element.
Displayed or not as the left menu is opened or not.
Type:
- Object
- Source:
(readonly) level1MenuLinkElements :Object
List of first level link elements in left menu.
Type:
- Object
- Source:
(readonly) logoutLinkElement :Object
Logout link element.
Type:
- Object
- Source:
(readonly) pageElement :Object
Page element.
Page wrapper holding the content scrollbar.
Type:
- Object
- Inherited From:
- Source:
(readonly) popoverElement :Object
Popover element.
Type:
- Object
- Source:
(readonly) profileLinkElement :Object
Profile link element.
Type:
- Object
- Source:
(readonly) toggleLeftMenuLinkElement :Object
Button to toggle left menu.
Type:
- Object
- Source:
translations :Object
List of back end translations.
Type:
- Object
- Source:
Methods
(private, static) clickMenuRecursive(elements, itemName) → {Promise}
Looks for a menu item and click on it.
This will look for the item in menu and sub menus to find the item by its name.
This:
Parameters:
Name | Type | Description |
---|---|---|
elements |
Object | Menu items elements |
itemName |
String | Name of the menu item to look for |
- Source:
Returns:
A promise resolving when the menu item is clicked
- Type
- Promise
clickMenu(itemName) → {Promise}
Clicks on a menu item.
This will look for the item in menu and sub menus to find the item by its name.
Parameters:
Name | Type | Description |
---|---|---|
itemName |
String | The name of the menu item |
- Source:
Returns:
Promise resolving when menu is clicked
- Type
- Promise
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logAsAdmin();
page.clickMenu('Roles').then(function() {
console.log('Roles menu item clicked');
});
clickProfile() → {Promise}
Clicks on profile link.
- Source:
Returns:
Promise resolving when profile link is clicked
- Type
- Promise
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logAsAdmin();
page.clickProfile().then(function() {
console.log('Profile link clicked');
});
closeAlerts() → {Promise}
Closes all alerts.
- Source:
Returns:
Promise resolving when all alerts are closed
- Type
- Promise
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logAsAdmin();
page.closeAlerts().then(function() {
console.log('All alerts closed');
});
closeMenu() → {Promise}
Closes menu.
- Source:
Returns:
Promise resolving when menu is closed
- Type
- Promise
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logAsAdmin();
page.closeMenu().then(function() {
console.log('Left menu closed');
});
closeSubMenu(itemName) → {Promise}
Closes an item sub menu by its name.
Parameters:
Name | Type | Description |
---|---|---|
itemName |
String | The name of the menu item having a sub menu |
- Source:
Returns:
Promise resolving when sub menu is closed
- Type
- Promise
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logAsAdmin();
page.closeSubMenu('Rights').then(function() {
console.log('Rights sub menu closed');
});
deleteCookies() → {Promise}
Removes all cookies on the actual page.
- Inherited From:
- Source:
Returns:
Promise resolving when all cookies are deleted
- Type
- Promise
getAlertMessages() → {Promise}
Gets all alert messages.
- Source:
Returns:
Promise resolving with all alert messages
- Type
- Promise
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logAsAdmin();
page.getAlertMessages().then(function(messages) {
console.log(messages);
});
getLanguageOption(languageCode) → {Object}
Gets language link element.
Parameters:
Name | Type | Description |
---|---|---|
languageCode |
String | The language code to load (e.g. en) |
- Source:
Returns:
The language option element
- Type
- Object
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.click(page.getLanguageOption('fr')).then(function() {
console.log('Page is now in french');
});
getLanguages() → {Array}
Gets the list of available languages.
- Source:
Returns:
The list of available languages
- Type
- Array
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
console.log(page.getLanguages());
getLevel1MenuItems(itemNameopt) → {Promise}
Gets level 1 menu items.
All level 1 menu items will be returned with the promise unless itemName is specified then all elements corresponding to the item name will be returned.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
itemName |
String |
<optional> |
The translated name of the menu item to look for, leave empty to get all level 1 menu items |
- Source:
Returns:
Promise resolving with the list of elements
- Type
- Promise
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logAsAdmin();
page.getLevel1MenuItems('Rights').then(function(elements) {
console.log(elements);
});
getLevel2MenuItems(level1ItemName, level2ItemNameopt) → {Promise}
Gets level 2 menu items.
All level 2 menu items will be returned with the promise unless itemName is specified then all elements corresponding to the item name will be returned.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
level1ItemName |
String | The translated name of the first level menu item to look for |
|
level2ItemName |
String |
<optional> |
The translated name of the second menu item to look for, leave empty to get all level 2 menu items |
- Source:
Returns:
Promise resolving with the list of elements
- Type
- Promise
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logAsAdmin();
page.getLevel2MenuItems('Rights', 'Users').then(function(elements) {
console.log(elements);
});
getPath() → {Promise}
Helper Url Get only current url path without host
- Inherited From:
- Source:
Returns:
Promise resolving with current path
- Type
- Promise
getTitle() → {Promise}
Gets page title as described by the HTMLTitleElement.
- Inherited From:
- Source:
Returns:
Promise resolving with the title of the page
- Type
- Promise
Example
// With MyPage extending Page
var page = new MyPage();
assert.eventually.equal(page.getTitle(), 'My page title');
getUser() → {Object}
Gets current logged in user.
- Source:
Returns:
The current logged in user
- Type
- Object
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logAsAdmin().then(function() {
console.log(page.getUser());
});
isSubMenuOpened(itemName) → {Promise}
Tests if a sub menu is opened.
Parameters:
Name | Type | Description |
---|---|---|
itemName |
String | The name of the menu item |
- Source:
Returns:
Promise resolving with true if the sub menu is opened, false if it's closed
- Type
- Promise
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logAsAdmin();
page.isSubMenuOpened('Rights').then(function(isOpened) {
console.log('Is sub menu opened ?' + isOpened);
});
load() → {Promise}
Loads the page and select the first available language.
This will automatically select the first language in the list of available languages.
- Overrides:
- Source:
Returns:
Promise resolving when the page is loaded and language changed
- Type
- Promise
Example
var BackEndPage = require('@openveo/test').e2e.pages.BackEndPage;
function MyBackEndPage() {
MyBackEndPage.super_.call(this);
this.path = 'be/myBackEndPage';
}
module.exports = MyBackEndPage;
util.inherits(MyBackEndPage, BackEndPage);
var page = new MyBackEndPage();
page.logAsAdmin();
page.load().then(function() {
console.log('Page fully loaded in the first language');
});
logAs(user) → {Promise}
Authenticates to the back end using the given account.
If an account is already logged in, it will be logged out.
Parameters:
Name | Type | Description |
---|---|---|
user |
Object | Information about the user |
- Source:
Returns:
Promise resolving when authenticated to the back end
- Type
- Promise
Example
var user = {
"email": "some-user@veo-labs.com",
"password": "some-user"
}
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logAs(user).then(function() {
console.log('Logged as some-user');
});
logAsAdmin() → {Promise}
Logs to the back end using the super administrator account.
The super administrator can perform any actions. If an account is already logged in, it will be logged out.
- Source:
Returns:
Promise resolving when authenticated as the super administrator
- Type
- Promise
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logAsAdmin().then(function() {
console.log('Logged as super admin');
});
logout() → {Promise}
Logs out current authenticated user.
This will lead to the login page.
- Source:
Returns:
Promise resolving when user is logged out and login page is displayed
- Type
- Promise
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logAsAdmin();
page.logout().then(function() {
console.log('Logged out');
});
logToCasAs(user) → {Promise}
Authenticates to the back end using the given CAS account.
cas-server-mock module must be used for this to work. Also process.protractorConf.casConf.userIdAttribute should be set to the name of the CAS user attribute which must be used as user's login. If an account is already logged in, it will be logged out.
Parameters:
Name | Type | Description |
---|---|---|
user |
Object | Information about the CAS user |
- Source:
Returns:
Promise resolving when authenticated to the back end
- Type
- Promise
Example
var user = {
name: 'test',
attributes: {
name: 'test',
mail: 'test@openveo.com',
groups: ['test-group1', 'test-group2']
}
};
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logToCasAs(user).then(function() {
console.log('Logged as test');
});
logToLdapAs(user) → {Promise}
Authenticates to the back end using the given LDAP account.
process.protractorConf.ldapConf.userIdAttribute should be set to the name of the LDAP user attribute which must be used as user's login. If an account is already logged in, it will be logged out.
Parameters:
Name | Type | Description |
---|---|---|
user |
Object | Information about the LDAP user |
- Source:
Returns:
Promise resolving when authenticated to the back end
- Type
- Promise
Example
var user = {
dn: 'cn=test,dc=test',
cn: 'test',
groups: 'test-group1,test-group2',
mail: 'test@openveo.com'
};
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logToLdapAs(user).then(function() {
console.log('Logged as test');
});
onLoaded() → {Promise}
Handles page loaded.
Use this method to perform actions after the page is loaded. Typically, verify that the page is loaded by waiting for elements to be present on the page.
By default it does nothing, override it to define your own behaviour.
- Inherited From:
- Source:
Returns:
Promise resolving when the page is fully loaded
- Type
- Promise
openMenu() → {Promise}
Opens left menu.
- Source:
Returns:
Promise resolving when left menu is opened
- Type
- Promise
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logAsAdmin();
page.openMenu().then(function() {
console.log('Left menu opened');
});
openSubMenu(itemName) → {Promise}
Opens an item sub menu.
Parameters:
Name | Type | Description |
---|---|---|
itemName |
String | The name of the menu item |
- Source:
Returns:
Promise resolving when sub menu is opened
- Type
- Promise
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
page.logAsAdmin();
page.openSubMenu('Rights').then(function() {
console.log('Rights sub menu opened');
});
refresh() → {Promise}
Refreshes actual page.
- Inherited From:
- Source:
Returns:
Promise resolving when the page is fully loaded
- Type
- Promise
selectLanguage(language) → {Promise}
Sets page language.
It uses the top menu to change the language, a page reload will be performed.
Parameters:
Name | Type | Description |
---|---|---|
language |
Object | The language to load |
- Source:
Returns:
Promise resolving when the page is reloaded with the expected language
- Type
- Promise
Example
// With MyBackEndPage extending BackEndPage
var page = new MyBackEndPage();
var languages = page.getLanguages();
page.logAsAdmin();
page.selectLanguage(languages[1]).then(function() {
console.log('Page reloaded in french');
});
sendRequest(path, method, data) → {Promise}
Sends an http request and return its reponse.
This will execute the request from the page.
Parameters:
Name | Type | Description |
---|---|---|
path |
String | Request's path |
method |
String | HTTP method to use |
data |
Object | Request's data to send in body |
- Inherited From:
- Source:
Returns:
Promise resolving with the request's response
- Type
- Promise