OpenVeo test API

API Docs for: 8.0.0
Show:

Helper

Module: e2e

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 EntityProvider

    The 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());

Methods

addEntities

Syntax

addEntities

(
  • entities
)
Promise async

Summary

Adds multiple entities at the same time.

This method bypass the web browser to directly add entities into database.

Parameters:

  • entities Array

    A list of entities to add

Returns:

Promise:

Promise resolving when entities are added with:

  • Array The list of added entities

addEntitiesAuto

Syntax

addEntitiesAuto

(
  • name
  • total
  • [offset=0]
)
Promise async

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:

  • name String

    Base name of the entities to add

  • total Number

    Number of entities to add

  • [offset=0] Number optional

    Index to start from for the name suffix

Returns:

Promise:

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

getAddExample

() Object

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:

Object:

The data to add

getEntities

Syntax

getEntities

(
  • [filter]
)
Promise async

Summary

Gets all entities from database.

Parameters:

  • [filter] ResourceFilter optional

    Rules to filter entities

Returns:

Promise:

Promise resolving with the list of entities

getUpdateExample

Syntax

getUpdateExample

() Object

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:

Object:

The data to perform the update

getValidationExample

Syntax

getValidationExample

() Object

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:

Object:

The entity which will validate a get /entityName/:id response

removeAllEntities

Syntax

removeAllEntities

(
  • safeEntities
)
Promise async

Summary

Removes all entities from database.

Parameters:

  • safeEntities Array

    A list of entities to keep safe

Returns:

Promise:

Promise resolving when all entities are removed

removeEntities

Syntax

removeEntities

(
  • entities
)
Promise async

Summary

Removes multiple entities at the same time.

This method bypass the web browser to directly remove entities from database.

Parameters:

  • entities Array

    A list of entities

Returns:

Promise:

Promise resolving when entities are removed

translate

Syntax

translate

(
  • key
  • dictionary
)
String

Summary

Translates a dictionary key.

Parameters:

  • key String

    The key to translate

  • dictionary Object

    The dictionary of translations

Returns:

String:

The translated text

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'];