From 6b633d47c65336649c4fb64e7a4c86157368d462 Mon Sep 17 00:00:00 2001
From: Ramesh Kumar <r.kumar@redkarma.eu>
Date: Wed, 2 Sep 2020 10:36:05 +0530
Subject: [PATCH] TMSS-312: Test Scripts for Project Create, View and Edit
 pages are updated.

---
 SAS/TMSS/frontend/tmss_webapp/src/App.css     |   2 +-
 .../src/__mocks__/project.service.data.js     | 114 ++----------------
 .../src/routes/Project/ResourceInputList.js   |   1 +
 .../src/routes/Project/create.test.js         |  52 ++++----
 .../src/routes/Project/edit.test.js           |  44 +++----
 .../src/routes/Project/view.test.js           |   2 +-
 6 files changed, 67 insertions(+), 148 deletions(-)

diff --git a/SAS/TMSS/frontend/tmss_webapp/src/App.css b/SAS/TMSS/frontend/tmss_webapp/src/App.css
index f77eebacaca..8f8060fe51b 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/App.css
+++ b/SAS/TMSS/frontend/tmss_webapp/src/App.css
@@ -94,7 +94,7 @@ p {
   margin-bottom: 10px;
 }
 
-.p-chips-token span {
+.p-chips-token,.p-inputnumber span {
   margin-bottom: 0px;
 }
 
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/project.service.data.js b/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/project.service.data.js
index 066fd339758..42680f340c6 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/project.service.data.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/project.service.data.js
@@ -7,180 +7,90 @@ const ProjectServiceMock= {
         "url": "http://localhost:3000/api/resource_type/LOFAR%20Observing%20Time/",
         "created_at": "2020-07-29T07:31:21.708296",
         "description": "LOFAR Observing Time",
-        "resource_unit": "http://localhost:3000/api/resource_unit/second/",
-        "resource_unit_id": "second",
         "tags": [
         ],
         "updated_at": "2020-07-29T07:31:21.708316",
-        "resourceUnit": {
-            "name": "second",
-            "url": "http://localhost:3000/api/resource_unit/second/",
-            "created_at": "2020-07-29T07:31:21.070088",
-            "description": "Unit of time or duration",
-            "tags": [
-            ],
-            "updated_at": "2020-07-29T07:31:21.070114"
-        }
+        "quantity_value": "time"
     },
     {
         "name": "LOFAR Observing Time prio A",
         "url": "http://localhost:3000/api/resource_type/LOFAR%20Observing%20Time%20prio%20A/",
         "created_at": "2020-07-29T07:31:21.827537",
         "description": "LOFAR Observing Time prio A",
-        "resource_unit": "http://localhost:3000/api/resource_unit/second/",
-        "resource_unit_id": "second",
         "tags": [
         ],
         "updated_at": "2020-07-29T07:31:21.827675",
-        "resourceUnit": {
-            "name": "second",
-            "url": "http://localhost:3000/api/resource_unit/second/",
-            "created_at": "2020-07-29T07:31:21.070088",
-            "description": "Unit of time or duration",
-            "tags": [
-            ],
-            "updated_at": "2020-07-29T07:31:21.070114"
-        }
+        "quantity_value": "time"
     },
     {
         "name": "LOFAR Observing Time prio B",
         "url": "http://localhost:3000/api/resource_type/LOFAR%20Observing%20Time%20prio%20B/",
         "created_at": "2020-07-29T07:31:21.950948",
         "description": "LOFAR Observing Time prio B",
-        "resource_unit": "http://localhost:3000/api/resource_unit/second/",
-        "resource_unit_id": "second",
         "tags": [
         ],
         "updated_at": "2020-07-29T07:31:21.950968",
-        "resourceUnit": {
-            "name": "second",
-            "url": "http://localhost:3000/api/resource_unit/second/",
-            "created_at": "2020-07-29T07:31:21.070088",
-            "description": "Unit of time or duration",
-            "tags": [
-            ],
-            "updated_at": "2020-07-29T07:31:21.070114"
-        }
+        "quantity_value": "time"
     },
     {
         "name": "CEP Processing Time",
         "url": "http://localhost:3000/api/resource_type/CEP%20Processing%20Time/",
         "created_at": "2020-07-29T07:31:22.097916",
         "description": "CEP Processing Time",
-        "resource_unit": "http://localhost:3000/api/resource_unit/second/",
-        "resource_unit_id": "second",
         "tags": [
         ],
         "updated_at": "2020-07-29T07:31:22.097941",
-        "resourceUnit": {
-            "name": "second",
-            "url": "http://localhost:3000/api/resource_unit/second/",
-            "created_at": "2020-07-29T07:31:21.070088",
-            "description": "Unit of time or duration",
-            "tags": [
-            ],
-            "updated_at": "2020-07-29T07:31:21.070114"
-        }
+        "quantity_value": "time"
     },
     {
         "name": "LTA Storage",
         "url": "http://localhost:3000/api/resource_type/LTA%20Storage/",
         "created_at": "2020-07-29T07:31:22.210071",
         "description": "LTA Storage",
-        "resource_unit": "http://localhost:3000/api/resource_unit/byte/",
-        "resource_unit_id": "byte",
         "tags": [
         ],
         "updated_at": "2020-07-29T07:31:22.210091",
-        "resourceUnit": {
-            "name": "byte",
-            "url": "http://localhost:3000/api/resource_unit/byte/",
-            "created_at": "2020-07-29T07:31:21.500997",
-            "description": "Unit of data storage",
-            "tags": [
-            ],
-            "updated_at": "2020-07-29T07:31:21.501028"
-        }
+        "quantity_value": "bytes"
     },
     {
         "name": "Number of triggers",
         "url": "http://localhost:3000/api/resource_type/Number%20of%20triggers/",
         "created_at": "2020-07-29T07:31:22.317313",
         "description": "Number of triggers",
-        "resource_unit": "http://localhost:3000/api/resource_unit/number/",
-        "resource_unit_id": "number",
         "tags": [
         ],
         "updated_at": "2020-07-29T07:31:22.317341",
-        "resourceUnit": {
-            "name": "number",
-            "url": "http://localhost:3000/api/resource_unit/number/",
-            "created_at": "2020-07-29T07:31:21.596364",
-            "description": "Unit of count",
-            "tags": [
-            ],
-            "updated_at": "2020-07-29T07:31:21.596385"
-        }
+        "quantity_value": "number"
     },
     {
         "name": "LOFAR Support Time",
         "url": "http://localhost:3000/api/resource_type/LOFAR%20Support%20Time/",
         "created_at": "2020-07-29T07:31:22.437945",
         "description": "LOFAR Support Time",
-        "resource_unit": "http://localhost:3000/api/resource_unit/second/",
-        "resource_unit_id": "second",
         "tags": [
         ],
         "updated_at": "2020-07-29T07:31:22.437964",
-        "resourceUnit": {
-            "name": "second",
-            "url": "http://localhost:3000/api/resource_unit/second/",
-            "created_at": "2020-07-29T07:31:21.070088",
-            "description": "Unit of time or duration",
-            "tags": [
-            ],
-            "updated_at": "2020-07-29T07:31:21.070114"
-        }
+        "quantity_value": "time"
     },
     {
         "name": "LOFAR Support hours",
         "url": "http://localhost:3000/api/resource_type/LOFAR%20Support%20hours/",
         "created_at": "2020-07-29T07:31:22.571850",
         "description": "LOFAR Support hours",
-        "resource_unit": "http://localhost:3000/api/resource_unit/second/",
-        "resource_unit_id": "second",
         "tags": [
         ],
         "updated_at": "2020-07-29T07:31:22.571869",
-        "resourceUnit": {
-            "name": "second",
-            "url": "http://localhost:3000/api/resource_unit/second/",
-            "created_at": "2020-07-29T07:31:21.070088",
-            "description": "Unit of time or duration",
-            "tags": [
-            ],
-            "updated_at": "2020-07-29T07:31:21.070114"
-        }
+        "quantity_value": "time"
     },
     {
         "name": "Support hours",
         "url": "http://localhost:3000/api/resource_type/Support%20hours/",
         "created_at": "2020-07-29T07:31:22.694438",
         "description": "Support hours",
-        "resource_unit": "http://localhost:3000/api/resource_unit/second/",
-        "resource_unit_id": "second",
         "tags": [
         ],
         "updated_at": "2020-07-29T07:31:22.694514",
-        "resourceUnit": {
-            "name": "second",
-            "url": "http://localhost:3000/api/resource_unit/second/",
-            "created_at": "2020-07-29T07:31:21.070088",
-            "description": "Unit of time or duration",
-            "tags": [
-            ],
-            "updated_at": "2020-07-29T07:31:21.070114"
-        }
+        "quantity_value": "time"
     }
     ],
     projectResourceDefaults: {
@@ -212,7 +122,7 @@ const ProjectServiceMock= {
         "private_data": true,
         "project_category": "Regular",
         "project_category_value": "Regular",
-        "project_quota": [
+        "quota": [
           "http://192.168.99.100:8008/api/project_quota/70/",
           "http://192.168.99.100:8008/api/project_quota/71/",
           "http://192.168.99.100:8008/api/project_quota/72/",
@@ -222,7 +132,7 @@ const ProjectServiceMock= {
           "http://192.168.99.100:8008/api/project_quota/76/",
           "http://192.168.99.100:8008/api/project_quota/77/"
         ],
-        "project_quota_ids": [
+        "quota_ids": [
           70,
           71,
           72,
@@ -307,7 +217,7 @@ const ProjectServiceMock= {
           "project_id": "OSR-11",
           "resource_type": "http://192.168.99.100:8008/api/resource_type/Support%20hours/",
           "resource_type_id": "Support hours",
-          "value": 8
+          "value": 32400
         }
       ]
 }
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/ResourceInputList.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/ResourceInputList.js
index c1d9019421f..d074a38c1ee 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/ResourceInputList.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/ResourceInputList.js
@@ -41,6 +41,7 @@ export class ResourceInputList extends Component {
                         <InputNumber key={'item1-'+ index} id={'item1-'+ index} name={'item1-'+ index}
                             suffix={` ${this.props.unitMap[item.quantity_value]?this.props.unitMap[item.quantity_value].display:''}`}
                             placeholder={` ${this.props.unitMap[item.quantity_value]?this.props.unitMap[item.quantity_value].display:item.name}`} min={0} useGrouping={false}
+                            inputId={`${item.name}`} min={0} useGrouping={false}
                             value={this.state.projectQuota[item.name]} 
                             onChange={(e) => this.onInputChange(item.name, e)}
                             onBlur={(e) => this.onInputChange(item.name, e)}
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.test.js
index 84c2b338449..7eccc6d8e88 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.test.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.test.js
@@ -3,6 +3,7 @@ import { BrowserRouter as Router } from 'react-router-dom';
 import { act } from "react-dom/test-utils";
 import { render, cleanup, fireEvent } from '@testing-library/react';
 import '@testing-library/jest-dom/extend-expect';
+import _ from 'lodash';
 
 import {ProjectCreate} from './create';
 import ProjectService from '../../services/project.service';
@@ -65,6 +66,7 @@ it("renders without crashing with all back-end data loaded", async () => {
     await act(async () => {
         content = render(<Router><ProjectCreate /></Router>);
     });
+    const spinButtons = content.queryAllByRole("spinbutton");
     
     expect(content.queryByText('Project - Add')).not.toBe(null);        // Page loaded successfully
     expect(projectCategoriesSpy).toHaveBeenCalled();                    // Mock Spy called successfully
@@ -73,8 +75,8 @@ it("renders without crashing with all back-end data loaded", async () => {
     expect(content.queryByText('Cycle-0')).toBeInTheDocument();         // Cycle multi-select loaded successfully
     expect(content.queryAllByText('Add Resources').length).toBe(2);     // Resource Dropdown loaded successfully
     expect(content.queryByText('Support hours')).toBeInTheDocument();         // Resources other than Default Resources listed in dropdown
-    expect(content.queryByPlaceholderText('Support Hours')).toBe(null);       // No resources other than Default Resources listed to get input
-    expect(content.queryByPlaceholderText('LOFAR Observing Time').value).toBe('1 Hours');         // Default Resource Listed with default value
+    expect(_.filter(spinButtons, {"id": "Support hours"}).length).toBe(0);       // No resources other than Default Resources listed to get input
+    expect(_.filter(spinButtons, {"id": "LOFAR Observing Time"})[0].value).toBe('1 Hours');         // Default Resource Listed with default value
 });
 
 it("Save button disabled initially when no data entered", async () => {
@@ -222,31 +224,31 @@ it("save project with default resources", async () => {
     expect(content.queryByTestId('projectId').value).toBe("");
     expect(content.queryByText("Success")).toBe(null);
     
-    const lofarObsTimeInput = content.queryByPlaceholderText('LOFAR Observing Time');
+    const lofarObsTimeInput = _.filter(spinButtons, {"id": "LOFAR Observing Time"})[0];
     fireEvent.change(lofarObsTimeInput, { target: { value: 10 } });
     expect(lofarObsTimeInput.value).toBe('10');
     
-    const lofarObsTimeAInput = content.queryByPlaceholderText('LOFAR Observing Time prio A');
+    const lofarObsTimeAInput = _.filter(spinButtons, {"id": "LOFAR Observing Time prio A"})[0];
     fireEvent.change(lofarObsTimeAInput, { target: { value: 15 } });
     expect(lofarObsTimeAInput.value).toBe('15');
     
-    const lofarObsTimeBInput = content.queryByPlaceholderText('LOFAR Observing Time prio B');
+    const lofarObsTimeBInput = _.filter(spinButtons, {"id": "LOFAR Observing Time prio B"})[0];
     fireEvent.change(lofarObsTimeBInput, { target: { value: 20 } });
     expect(lofarObsTimeBInput.value).toBe('20');
     
-    const cepProcTimeInput = content.queryByPlaceholderText('CEP Processing Time');
+    const cepProcTimeInput = _.filter(spinButtons, {"id": "CEP Processing Time"})[0];
     fireEvent.change(cepProcTimeInput, { target: { value: 5 } });
     expect(cepProcTimeInput.value).toBe('5');
     
-    const ltaStorageInput = content.queryByPlaceholderText('LTA Storage');
+    const ltaStorageInput = _.filter(spinButtons, {"id": "LTA Storage"})[0];
     fireEvent.change(ltaStorageInput, { target: { value: 2 } });
     expect(ltaStorageInput.value).toBe('2');
     
-    const noOfTriggerInput = content.queryByPlaceholderText('Number of triggers');
+    const noOfTriggerInput = _.filter(spinButtons, {"id": "Number of triggers"})[0];
     fireEvent.change(noOfTriggerInput, { target: { value: 3 } });
     expect(noOfTriggerInput.value).toBe('3');
     
-    const lofarSupTimeInput = content.queryByPlaceholderText('LOFAR Support Time');
+    const lofarSupTimeInput = _.filter(spinButtons, {"id": "LOFAR Support Time"})[0];
     fireEvent.change(lofarSupTimeInput, { target: { value: 25 } });
     expect(lofarSupTimeInput.value).toBe('25');
     
@@ -268,7 +270,7 @@ it("save project with added resources", async () => {
 
     const nameInput = content.queryByTestId('name');
     const descInput = content.queryByTestId('description');
-    const spinButtons = content.queryAllByRole("spinbutton");
+    let spinButtons = content.queryAllByRole("spinbutton");
     const rankInput = spinButtons.filter(function(element) { return element.id==="proj-rank"})[0];
 
     fireEvent.change(nameInput, { target: { value: 'OSR' } });
@@ -281,31 +283,31 @@ it("save project with added resources", async () => {
     expect(content.queryByTestId('projectId').value).toBe("");
     expect(content.queryByText("Success")).toBe(null);
     
-    const lofarObsTimeInput = content.queryByPlaceholderText('LOFAR Observing Time');
+    const lofarObsTimeInput = _.filter(spinButtons, {"id": "LOFAR Observing Time"})[0];
     fireEvent.change(lofarObsTimeInput, { target: { value: 10 } });
     expect(lofarObsTimeInput.value).toBe('10');
     
-    const lofarObsTimeAInput = content.queryByPlaceholderText('LOFAR Observing Time prio A');
+    const lofarObsTimeAInput = _.filter(spinButtons, {"id": "LOFAR Observing Time prio A"})[0];
     fireEvent.change(lofarObsTimeAInput, { target: { value: 15 } });
     expect(lofarObsTimeAInput.value).toBe('15');
     
-    const lofarObsTimeBInput = content.queryByPlaceholderText('LOFAR Observing Time prio B');
+    const lofarObsTimeBInput = _.filter(spinButtons, {"id": "LOFAR Observing Time prio B"})[0];
     fireEvent.change(lofarObsTimeBInput, { target: { value: 20 } });
     expect(lofarObsTimeBInput.value).toBe('20');
     
-    const cepProcTimeInput = content.queryByPlaceholderText('CEP Processing Time');
+    const cepProcTimeInput = _.filter(spinButtons, {"id": "CEP Processing Time"})[0];
     fireEvent.change(cepProcTimeInput, { target: { value: 5 } });
     expect(cepProcTimeInput.value).toBe('5');
     
-    const ltaStorageInput = content.queryByPlaceholderText('LTA Storage');
+    const ltaStorageInput = _.filter(spinButtons, {"id": "LTA Storage"})[0];
     fireEvent.change(ltaStorageInput, { target: { value: 2 } });
     expect(ltaStorageInput.value).toBe('2');
     
-    const noOfTriggerInput = content.queryByPlaceholderText('Number of triggers');
+    const noOfTriggerInput = _.filter(spinButtons, {"id": "Number of triggers"})[0];
     fireEvent.change(noOfTriggerInput, { target: { value: 3 } });
     expect(noOfTriggerInput.value).toBe('3');
     
-    const lofarSupTimeInput = content.queryByPlaceholderText('LOFAR Support Time');
+    const lofarSupTimeInput = _.filter(spinButtons, {"id": "LOFAR Support Time"})[0];
     fireEvent.change(lofarSupTimeInput, { target: { value: 25 } });
     expect(lofarSupTimeInput.value).toBe('25');
     
@@ -313,7 +315,7 @@ it("save project with added resources", async () => {
     expect(content.queryAllByText('Add Resources').length).toBe(2);
     expect(content.queryAllByText('Support hours').length).toBe(1);
     expect(content.getAllByRole("listbox")[3].children.length).toBe(2);
-    expect(content.queryByPlaceholderText('Support hours')).toBe(null);
+    expect(_.filter(spinButtons, {"id": "Support hours"}).length).toBe(0);
     const addResourceInput = content.getAllByRole("listbox")[3].children[1] ;
     fireEvent.click(addResourceInput);
     // After selecting New Resource
@@ -323,9 +325,10 @@ it("save project with added resources", async () => {
     const addResourceBtn = content.queryByTestId('add_res_btn');
     fireEvent.click(addResourceBtn);
     expect(content.queryAllByText('Add Resources').length).toBe(2);
-    expect(content.queryByPlaceholderText('Support hours')).not.toBe(null);
+    spinButtons = content.queryAllByRole("spinbutton");
 
-    const newResourceInput = content.queryByPlaceholderText('Support hours');
+    const newResourceInput = _.filter(spinButtons, {"id": "Support hours"})[0];
+    expect(newResourceInput).not.toBe(null);
     fireEvent.change(newResourceInput, { target: { value: 30 } });
     expect(newResourceInput.value).toBe('30');
     
@@ -360,15 +363,18 @@ it("remove default resource and added resource", async () => {
     const addResourceBtn = content.queryByTestId('add_res_btn');
     fireEvent.click(addResourceBtn);
     expect(content.queryAllByText('Add Resources').length).toBe(2);
-    expect(content.queryByPlaceholderText('Support hours')).not.toBe(null);
 
-    expect(content.queryByPlaceholderText('CEP Processing Time')).not.toBe(null);
+    const spinButtons = content.queryAllByRole("spinbutton");
+    
+    expect(_.filter(spinButtons, {"id": "Support hours"})[0]).not.toBe(null);
+
+    expect(_.filter(spinButtons, {"id": "CEP Processing Time"})[0]).not.toBe(null);
     expect(content.queryByTestId('CEP Processing Time-btn')).not.toBe(null);
     const removeDefResBtn = content.queryByTestId('CEP Processing Time-btn');
     await act(async () => {
         fireEvent.click(content.queryByTestId('CEP Processing Time-btn'));
     });
-    expect(content.queryByPlaceholderText('CEP Processing Time')).toBe(null);
+    expect(_.filter(spinButtons, {"id": "CEP Processing Time"}).length).toBe(0);
     expect(content.queryByTestId('CEP Processing Time-btn')).toBe(null);
 
     const removeResourceBtn = content.queryByTestId('Support hours-btn');
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/edit.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/edit.test.js
index dd13177fac9..eae81b7db67 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/edit.test.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/edit.test.js
@@ -112,10 +112,10 @@ it("renders input fields with Project details if found", async () => {
     expect(content.queryByTestId("name").value).toBe('OSR-11');
 
     const spinButtons = content.queryAllByRole("spinbutton");
-    const trigPrioInput = spinButtons.filter(function(element) { return element.id==="trig_prio"})[0];
+    const trigPrioInput = _.filter(spinButtons, {"id": "trig_prio"})[0];
     expect(trigPrioInput.value).toBe("990"); 
     
-    const rankInput = spinButtons.filter(function(element) { return element.id==="proj-rank"})[0];
+    const rankInput = _.filter(spinButtons, {"id": "proj-rank"})[0];
     expect(rankInput.value).toBe("5"); 
 
     const trigger = content.getAllByLabelText(/trigger/i).filter((element) => { return element.id==="trigger"})[0];
@@ -132,15 +132,15 @@ it("renders input fields with Project details if found", async () => {
     const cycleInput = content.getAllByRole("listbox")[2] ;
     expect(content.queryAllByText('Cycle 0').length).toBe(2);
 
-    expect(content.queryByPlaceholderText("CEP Processing Time").value).toBe("10 Hours");
-    expect(content.queryByPlaceholderText("LOFAR Observing Time").value).toBe("20 Hours");
-    expect(content.queryByPlaceholderText("LOFAR Observing Time prio A").value).toBe("30 Hours");
-    expect(content.queryByPlaceholderText("LOFAR Observing Time prio B").value).toBe("40 Hours");
-    expect(content.queryByPlaceholderText("LOFAR Support Time").value).toBe("50 Hours");
-    expect(content.queryByPlaceholderText("LTA Storage").value).toBe("6 TB");
-    expect(content.queryByPlaceholderText("Number of triggers").value).toBe("7 Numbers");
-    expect(content.queryByPlaceholderText("Support hours").value).toBe("8 ");
-
+    expect(_.filter(spinButtons, {"id": "CEP Processing Time"})[0].value).toBe("10 Hours");
+    expect(_.filter(spinButtons, {"id": "LOFAR Observing Time"})[0].value).toBe("20 Hours");
+    expect(_.filter(spinButtons, {"id": "LOFAR Observing Time prio A"})[0].value).toBe("30 Hours");
+    expect(_.filter(spinButtons, {"id": "LOFAR Observing Time prio B"})[0].value).toBe("40 Hours");
+    expect(_.filter(spinButtons, {"id": "LOFAR Support Time"})[0].value).toBe("50 Hours");
+    expect(_.filter(spinButtons, {"id": "LTA Storage"})[0].value).toBe("6 TB");
+    expect(_.filter(spinButtons, {"id": "Number of triggers"})[0].value).toBe("7 Numbers");
+    expect(_.filter(spinButtons, {"id": "Support hours"})[0].value).toBe("9 Hours");
+    
     expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy();
 
 });
@@ -157,11 +157,11 @@ it("save Project after editing fields", async () => {
     expect(content.queryByTestId("name").value).toBe('OSR-11');
 
     const spinButtons = content.queryAllByRole("spinbutton");
-    const trigPrioInput = spinButtons.filter(function(element) { return element.id==="trig_prio"})[0];
+    const trigPrioInput = _.filter(spinButtons, {"id": "trig_prio"})[0];
     fireEvent.blur(trigPrioInput, { target: { value: 900 } });
     expect(trigPrioInput.value).toBe("900"); 
     
-    const rankInput = spinButtons.filter(function(element) { return element.id==="proj-rank"})[0];
+    const rankInput = _.filter(spinButtons, {"id": "proj-rank"})[0];
     fireEvent.blur(rankInput, { target: { value: 2 } });
     expect(rankInput.value).toBe("2");
 
@@ -190,19 +190,19 @@ it("save Project after editing fields", async () => {
     expect(content.queryAllByText('Cycle-0').length).toBe(2);
     expect(content.queryAllByText('Cycle 0').length).toBe(1);
 
-    const lofarObsTimeInput = content.queryByPlaceholderText('LOFAR Observing Time');
+    const lofarObsTimeInput = _.filter(spinButtons, {"id": "LOFAR Observing Time"})[0];
     fireEvent.blur(lofarObsTimeInput, { target: { value: 10 } });
     expect(lofarObsTimeInput.value).toBe('10 Hours');
     
-    const cepProcTimeInput = content.queryByPlaceholderText('CEP Processing Time');
+    const cepProcTimeInput = _.filter(spinButtons, {"id": "CEP Processing Time"})[0];
     fireEvent.blur(cepProcTimeInput, { target: { value: 5 } });
     expect(cepProcTimeInput.value).toBe('5 Hours');
     
-    const ltaStorageInput = content.queryByPlaceholderText('LTA Storage');
+    const ltaStorageInput = _.filter(spinButtons, {"id": "LTA Storage"})[0];
     fireEvent.blur(ltaStorageInput, { target: { value: 2 } });
     expect(ltaStorageInput.value).toBe('2 TB');
     
-    const noOfTriggerInput = content.queryByPlaceholderText('Number of triggers');
+    const noOfTriggerInput = _.filter(spinButtons, {"id": "Number of triggers"})[0];
     fireEvent.blur(noOfTriggerInput, { target: { value: 3 } });
     expect(noOfTriggerInput.value).toBe('3 Numbers');
     
@@ -238,13 +238,15 @@ it("save Project after adding, modifying and deleting resources", async () => {
     const addResourceBtn = content.queryByTestId('add_res_btn');
     fireEvent.click(addResourceBtn);
     expect(content.queryAllByText('Add Resources').length).toBe(2);
-    expect(content.queryByPlaceholderText('LOFAR Support hours')).not.toBe(null);
-    const lofarSupHrsInput = content.queryByPlaceholderText('LOFAR Support hours');
+    
+    const spinButtons = content.queryAllByRole("spinbutton");
+    const lofarSupHrsInput = _.filter(spinButtons, {"id": "LOFAR Support hours"})[0];
+    expect(lofarSupHrsInput).not.toBe(null);
     fireEvent.blur(lofarSupHrsInput, { target: { value: 100 } });
-    expect(lofarSupHrsInput.value).toBe('100 ');
+    expect(lofarSupHrsInput.value).toBe('100 Hours');
 
     // Editing existing resource
-    const lofarObsTimeInput = content.queryByPlaceholderText('LOFAR Observing Time');
+    const lofarObsTimeInput = _.filter(spinButtons, {"id": "LOFAR Observing Time"})[0];
     fireEvent.blur(lofarObsTimeInput, { target: { value: 10 } });
     expect(lofarObsTimeInput.value).toBe('10 Hours');
     
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.test.js
index aaf9327d030..3847248a84c 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.test.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.test.js
@@ -66,7 +66,7 @@ it("renders Project details if found", async () => {
     expect(content.queryByText("50 Hours")).not.toBe(null);
     expect(content.queryByText("6 TB")).not.toBe(null);
     expect(content.queryByText("7 Numbers")).not.toBe(null);
-    expect(content.queryByText("8")).not.toBe(null);
+    expect(content.queryByText("9 Hours")).not.toBe(null);
 
 });
 
-- 
GitLab