Constructor
new Helper(provider)
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.
Parameters:
Name | Type | Description |
---|---|---|
provider |
Object | The entity provider that will be used by the Helper |
- Source:
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());
Members
(readonly) flow :Object
Protractor control flow.
Type:
- Object
- Source:
(readonly) provider :Object
The entity provider that will be used by the Helper.
Type:
- Object
- Source:
sortProperties :Array
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'.
Type:
- Array
- Source:
Example
[{
name: 'title',
type: 'string'
},{
name: 'description',
type: 'string'
},{
name: 'date',
type: 'number'
},{
name: 'state',
type: 'number'
},{
name: 'views',
type: 'number'
}]
(readonly) textSearchProperties :Array
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.
Type:
- Array
- Source:
Example
['name', 'description'];
Methods
(async) addEntities(entities) → {Promise}
Adds multiple entities at the same time.
This method bypass the web browser to directly add entities into database.
Parameters:
Name | Type | Description |
---|---|---|
entities |
Array | A list of entities to add |
- Source:
Returns:
Promise resolving when entities are added with:
- Array The list of added entities
- Type
- Promise
(async) addEntitiesAuto(name, total, offsetopt) → {Promise}
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:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
String | Base name of the entities to add |
||
total |
Number | Number of entities to add |
||
offset |
Number |
<optional> |
0 | Index to start from for the name suffix |
- Source:
Returns:
Promise resolving with the added entities
- Type
- Promise
Examples
// 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() → {Object}
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.
- Source:
Returns:
The data to add
- Type
- Object
(async) getEntities(filteropt) → {Promise}
Gets all entities from database.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
filter |
Object |
<optional> |
Rules to filter entities |
- Source:
Returns:
Promise resolving with the list of entities
- Type
- Promise
getUpdateExample() → {Object}
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.
- Source:
Returns:
The data to perform the update
- Type
- Object
getValidationExample() → {Object}
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.
- Source:
Returns:
The entity which will validate a get /entityName/:id response
- Type
- Object
(async) removeAllEntities(safeEntities) → {Promise}
Removes all entities from database.
Parameters:
Name | Type | Description |
---|---|---|
safeEntities |
Array | A list of entities to keep safe |
- Source:
Returns:
Promise resolving when all entities are removed
- Type
- Promise
(async) removeEntities(entities) → {Promise}
Removes multiple entities at the same time.
This method bypass the web browser to directly remove entities from database.
Parameters:
Name | Type | Description |
---|---|---|
entities |
Array | A list of entities |
- Source:
Returns:
Promise resolving when entities are removed
- Type
- Promise
translate(key, dictionary) → {String}
Translates a dictionary key.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | The key to translate |
dictionary |
Object | The dictionary of translations |
- Source:
Returns:
The translated text
- Type
- String