diff options
Diffstat (limited to 'openecomp-ui')
15 files changed, 103 insertions, 45 deletions
diff --git a/openecomp-ui/.babelrc b/openecomp-ui/.babelrc index 7949c034d8..7b8d637641 100644 --- a/openecomp-ui/.babelrc +++ b/openecomp-ui/.babelrc @@ -1,14 +1,29 @@ { - "presets": [["env", { - "targets": { - "browsers": ["last 2 versions", "Firefox >= 47"] - } - }], "react"], + "presets": [ + [ + "@babel/preset-env", + { + "targets": { + "browsers": [ + "last 2 versions", + "Firefox >= 47" + ] + } + } + ], + "@babel/preset-react" + ], "plugins": [ - "transform-object-rest-spread", - "transform-class-properties", - "transform-runtime", - "transform-decorators-legacy" + "@babel/plugin-proposal-object-rest-spread", + "@babel/plugin-proposal-class-properties", + "@babel/plugin-transform-runtime", + "@babel/plugin-transform-modules-commonjs", + [ + "@babel/plugin-proposal-decorators", + { + "legacy": true + } + ] ], "sourceMap": "inline" } diff --git a/openecomp-ui/package.json b/openecomp-ui/package.json index 9fb606c03e..e7b47cf15c 100644 --- a/openecomp-ui/package.json +++ b/openecomp-ui/package.json @@ -29,7 +29,7 @@ "intl-relativeformat": "^1.2.0", "lodash": "^4.13.1", "md5": "^2.1.0", - "onap-ui-react": "^1.0.0", + "onap-ui-react": "^1.0.2", "onap-ui-common": "^1.0.101", "prop-types": "^15.6.2", "react": "^16.4.2", @@ -52,16 +52,19 @@ "validator": "^4.3.0" }, "devDependencies": { - "babel-core": "^6.26.0", + "@babel/core": "^7.26.0", + "@babel/plugin-proposal-class-properties": "^7.18.6", + "@babel/plugin-proposal-decorators": "^7.25.9", + "@babel/plugin-proposal-object-rest-spread": "^7.20.7", + "@babel/plugin-transform-modules-commonjs": "^7.26.3", + "@babel/plugin-transform-runtime": "^7.25.9", + "@babel/preset-env": "^7.26.0", + "@babel/preset-react": "^7.26.3", + "@babel/runtime": "^7.26.0", + "@testing-library/react": "11", "babel-eslint": "^8.2.1", - "babel-jest": "^22.1.0", - "babel-loader": "7.1.4", - "babel-plugin-transform-class-properties": "^6.10.2", - "babel-plugin-transform-decorators-legacy": "^1.3.4", - "babel-plugin-transform-object-rest-spread": "^6.8.0", - "babel-plugin-transform-runtime": "^6.22.0", - "babel-preset-env": "^1.6.1", - "babel-preset-react": "^6.23.0", + "babel-jest": "^29.7.0", + "babel-loader": "^8.0.0", "clean-webpack-plugin": "^0.1.19", "css-loader": "^0.23.1", "deep-freeze": "0.0.1", @@ -80,13 +83,14 @@ "http-proxy-middleware": "^0.17.4", "ignore-loader": "^0.1.1", "jasmine-core": "^2.5.2", - "jest": "^21.2.1", + "jest": "^29.7.0", + "jest-environment-jsdom": "^29.7.0", "jshint": "^2.9.4", "json-loader": "^0.5.4", "jsx-loader": "^0.13.2", "mkdirp": "^0.5.1", "moment": "^2.18.1", - "node-sass": "^4.7.2", + "node-sass": "^9.0.0", "node-watch": "^0.3.5", "prettier": "1.10.2", "prompt": "^0.2.14", @@ -141,7 +145,8 @@ "setupTestFrameworkScriptFile": "<rootDir>/test-utils/test-setup.js", "testPathIgnorePatterns": [ "<rootDir>/node_modules/", - "<rootDir>/test/nfvo-components/storyshots.test.js" + "<rootDir>/test/nfvo-components/storyshots.test.js", + "<rootDir>/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js" ], "collectCoverageFrom": [ "src/**/*.{js,jsx}" @@ -152,6 +157,17 @@ ], "coverageReporters": [ "lcov" + ], + "testEnvironment": "jest-environment-jsdom", + "transformIgnorePatterns": [ + "<rootDir>/node_modules/(?!cheerio|enzyme)/" + ], + "transform": { + "^.+\\.jsx?$": "babel-jest" + }, + "extensionsToTreatAsEsm": [ + ".jsx" + ] } } diff --git a/openecomp-ui/pom.xml b/openecomp-ui/pom.xml index 54f39db248..766d405b37 100644 --- a/openecomp-ui/pom.xml +++ b/openecomp-ui/pom.xml @@ -102,7 +102,7 @@ <goal>install-node-and-yarn</goal> </goals> <configuration> - <nodeVersion>v14.17.1</nodeVersion> + <nodeVersion>v16.20.0</nodeVersion> <yarnVersion>v1.19.1</yarnVersion> </configuration> </execution> diff --git a/openecomp-ui/test-utils/MockRest.js b/openecomp-ui/test-utils/MockRest.js index 6cc676a2bb..0ec0d42e73 100644 --- a/openecomp-ui/test-utils/MockRest.js +++ b/openecomp-ui/test-utils/MockRest.js @@ -41,7 +41,7 @@ export default { fetch(baseUrl, options) { const {fetch} = queue; if(!fetch.length) { - throw new Error(`Fetch operation was called without proper handler. baseUrl: '${baseUrl}' options: '${options}'`); + throw new Error(`Fetch operation was called without proper handler. baseUrl: ${baseUrl} options: ${options}`); } return handleOperation(fetch.shift(), {options, baseUrl}); }, diff --git a/openecomp-ui/test/activity-log/ActivityLog.test.js b/openecomp-ui/test/activity-log/ActivityLog.test.js index a397197773..998abb2f95 100644 --- a/openecomp-ui/test/activity-log/ActivityLog.test.js +++ b/openecomp-ui/test/activity-log/ActivityLog.test.js @@ -30,12 +30,16 @@ import VersionFactory from 'test-utils/factories/common/VersionFactory.js'; import { UserFactory } from 'test-utils/factories/users/UsersFactories.js'; import { actionTypes as userActionTypes } from 'sdc-app/onboarding/users/UsersConstants.js'; +import Adapter from 'enzyme-adapter-react-16'; +import Enzyme from 'enzyme'; describe('Activity Log Module Tests', function() { const LICENSE_MODEL_ID = '555'; const version = VersionFactory.build(); const usersList = UserFactory.buildList(3); + Enzyme.configure({ adapter: new Adapter() }) + it('mapStateToProps mapper exists', () => { expect(mapStateToProps).toBeTruthy(); }); diff --git a/openecomp-ui/test/features/featureToggle.test.js b/openecomp-ui/test/features/featureToggle.test.js index 707180bc9b..1aaf840091 100644 --- a/openecomp-ui/test/features/featureToggle.test.js +++ b/openecomp-ui/test/features/featureToggle.test.js @@ -19,8 +19,13 @@ import {mount} from 'enzyme'; import deepFreeze from 'deep-freeze'; import FeatureFactory from 'test-utils/factories/features/FeaturesFactory.js'; import {FeatureComponent} from 'sdc-app/features/featureToggle.js'; +import Adapter from 'enzyme-adapter-react-16'; +import Enzyme from 'enzyme'; describe('feature toggle decorator test', () => { + + Enzyme.configure({ adapter: new Adapter() }) + it('feature on toggle test', () => { const featuresList = [FeatureFactory.build({name: 'TEST', active: true})]; deepFreeze(featuresList); diff --git a/openecomp-ui/test/nfvo-components/input/validation/input.test.js b/openecomp-ui/test/nfvo-components/input/validation/input.test.js index 841f64ac3f..8b4b0fa1d7 100644 --- a/openecomp-ui/test/nfvo-components/input/validation/input.test.js +++ b/openecomp-ui/test/nfvo-components/input/validation/input.test.js @@ -20,8 +20,13 @@ import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js'; import Input from 'nfvo-components/input/validation/Input.jsx'; import Overlay from 'react-bootstrap/lib/Overlay.js'; import {shallow} from 'enzyme'; +import Adapter from 'enzyme-adapter-react-16'; +import Enzyme from 'enzyme'; describe('Input', function () { + + Enzyme.configure({ adapter: new Adapter() }) + it('should render with type text', () => { let renderedOutput = TestUtils.renderIntoDocument(<Input type='text' data-test-id='mytest' />); const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest'); diff --git a/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js b/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js index 269e5681c4..6e65740c2b 100644 --- a/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js +++ b/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js @@ -16,12 +16,15 @@ import React from 'react'; import {mount} from 'enzyme'; +import Adapter from 'enzyme-adapter-react-16'; +import Enzyme from 'enzyme'; import TestUtils from 'react-dom/test-utils'; import ListEditorView from 'src/nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'src/nfvo-components/listEditor/ListEditorItemView.jsx'; describe('listEditor Module Tests', function () { + Enzyme.configure({ adapter: new Adapter() }) it('list editor view should exist', () => { expect(ListEditorView).toBeTruthy(); diff --git a/openecomp-ui/test/onboard/filter/filter.test.js b/openecomp-ui/test/onboard/filter/filter.test.js index bf9ce63346..8d984d57b4 100644 --- a/openecomp-ui/test/onboard/filter/filter.test.js +++ b/openecomp-ui/test/onboard/filter/filter.test.js @@ -60,7 +60,7 @@ describe('Onboard Filter Tests', () => { type: actionTypes.FILTER_DATA_CHANGED, deltaData: {} }); - return timeoutPromise.then(function() { + timeoutPromise.then(function() { expect(store.getState()).toEqual(expectedStore); done(); }); @@ -107,7 +107,7 @@ describe('Onboard Filter Tests', () => { deltaData: { versionStatus: versionStatus.CERTIFIED } }); - return timeoutPromise.then(function() { + timeoutPromise.then(function() { expect(store.getState()).toEqual(expectedStoreWithFilteredLists); done(); }); @@ -136,7 +136,7 @@ describe('Onboard Filter Tests', () => { tabsMapping.CATALOG ); - return timeoutPromise.then(() => { + timeoutPromise.then(function() { expect(store.getState().onboard.filter.versionStatus).toEqual( versionStatus.CERTIFIED ); diff --git a/openecomp-ui/test/onboard/filter/filterView.test.js b/openecomp-ui/test/onboard/filter/filterView.test.js index 9e6e1ee4c2..f071befb9c 100644 --- a/openecomp-ui/test/onboard/filter/filterView.test.js +++ b/openecomp-ui/test/onboard/filter/filterView.test.js @@ -19,9 +19,12 @@ import { mount } from 'enzyme'; import { Provider } from 'react-redux'; import { storeCreator } from 'sdc-app/AppStore.js'; import Filter from 'sdc-app/onboarding//onboard/filter/Filter.jsx'; +import Adapter from 'enzyme-adapter-react-16'; +import Enzyme from 'enzyme'; describe('Filter component view Tests', () => { it('simple jsx test', () => { + Enzyme.configure({ adapter: new Adapter() }) const store = storeCreator(); const wrapper = mount( <Provider store={store}> diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/test.js b/openecomp-ui/test/softwareProduct/components/monitoring/test.js index 50fda91871..f7f690851e 100644 --- a/openecomp-ui/test/softwareProduct/components/monitoring/test.js +++ b/openecomp-ui/test/softwareProduct/components/monitoring/test.js @@ -34,25 +34,24 @@ describe('Software Product Components Monitoring Module Tests', function () { }); - it('Fetch for existing files - no files', done => { - + it('Fetch for existing files - no files', (done) => { let emptyResult = VSPComponentsMonitoringRestFactory.build(); - - mockRest.addHandler('fetch', ({ baseUrl}) => { + + mockRest.addHandler('fetch', ({ baseUrl }) => { expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/uploads`); return emptyResult; }); - - return SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {softwareProductId, version, componentId}).then(() => { - var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState(); + + // Return the promise so Jest knows to wait for it + SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, { softwareProductId, version, componentId }).then(() => { + var { softwareProduct: { softwareProductComponents: { monitoring } } } = store.getState(); expect(monitoring[trap]).toEqual(emptyResult[trap]); expect(monitoring[poll]).toEqual(emptyResult[poll]); expect(monitoring[ves]).toEqual(emptyResult[ves]); done(); }); - - }); + it('Fetch for existing files - only snmp trap file exists', done => { let response = VSPComponentsMonitoringRestFactory.build({}, {createTrap: true}); @@ -62,7 +61,7 @@ describe('Software Product Components Monitoring Module Tests', function () { return response; }); - return SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {softwareProductId, version, componentId}).then(() => { + SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {softwareProductId, version, componentId}).then(() => { var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState(); expect(monitoring[poll]).toEqual(undefined); @@ -81,7 +80,7 @@ describe('Software Product Components Monitoring Module Tests', function () { return response; }); - return SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {softwareProductId, version, componentId}).then(() => { + SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {softwareProductId, version, componentId}).then(() => { var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState(); expect(monitoring[trap]).toEqual(response[trap]); @@ -101,7 +100,7 @@ describe('Software Product Components Monitoring Module Tests', function () { let file = new Blob([JSON.stringify(debug, null, 2)], {type: 'application/json'});; let formData = new FormData(); formData.append('upload', file); - return SoftwareProductComponentsMonitoringActionHelper.uploadFile(store.dispatch, { + SoftwareProductComponentsMonitoringActionHelper.uploadFile(store.dispatch, { softwareProductId, version, componentId, @@ -125,7 +124,7 @@ describe('Software Product Components Monitoring Module Tests', function () { }); - return SoftwareProductComponentsMonitoringActionHelper.deleteFile(store.dispatch, { + SoftwareProductComponentsMonitoringActionHelper.deleteFile(store.dispatch, { softwareProductId, version, componentId, diff --git a/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js b/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js index 15b2960191..38c84f0b45 100644 --- a/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js +++ b/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js @@ -15,7 +15,7 @@ */ import React from 'react'; -import {mount} from 'enzyme'; +// import {mount} from 'enzyme'; import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependencies.js'; import { SoftwareProductDependenciesResponseFactory, diff --git a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js index 3be1d68bbc..bb8bb3f638 100644 --- a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js +++ b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js @@ -78,13 +78,13 @@ describe('Software Product Validation Action Helper Tests', function() { 'softwareProduct.softwareProductValidation.vspChecks', vspChecksList ); - mockRest.addHandler('fetch', ({ baseUrl }) => { + mockRest.addHandler('fetch', ({ options, data, baseUrl }) => { expect(baseUrl).toEqual( `${restPrefix}/v1.0/externaltesting/testcasetree` ); return vspChecksList; }); - return SoftwareProductValidationActionHelper.fetchVspChecks( + SoftwareProductValidationActionHelper.fetchVspChecks( store.dispatch ) .then(() => { diff --git a/openecomp-ui/test/versionsPage/VersionsPage.test.js b/openecomp-ui/test/versionsPage/VersionsPage.test.js index fd7659e70e..d785c992e9 100644 --- a/openecomp-ui/test/versionsPage/VersionsPage.test.js +++ b/openecomp-ui/test/versionsPage/VersionsPage.test.js @@ -16,7 +16,7 @@ import React from 'react'; import ShallowRenderer from 'react-test-renderer/shallow'; -import {mount} from 'enzyme'; +// import {mount} from 'enzyme'; import {Provider} from 'react-redux'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; diff --git a/openecomp-ui/webpack.config.js b/openecomp-ui/webpack.config.js index a007714a2e..225ebcc02a 100644 --- a/openecomp-ui/webpack.config.js +++ b/openecomp-ui/webpack.config.js @@ -59,7 +59,15 @@ module.exports = (env, argv) => { { test: /\.(js|jsx)$/, include: path.resolve(__dirname, 'src'), - use: [{ loader: 'babel-loader' }] + use: [ + { + loader: 'babel-loader', + options: { + presets: ['@babel/preset-env'], // Add any additional presets like @babel/preset-react if necessary + cacheDirectory: true + } + } + ] }, { test: /\.(js|jsx)$/, |