blob: 064a32312c6a72f78cdb4d88566706146d3082a9 [file] [log] [blame]
atulpurohit8b346842019-11-05 14:31:56 +05301/*
2 * Copyright © 2019 Vodafone Group
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 */
16import deepFreeze from 'deep-freeze';
17import mockRest from 'test-utils/MockRest.js';
18import { cloneAndSet } from 'test-utils/Util.js';
19import { storeCreator } from 'sdc-app/AppStore.js';
20import SoftwareProductValidationResultsViewActionHelper from 'sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsViewActionHelper.js';
21import { tabsMapping } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationConstants.js';
22import Configuration from 'sdc-app/config/Configuration.js';
23import { VSPTestResultsSuccessFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js';
24import { VSPTestResultsFailureFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js';
25import { VSPTestResultKeysFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js';
26import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
27import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
28import { VSPTestsRequestFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
29import { VSPGeneralInfoFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
30import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
31
32
33describe('Software Product Validation Test Result Action Helper Tests', function() {
34 const store = storeCreator();
35 deepFreeze(store.getState());
36 const version = VersionFactory.build();
37 const vspId = 10000;
38 const vspChecksList = VSPChecksFactory.build();
39 const vspTestsMap = VSPTestsMapFactory.build();
40
41 const errorMessage = { msg: 'Test Error Message' };
42 const testsRequest = VSPTestsRequestFactory.build();
43 const generalInfo = VSPGeneralInfoFactory.build();
44 const isValidationDisabled = false;
45 const testResultKeys = VSPTestResultKeysFactory.build();
46 const vspTestResults = VSPTestResultsSuccessFactory.build();
47 const requestQuery = "requestId="+testResultKeys.testResultKeys.requestId
48 + "&" + "endPoint=" + testResultKeys.testResultKeys.endPoints[0];
49 let restPrefix = Configuration.get('restPrefix');
50 let onClose = () => {};
51
52 const modal = {
53 type: 'error',
54 title: 'Error',
55 modalComponentName: 'Error',
56 modalComponentProps: {
57 onClose: onClose
58 },
59 msg: {
60 msg: 'Test Error Message'
61 },
62 cancelButtonText: 'OK'
63 };
64
65 it('Software Products Validation Test Result Action Helper : fetch vsp', () => {
66 let expectedStore = cloneAndSet(
67 store.getState(),
68 'softwareProduct.softwareProductValidationResult.vspChecks',
69 vspChecksList
70 );
71 mockRest.addHandler('fetch', ({ baseUrl }) => {
72 expect(baseUrl).toEqual(
73 `${restPrefix}/v1.0/externaltesting/testcasetree`
74 );
75 return vspChecksList;
76 });
77 return SoftwareProductValidationResultsViewActionHelper.fetchVspChecks(
78 store.dispatch
79 ).then(() => {
80 var stat = store.getState();
81 expect(stat).toEqual(expectedStore);
82 })
83 });
84
85 it('Software Products Validation Test Result Action Helper : RefreshValidationResults', () => {
86 let expectedStore = cloneAndSet(
87 store.getState(),
88 'softwareProduct.softwareProductValidationResult.vspTestResults',
89 vspTestResults.vspTestResults
90 );
91 mockRest.addHandler('fetch', ({ baseUrl }) => {
92 expect(baseUrl).toEqual(
93 `${restPrefix}/v1.0/externaltesting/executions?${requestQuery}`
94 );
95 return vspTestResults.vspTestResults;
96 });
97 return SoftwareProductValidationResultsViewActionHelper.refreshValidationResults(
98 store.dispatch, {
99 requestId: testResultKeys.testResultKeys.requestId,
100 endPoints: testResultKeys.testResultKeys.endPoints
101 }
102 ).then(() => {
103 var stt = store.getState();
104 expect(stt).toEqual(expectedStore);
105 })
106 });
107})