blob: 0b99933a7fb5122a2fa7d482834d7f777beb27c2 [file] [log] [blame]
svishnev1eb66b72018-01-11 14:39:45 +02001/*
Einav Weiss Keidard2f57942018-02-14 14:00:07 +02002 * Copyright © 2016-2018 European Support Limited
AviZi280f8012017-06-09 02:39:56 +03003 *
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
Einav Weiss Keidard2f57942018-02-14 14:00:07 +02007 *
svishnev1eb66b72018-01-11 14:39:45 +02008 * http://www.apache.org/licenses/LICENSE-2.0
Einav Weiss Keidard2f57942018-02-14 14:00:07 +02009 *
AviZi280f8012017-06-09 02:39:56 +030010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
svishnev1eb66b72018-01-11 14:39:45 +020012 * 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.
AviZi280f8012017-06-09 02:39:56 +030015 */
16
AviZi280f8012017-06-09 02:39:56 +030017import React from 'react';
Einav Weiss Keidard2f57942018-02-14 14:00:07 +020018import TestUtils from 'react-dom/test-utils';
AviZi280f8012017-06-09 02:39:56 +030019
talig8e9c0652017-12-20 14:30:43 +020020import {Provider} from 'react-redux';
21import {storeCreator} from 'sdc-app/AppStore.js';
22
AviZi280f8012017-06-09 02:39:56 +030023import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
24import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js';
25import {LicenseAgreementStoreFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
26import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
27import {default as SoftwareProductQSchemaFactory} from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js';
28import {default as VspQdataFactory} from 'test-utils/factories/softwareProduct/VspQdataFactory.js';
29import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js';
30import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
talig8e9c0652017-12-20 14:30:43 +020031import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
AviZi280f8012017-06-09 02:39:56 +030032
33import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js';
34import SoftwareProductLandingPageView from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx';
35
36
37describe('Software Product Landing Page: ', function () {
38
talig8e9c0652017-12-20 14:30:43 +020039 let currentSoftwareProduct = {}, softwareProductCategories = [], currentScreen = {},
AviZi280f8012017-06-09 02:39:56 +030040 finalizedLicenseModelList, licenseAgreementList, featureGroupsList, qschema, qdata = {};
41 const dummyFunc = () => {};
talig8e9c0652017-12-20 14:30:43 +020042
AviZi280f8012017-06-09 02:39:56 +030043 beforeAll(function() {
44 finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(2);
talig8e9c0652017-12-20 14:30:43 +020045 currentSoftwareProduct = VSPEditorFactory.build({id:'RTRTG454545', vendorId: finalizedLicenseModelList[0].id, vendorName: finalizedLicenseModelList[0].name, onBoardingMethod: 'HEAT'});
AviZi280f8012017-06-09 02:39:56 +030046 softwareProductCategories = CategoryWithSubFactory.buildList(2,{},{quantity: 1});
47 licenseAgreementList = LicenseAgreementStoreFactory.buildList(2);
48 featureGroupsList = FeatureGroupStoreFactory.buildList(2,{referencingLicenseAgreements:[licenseAgreementList[0].id]});
talig8e9c0652017-12-20 14:30:43 +020049 currentScreen = CurrentScreenFactory.build();
AviZi280f8012017-06-09 02:39:56 +030050 qdata = VspQdataFactory.build();
51 qschema = SoftwareProductQSchemaFactory.build(qdata);
AviZi280f8012017-06-09 02:39:56 +030052 });
53
AviZi280f8012017-06-09 02:39:56 +030054 it('should mapper exist', () => {
55 expect(mapStateToProps).toBeTruthy();
56 });
57
58 it('should mapper return vsp basic data', () => {
talig8e9c0652017-12-20 14:30:43 +020059 const state = {
60 currentScreen,
AviZi280f8012017-06-09 02:39:56 +030061 softwareProduct: {
62 softwareProductEditor: {
63 data: currentSoftwareProduct
64 },
65 softwareProductCategories,
66 softwareProductQuestionnaire: {
67 qdata,
68 qschema
69 },
70 softwareProductComponents: {
71 componentsList:[]
talig8e9c0652017-12-20 14:30:43 +020072 },
73 softwareProductAttachments: {
74 heatSetup: {}
AviZi280f8012017-06-09 02:39:56 +030075 }
76 },
77 finalizedLicenseModelList,
78 licenseModel: {
79 licenseAgreement: {
80 licenseAgreementList
81 },
82 featureGroup: {
83 featureGroupsList
84 }
85 }
86 };
87
talig8e9c0652017-12-20 14:30:43 +020088 const result = mapStateToProps(state);
AviZi280f8012017-06-09 02:39:56 +030089 expect(result.currentSoftwareProduct).toBeTruthy();
AviZi280f8012017-06-09 02:39:56 +030090
91 });
92
93 it('vsp landing basic view', () => {
94
95 const params = {
talig8e9c0652017-12-20 14:30:43 +020096 ...currentScreen.props,
AviZi280f8012017-06-09 02:39:56 +030097 currentSoftwareProduct,
AviZi280f8012017-06-09 02:39:56 +030098 componentsList: VSPComponentsFactory.buildList(2)
99 };
100
Avi Zivb8e2faf2017-07-18 19:45:38 +0300101 const store = storeCreator();
talig8e9c0652017-12-20 14:30:43 +0200102 let vspLandingView = TestUtils.renderIntoDocument(
103 <Provider store={store}>
104 <SoftwareProductLandingPageView {...params}/>
105 </Provider>
106 );
AviZi280f8012017-06-09 02:39:56 +0300107 expect(vspLandingView).toBeTruthy();
108 });
109
110 it('vsp landing handleOnDragEnter test ', () => {
111
112 const params = {
113 currentSoftwareProduct,
talig8e9c0652017-12-20 14:30:43 +0200114 ...currentScreen.props,
AviZi280f8012017-06-09 02:39:56 +0300115 componentsList: VSPComponentsFactory.buildList(2)
116 };
117
Avi Zivb8e2faf2017-07-18 19:45:38 +0300118 const store = storeCreator();
talig8e9c0652017-12-20 14:30:43 +0200119 let vspLandingView = TestUtils.renderIntoDocument(
120 <Provider store={store}>
121 <SoftwareProductLandingPageView {...params}/>
122 </Provider>
123 );
Avi Zivb8e2faf2017-07-18 19:45:38 +0300124 let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType(
125 vspLandingView,
126 SoftwareProductLandingPageView
127 );
AviZi280f8012017-06-09 02:39:56 +0300128 expect(vspLandingView).toBeTruthy();
Avi Zivb8e2faf2017-07-18 19:45:38 +0300129 vspLandingViewWrapper.handleOnDragEnter(false);
130 expect(vspLandingViewWrapper.state.dragging).toEqual(true);
AviZi280f8012017-06-09 02:39:56 +0300131 });
132
133
134 it('vsp landing handleImportSubmit test ', () => {
135
136 const params = {
talig8e9c0652017-12-20 14:30:43 +0200137 ...currentScreen.props,
AviZi280f8012017-06-09 02:39:56 +0300138 currentSoftwareProduct,
AviZi280f8012017-06-09 02:39:56 +0300139 componentsList: VSPComponentsFactory.buildList(2),
140 onUploadConfirmation: dummyFunc,
141 onUpload: dummyFunc,
142 onInvalidFileSizeUpload: dummyFunc
143 };
svishnev1eb66b72018-01-11 14:39:45 +0200144
AviZi280f8012017-06-09 02:39:56 +0300145 const files = [
146 {
147 name: 'aaa',
148 size: 123
149 }
150 ];
151
Avi Zivb8e2faf2017-07-18 19:45:38 +0300152 const store = storeCreator();
153
talig8e9c0652017-12-20 14:30:43 +0200154 let vspLandingView = TestUtils.renderIntoDocument(
155 <Provider store={store}>
156 <SoftwareProductLandingPageView {...params}/>
157 </Provider>
158 );
159
Avi Zivb8e2faf2017-07-18 19:45:38 +0300160 let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType(
161 vspLandingView,
162 SoftwareProductLandingPageView
163 );
164 expect(vspLandingView).toBeTruthy();
165 vspLandingViewWrapper.handleImportSubmit(files, false);
166 expect(vspLandingViewWrapper.state.dragging).toEqual(false);
167 expect(vspLandingViewWrapper.state.fileName).toEqual(files[0].name);
AviZi280f8012017-06-09 02:39:56 +0300168 const files1 = [
169 {
170 name: 'bbb',
171 size: 0
172 }
173 ];
Avi Zivb8e2faf2017-07-18 19:45:38 +0300174 vspLandingViewWrapper.handleImportSubmit(files1, false);
AviZi280f8012017-06-09 02:39:56 +0300175 });
176
177 it('vsp landing handleImportSubmit with damaged file test ', () => {
178
179 const params = {
180 currentSoftwareProduct,
talig8e9c0652017-12-20 14:30:43 +0200181 ...currentScreen.props,
AviZi280f8012017-06-09 02:39:56 +0300182 componentsList: VSPComponentsFactory.buildList(2),
183 onUploadConfirmation: dummyFunc,
184 onUpload: dummyFunc,
185 onInvalidFileSizeUpload: dummyFunc
186 };
187
Avi Zivb8e2faf2017-07-18 19:45:38 +0300188 const store = storeCreator();
189
talig8e9c0652017-12-20 14:30:43 +0200190 let vspLandingView = TestUtils.renderIntoDocument(
191 <Provider store={store}>
192 <SoftwareProductLandingPageView {...params}/>
193 </Provider>
194 );
Avi Zivb8e2faf2017-07-18 19:45:38 +0300195
196 let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType(
197 vspLandingView,
198 SoftwareProductLandingPageView
svishnev1eb66b72018-01-11 14:39:45 +0200199 );
AviZi280f8012017-06-09 02:39:56 +0300200 expect(vspLandingView).toBeTruthy();
201 const files = [
202 {
203 name: 'aaa',
204 size: 0
205 }
206 ];
207
Avi Zivb8e2faf2017-07-18 19:45:38 +0300208 vspLandingViewWrapper.handleImportSubmit(files, false);
209 expect(vspLandingViewWrapper.state.dragging).toEqual(false);
210 expect(vspLandingViewWrapper.state.fileName).toEqual('');
AviZi280f8012017-06-09 02:39:56 +0300211 });
212});