From 091edfdac90f66d91caff1b93131f99ba74f9aeb Mon Sep 17 00:00:00 2001 From: svishnev Date: Mon, 19 Mar 2018 12:15:19 +0200 Subject: ui support for archive items Issue-ID: SDC-1088 Change-Id: I836e4896a8ec6bb065f9d2571f514916ccf6759f Signed-off-by: svishnev --- .../creation/LicenseModelCreation.test.js | 4 +++ .../test/licenseModel/entitlementPools/test.js | 6 ++-- .../VersionController/versionController.test.js | 7 +++++ .../test/onboard/onboardingCatalog/test.js | 20 ++++++------- .../test/onboard/onboardingCatalog/views.test.js | 12 ++++++-- openecomp-ui/test/onboard/test.js | 18 ++++++------ .../creation/SoftwareProductCreation.test.js | 8 ++++++ .../softwareProduct/details/detailsView.test.js | 22 ++++++++++----- openecomp-ui/test/softwareProduct/details/test.js | 29 +++++++++++-------- .../test/versionsPage/VersionsPage.test.js | 33 ++++++++++++++++++++-- 10 files changed, 115 insertions(+), 44 deletions(-) (limited to 'openecomp-ui/test') diff --git a/openecomp-ui/test/licenseModel/creation/LicenseModelCreation.test.js b/openecomp-ui/test/licenseModel/creation/LicenseModelCreation.test.js index a52d06baa3..59ac267b04 100644 --- a/openecomp-ui/test/licenseModel/creation/LicenseModelCreation.test.js +++ b/openecomp-ui/test/licenseModel/creation/LicenseModelCreation.test.js @@ -28,6 +28,8 @@ describe('License Model Creation Module Tests', function() { it ('should return empty data', () => { let state = { licenseModelList: [], + archivedLicenseModelList: [], + finalizedLicenseModelList: [], licenseModel: { licenseModelCreation: { data: {} @@ -43,6 +45,8 @@ describe('License Model Creation Module Tests', function() { it ('should return vlm names list', () => { let state = { + archivedLicenseModelList: [], + finalizedLicenseModelList: [], licenseModelList: [{ name: 'vlm1', id: 'vlm1_id' diff --git a/openecomp-ui/test/licenseModel/entitlementPools/test.js b/openecomp-ui/test/licenseModel/entitlementPools/test.js index 173384dc02..dc56b11f1b 100644 --- a/openecomp-ui/test/licenseModel/entitlementPools/test.js +++ b/openecomp-ui/test/licenseModel/entitlementPools/test.js @@ -88,14 +88,14 @@ describe('Entitlement Pools Module Tests', function () { } }; }); - + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`); expect(data).toEqual(undefined); expect(options).toEqual(undefined); return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}}; }); - + return EntitlementPoolsActionHelper.deleteEntitlementPool(store.dispatch, { licenseModelId: LICENSE_MODEL_ID, version, @@ -148,6 +148,8 @@ describe('Entitlement Pools Module Tests', function () { return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}}; }); + + return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch, { licenseModelId: LICENSE_MODEL_ID, diff --git a/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js b/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js index 3b4f0de893..ae24dbf9cd 100644 --- a/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js +++ b/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js @@ -135,4 +135,11 @@ describe('versionController UI Component', () => { expect(elem.length).toBe(1); }); + it ('Do not show action buttons in case of archived item', () =>{ + let propsForArchivedItem = {...props, isArchived: true}; + let versionController = TestUtils.renderIntoDocument(); + let saveBtn = TestUtils.scryRenderedDOMComponentsWithClass(versionController,'collaborator-action-buttons'); + expect(saveBtn).toBeTruthy(); + expect(saveBtn.length).toBe(0); + }); }); diff --git a/openecomp-ui/test/onboard/onboardingCatalog/test.js b/openecomp-ui/test/onboard/onboardingCatalog/test.js index cc54e3199e..4e38675fb7 100644 --- a/openecomp-ui/test/onboard/onboardingCatalog/test.js +++ b/openecomp-ui/test/onboard/onboardingCatalog/test.js @@ -1,17 +1,17 @@ -/*! - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +/* + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing - * permissions and limitations under the License. + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ import {storeCreator} from 'sdc-app/AppStore.js'; import {OnboardingCatalogStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js'; @@ -29,8 +29,8 @@ describe('Onboarding Catalog Module Tests', () => { it('should change active tab to All', () => { const store = storeCreator(); - const expectedStore = OnboardingCatalogStoreFactory.build({activeTab: tabsMapping.ALL}); - OnboardingCatalogActionHelper.changeActiveTab(store.dispatch, tabsMapping.ALL); + const expectedStore = OnboardingCatalogStoreFactory.build({activeTab: tabsMapping.ACTIVE}); + OnboardingCatalogActionHelper.changeActiveTab(store.dispatch, tabsMapping.ACTIVE); expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore); }); diff --git a/openecomp-ui/test/onboard/onboardingCatalog/views.test.js b/openecomp-ui/test/onboard/onboardingCatalog/views.test.js index 289826ad84..63b49aafab 100644 --- a/openecomp-ui/test/onboard/onboardingCatalog/views.test.js +++ b/openecomp-ui/test/onboard/onboardingCatalog/views.test.js @@ -15,6 +15,9 @@ */ import React from 'react'; +import {Provider} from 'react-redux'; +import {storeCreator} from 'sdc-app/AppStore.js'; + import TestUtils from 'react-dom/test-utils'; import {defaultStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js'; import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; @@ -80,8 +83,13 @@ describe('OnBoarding Catalog test - View: ', function () { }; let params = {...func, ...mapStateToProps(data)}; - let CatalogView = TestUtils.renderIntoDocument(); + const store = storeCreator(); + + let CatalogView = TestUtils.renderIntoDocument( + + + ); expect(CatalogView).toBeTruthy(); }); diff --git a/openecomp-ui/test/onboard/test.js b/openecomp-ui/test/onboard/test.js index 18bb042aea..232c5615c9 100644 --- a/openecomp-ui/test/onboard/test.js +++ b/openecomp-ui/test/onboard/test.js @@ -1,17 +1,17 @@ -/*! - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +/* + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing - * permissions and limitations under the License. + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ import {storeCreator} from 'sdc-app/AppStore.js'; import {OnboardStoreFactory} from 'test-utils/factories/onboard/OnboardFactories.js'; @@ -54,7 +54,7 @@ describe('Onboard Module Tests', () => { const expectedStore = OnboardStoreFactory.build(); OnboardActionHelper.changeSearchValue(store.dispatch, 'hello'); OnboardActionHelper.changeActiveTab(store.dispatch, onboardTabsMapping.CATALOG); - OnboardingCatalogActionHelper.changeActiveTab(store.dispatch, onboardCatalogTabsMapping.ALL); + OnboardingCatalogActionHelper.changeActiveTab(store.dispatch, onboardCatalogTabsMapping.ACTIVE); OnboardActionHelper.resetOnboardStore(store.dispatch, 'hello'); expect(store.getState().onboard).toEqual(expectedStore); }); diff --git a/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js b/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js index 51db931a9a..20ca17d3d0 100644 --- a/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js +++ b/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js @@ -31,6 +31,8 @@ describe('Software Product Creation Module Tests', function() { it ('should return empty data', () => { let state = { softwareProductList: [], + finalizedSoftwareProductList: [], + archivedSoftwareProductList: [], softwareProduct: { softwareProductCreation: { data: {} @@ -46,6 +48,8 @@ describe('Software Product Creation Module Tests', function() { it ('should return vsp names list', () => { let state = { + finalizedSoftwareProductList: [], + archivedSoftwareProductList: [], softwareProductList: [{ name: 'vsp1', id: 'vsp1_id' @@ -73,6 +77,8 @@ describe('Software Product Creation Module Tests', function() { let state = { softwareProductList: [], + finalizedSoftwareProductList: [], + archivedSoftwareProductList: [], softwareProduct: { softwareProductCreation: SoftwareProductCreationFactory.build(), softwareProductCategories: CategoryWithSubFactory.buildList({}, {quantity: 2}) @@ -97,6 +103,8 @@ describe('Software Product Creation Module Tests', function() { let finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(3); let state = { softwareProductList: [], + finalizedSoftwareProductList: [], + archivedSoftwareProductList: [], softwareProduct: { softwareProductCreation: SoftwareProductCreationFactoryWithSelectedVendor.build({selectedVendorId: finalizedLicenseModelList[0].id}), softwareProductCategories: CategoryWithSubFactory.buildList({}, {quantity: 2}) diff --git a/openecomp-ui/test/softwareProduct/details/detailsView.test.js b/openecomp-ui/test/softwareProduct/details/detailsView.test.js index 33cc36ed59..46983f5d80 100644 --- a/openecomp-ui/test/softwareProduct/details/detailsView.test.js +++ b/openecomp-ui/test/softwareProduct/details/detailsView.test.js @@ -1,7 +1,7 @@ /* * Copyright © 2016-2018 European Support Limited * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the 'License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -25,7 +25,6 @@ import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/Featu import {SchemaGenericFieldInfoFactory} from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; import {default as VspQdataFactory, VspDataMapFactory} from 'test-utils/factories/softwareProduct/VspQdataFactory.js'; import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; -import VersionFactory from 'test-utils/factories/common/VersionFactory.js'; import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js'; describe('Software Product Details: ', function () { @@ -46,9 +45,14 @@ describe('Software Product Details: ', function () { licenseAgreementList = LicenseAgreementStoreFactory.buildList(2); licensingVersionsList = [ { - "id":"0127b419e9574a11aab8e031a78fc534", - "name":"1.0","description":"Initial version", - "baseId":"","status":"Certified","creationTime":1506409288390,"modificationTime":1506409288390,"additionalInfo":{"OptionalCreationMethods":["minor"]}},{"id":"ea159ffedd9a4f9a8a56d53ba66b7314","name":"2.0","description":"ggggg","baseId":"0127b419e9574a11aab8e031a78fc534","status":"Draft","creationTime":1508839019802,"modificationTime":1508839019802,"additionalInfo":{"OptionalCreationMethods":[]}} + 'id':'0127b419e9574a11aab8e031a78fc534', + 'name':'1.0','description':'Initial version', + 'baseId':'','status':'Certified','creationTime':1506409288390, + 'modificationTime':1506409288390,'additionalInfo':{'OptionalCreationMethods':['minor']}}, + {'id':'ea159ffedd9a4f9a8a56d53ba66b7314','name':'2.0','description':'ggggg', + 'baseId':'0127b419e9574a11aab8e031a78fc534','status':'Draft','creationTime':1508839019802, + 'modificationTime':1508839019802,'additionalInfo':{'OptionalCreationMethods':[]} + } ]; featureGroupsList = FeatureGroupStoreFactory.buildList(2, {referencingLicenseAgreements: [licenseAgreementList[0].id]}); qdata = VspQdataFactory.build(); @@ -109,7 +113,9 @@ describe('Software Product Details: ', function () { featureGroup: { featureGroupsList: [] } - } + }, + archivedLicenseModelList: [], + archivedSoftwareProductList: [] }; var result = mapStateToProps(obj); @@ -145,7 +151,9 @@ describe('Software Product Details: ', function () { dataMap } }, - finalizedLicenseModelList: finalizedLicenseModelList, + finalizedLicenseModelList: finalizedLicenseModelList, + archivedLicenseModelList: [], + archivedSoftwareProductList: [], licenseModel: { licenseAgreement: { licenseAgreementList: licenseAgreementList diff --git a/openecomp-ui/test/softwareProduct/details/test.js b/openecomp-ui/test/softwareProduct/details/test.js index 27cbaa40ef..60506243ff 100644 --- a/openecomp-ui/test/softwareProduct/details/test.js +++ b/openecomp-ui/test/softwareProduct/details/test.js @@ -1,17 +1,17 @@ -/*! - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +/* + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing - * permissions and limitations under the License. + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; @@ -35,7 +35,7 @@ import VersionFactory from 'test-utils/factories/common/VersionFactory.js'; import {InitializedCurrentScreenFactory} from 'test-utils/factories/common/CurrentScreenFactory.js'; describe('Software Product Details Module Tests', function () { - it('Get Software Products List', () => { + it('Get Software Products List', async () => { const store = storeCreator(); deepFreeze(store.getState()); const softwareProductList = VSPEditorFactory.buildList(2); @@ -57,11 +57,18 @@ describe('Software Product Details Module Tests', function () { return {results: []}; }); - return SoftwareProductActionHelper.fetchSoftwareProductList(store.dispatch).then(() => { - return SoftwareProductActionHelper.fetchFinalizedSoftwareProductList(store.dispatch); - }).then(() => { - expect(store.getState()).toEqual(expectedStore); + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/?Status=ARCHIVED'); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: []}; }); + + await SoftwareProductActionHelper.fetchSoftwareProductList(store.dispatch); + await SoftwareProductActionHelper.fetchFinalizedSoftwareProductList(store.dispatch); + await SoftwareProductActionHelper.fetchArchivedSoftwareProductList(store.dispatch); + + expect(store.getState()).toEqual(expectedStore); }); it('Add Software Product', () => { diff --git a/openecomp-ui/test/versionsPage/VersionsPage.test.js b/openecomp-ui/test/versionsPage/VersionsPage.test.js index 61e93cb9d2..fd7659e70e 100644 --- a/openecomp-ui/test/versionsPage/VersionsPage.test.js +++ b/openecomp-ui/test/versionsPage/VersionsPage.test.js @@ -16,11 +16,12 @@ import React from 'react'; import ShallowRenderer from 'react-test-renderer/shallow'; +import {mount} from 'enzyme'; +import {Provider} from 'react-redux'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; import Configuration from 'sdc-app/config/Configuration.js'; import {storeCreator} from 'sdc-app/AppStore.js'; - import {mapStateToProps, mapActionsToProps} from 'sdc-app/onboarding/versionsPage/VersionsPage.js'; import VersionsPageView from 'sdc-app/onboarding/versionsPage/VersionsPage.jsx'; import VersionsPageActionHelper from 'sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js'; @@ -29,6 +30,7 @@ import {itemTypes as versionPageItemTypes} from 'sdc-app/onboarding/versionsPage import VersionFactory from 'test-utils/factories/common/VersionFactory.js'; import {VersionsPageCreationFactory} from 'test-utils/factories/versionsPage/VersionsPageCreationFactories.js'; import {VersionsPageAdditionalPropsFactory} from 'test-utils/factories/versionsPage/VersionsPageFactories.js'; +import {cloneAndSet} from 'test-utils/Util.js'; describe('Versions Page Module Tests', () => { @@ -45,7 +47,15 @@ describe('Versions Page Module Tests', () => { userInfo: 'user123' }, versionsPage: { - permissions: {}, + permissions: { + contributors: [], + owner: { + userId: 'fgfgfg', + permission: 'Owner', + fullName: 'Test User', + role: 'Test ROLE' + } + }, versionsList: {versions: []}, versionCreation: {} } @@ -71,7 +81,7 @@ describe('Versions Page Module Tests', () => { const additionalProps = VersionsPageAdditionalPropsFactory.build(); - const props = Object.assign({}, mapStateToProps(state), mapActionsToProps(dispatch, additionalProps)); + const props = {...mapStateToProps(state), ...mapActionsToProps(dispatch, additionalProps)}; const renderer = new ShallowRenderer(); renderer.render(); @@ -79,6 +89,23 @@ describe('Versions Page Module Tests', () => { expect(renderedOutput).toBeTruthy(); }); + /** + * turn on when ARCHIVE_ITEM feature toggle will be removed in VersionPage.jsx + */ + // it('archive btn test', () => { + + // const store = storeCreator(); + // const dispatch = store.dispatch; + + // const additionalProps = VersionsPageAdditionalPropsFactory.build(); + // const props = {...mapStateToProps(state), ...mapActionsToProps(dispatch, additionalProps)}; + // const wrapper = mount(); + // const depricateBtn = wrapper.find('.depricate-btn'); + // expect(depricateBtn).toBeTruthy(); + // expect(depricateBtn.text()).toBe('ARCHIVE'); + // }); + + }); -- cgit 1.2.3-korg