blob: c53919b802faf06bc2cc52ba5bf7fa919b67f466 [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001/*!
2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
15 */
16
17
18
19import React from 'react';
20import TestUtils from 'react-addons-test-utils';
21
talig8e9c0652017-12-20 14:30:43 +020022import {Provider} from 'react-redux';
23import {storeCreator} from 'sdc-app/AppStore.js';
24
AviZi280f8012017-06-09 02:39:56 +030025import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
26import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js';
27import {LicenseAgreementStoreFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
28import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
29import {default as SoftwareProductQSchemaFactory} from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js';
30import {default as VspQdataFactory} from 'test-utils/factories/softwareProduct/VspQdataFactory.js';
31import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js';
32import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
talig8e9c0652017-12-20 14:30:43 +020033import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
AviZi280f8012017-06-09 02:39:56 +030034
35import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js';
36import SoftwareProductLandingPageView from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx';
37
38
39describe('Software Product Landing Page: ', function () {
40
talig8e9c0652017-12-20 14:30:43 +020041 let currentSoftwareProduct = {}, softwareProductCategories = [], currentScreen = {},
AviZi280f8012017-06-09 02:39:56 +030042 finalizedLicenseModelList, licenseAgreementList, featureGroupsList, qschema, qdata = {};
43 const dummyFunc = () => {};
talig8e9c0652017-12-20 14:30:43 +020044
AviZi280f8012017-06-09 02:39:56 +030045 beforeAll(function() {
46 finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(2);
talig8e9c0652017-12-20 14:30:43 +020047 currentSoftwareProduct = VSPEditorFactory.build({id:'RTRTG454545', vendorId: finalizedLicenseModelList[0].id, vendorName: finalizedLicenseModelList[0].name, onBoardingMethod: 'HEAT'});
AviZi280f8012017-06-09 02:39:56 +030048 softwareProductCategories = CategoryWithSubFactory.buildList(2,{},{quantity: 1});
49 licenseAgreementList = LicenseAgreementStoreFactory.buildList(2);
50 featureGroupsList = FeatureGroupStoreFactory.buildList(2,{referencingLicenseAgreements:[licenseAgreementList[0].id]});
talig8e9c0652017-12-20 14:30:43 +020051 currentScreen = CurrentScreenFactory.build();
AviZi280f8012017-06-09 02:39:56 +030052 qdata = VspQdataFactory.build();
53 qschema = SoftwareProductQSchemaFactory.build(qdata);
AviZi280f8012017-06-09 02:39:56 +030054 });
55
AviZi280f8012017-06-09 02:39:56 +030056 it('should mapper exist', () => {
57 expect(mapStateToProps).toBeTruthy();
58 });
59
60 it('should mapper return vsp basic data', () => {
talig8e9c0652017-12-20 14:30:43 +020061 const state = {
62 currentScreen,
AviZi280f8012017-06-09 02:39:56 +030063 softwareProduct: {
64 softwareProductEditor: {
65 data: currentSoftwareProduct
66 },
67 softwareProductCategories,
68 softwareProductQuestionnaire: {
69 qdata,
70 qschema
71 },
72 softwareProductComponents: {
73 componentsList:[]
talig8e9c0652017-12-20 14:30:43 +020074 },
75 softwareProductAttachments: {
76 heatSetup: {}
AviZi280f8012017-06-09 02:39:56 +030077 }
78 },
79 finalizedLicenseModelList,
80 licenseModel: {
81 licenseAgreement: {
82 licenseAgreementList
83 },
84 featureGroup: {
85 featureGroupsList
86 }
87 }
88 };
89
talig8e9c0652017-12-20 14:30:43 +020090 const result = mapStateToProps(state);
AviZi280f8012017-06-09 02:39:56 +030091 expect(result.currentSoftwareProduct).toBeTruthy();
AviZi280f8012017-06-09 02:39:56 +030092
93 });
94
95 it('vsp landing basic view', () => {
96
97 const params = {
talig8e9c0652017-12-20 14:30:43 +020098 ...currentScreen.props,
AviZi280f8012017-06-09 02:39:56 +030099 currentSoftwareProduct,
AviZi280f8012017-06-09 02:39:56 +0300100 componentsList: VSPComponentsFactory.buildList(2)
101 };
102
Avi Zivb8e2faf2017-07-18 19:45:38 +0300103 const store = storeCreator();
talig8e9c0652017-12-20 14:30:43 +0200104 let vspLandingView = TestUtils.renderIntoDocument(
105 <Provider store={store}>
106 <SoftwareProductLandingPageView {...params}/>
107 </Provider>
108 );
AviZi280f8012017-06-09 02:39:56 +0300109 expect(vspLandingView).toBeTruthy();
110 });
111
112 it('vsp landing handleOnDragEnter test ', () => {
113
114 const params = {
115 currentSoftwareProduct,
talig8e9c0652017-12-20 14:30:43 +0200116 ...currentScreen.props,
AviZi280f8012017-06-09 02:39:56 +0300117 componentsList: VSPComponentsFactory.buildList(2)
118 };
119
Avi Zivb8e2faf2017-07-18 19:45:38 +0300120 const store = storeCreator();
talig8e9c0652017-12-20 14:30:43 +0200121 let vspLandingView = TestUtils.renderIntoDocument(
122 <Provider store={store}>
123 <SoftwareProductLandingPageView {...params}/>
124 </Provider>
125 );
Avi Zivb8e2faf2017-07-18 19:45:38 +0300126 let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType(
127 vspLandingView,
128 SoftwareProductLandingPageView
129 );
AviZi280f8012017-06-09 02:39:56 +0300130 expect(vspLandingView).toBeTruthy();
Avi Zivb8e2faf2017-07-18 19:45:38 +0300131 vspLandingViewWrapper.handleOnDragEnter(false);
132 expect(vspLandingViewWrapper.state.dragging).toEqual(true);
AviZi280f8012017-06-09 02:39:56 +0300133 });
134
135
136 it('vsp landing handleImportSubmit test ', () => {
137
138 const params = {
talig8e9c0652017-12-20 14:30:43 +0200139 ...currentScreen.props,
AviZi280f8012017-06-09 02:39:56 +0300140 currentSoftwareProduct,
AviZi280f8012017-06-09 02:39:56 +0300141 componentsList: VSPComponentsFactory.buildList(2),
142 onUploadConfirmation: dummyFunc,
143 onUpload: dummyFunc,
144 onInvalidFileSizeUpload: dummyFunc
145 };
Avi Zivb8e2faf2017-07-18 19:45:38 +0300146
AviZi280f8012017-06-09 02:39:56 +0300147 const files = [
148 {
149 name: 'aaa',
150 size: 123
151 }
152 ];
153
Avi Zivb8e2faf2017-07-18 19:45:38 +0300154 const store = storeCreator();
155
talig8e9c0652017-12-20 14:30:43 +0200156 let vspLandingView = TestUtils.renderIntoDocument(
157 <Provider store={store}>
158 <SoftwareProductLandingPageView {...params}/>
159 </Provider>
160 );
161
Avi Zivb8e2faf2017-07-18 19:45:38 +0300162 let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType(
163 vspLandingView,
164 SoftwareProductLandingPageView
165 );
166 expect(vspLandingView).toBeTruthy();
167 vspLandingViewWrapper.handleImportSubmit(files, false);
168 expect(vspLandingViewWrapper.state.dragging).toEqual(false);
169 expect(vspLandingViewWrapper.state.fileName).toEqual(files[0].name);
AviZi280f8012017-06-09 02:39:56 +0300170 const files1 = [
171 {
172 name: 'bbb',
173 size: 0
174 }
175 ];
Avi Zivb8e2faf2017-07-18 19:45:38 +0300176 vspLandingViewWrapper.handleImportSubmit(files1, false);
AviZi280f8012017-06-09 02:39:56 +0300177 });
178
179 it('vsp landing handleImportSubmit with damaged file test ', () => {
180
181 const params = {
182 currentSoftwareProduct,
talig8e9c0652017-12-20 14:30:43 +0200183 ...currentScreen.props,
AviZi280f8012017-06-09 02:39:56 +0300184 componentsList: VSPComponentsFactory.buildList(2),
185 onUploadConfirmation: dummyFunc,
186 onUpload: dummyFunc,
187 onInvalidFileSizeUpload: dummyFunc
188 };
189
Avi Zivb8e2faf2017-07-18 19:45:38 +0300190 const store = storeCreator();
191
talig8e9c0652017-12-20 14:30:43 +0200192 let vspLandingView = TestUtils.renderIntoDocument(
193 <Provider store={store}>
194 <SoftwareProductLandingPageView {...params}/>
195 </Provider>
196 );
Avi Zivb8e2faf2017-07-18 19:45:38 +0300197
198 let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType(
199 vspLandingView,
200 SoftwareProductLandingPageView
201 );
AviZi280f8012017-06-09 02:39:56 +0300202 expect(vspLandingView).toBeTruthy();
203 const files = [
204 {
205 name: 'aaa',
206 size: 0
207 }
208 ];
209
Avi Zivb8e2faf2017-07-18 19:45:38 +0300210 vspLandingViewWrapper.handleImportSubmit(files, false);
211 expect(vspLandingViewWrapper.state.dragging).toEqual(false);
212 expect(vspLandingViewWrapper.state.fileName).toEqual('');
AviZi280f8012017-06-09 02:39:56 +0300213 });
214});