Helper
Summary
Helpers intends to use EntityProviders to manipulate the Database without requesting the web browser but staying in protractor's control flow.
Do not use this directly but extend it.
Constructor
Helper
Syntax
Helper
-
provider
Summary
Parameters:
-
provider
EntityProviderThe entity provider that will be used by the Helper
Example:
var Helper = require('@openveo/test').e2e.helpers.Helper;
function MyHelper(provider) {
MyHelper.super_.call(this);
}
module.exports = MyHelper;
util.inherits(MyHelper, Helper);
var helper = new MyHelper(new MyProvider());
Item Index
Methods
Properties
Methods
addEntities
Syntax
Summary
Adds multiple entities at the same time.
This method bypass the web browser to directly add entities into database.
Parameters:
-
entities
ArrayA list of entities to add
Returns:
Promise resolving when entities are added with:
- Array The list of added entities
addEntitiesAuto
Syntax
Summary
Adds multiple entities at the same time with automatic index.
This method bypass the web browser to directly add entities into database.
All created entities will have the same name suffixed by the index.
Parameters:
Returns:
Promise resolving with the added entities
Example:
// With MyHelper extending Helper
var helper = new MyHelper();
helper.addEntitiesAuto('My entity', 2).then(function(entities) {
console.log('Entity "My entity 0" created');
console.log('Entity "My entity 1" created');
console.log(entities);
});
helper.addEntitiesAuto('My entity', 2, 2).then(function(entities) {
console.log('Entity "My entity 2" created');
console.log('Entity "My entity 3" created');
console.log(entities);
});
getAddExample
Syntax
Summary
Gets entity object example to use with web service put /entityName.
If the entity managed by the Helper is registered to be tested automatically by the core, it needs to implement this method which will be used to perform a put /entityName.
Returns:
The data to add
getEntities
Syntax
Summary
Gets all entities from database.
Parameters:
-
[filter]
ResourceFilter optionalRules to filter entities
Returns:
Promise resolving with the list of entities
getUpdateExample
Syntax
Summary
Gets entity object example to use with web service post /entityName.
If the entity managed by the Helper is registered to be tested automatically by the core, it needs to implement this method which will be used to perform a post /entityName.
Returns:
The data to perform the update
getValidationExample
Syntax
Summary
Prepares an entity to be tested against an entity coming from a get /entityName/:id.
All properties of the returned object must match properties from a get /entityName/:id.
If the entity managed by the Helper is registered to be tested automatically by the core, it needs to implement this method which will be used to perform a post /entityName.
Returns:
The entity which will validate a get /entityName/:id response
removeAllEntities
Syntax
Summary
Removes all entities from database.
Parameters:
-
safeEntities
ArrayA list of entities to keep safe
Returns:
Promise resolving when all entities are removed
Properties
flow
Syntax
flow
ControlFlow
final
Summary
Protractor control flow.
provider
Syntax
provider
EntityProvider
final
Summary
The entity provider that will be used by the Helper.
sortProperties
Syntax
sortProperties
Array
Summary
The list of entity properties which sortBy will search on when requesting the web service.
If the entity managed by the Helper is registered to be tested automatically by the core and has to be tested on the "sortBy" parameter, this property must list all possible values of the "sortBy" parameter of a get /entityName request with the expected type.
Possible type valus are 'string', 'number' and 'date'.
Example:
[{
name: 'title',
type: 'string'
},{
name: 'description',
type: 'string'
},{
name: 'date',
type: 'number'
},{
name: 'state',
type: 'number'
},{
name: 'views',
type: 'number'
}]
textSearchProperties
Syntax
textSearchProperties
Array
Summary
The list of entity properties names which "query" parameter will search on when requesting the web service.
If the entity managed by the Helper is registered to be tested automatically by the core and has to be tested on the "query" parameter, this property must list all possible values of the "query" parameter of a get /entityName request.
Example:
['name', 'description'];