From 1b5f0c3d565b66983f4873a61d6adfd1c20ce227 Mon Sep 17 00:00:00 2001 From: Ramesh Kumar <ramesh.p@matriotsolutions.com> Date: Wed, 23 Feb 2022 18:38:20 +0530 Subject: [PATCH] TMSS-1544: SU create test script updated for constraint values when strategy is selected --- .../__mocks__/scheduleunit.service.data.js | 374 ++++++++++++++++++ .../src/routes/Scheduling/create.test.js | 61 ++- 2 files changed, 433 insertions(+), 2 deletions(-) diff --git a/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/scheduleunit.service.data.js b/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/scheduleunit.service.data.js index c6b17409803..c7e29cc6e05 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/scheduleunit.service.data.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/scheduleunit.service.data.js @@ -1128,6 +1128,380 @@ const SUServiceMock= { }, "updated_at": "2022-02-03T01:54:06.310514", "version": 1 + }, + { + "id": 9, + "url": "http://localhost:8008/api/scheduling_unit_observing_strategy_template/9", + "created_at": "2022-02-23T10:43:07.385240", + "description": "This observation strategy template defines a single simple Target observation.", + "name": "Simple Observation", + "purpose": "http://localhost:8008/api/template_purpose/technical_commissioning", + "purpose_value": "technical_commissioning", + "scheduling_unit_template": "http://localhost:8008/api/scheduling_unit_template/1", + "scheduling_unit_template_id": 1, + "state": "http://localhost:8008/api/template_state/active", + "state_value": "active", + "tags": [], + "template": { + "tasks": { + "Observation": { + "tags": [], + "description": "A simple short test observation", + "specifications_doc": { + "QA": { + "plots": { + "enabled": true, + "autocorrelation": true, + "crosscorrelation": true + }, + "file_conversion": { + "enabled": true, + "nr_of_subbands": -1, + "nr_of_timestamps": 256 + }, + "inspection_plots": "msplots" + }, + "SAPs": [ + { + "name": "Polaris", + "subbands": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135, + 136, + 137, + 138, + 139, + 140, + 141, + 142, + 143, + 144, + 145, + 146, + 147, + 148, + 149, + 150, + 151, + 152, + 153, + 154, + 155, + 156, + 157, + 158, + 159, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 174, + 175, + 176, + 177, + 178, + 179, + 180, + 181, + 182, + 183, + 184, + 185, + 186, + 187, + 188, + 189, + 190, + 191, + 192, + 193, + 194, + 195, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 210, + 211, + 212, + 213, + 214, + 215, + 216, + 217, + 218, + 219, + 220, + 221, + 222, + 223, + 224, + 225, + 226, + 227, + 228, + 229, + 230, + 231, + 232, + 233, + 234, + 235, + 236, + 237, + 238, + 239, + 240, + 241, + 242, + 243 + ], + "digital_pointing": { + "angle1": 0.6624317181687094, + "angle2": 1.5579526427549426, + "target": "target1", + "direction_type": "J2000" + } + } + ], + "filter": "HBA_110_190", + "duration": 120, + "tile_beam": { + "angle1": 0.6624317181687094, + "angle2": 1.5579526427549426, + "target": "target1", + "direction_type": "J2000" + }, + "correlator": { + "storage_cluster": "CEP4", + "integration_time": 1, + "channels_per_subband": 64 + }, + "antenna_set": "HBA_DUAL_INNER", + "station_groups": [ + { + "stations": [ + "CS002", + "CS003", + "CS004", + "CS005", + "CS006", + "CS007" + ], + "max_nr_missing": 1 + } + ] + }, + "specifications_template": { + "name": "target observation" + } + } + }, + "parameters": [ + { + "name": "Scheduling Constraints", + "refs": [ + "#/scheduling_constraints_doc" + ] + }, + { + "name": "Duration", + "refs": [ + "#/tasks/Observation/specifications_doc/duration" + ] + }, + { + "name": "Target Pointing", + "refs": [ + "#/tasks/Observation/specifications_doc/SAPs/0/digital_pointing" + ] + }, + { + "name": "Tile Beam", + "refs": [ + "#/tasks/Observation/specifications_doc/tile_beam" + ] + } + ], + "task_relations": [], + "task_scheduling_relations": [], + "scheduling_constraints_doc": { + "sky": { + "min_distance": { + "sun": 0, + "moon": 0, + "jupiter": 0 + }, + "min_elevation": { + "target": 0.1 + }, + "transit_offset": { + "to": 21600, + "from": -21600 + } + }, + "scheduler": "dynamic" + }, + "scheduling_constraints_template": { + "name": "constraints" + } + }, + "updated_at": "2022-02-23T10:43:07.385256", + "version": 1 } ], schedulingUnitFromObservStrategy: { diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.test.js index 75835849f6a..3e85153edec 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.test.js @@ -1,7 +1,7 @@ import React from 'react'; import { BrowserRouter as Router } from 'react-router-dom'; import { act } from "react-dom/test-utils"; -import { render, cleanup, fireEvent, waitForElement } from '@testing-library/react'; +import { render, screen, cleanup, fireEvent, waitForElement } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import '@testing-library/jest-dom' // import renderer from 'react-test-renderer'; @@ -221,4 +221,61 @@ it("creates new Scheduling Unit with default values", async() => { }); expect(saveSUFromStrategySpy).toHaveBeenCalled(); expect(content.queryByText('Success')).toBeInTheDocument(); //check popup appear after create SU successfully -}); \ No newline at end of file +}); + +it("checks Constraint value change when UC1 CTC+pipelines strategy is selected", async() => { + console.log("checks Constraint value change when UC1 CTC+pipelines strategy is selected ------------------------"); + let content; + await act(async () => { + content =render(<Router><SchedulingUnitCreate location={{pathname: '/schedulingunit/'}}/></Router>); + }); + expect(screen.getByDisplayValue("dynamic")).toBeInTheDocument(); + expect(screen.getByLabelText("specification[time][at]").value).toBe(""); + expect(screen.getByLabelText("specification[time][after]").value).toBe(""); + expect(screen.getByLabelText("specification[time][before]").value).toBe(""); + expect(screen.getByLabelText("specification[sky][transit_offset][from]").value).toBe("02:00:00"); + expect(screen.getByLabelText("specification[sky][transit_offset][to]").value).toBe("02:00:00"); + expect(screen.getByLabelText("specification[sky][min_distance][sun]").value).toBe("28.65"); + expect(screen.getByLabelText("specification[sky][min_distance][moon]").value).toBe("28.65"); + expect(screen.getByLabelText("specification[sky][min_distance][jupiter]").value).toBe("28.65"); + expect(screen.getByLabelText("specification[sky][min_elevation][calibrator]").value).toBe("28.65"); + expect(screen.getByLabelText("specification[sky][min_elevation][target]").value).toBe("28.65"); + const uc1ObservStrategyInput = content.queryByText("UC1 CTC+pipelines"); + await act( async() => { + fireEvent.click(uc1ObservStrategyInput); + await new Promise((r) => setTimeout(r, 1000)); + }); + expect(screen.getByLabelText("specification[sky][transit_offset][from]").value).toBe("-00:24:00"); + expect(screen.getByLabelText("specification[sky][transit_offset][to]").value).toBe("00:24:00"); +}); + +it("checks Constraint value change when Simple Observation strategy is selected", async() => { + console.log("checks Constraint value change when Simple Observation strategy is selected ------------------------"); + let content; + await act(async () => { + content =render(<Router><SchedulingUnitCreate location={{pathname: '/schedulingunit/'}}/></Router>); + }); + expect(screen.getByDisplayValue("dynamic")).toBeInTheDocument(); + expect(screen.getByLabelText("specification[time][at]").value).toBe(""); + expect(screen.getByLabelText("specification[time][after]").value).toBe(""); + expect(screen.getByLabelText("specification[time][before]").value).toBe(""); + expect(screen.getByLabelText("specification[sky][transit_offset][from]").value).toBe("02:00:00"); + expect(screen.getByLabelText("specification[sky][transit_offset][to]").value).toBe("02:00:00"); + expect(screen.getByLabelText("specification[sky][min_distance][sun]").value).toBe("28.65"); + expect(screen.getByLabelText("specification[sky][min_distance][moon]").value).toBe("28.65"); + expect(screen.getByLabelText("specification[sky][min_distance][jupiter]").value).toBe("28.65"); + expect(screen.getByLabelText("specification[sky][min_elevation][calibrator]").value).toBe("28.65"); + expect(screen.getByLabelText("specification[sky][min_elevation][target]").value).toBe("28.65"); + const simpleObservStrategyInput = content.queryByText("Simple Observation"); + await act( async() => { + fireEvent.click(simpleObservStrategyInput); + await new Promise((r) => setTimeout(r, 1000)); + }); + expect(screen.getByLabelText("specification[sky][transit_offset][from]").value).toBe("-06:00:00"); + expect(screen.getByLabelText("specification[sky][transit_offset][to]").value).toBe("06:00:00"); + expect(screen.getByLabelText("specification[sky][min_distance][sun]").value).toBe("0.00"); + expect(screen.getByLabelText("specification[sky][min_distance][moon]").value).toBe("0.00"); + expect(screen.getByLabelText("specification[sky][min_distance][jupiter]").value).toBe("0.00"); + expect(screen.getByLabelText("specification[sky][min_elevation][calibrator]").value).toBe("28.65"); + expect(screen.getByLabelText("specification[sky][min_elevation][target]").value).toBe("5.73"); +}); -- GitLab