blob: 3ff7f20f734ff9696cb7d49e6a957019098b577b [file] [log] [blame]
ayalaben3fb47c42018-06-24 10:42:43 +03001/*
2 * Copyright © 2016-2017 European Support Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16const {Then, When} = require('cucumber');
17const assert = require('assert');
18const util = require('./Utils.js');
19/**
20 * @module Item
21 * @description uses item id and version id from context
22 * @exampleFile Example_VSP.feature, Example_VLM.feature
23 * @step I want to make sure this Item has status {string}
24 **/
25Then('I want to make sure this Item has status {string}', function (string) {
26 let path = '/items/' + this.context.item.id + '/versions';
27 return util.request(this.context, 'GET', path).then(result => {
28 assert.equal(result.data.results[0].id, this.context.item.versionId);
29 assert.equal(result.data.results[0].status, string);
30 });
31});
32/**
33 * @module Item
34 * @description uses item id and version id from context
35 * @exampleFile Example_VSP.feature, Example_VLM.feature
36 * @step I want to commit this Item
37 **/
38Then('I want to commit this Item', function () {
39 let path = '/items/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/actions';
40 let inputData = {action: 'Commit', commitRequest: {message: '00Behave'}};
41 return util.request(this.context, 'PUT', path, inputData);
42});
43/**
44 * @module Item
45 * @description creates a new major version. item id and version id from context
46 * @exampleFile Example_VLM.feature
47 * @step I want to create a new version for this Item
48 **/
49Then('I want to create a new version for this Item', function () {
50 let path = '/items/' + this.context.item.id + '/versions/' + this.context.item.versionId;
51 let inputData = {description: 'Behave Version', creationMethod: 'major'};
52 return util.request(this.context, 'POST', path, inputData).then(result => {
53 assert.equal(result.data.status, 'Draft');
54 });
55});
56/**
57 * @module Item
58 * @description reverts to a revision with a given saved property. Should be set from the revision list first
59 * @exampleFile Example_VLM.feature
60 * @step I want to commit this Item
61 **/
62Then('I want to revert this Item to the revision with the value from saved property {string}', function (string) {
63 let path = '/items/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/actions';
64 let inputData = {action: 'Revert', revisionRequest: {revisionId: this.context[string]}};
65 return util.request(this.context, 'PUT', path, inputData);
66});
67
68
69/**
70 * @module Item
71 * @exampleFile ArchiveItem.feature
72 * @step I want to archive this item
73 **/
74Then('I want to archive this item', function() {
75 let path = '/items/' + this.context.item.id + '/actions'
76 let inputData = {action: 'ARCHIVE'};
77 return util.request(this.context, 'PUT', path, inputData);
78});
79
80
81/**
82 * @module Item
83 * @exampleFile ArchiveItem.feature
84 * @step I want to restore this item
85 **/
86Then('I want to restore this item', function() {
87 let path = '/items/' + this.context.item.id + '/actions'
88 let inputData = {action: 'RESTORE'};
89 return util.request(this.context, 'PUT', path, inputData);
90});
91