Merge "Increase code coverage" 1.3.0
authorJames Forsyth <jf2512@att.com>
Thu, 11 Oct 2018 13:16:50 +0000 (13:16 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 11 Oct 2018 13:16:50 +0000 (13:16 +0000)
resources/scss/header/_layout.scss
scripts/build/build.sh
src/app/MainScreenWrapper.jsx
src/app/contextHandler/ContextHandlerActions.js
src/app/networking/NetworkCalls.js
src/generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.jsx
src/generic-components/notifications/NotificationReducer.js
test/generic-components/notifications/NotificationReducer.test.js [new file with mode: 0644]

index aca42ce..14d90ac 100644 (file)
     .vnf-search-button-icon {
       background-image: url($icons-folder-path + '/vnfSearchicon.png');
     }
+
+    .configurable-view-button-icon {
+      background-image: url($icons-folder-path + '/reports.svg');
+      -webkit-filter: brightness(500);
+      filter: brightness(500);
+    }
   }
 
   .main-menu-button:hover, .main-menu-button:focus {
     .vnf-search-button-icon {
       background-image: url($icons-folder-path + '/vnfSearchicon_hover.png');
     }
+
+    .configurable-view-button-icon {
+      background-image: url($icons-folder-path + '/reports.svg');
+      -webkit-filter: brightness(1);
+      filter: brightness(1);
+    }
   }
 
   .main-menu-button-active {
     width: 100%;
     height: 90px;
     text-align: center;
+    padding-top: 5px;
 
     .view-inspect-button-icon {
       background-image: url($icons-folder-path + '/binocularicon_active.png');
     .vnf-search-button-icon {
       background-image: url($icons-folder-path + '/vnfSearchicon_active.png');
     }
+
+    .configurable-view-button-icon {
+      background-image: url($icons-folder-path + '/reports.svg');
+      -webkit-filter: brightness(0.55);
+      filter: brightness(0.55);
+    }
   }
 
   .search-bar {
index 7af49cd..24ede22 100644 (file)
@@ -149,6 +149,7 @@ else
   npm install --save ${extensionList}
   # copy content when there are extensions
   UpdateFEwithExtensions
+  UpdateFEWithCustomViews
 fi
 
 # Copy style
index 730ac93..3348494 100644 (file)
@@ -140,6 +140,8 @@ class MainScreenWrapper extends Component {
       extensibleViewNetworkCallbackData,
       onExtensibleViewMessageCallback,
       onOverlayNetworkCallback,
+      configurableViewsConfig,
+      customComponents,
       customRoutes
     } = this.props;
 
@@ -199,6 +201,8 @@ class MainScreenWrapper extends Component {
 
     });
 
+    let configurableViewList = getConfigurableRoutes(configurableViewsConfig, customComponents);
+
     return (
       <Router>
         <div className='main-app-container'>
@@ -210,6 +214,7 @@ class MainScreenWrapper extends Component {
           <Route key='VnfSearchRoute' path='/vnfSearch/:filters?' component={VnfSearch}/>
           {customViewList}
           {customRoutes}
+          {configurableViewList}
         </div>
       </Router>
     );
index b4805e1..f3ede6d 100644 (file)
@@ -105,7 +105,8 @@ function fetchSubscriptionPayload(fetchRequestCallback) {
 
 export function getSubscriptionPayload() {
   let externalfetchRequest =
-    () => networkCall.getRequest(SUBSCRIPTION_PAYLOAD_URL, GET);
+  () => networkCall.getRequest(SUBSCRIPTION_PAYLOAD_URL, GET);
+  
   return dispatch => {
     dispatch(fetchSubscriptionPayload(externalfetchRequest));
   };
index e391391..9bf7535 100644 (file)
@@ -55,9 +55,7 @@ function getRequest(URL, GET) {
   return fetch(URL, {
     credentials: 'same-origin',
     method: GET
-  }).then(
-    (response) => response.json()
-  );
+  });
 }
 
 const genericRequest = (url, relativeURL, httpMethodType) => {
index 4f93125..47cdc9a 100644 (file)
@@ -164,7 +164,8 @@ export default class AutoCompleteSearchBar extends Component {
                     <Highlighter key={arrayIndex + 'high'}
                                  highlightClassName='highlight'
                                  searchWords={toHighLightArray}
-                                 textToHighlight={suggestionTextArray[arrayIndex]}/>
+                                 textToHighlight={suggestionTextArray[arrayIndex]}
+                                 autoEscape={true}/>
                     { ++arrayIndex ? ' ' : ' '}
                  </span>);
 
@@ -185,7 +186,8 @@ export default class AutoCompleteSearchBar extends Component {
                       <Highlighter key={arrayIndex + 'high'}
                                    highlightClassName='highlight'
                                    searchWords={toHighLightArray}
-                                   textToHighlight={suggestionTextArray[arrayIndex]}/>
+                                   textToHighlight={suggestionTextArray[arrayIndex]}
+                                   autoEscape={true}/>
                       { ++arrayIndex ? ' ' : ' '}
                    </span>);
 
index e20a8fb..1f5122c 100644 (file)
 import NotificationConstants from './NotificationConstants.js';
 
 export default (state = null, action) => {
-  switch (action.type) {
-    case NotificationConstants.NOTIFY_INFO:
-      return {
-        type: 'default',
-        title: action.data.title,
-        msg: action.data.msg,
-        timeout: action.data.timeout
-      };
-    
-    case NotificationConstants.NOTIFY_ERROR:
-      return {
-        type: 'error',
-        title: action.data.title,
-        msg: action.data.msg,
-        timeout: action.data.timeout
-      };
-    
-    case NotificationConstants.NOTIFY_WARNING:
-      return {
-        type: 'warning',
-        title: action.data.title,
-        msg: action.data.msg,
-        timeout: action.data.timeout
-      };
-    
-    case NotificationConstants.NOTIFY_SUCCESS:
-      return {
-        type: 'success',
+    switch (action.type) {
+        case NotificationConstants.NOTIFY_INFO:
+            return createStatus('default', action);
+        case NotificationConstants.NOTIFY_ERROR:
+            return createStatus('error', action);
+        case NotificationConstants.NOTIFY_WARNING:
+            return createStatus('warning', action);
+        case NotificationConstants.NOTIFY_SUCCESS:
+            return createStatus('success', action);
+        case NotificationConstants.NOTIFY_CLOSE:
+            return null;
+        default:
+            return state;
+    }
+
+};
+
+function createStatus(type, action) {
+    return {
+        type: type,
         title: action.data.title,
         msg: action.data.msg,
         timeout: action.data.timeout
-      };
-    case NotificationConstants.NOTIFY_CLOSE:
-      return null;
-    
-    default:
-      return state;
-  }
-  
-};
+    };
+}
diff --git a/test/generic-components/notifications/NotificationReducer.test.js b/test/generic-components/notifications/NotificationReducer.test.js
new file mode 100644 (file)
index 0000000..40d6b05
--- /dev/null
@@ -0,0 +1,197 @@
+import NotificationReducer from 'generic-components/notifications/NotificationReducer';
+import NotificationConstants from "generic-components/notifications/NotificationConstants";
+
+
+describe('NotificationReducer', () => {
+    const defaultState = {
+        type: 'default',
+        title: 'some default title',
+        msg: 'some default message',
+        timeout: 1
+    };
+
+    it('Should return default state when action type is not supported', () => {
+        // given
+        const unsupportedAction = {
+            type: undefined
+        };
+
+        // when
+        const actualState = NotificationReducer(defaultState, unsupportedAction);
+
+        // then
+        expect(actualState).toEqual(defaultState);
+    });
+
+    it('Should return state with type default when action type is info', () => {
+        // given
+        const expectedState = {
+            type: 'default',
+            title: 'some title',
+            msg: 'some message',
+            timeout: 5
+        };
+
+        const infoAction =  {
+            type: NotificationConstants.NOTIFY_INFO,
+            data: {
+                title: "some title",
+                msg: "some message",
+                timeout: 5
+            }
+        };
+
+        // when
+        const actualState = NotificationReducer(defaultState, infoAction);
+
+        // then
+        expect(actualState).toEqual(expectedState);
+    });
+
+
+    it('Should return status with type success when action type is success', () => {
+        // given
+        const expectedState = {
+            type: 'success',
+            title: 'some title',
+            msg: 'some message',
+            timeout: 2
+        };
+
+        const infoAction =  {
+            type: NotificationConstants.NOTIFY_SUCCESS,
+            data: {
+                title: "some title",
+                msg: "some message",
+                timeout: 2
+            }
+        };
+
+        // when
+        const actualState = NotificationReducer(defaultState, infoAction);
+
+        // then
+        expect(actualState).toEqual(expectedState);
+    });
+
+    it('Should return status with type success when action type is success', () => {
+        // given
+        const expectedState = {
+            type: 'success',
+            title: 'some title',
+            msg: 'some message',
+            timeout: 2
+        };
+
+        const infoAction =  {
+            type: NotificationConstants.NOTIFY_SUCCESS,
+            data: {
+                title: "some title",
+                msg: "some message",
+                timeout: 2
+            }
+        };
+
+        // when
+        const actualState = NotificationReducer(defaultState, infoAction);
+
+        // then
+        expect(actualState).toEqual(expectedState);
+    });
+
+    it('Should return status with type error when action type is error', () => {
+        // given
+        const expectedState = {
+            type: 'error',
+            title: 'some title',
+            msg: 'some message',
+            timeout: 2
+        };
+
+        const infoAction =  {
+            type: NotificationConstants.NOTIFY_ERROR,
+            data: {
+                title: "some title",
+                msg: "some message",
+                timeout: 2
+            }
+        };
+
+        // when
+        const actualState = NotificationReducer(defaultState, infoAction);
+
+        // then
+        expect(actualState).toEqual(expectedState);
+    });
+
+    it('Should return status with type error when action type is error', () => {
+        // given
+        const expectedState = {
+            type: 'error',
+            title: 'some title',
+            msg: 'some message',
+            timeout: 2
+        };
+
+        const infoAction =  {
+            type: NotificationConstants.NOTIFY_ERROR,
+            data: {
+                title: "some title",
+                msg: "some message",
+                timeout: 2
+            }
+        };
+
+        // when
+        const actualState = NotificationReducer(defaultState, infoAction);
+
+        // then
+        expect(actualState).toEqual(expectedState);
+    });
+
+    it('Should return status with type warning when action type is warning', () => {
+        // given
+        const expectedState = {
+            type: 'warning',
+            title: 'some title',
+            msg: 'some message',
+            timeout: 2
+        };
+
+        const infoAction =  {
+            type: NotificationConstants.NOTIFY_WARNING,
+            data: {
+                title: "some title",
+                msg: "some message",
+                timeout: 2
+            }
+        };
+
+        // when
+        const actualState = NotificationReducer(defaultState, infoAction);
+
+        // then
+        expect(actualState).toEqual(expectedState);
+    });
+
+    it('Should return null when action type is close', () => {
+        // given
+        const expectedState = null;
+
+        const infoAction =  {
+            type: NotificationConstants.NOTIFY_CLOSE,
+            data: {
+                title: "some title",
+                msg: "some message",
+                timeout: 2
+            }
+        };
+
+        // when
+        const actualState = NotificationReducer(defaultState, infoAction);
+
+        // then
+        expect(actualState).toEqual(expectedState);
+    });
+
+});