Skip to content
Snippets Groups Projects
Commit 6b633d47 authored by Ramesh Kumar's avatar Ramesh Kumar
Browse files

TMSS-312: Test Scripts for Project Create, View and Edit pages are updated.

parent 92c29c32
No related branches found
No related tags found
1 merge request!206Resolve TMSS-312
...@@ -94,7 +94,7 @@ p { ...@@ -94,7 +94,7 @@ p {
margin-bottom: 10px; margin-bottom: 10px;
} }
.p-chips-token span { .p-chips-token,.p-inputnumber span {
margin-bottom: 0px; margin-bottom: 0px;
} }
......
...@@ -7,180 +7,90 @@ const ProjectServiceMock= { ...@@ -7,180 +7,90 @@ const ProjectServiceMock= {
"url": "http://localhost:3000/api/resource_type/LOFAR%20Observing%20Time/", "url": "http://localhost:3000/api/resource_type/LOFAR%20Observing%20Time/",
"created_at": "2020-07-29T07:31:21.708296", "created_at": "2020-07-29T07:31:21.708296",
"description": "LOFAR Observing Time", "description": "LOFAR Observing Time",
"resource_unit": "http://localhost:3000/api/resource_unit/second/",
"resource_unit_id": "second",
"tags": [ "tags": [
], ],
"updated_at": "2020-07-29T07:31:21.708316", "updated_at": "2020-07-29T07:31:21.708316",
"resourceUnit": { "quantity_value": "time"
"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"
}
}, },
{ {
"name": "LOFAR Observing Time prio A", "name": "LOFAR Observing Time prio A",
"url": "http://localhost:3000/api/resource_type/LOFAR%20Observing%20Time%20prio%20A/", "url": "http://localhost:3000/api/resource_type/LOFAR%20Observing%20Time%20prio%20A/",
"created_at": "2020-07-29T07:31:21.827537", "created_at": "2020-07-29T07:31:21.827537",
"description": "LOFAR Observing Time prio A", "description": "LOFAR Observing Time prio A",
"resource_unit": "http://localhost:3000/api/resource_unit/second/",
"resource_unit_id": "second",
"tags": [ "tags": [
], ],
"updated_at": "2020-07-29T07:31:21.827675", "updated_at": "2020-07-29T07:31:21.827675",
"resourceUnit": { "quantity_value": "time"
"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"
}
}, },
{ {
"name": "LOFAR Observing Time prio B", "name": "LOFAR Observing Time prio B",
"url": "http://localhost:3000/api/resource_type/LOFAR%20Observing%20Time%20prio%20B/", "url": "http://localhost:3000/api/resource_type/LOFAR%20Observing%20Time%20prio%20B/",
"created_at": "2020-07-29T07:31:21.950948", "created_at": "2020-07-29T07:31:21.950948",
"description": "LOFAR Observing Time prio B", "description": "LOFAR Observing Time prio B",
"resource_unit": "http://localhost:3000/api/resource_unit/second/",
"resource_unit_id": "second",
"tags": [ "tags": [
], ],
"updated_at": "2020-07-29T07:31:21.950968", "updated_at": "2020-07-29T07:31:21.950968",
"resourceUnit": { "quantity_value": "time"
"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"
}
}, },
{ {
"name": "CEP Processing Time", "name": "CEP Processing Time",
"url": "http://localhost:3000/api/resource_type/CEP%20Processing%20Time/", "url": "http://localhost:3000/api/resource_type/CEP%20Processing%20Time/",
"created_at": "2020-07-29T07:31:22.097916", "created_at": "2020-07-29T07:31:22.097916",
"description": "CEP Processing Time", "description": "CEP Processing Time",
"resource_unit": "http://localhost:3000/api/resource_unit/second/",
"resource_unit_id": "second",
"tags": [ "tags": [
], ],
"updated_at": "2020-07-29T07:31:22.097941", "updated_at": "2020-07-29T07:31:22.097941",
"resourceUnit": { "quantity_value": "time"
"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"
}
}, },
{ {
"name": "LTA Storage", "name": "LTA Storage",
"url": "http://localhost:3000/api/resource_type/LTA%20Storage/", "url": "http://localhost:3000/api/resource_type/LTA%20Storage/",
"created_at": "2020-07-29T07:31:22.210071", "created_at": "2020-07-29T07:31:22.210071",
"description": "LTA Storage", "description": "LTA Storage",
"resource_unit": "http://localhost:3000/api/resource_unit/byte/",
"resource_unit_id": "byte",
"tags": [ "tags": [
], ],
"updated_at": "2020-07-29T07:31:22.210091", "updated_at": "2020-07-29T07:31:22.210091",
"resourceUnit": { "quantity_value": "bytes"
"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"
}
}, },
{ {
"name": "Number of triggers", "name": "Number of triggers",
"url": "http://localhost:3000/api/resource_type/Number%20of%20triggers/", "url": "http://localhost:3000/api/resource_type/Number%20of%20triggers/",
"created_at": "2020-07-29T07:31:22.317313", "created_at": "2020-07-29T07:31:22.317313",
"description": "Number of triggers", "description": "Number of triggers",
"resource_unit": "http://localhost:3000/api/resource_unit/number/",
"resource_unit_id": "number",
"tags": [ "tags": [
], ],
"updated_at": "2020-07-29T07:31:22.317341", "updated_at": "2020-07-29T07:31:22.317341",
"resourceUnit": { "quantity_value": "number"
"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"
}
}, },
{ {
"name": "LOFAR Support Time", "name": "LOFAR Support Time",
"url": "http://localhost:3000/api/resource_type/LOFAR%20Support%20Time/", "url": "http://localhost:3000/api/resource_type/LOFAR%20Support%20Time/",
"created_at": "2020-07-29T07:31:22.437945", "created_at": "2020-07-29T07:31:22.437945",
"description": "LOFAR Support Time", "description": "LOFAR Support Time",
"resource_unit": "http://localhost:3000/api/resource_unit/second/",
"resource_unit_id": "second",
"tags": [ "tags": [
], ],
"updated_at": "2020-07-29T07:31:22.437964", "updated_at": "2020-07-29T07:31:22.437964",
"resourceUnit": { "quantity_value": "time"
"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"
}
}, },
{ {
"name": "LOFAR Support hours", "name": "LOFAR Support hours",
"url": "http://localhost:3000/api/resource_type/LOFAR%20Support%20hours/", "url": "http://localhost:3000/api/resource_type/LOFAR%20Support%20hours/",
"created_at": "2020-07-29T07:31:22.571850", "created_at": "2020-07-29T07:31:22.571850",
"description": "LOFAR Support hours", "description": "LOFAR Support hours",
"resource_unit": "http://localhost:3000/api/resource_unit/second/",
"resource_unit_id": "second",
"tags": [ "tags": [
], ],
"updated_at": "2020-07-29T07:31:22.571869", "updated_at": "2020-07-29T07:31:22.571869",
"resourceUnit": { "quantity_value": "time"
"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"
}
}, },
{ {
"name": "Support hours", "name": "Support hours",
"url": "http://localhost:3000/api/resource_type/Support%20hours/", "url": "http://localhost:3000/api/resource_type/Support%20hours/",
"created_at": "2020-07-29T07:31:22.694438", "created_at": "2020-07-29T07:31:22.694438",
"description": "Support hours", "description": "Support hours",
"resource_unit": "http://localhost:3000/api/resource_unit/second/",
"resource_unit_id": "second",
"tags": [ "tags": [
], ],
"updated_at": "2020-07-29T07:31:22.694514", "updated_at": "2020-07-29T07:31:22.694514",
"resourceUnit": { "quantity_value": "time"
"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"
}
} }
], ],
projectResourceDefaults: { projectResourceDefaults: {
...@@ -212,7 +122,7 @@ const ProjectServiceMock= { ...@@ -212,7 +122,7 @@ const ProjectServiceMock= {
"private_data": true, "private_data": true,
"project_category": "Regular", "project_category": "Regular",
"project_category_value": "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/70/",
"http://192.168.99.100:8008/api/project_quota/71/", "http://192.168.99.100:8008/api/project_quota/71/",
"http://192.168.99.100:8008/api/project_quota/72/", "http://192.168.99.100:8008/api/project_quota/72/",
...@@ -222,7 +132,7 @@ const ProjectServiceMock= { ...@@ -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/76/",
"http://192.168.99.100:8008/api/project_quota/77/" "http://192.168.99.100:8008/api/project_quota/77/"
], ],
"project_quota_ids": [ "quota_ids": [
70, 70,
71, 71,
72, 72,
...@@ -307,7 +217,7 @@ const ProjectServiceMock= { ...@@ -307,7 +217,7 @@ const ProjectServiceMock= {
"project_id": "OSR-11", "project_id": "OSR-11",
"resource_type": "http://192.168.99.100:8008/api/resource_type/Support%20hours/", "resource_type": "http://192.168.99.100:8008/api/resource_type/Support%20hours/",
"resource_type_id": "Support hours", "resource_type_id": "Support hours",
"value": 8 "value": 32400
} }
] ]
} }
......
...@@ -41,6 +41,7 @@ export class ResourceInputList extends Component { ...@@ -41,6 +41,7 @@ export class ResourceInputList extends Component {
<InputNumber key={'item1-'+ index} id={'item1-'+ index} name={'item1-'+ index} <InputNumber key={'item1-'+ index} id={'item1-'+ index} name={'item1-'+ index}
suffix={` ${this.props.unitMap[item.quantity_value]?this.props.unitMap[item.quantity_value].display:''}`} 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} 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]} value={this.state.projectQuota[item.name]}
onChange={(e) => this.onInputChange(item.name, e)} onChange={(e) => this.onInputChange(item.name, e)}
onBlur={(e) => this.onInputChange(item.name, e)} onBlur={(e) => this.onInputChange(item.name, e)}
......
...@@ -3,6 +3,7 @@ import { BrowserRouter as Router } from 'react-router-dom'; ...@@ -3,6 +3,7 @@ import { BrowserRouter as Router } from 'react-router-dom';
import { act } from "react-dom/test-utils"; import { act } from "react-dom/test-utils";
import { render, cleanup, fireEvent } from '@testing-library/react'; import { render, cleanup, fireEvent } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect'; import '@testing-library/jest-dom/extend-expect';
import _ from 'lodash';
import {ProjectCreate} from './create'; import {ProjectCreate} from './create';
import ProjectService from '../../services/project.service'; import ProjectService from '../../services/project.service';
...@@ -65,6 +66,7 @@ it("renders without crashing with all back-end data loaded", async () => { ...@@ -65,6 +66,7 @@ it("renders without crashing with all back-end data loaded", async () => {
await act(async () => { await act(async () => {
content = render(<Router><ProjectCreate /></Router>); content = render(<Router><ProjectCreate /></Router>);
}); });
const spinButtons = content.queryAllByRole("spinbutton");
expect(content.queryByText('Project - Add')).not.toBe(null); // Page loaded successfully expect(content.queryByText('Project - Add')).not.toBe(null); // Page loaded successfully
expect(projectCategoriesSpy).toHaveBeenCalled(); // Mock Spy called successfully expect(projectCategoriesSpy).toHaveBeenCalled(); // Mock Spy called successfully
...@@ -73,8 +75,8 @@ it("renders without crashing with all back-end data loaded", async () => { ...@@ -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.queryByText('Cycle-0')).toBeInTheDocument(); // Cycle multi-select loaded successfully
expect(content.queryAllByText('Add Resources').length).toBe(2); // Resource Dropdown 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.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(_.filter(spinButtons, {"id": "Support hours"}).length).toBe(0); // 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": "LOFAR Observing Time"})[0].value).toBe('1 Hours'); // Default Resource Listed with default value
}); });
it("Save button disabled initially when no data entered", async () => { it("Save button disabled initially when no data entered", async () => {
...@@ -222,31 +224,31 @@ it("save project with default resources", async () => { ...@@ -222,31 +224,31 @@ it("save project with default resources", async () => {
expect(content.queryByTestId('projectId').value).toBe(""); expect(content.queryByTestId('projectId').value).toBe("");
expect(content.queryByText("Success")).toBe(null); 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 } }); fireEvent.change(lofarObsTimeInput, { target: { value: 10 } });
expect(lofarObsTimeInput.value).toBe('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 } }); fireEvent.change(lofarObsTimeAInput, { target: { value: 15 } });
expect(lofarObsTimeAInput.value).toBe('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 } }); fireEvent.change(lofarObsTimeBInput, { target: { value: 20 } });
expect(lofarObsTimeBInput.value).toBe('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 } }); fireEvent.change(cepProcTimeInput, { target: { value: 5 } });
expect(cepProcTimeInput.value).toBe('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 } }); fireEvent.change(ltaStorageInput, { target: { value: 2 } });
expect(ltaStorageInput.value).toBe('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 } }); fireEvent.change(noOfTriggerInput, { target: { value: 3 } });
expect(noOfTriggerInput.value).toBe('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 } }); fireEvent.change(lofarSupTimeInput, { target: { value: 25 } });
expect(lofarSupTimeInput.value).toBe('25'); expect(lofarSupTimeInput.value).toBe('25');
...@@ -268,7 +270,7 @@ it("save project with added resources", async () => { ...@@ -268,7 +270,7 @@ it("save project with added resources", async () => {
const nameInput = content.queryByTestId('name'); const nameInput = content.queryByTestId('name');
const descInput = content.queryByTestId('description'); 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]; const rankInput = spinButtons.filter(function(element) { return element.id==="proj-rank"})[0];
fireEvent.change(nameInput, { target: { value: 'OSR' } }); fireEvent.change(nameInput, { target: { value: 'OSR' } });
...@@ -281,31 +283,31 @@ it("save project with added resources", async () => { ...@@ -281,31 +283,31 @@ it("save project with added resources", async () => {
expect(content.queryByTestId('projectId').value).toBe(""); expect(content.queryByTestId('projectId').value).toBe("");
expect(content.queryByText("Success")).toBe(null); 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 } }); fireEvent.change(lofarObsTimeInput, { target: { value: 10 } });
expect(lofarObsTimeInput.value).toBe('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 } }); fireEvent.change(lofarObsTimeAInput, { target: { value: 15 } });
expect(lofarObsTimeAInput.value).toBe('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 } }); fireEvent.change(lofarObsTimeBInput, { target: { value: 20 } });
expect(lofarObsTimeBInput.value).toBe('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 } }); fireEvent.change(cepProcTimeInput, { target: { value: 5 } });
expect(cepProcTimeInput.value).toBe('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 } }); fireEvent.change(ltaStorageInput, { target: { value: 2 } });
expect(ltaStorageInput.value).toBe('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 } }); fireEvent.change(noOfTriggerInput, { target: { value: 3 } });
expect(noOfTriggerInput.value).toBe('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 } }); fireEvent.change(lofarSupTimeInput, { target: { value: 25 } });
expect(lofarSupTimeInput.value).toBe('25'); expect(lofarSupTimeInput.value).toBe('25');
...@@ -313,7 +315,7 @@ it("save project with added resources", async () => { ...@@ -313,7 +315,7 @@ it("save project with added resources", async () => {
expect(content.queryAllByText('Add Resources').length).toBe(2); expect(content.queryAllByText('Add Resources').length).toBe(2);
expect(content.queryAllByText('Support hours').length).toBe(1); expect(content.queryAllByText('Support hours').length).toBe(1);
expect(content.getAllByRole("listbox")[3].children.length).toBe(2); 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] ; const addResourceInput = content.getAllByRole("listbox")[3].children[1] ;
fireEvent.click(addResourceInput); fireEvent.click(addResourceInput);
// After selecting New Resource // After selecting New Resource
...@@ -323,9 +325,10 @@ it("save project with added resources", async () => { ...@@ -323,9 +325,10 @@ it("save project with added resources", async () => {
const addResourceBtn = content.queryByTestId('add_res_btn'); const addResourceBtn = content.queryByTestId('add_res_btn');
fireEvent.click(addResourceBtn); fireEvent.click(addResourceBtn);
expect(content.queryAllByText('Add Resources').length).toBe(2); 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 } }); fireEvent.change(newResourceInput, { target: { value: 30 } });
expect(newResourceInput.value).toBe('30'); expect(newResourceInput.value).toBe('30');
...@@ -360,15 +363,18 @@ it("remove default resource and added resource", async () => { ...@@ -360,15 +363,18 @@ it("remove default resource and added resource", async () => {
const addResourceBtn = content.queryByTestId('add_res_btn'); const addResourceBtn = content.queryByTestId('add_res_btn');
fireEvent.click(addResourceBtn); fireEvent.click(addResourceBtn);
expect(content.queryAllByText('Add Resources').length).toBe(2); 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); expect(content.queryByTestId('CEP Processing Time-btn')).not.toBe(null);
const removeDefResBtn = content.queryByTestId('CEP Processing Time-btn'); const removeDefResBtn = content.queryByTestId('CEP Processing Time-btn');
await act(async () => { await act(async () => {
fireEvent.click(content.queryByTestId('CEP Processing Time-btn')); 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); expect(content.queryByTestId('CEP Processing Time-btn')).toBe(null);
const removeResourceBtn = content.queryByTestId('Support hours-btn'); const removeResourceBtn = content.queryByTestId('Support hours-btn');
......
...@@ -112,10 +112,10 @@ it("renders input fields with Project details if found", async () => { ...@@ -112,10 +112,10 @@ it("renders input fields with Project details if found", async () => {
expect(content.queryByTestId("name").value).toBe('OSR-11'); expect(content.queryByTestId("name").value).toBe('OSR-11');
const spinButtons = content.queryAllByRole("spinbutton"); 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"); 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"); expect(rankInput.value).toBe("5");
const trigger = content.getAllByLabelText(/trigger/i).filter((element) => { return element.id==="trigger"})[0]; 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 () => { ...@@ -132,15 +132,15 @@ it("renders input fields with Project details if found", async () => {
const cycleInput = content.getAllByRole("listbox")[2] ; const cycleInput = content.getAllByRole("listbox")[2] ;
expect(content.queryAllByText('Cycle 0').length).toBe(2); expect(content.queryAllByText('Cycle 0').length).toBe(2);
expect(content.queryByPlaceholderText("CEP Processing Time").value).toBe("10 Hours"); expect(_.filter(spinButtons, {"id": "CEP Processing Time"})[0].value).toBe("10 Hours");
expect(content.queryByPlaceholderText("LOFAR Observing Time").value).toBe("20 Hours"); expect(_.filter(spinButtons, {"id": "LOFAR Observing Time"})[0].value).toBe("20 Hours");
expect(content.queryByPlaceholderText("LOFAR Observing Time prio A").value).toBe("30 Hours"); expect(_.filter(spinButtons, {"id": "LOFAR Observing Time prio A"})[0].value).toBe("30 Hours");
expect(content.queryByPlaceholderText("LOFAR Observing Time prio B").value).toBe("40 Hours"); expect(_.filter(spinButtons, {"id": "LOFAR Observing Time prio B"})[0].value).toBe("40 Hours");
expect(content.queryByPlaceholderText("LOFAR Support Time").value).toBe("50 Hours"); expect(_.filter(spinButtons, {"id": "LOFAR Support Time"})[0].value).toBe("50 Hours");
expect(content.queryByPlaceholderText("LTA Storage").value).toBe("6 TB"); expect(_.filter(spinButtons, {"id": "LTA Storage"})[0].value).toBe("6 TB");
expect(content.queryByPlaceholderText("Number of triggers").value).toBe("7 Numbers"); expect(_.filter(spinButtons, {"id": "Number of triggers"})[0].value).toBe("7 Numbers");
expect(content.queryByPlaceholderText("Support hours").value).toBe("8 "); expect(_.filter(spinButtons, {"id": "Support hours"})[0].value).toBe("9 Hours");
expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy(); expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy();
}); });
...@@ -157,11 +157,11 @@ it("save Project after editing fields", async () => { ...@@ -157,11 +157,11 @@ it("save Project after editing fields", async () => {
expect(content.queryByTestId("name").value).toBe('OSR-11'); expect(content.queryByTestId("name").value).toBe('OSR-11');
const spinButtons = content.queryAllByRole("spinbutton"); 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 } }); fireEvent.blur(trigPrioInput, { target: { value: 900 } });
expect(trigPrioInput.value).toBe("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 } }); fireEvent.blur(rankInput, { target: { value: 2 } });
expect(rankInput.value).toBe("2"); expect(rankInput.value).toBe("2");
...@@ -190,19 +190,19 @@ it("save Project after editing fields", async () => { ...@@ -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(2);
expect(content.queryAllByText('Cycle 0').length).toBe(1); 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 } }); fireEvent.blur(lofarObsTimeInput, { target: { value: 10 } });
expect(lofarObsTimeInput.value).toBe('10 Hours'); 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 } }); fireEvent.blur(cepProcTimeInput, { target: { value: 5 } });
expect(cepProcTimeInput.value).toBe('5 Hours'); 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 } }); fireEvent.blur(ltaStorageInput, { target: { value: 2 } });
expect(ltaStorageInput.value).toBe('2 TB'); 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 } }); fireEvent.blur(noOfTriggerInput, { target: { value: 3 } });
expect(noOfTriggerInput.value).toBe('3 Numbers'); expect(noOfTriggerInput.value).toBe('3 Numbers');
...@@ -238,13 +238,15 @@ it("save Project after adding, modifying and deleting resources", async () => { ...@@ -238,13 +238,15 @@ it("save Project after adding, modifying and deleting resources", async () => {
const addResourceBtn = content.queryByTestId('add_res_btn'); const addResourceBtn = content.queryByTestId('add_res_btn');
fireEvent.click(addResourceBtn); fireEvent.click(addResourceBtn);
expect(content.queryAllByText('Add Resources').length).toBe(2); 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 } }); fireEvent.blur(lofarSupHrsInput, { target: { value: 100 } });
expect(lofarSupHrsInput.value).toBe('100 '); expect(lofarSupHrsInput.value).toBe('100 Hours');
// Editing existing resource // 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 } }); fireEvent.blur(lofarObsTimeInput, { target: { value: 10 } });
expect(lofarObsTimeInput.value).toBe('10 Hours'); expect(lofarObsTimeInput.value).toBe('10 Hours');
......
...@@ -66,7 +66,7 @@ it("renders Project details if found", async () => { ...@@ -66,7 +66,7 @@ it("renders Project details if found", async () => {
expect(content.queryByText("50 Hours")).not.toBe(null); expect(content.queryByText("50 Hours")).not.toBe(null);
expect(content.queryByText("6 TB")).not.toBe(null); expect(content.queryByText("6 TB")).not.toBe(null);
expect(content.queryByText("7 Numbers")).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);
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment