Fix 'Unable to add metadata on inputs'-bug
[sdc.git] / cucumber-js-test-apis-ci / stepDefinitions / VF_steps.js
1 /*
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  */
16 const {Then, When} = require('cucumber');
17 const assert = require('assert');
18 const util = require('../cucumber-common/utils/Utils.js');
19
20
21 /**
22  * @module VF
23  * @description Creates a VF for this Item (does NOT work on localhost). will get the data for the item and then update the input
24  * data for the VF call.
25  * @exampleFile Example_VSP.feature
26  * @step I want to create a VF for this Item
27  **/
28 Then('I want to create a VF for this Item', function () {
29         return util.request(this.context, 'GET', '/vendor-software-products/' + this.context.item.id + '/versions/' + this.context.item.versionId).then(result => {
30                 this.context.inputData = util.getJSONFromFile('resources/json/createVF.json');
31                 // start replacing stuff
32                 this.context.inputData.contactId = this.context.headers['catalog']["USER_ID"];
33                 this.context.inputData.categories[0].uniqueId = result.data.category;
34                 this.context.inputData.categories[0].subcategories[0].uniqueId = result.data.subCategory;
35                 this.context.inputData.description = result.data.description;
36                 this.context.inputData.name = result.data.name;
37                 this.context.inputData.tags[0] = result.data.name;
38                 this.context.inputData.vendorName = result.data.vendorName;
39                 this.context.inputData.csarUUID = this.context.item.id;
40                 return util.request(this.context, 'POST', '/catalog/resources', this.context.inputData, 'catalog');
41         });
42 });
43