2 * Copyright © 2019 Vodafone Group
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 import deepFreeze from 'deep-freeze';
17 import mockRest from 'test-utils/MockRest.js';
18 import { cloneAndSet } from 'test-utils/Util.js';
19 import { storeCreator } from 'sdc-app/AppStore.js';
20 import SoftwareProductValidationResultsViewActionHelper from 'sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsViewActionHelper.js';
21 import { tabsMapping } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationConstants.js';
22 import Configuration from 'sdc-app/config/Configuration.js';
23 import { VSPTestResultsSuccessFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js';
24 import { VSPTestResultsFailureFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js';
25 import { VSPTestResultKeysFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js';
26 import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
27 import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
28 import { VSPTestsRequestFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
29 import { VSPGeneralInfoFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
30 import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
33 describe('Software Product Validation Test Result Action Helper Tests', function() {
34 const store = storeCreator();
35 deepFreeze(store.getState());
36 const version = VersionFactory.build();
38 const vspChecksList = VSPChecksFactory.build();
39 const vspTestsMap = VSPTestsMapFactory.build();
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 = () => {};
55 modalComponentName: 'Error',
56 modalComponentProps: {
60 msg: 'Test Error Message'
62 cancelButtonText: 'OK'
65 it('Software Products Validation Test Result Action Helper : fetch vsp', () => {
66 let expectedStore = cloneAndSet(
68 'softwareProduct.softwareProductValidationResult.vspChecks',
71 mockRest.addHandler('fetch', ({ baseUrl }) => {
72 expect(baseUrl).toEqual(
73 `${restPrefix}/v1.0/externaltesting/testcasetree`
77 return SoftwareProductValidationResultsViewActionHelper.fetchVspChecks(
80 var stat = store.getState();
81 expect(stat).toEqual(expectedStore);
85 it('Software Products Validation Test Result Action Helper : RefreshValidationResults', () => {
86 let expectedStore = cloneAndSet(
88 'softwareProduct.softwareProductValidationResult.vspTestResults',
89 vspTestResults.vspTestResults
91 mockRest.addHandler('fetch', ({ baseUrl }) => {
92 expect(baseUrl).toEqual(
93 `${restPrefix}/v1.0/externaltesting/executions?${requestQuery}`
95 return vspTestResults.vspTestResults;
97 return SoftwareProductValidationResultsViewActionHelper.refreshValidationResults(
99 requestId: testResultKeys.testResultKeys.requestId,
100 endPoints: testResultKeys.testResultKeys.endPoints
103 var stt = store.getState();
104 expect(stt).toEqual(expectedStore);