From 95b7c3ccda7f481b85a29fd7e79dd73d5be5006a Mon Sep 17 00:00:00 2001
From: Ramesh Kumar <ramesh.p@matriotsolutions.com>
Date: Mon, 4 Apr 2022 18:04:32 +0530
Subject: [PATCH] TMSS-1559: Updated test scripts to test multiple versions of
 simple obervation and LBA strategy templates

---
 .../tmss_webapp/prepareTemplateSchemas.js     |   2 +
 .../tmss_webapp/prepareTemplateSchemas_dev.js |   2 +
 .../observing_strategy_templates.json         | 666 +++++++++++++++++-
 .../__mocks__/scheduleunit.service.data.js    |  36 +
 .../src/routes/Scheduling/create.js           |  19 +-
 .../src/routes/Scheduling/create.test.js      | 451 ++++++------
 .../Scheduling/excelview.schedulingset.js     |   8 +-
 .../excelview.schedulingset.test.js           |  94 ++-
 .../src/services/schedule.service.js          |  15 +-
 9 files changed, 1018 insertions(+), 275 deletions(-)

diff --git a/SAS/TMSS/frontend/tmss_webapp/prepareTemplateSchemas.js b/SAS/TMSS/frontend/tmss_webapp/prepareTemplateSchemas.js
index aa78fb1d563..8199b2a93b9 100644
--- a/SAS/TMSS/frontend/tmss_webapp/prepareTemplateSchemas.js
+++ b/SAS/TMSS/frontend/tmss_webapp/prepareTemplateSchemas.js
@@ -129,6 +129,8 @@ getTemplateFiles('../../../../install/opt/lofar/share/tmss/schemas').then(async(
                 const data = fs.readFileSync(file, 'utf8');
                 let strategyTemplate = JSON.parse(data);
                 strategyTemplate.id = index;
+				strategyTemplate.state_value = strategyTemplate.state;
+				strategyTemplate.purpose_value = strategyTemplate.purpose;
 				index++;
                 strategies.push(strategyTemplate);
             }
diff --git a/SAS/TMSS/frontend/tmss_webapp/prepareTemplateSchemas_dev.js b/SAS/TMSS/frontend/tmss_webapp/prepareTemplateSchemas_dev.js
index 2113630586c..a33bc0611ea 100644
--- a/SAS/TMSS/frontend/tmss_webapp/prepareTemplateSchemas_dev.js
+++ b/SAS/TMSS/frontend/tmss_webapp/prepareTemplateSchemas_dev.js
@@ -123,6 +123,8 @@ getTemplateFiles('../../backend/src/tmss/tmssapp/schemas').then(async(backEndFil
 				const data = fs.readFileSync(file, 'utf8');
 				let strategyTemplate = JSON.parse(data);
 				strategyTemplate.id = index;
+				strategyTemplate.state_value = strategyTemplate.state;
+				strategyTemplate.purpose_value = strategyTemplate.purpose;
 				index++;
 				strategies.push(strategyTemplate);
 			}
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/observing_strategy_templates.json b/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/observing_strategy_templates.json
index d4267e94ce7..88525838420 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/observing_strategy_templates.json
+++ b/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/observing_strategy_templates.json
@@ -1219,7 +1219,9 @@
                 }
             },
             "version": 2,
-            "id": 1
+            "id": 1,
+            "state_value": "development",
+            "purpose_value": "technical_commissioning"
         },
         {
             "description": "BF test for pulsar timing. Full description to follow once accepted. High resolution and 8-bit output possible.",
@@ -2430,7 +2432,9 @@
                 }
             },
             "version": 2,
-            "id": 2
+            "id": 2,
+            "state_value": "development",
+            "purpose_value": "technical_commissioning"
         },
         {
             "description": "BF test for pulsar timing. Full description to follow once accepted.",
@@ -3620,7 +3624,9 @@
                 }
             },
             "version": 2,
-            "id": 3
+            "id": 3,
+            "state_value": "development",
+            "purpose_value": "technical_commissioning"
         },
         {
             "description": "BF Coherent Stokes test for COBALT2 Specifations.",
@@ -4624,7 +4630,249 @@
                 }
             },
             "version": 2,
-            "id": 4
+            "id": 4,
+            "state_value": "development",
+            "purpose_value": "technical_commissioning"
+        },
+        {
+            "description": "test version",
+            "name": "IM BF Cal&Tgt",
+            "purpose": "technical_commissioning",
+            "scheduling_unit_template": {
+                "name": "scheduling unit",
+                "version": 2
+            },
+            "state": "development",
+            "template": {
+                "parameters": [
+                    {
+                        "name": "Scheduling Constraints",
+                        "refs": [
+                            "#/scheduling_constraints_doc"
+                        ]
+                    },
+                    {
+                        "name": "Duration",
+                        "refs": [
+                            "#/tasks/Observation/specifications_doc/duration"
+                        ]
+                    },
+                    {
+                        "name": "Target Pointing",
+                        "refs": [
+                            "#/tasks/Observation/specifications_doc/station_configuration/SAPs/0/digital_pointing"
+                        ]
+                    },
+                    {
+                        "name": "Tile Beam",
+                        "refs": [
+                            "#/tasks/Observation/specifications_doc/station_configuration/tile_beam"
+                        ]
+                    },
+                    {
+                        "name": "Beamformers",
+                        "refs": [
+                            "#/tasks/Observation/specifications_doc/beamformers"
+                        ]
+                    }
+                ],
+                "scheduling_constraints_doc": {
+                    "daily": {
+                        "avoid_twilight": false,
+                        "require_day": false,
+                        "require_night": false
+                    },
+                    "scheduler": "dynamic",
+                    "sky": {
+                        "min_distance": {
+                            "jupiter": 0,
+                            "moon": 0,
+                            "sun": 0
+                        },
+                        "min_elevation": {
+                            "calibrator": 0.5,
+                            "target": 0.1
+                        },
+                        "transit_offset": {
+                            "from": -21600,
+                            "to": 21600
+                        }
+                    },
+                    "time": {
+                        "between": [],
+                        "not_between": []
+                    }
+                },
+                "scheduling_constraints_template": {
+                    "name": "constraints",
+                    "version": 1
+                },
+                "task_relations": [],
+                "task_scheduling_relations": [],
+                "tasks": {
+                    "Observation": {
+                        "description": "IM BF Cal&Tgt",
+                        "specifications_doc": {
+                            "QA": {
+                                "file_conversion": {
+                                    "enabled": true,
+                                    "nr_of_subbands": -1,
+                                    "nr_of_timestamps": 256
+                                },
+                                "inspection_plots": "msplots",
+                                "plots": {
+                                    "autocorrelation": true,
+                                    "crosscorrelation": true,
+                                    "enabled": true
+                                }
+                            },
+                            "beamformer": {
+                                "pipelines": [
+                                    {
+                                        "coherent": {
+                                            "SAPs": [],
+                                            "settings": {
+                                                "channels_per_subband": 1,
+                                                "quantisation": {
+                                                    "bits": 8,
+                                                    "enabled": false,
+                                                    "scale_max": 5,
+                                                    "scale_min": -5
+                                                },
+                                                "stokes": "I",
+                                                "subbands_per_file": 488,
+                                                "time_integration_factor": 1
+                                            }
+                                        },
+                                        "flys eye": {
+                                            "enabled": false,
+                                            "settings": {
+                                                "channels_per_subband": 1,
+                                                "quantisation": {
+                                                    "bits": 8,
+                                                    "enabled": false,
+                                                    "scale_max": 5,
+                                                    "scale_min": -5
+                                                },
+                                                "stokes": "I",
+                                                "subbands_per_file": 488,
+                                                "time_integration_factor": 1
+                                            }
+                                        },
+                                        "incoherent": {
+                                            "SAPs": [],
+                                            "settings": {
+                                                "channels_per_subband": 1,
+                                                "quantisation": {
+                                                    "bits": 8,
+                                                    "enabled": false,
+                                                    "scale_max": 5,
+                                                    "scale_min": -5
+                                                },
+                                                "stokes": "I",
+                                                "subbands_per_file": 488,
+                                                "time_integration_factor": 1
+                                            }
+                                        },
+                                        "name": "_beamformer_name_",
+                                        "station_groups": [
+                                            {
+                                                "max_nr_missing": 1,
+                                                "stations": [
+                                                    "CS001",
+                                                    "CS002",
+                                                    "CS003",
+                                                    "CS004",
+                                                    "CS005",
+                                                    "CS006",
+                                                    "CS007",
+                                                    "CS011",
+                                                    "CS013",
+                                                    "CS017",
+                                                    "CS021",
+                                                    "CS024",
+                                                    "CS026",
+                                                    "CS028",
+                                                    "CS030",
+                                                    "CS031",
+                                                    "CS032",
+                                                    "CS301",
+                                                    "CS302",
+                                                    "CS401",
+                                                    "CS501"
+                                                ]
+                                            }
+                                        ]
+                                    }
+                                ],
+                                "ppf": false
+                            },
+                            "calibrator": {
+                                "autoselect": true,
+                                "name": "calibrator",
+                                "pointing": {
+                                    "angle1": 0.6624317181687094,
+                                    "angle2": 1.5579526427549426,
+                                    "direction_type": "J2000",
+                                    "target": "_target_name_"
+                                }
+                            },
+                            "correlator": {
+                                "channels_per_subband": 64,
+                                "integration_time": 1,
+                                "storage_cluster": "CEP4",
+                                "topocentric_frequency_correction": false
+                            },
+                            "duration": 600,
+                            "station_configuration": {
+                                "SAPs": [
+                                    {
+                                        "digital_pointing": {
+                                            "angle1": 0.6624317181687094,
+                                            "angle2": 1.5579526427549426,
+                                            "direction_type": "J2000",
+                                            "target": "_target_name_"
+                                        },
+                                        "name": "_SAP_name_",
+                                        "subbands": [
+                                            255
+                                        ]
+                                    }
+                                ],
+                                "antenna_set": "HBA_DUAL",
+                                "filter": "HBA_110_190",
+                                "station_groups": [
+                                    {
+                                        "max_nr_missing": 1,
+                                        "stations": [
+                                            "CS002",
+                                            "CS003",
+                                            "CS004",
+                                            "CS005",
+                                            "CS006",
+                                            "CS007"
+                                        ]
+                                    }
+                                ],
+                                "tile_beam": {
+                                    "angle1": 0.6624317181687094,
+                                    "angle2": 1.5579526427549426,
+                                    "direction_type": "J2000",
+                                    "target": "_target_name_"
+                                }
+                            }
+                        },
+                        "specifications_template": {
+                            "name": "parallel calibrator target and beamforming observation",
+                            "version": 2
+                        }
+                    }
+                }
+            },
+            "version": 1,
+            "id": 5,
+            "state_value": "development",
+            "purpose_value": "technical_commissioning"
         },
         {
             "description": "This observation strategy template defines an single-beam HBA imaging strategy with a Calibrator-Target-Calibrator observation chain, plus a preprocessing pipeline for each and ingest of pipeline data only.",
@@ -5588,7 +5836,9 @@
                 }
             },
             "version": 2,
-            "id": 5
+            "id": 6,
+            "state_value": "development",
+            "purpose_value": "technical_commissioning"
         },
         {
             "description": "This observation strategy template defines a LoTSS deep field run with a Calibrator-Target-Calibrator observation chain, plus a preprocessing pipeline for each and ingest of pipeline data only, using a central beam with 3 flanking fields.",
@@ -6839,7 +7089,9 @@
                 }
             },
             "version": 2,
-            "id": 6
+            "id": 7,
+            "state_value": "development",
+            "purpose_value": "technical_commissioning"
         },
         {
             "description": "This observation strategy template defines a LoTSS (Co-)observing run with a Calibrator-Target-Calibrator observation chain, plus a preprocessing pipeline for each and ingest of pipeline data only. Fix target names.",
@@ -7902,7 +8154,9 @@
                 }
             },
             "version": 2,
-            "id": 7
+            "id": 8,
+            "state_value": "development",
+            "purpose_value": "technical_commissioning"
         },
         {
             "description": "LBA Imaging Observing Strategy using 2 Beams and a parallel Calibrator Beam with a preprocessing pipeline for each.",
@@ -8780,7 +9034,9 @@
                 }
             },
             "version": 2,
-            "id": 8
+            "id": 9,
+            "state_value": "development",
+            "purpose_value": "technical_commissioning"
         },
         {
             "description": "LBA Imaging Observing Strategy using 5 Beams and a parallel Calibrator Beam with a preprocessing pipeline for each, used for the LOFAR Decametre Sky Survey. LBA Sparse Even, 14.4-30.1 MHz, 1s, 64ch/sb",
@@ -9896,7 +10152,9 @@
                 }
             },
             "version": 2,
-            "id": 9
+            "id": 10,
+            "state_value": "development",
+            "purpose_value": "technical_commissioning"
         },
         {
             "description": "LBA Imaging Observing Strategy using 3 Beams and a parallel Calibrator Beam with a preprocessing pipeline for each, used for the LOFAR LBA High Survey and LBA Co-observing.",
@@ -10943,7 +11201,9 @@
                 }
             },
             "version": 2,
-            "id": 10
+            "id": 11,
+            "state_value": "development",
+            "purpose_value": "technical_commissioning"
         },
         {
             "description": "This observation strategy template defines a similar observation strategy as for LoTSS, but then with a single Calibrator at the end so that the Target Observation can start immediately once the trigger is submitted.",
@@ -11537,7 +11797,9 @@
                 }
             },
             "version": 2,
-            "id": 11
+            "id": 12,
+            "state_value": "development",
+            "purpose_value": "technical_commissioning"
         },
         {
             "description": "This observation strategy template defines a single simple beamforming observation.",
@@ -12231,7 +12493,9 @@
                 }
             },
             "version": 2,
-            "id": 12
+            "id": 13,
+            "state_value": "development",
+            "purpose_value": "technical_commissioning"
         },
         {
             "description": "This observation strategy template defines a single simple Target observation.",
@@ -12603,7 +12867,383 @@
                 }
             },
             "version": 2,
-            "id": 13
+            "id": 14,
+            "state_value": "development",
+            "purpose_value": "technical_commissioning"
+        },
+        {
+            "description": "This observation strategy template defines a single simple Target observation.",
+            "name": "Simple Observation",
+            "purpose": "production",
+            "scheduling_unit_template": {
+                "name": "scheduling unit",
+                "version": 2
+            },
+            "state": "active",
+            "template": {
+                "parameters": [
+                    {
+                        "name": "Scheduling Constraints",
+                        "refs": [
+                            "#/scheduling_constraints_doc"
+                        ]
+                    },
+                    {
+                        "name": "Duration",
+                        "refs": [
+                            "#/tasks/Observation/specifications_doc/duration"
+                        ]
+                    },
+                    {
+                        "name": "Target Pointing",
+                        "refs": [
+                            "#/tasks/Observation/specifications_doc/station_configuration/SAPs/0/digital_pointing"
+                        ]
+                    },
+                    {
+                        "name": "Tile Beam",
+                        "refs": [
+                            "#/tasks/Observation/specifications_doc/station_configuration/tile_beam"
+                        ]
+                    }
+                ],
+                "scheduling_constraints_doc": {
+                    "scheduler": "dynamic",
+                    "sky": {
+                        "min_distance": {
+                            "jupiter": 0,
+                            "moon": 0,
+                            "sun": 0
+                        },
+                        "min_elevation": {
+                            "target": 0.1
+                        },
+                        "transit_offset": {
+                            "from": -21600,
+                            "to": 21600
+                        }
+                    }
+                },
+                "scheduling_constraints_template": {
+                    "name": "constraints"
+                },
+                "task_relations": [],
+                "task_scheduling_relations": [],
+                "tasks": {
+                    "Observation": {
+                        "description": "A simple short test observation",
+                        "specifications_doc": {
+                            "QA": {
+                                "file_conversion": {
+                                    "enabled": true,
+                                    "nr_of_subbands": -1,
+                                    "nr_of_timestamps": 256
+                                },
+                                "inspection_plots": "msplots",
+                                "plots": {
+                                    "autocorrelation": true,
+                                    "crosscorrelation": true,
+                                    "enabled": true
+                                }
+                            },
+                            "correlator": {
+                                "channels_per_subband": 64,
+                                "integration_time": 1,
+                                "storage_cluster": "CEP4"
+                            },
+                            "duration": 120,
+                            "station_configuration": {
+                                "SAPs": [
+                                    {
+                                        "digital_pointing": {
+                                            "angle1": 0.6624317181687094,
+                                            "angle2": 1.5579526427549426,
+                                            "direction_type": "J2000",
+                                            "target": "target1"
+                                        },
+                                        "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
+                                        ]
+                                    }
+                                ],
+                                "antenna_set": "HBA_DUAL_INNER",
+                                "filter": "HBA_110_190",
+                                "station_groups": [
+                                    {
+                                        "max_nr_missing": 1,
+                                        "stations": [
+                                            "CS002",
+                                            "CS003",
+                                            "CS004",
+                                            "CS005",
+                                            "CS006",
+                                            "CS007"
+                                        ]
+                                    }
+                                ],
+                                "tile_beam": {
+                                    "angle1": 0.6624317181687094,
+                                    "angle2": 1.5579526427549426,
+                                    "direction_type": "J2000",
+                                    "target": "target1"
+                                }
+                            }
+                        },
+                        "specifications_template": {
+                            "name": "target observation",
+                            "version": 2
+                        }
+                    }
+                }
+            },
+            "version": 1,
+            "id": 15,
+            "state_value": "active",
+            "purpose_value": "production"
         }
     ]
 }
\ No newline at end of file
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 3be72e8a309..3d5f7be8bd0 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
@@ -1513,6 +1513,42 @@ const SUServiceMock= {
         // return templates.strategies.find(strategy=> { return strategy.name === name });
         return SUServiceMock.getObservStrategies().find(strategy=> { return strategy.name === name });
     },
+    templatePurposes: [
+        {
+          "value": "production",
+          "url": "http://localhost:3000/api/template_purpose/production"
+        },
+        {
+          "value": "scientific_commissioning",
+          "url": "http://localhost:3000/api/template_purpose/scientific_commissioning"
+        },
+        {
+          "value": "technical_commissioning",
+          "url": "http://localhost:3000/api/template_purpose/technical_commissioning"
+        },
+        {
+          "value": "system_health",
+          "url": "http://localhost:3000/api/template_purpose/system_health"
+        }
+      ],
+    templateStates: [
+        {
+          "value": "development",
+          "url": "http://localhost:3000/api/template_state/development"
+        },
+        {
+          "value": "active",
+          "url": "http://localhost:3000/api/template_state/active"
+        },
+        {
+          "value": "legacy",
+          "url": "http://localhost:3000/api/template_state/legacy"
+        },
+        {
+          "value": "obsolete",
+          "url": "http://localhost:3000/api/template_state/obsolete"
+        }
+    ],
     getSchedulingUnitFromObservStrategy: () => {
         const strategyId = SUServiceMock.getObservStrategy("Simple Observation")['id'];
         return {
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js
index ebf4ecb0b27..e79d058a1cd 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js
@@ -162,10 +162,10 @@ export class SchedulingUnitCreate extends Component {
     }
 
     getStrategyFilterOptions(filterValues, filterId) {  
-        if (filterValues.data.results) {
+        if (filterValues) {
             let optionList = [];
-            filterValues.data.results.forEach(choice => {
-                const tmpVar = {name: _.startCase(choice.value), value: choice.value};
+            filterValues.forEach(choice => {
+                const tmpVar = {name: choice.value, value: choice.value};
                 if(filterId === 'purpose') {
                     optionList.push(tmpVar);
                 }
@@ -309,7 +309,7 @@ export class SchedulingUnitCreate extends Component {
         if(defaultValues) {
             this.defaultConstraints = parentProps;
         } else {
-        this.setState({constraintInitParams : parentProps});
+            this.setState({constraintInitParams : parentProps});
         }
     }
     setConstraintsEditorOutput(jsonOutput, errors) {
@@ -569,28 +569,29 @@ export class SchedulingUnitCreate extends Component {
     reset() {
         const schedulingSets = this.state.schedulingSets;
         this.nameInput.element.focus();
-        const selectedProject = this.props.match.params.project;
+        const selectedProject = this.props.match?.params?.project;
                 
         this.setState({
             dialogVisible: false,
             isDirty: false,
             dialog: { header: '', detail: ''},      
             errors: [],
-            schedulingSets: this.props.match.params.project?schedulingSets:[],
+            schedulingSets: this.props.match?.params?.project?schedulingSets:[],
             schedulingUnit: {
                 name: '',
                 description: '',
                 project: selectedProject || null,
                 scheduling_constraints_template_id: this.constraintTemplates[0].id,
                 rank: '',
-                output_pinned: this.props.match.params.project?((_.find(this.projects, {'name': selectedProject}))?.auto_pin):null
+                output_pinned: this.props.match?.params?.project?((_.find(this.projects, {'name': selectedProject}))?.auto_pin):null
              },
-            projectDisabled: (this.props.match.params.project? true:false),
+            projectDisabled: (this.props.match?.params?.project? true:false),
             observStrategy: {},
             paramsOutput: null,
             validEditor: false,
             validFields: {},
             constraintSchema: null,
+            constraintInitParams: null,
             selectedStations: null,
             touched:false,
             stationGroup: []
@@ -835,7 +836,7 @@ export class SchedulingUnitCreate extends Component {
                                         maxSelectedLabels="1"
                                         selectedItemsLabel="{0} Selected"
                                         placeholder= "State"  />
-                                <Dropdown inputId="observStrategy" optionLabel="id" optionValue="id" 
+                                <Dropdown inputId="observStrategy" optionLabel="uniqueId" optionValue="id" 
                                         tooltip="Observation Strategy Template to be used to create the Scheduling Unit and Tasks. Strategies already used are highlighted in bold" tooltipOptions={this.tooltipOptions}
                                         value={this.state.observStrategy.id} 
                                         options={this.state.observStrategies} filter
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 b10b5f3c116..627a9148505 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
@@ -5,6 +5,7 @@ import { render, screen, cleanup, fireEvent, waitForElement  } from '@testing-li
 import '@testing-library/jest-dom/extend-expect';
 import '@testing-library/jest-dom'
 // import renderer from 'react-test-renderer';
+import _ from 'lodash';
 
 import {SchedulingUnitCreate} from './create';
 import ScheduleService from '../../services/schedule.service';
@@ -23,7 +24,7 @@ import AuthServiceMock from '../../__mocks__/auth.service.data';
 
 let projectListSpy, scheduleSetListSpy, observStrategiesSpy, taskTemplatesSpy, saveSUFromStrategySpy, updateSUSpy, createSUTasksSpy, 
 utilSpy, utcSpy, taskFilterDefSpy, suConstraintTemplateSpy, suFilterDefSpy, allTaskRelationSpy, stationGroupSpy, stationSpy, 
-userPermissionSpy, authPermissionSpy,  scheduleSetByIdSpy;
+userPermissionSpy, authPermissionSpy,  scheduleSetByIdSpy, templatePurposesSpy, templateStatesSpy;
 jest.setTimeout(120000);
 
 beforeEach(() => {
@@ -68,10 +69,13 @@ const setMockSpy = async () => {
     taskFilterDefSpy = jest.spyOn(TaskService, 'getTaskFilterDefinition');
     taskFilterDefSpy.mockImplementation(() => { return Promise.resolve(TaskServiceMock.getTaskFilterDefinition)});
 
+    templatePurposesSpy = jest.spyOn(ScheduleService, 'getStrategyPurpose');
+    templatePurposesSpy.mockImplementation(() => { return Promise.resolve(SUServiceMock.templatePurposes)});
+
+    templateStatesSpy = jest.spyOn(ScheduleService, 'getStrategyState');
+    templateStatesSpy.mockImplementation(() => { return Promise.resolve(SUServiceMock.templateStates)});
+
     suConstraintTemplateSpy = jest.spyOn(ScheduleService, 'getSchedulingConstraintTemplates');
-    // suConstraintTemplateSpy.mockImplementation(() => { return Promise.resolve(SUServiceMock.getSchedulingConstraintTemplates); });
-    // suConstraintTemplateSpy.mockImplementation(async() => { const mockSUCTemplates = await SUServiceMock.getSchedulingConstraintTemplates(); console.log(mockSUCTemplates); return mockSUCTemplates });
-    // const mockSUCTemplates = await SUServiceMock.getSUCTemplates();
     suConstraintTemplateSpy.mockImplementation(() => { return Promise.resolve(SUServiceMock.getSUCTemplates()); });
     console.log("1....................");
     
@@ -120,6 +124,8 @@ const clearMockSpy = () => {
     stationGroupSpy.mockRestore();
     stationSpy.mockRestore();
     scheduleSetByIdSpy.mockRestore();
+    templatePurposesSpy.mockRestore();
+    templateStatesSpy.mockRestore();
     //authPermissionSpy.mockRestore();
     //userPermissionSpy.mockRestore();
 }
@@ -131,9 +137,9 @@ it("renders SU create page with all fields and default values", async() => {
     //expect(tree).toMatchSnapshot();
     //await new Promise((wait) => setTimeout(wait, 4000));
     await act(async () => {
-        content = render(<Router><SchedulingUnitCreate  location={{pathname: '/schedulingunit/'}}/></Router>);
+        content = render(<Router><SchedulingUnitCreate  location={{pathname: '/schedulingunit/create'}}/></Router>);
+        await new Promise((r) => setTimeout(r, 2000));
     });
-   // await new Promise((wait) => setTimeout(wait, 1000));
     expect(content.queryByText('Scheduling Unit - Add')).not.toBe(null);        // Page loaded successfully
     expect(projectListSpy).toHaveBeenCalled();                                  // Mock Spy called successfully
     expect(observStrategiesSpy).toHaveBeenCalled();                             // Mock Spy called successfully
@@ -159,88 +165,8 @@ it("renders SU create page with all fields and default values", async() => {
 
     expect(content.queryByTestId('save-btn')).toHaveAttribute("disabled");
 
-    /*expect(content.queryByText('TMSS-Commissioning')).toBeInTheDocument();      // Project Dropdown  loaded successfully
-    expect(content.queryByText('UC1 observation strategy template')).toBeInTheDocument();      // Observation Strategy Dropdown  loaded successfully
-    expect(content.queryByText('Task Parameters')).not.toBeInTheDocument();      // JSON Editor not rendered
-    expect(content.queryByTestId('save-btn')).toHaveAttribute("disabled");*/
 });
  
-it("creates new Scheduling Unit with default values", async() => {
-    console.log("creates new Scheduling Unit with default values ------------------------");
-    
-    let content;
-    await act(async () => {
-        content = render(<Router><SchedulingUnitCreate  location={{pathname: '/schedulingunit/'}}/></Router>);
-        await new Promise((r) => setTimeout(r, 1000));
-    });
-    const nameInput = content.queryByTestId('name');
-    const descInput = content.queryByTestId('description');
-    const projInput = content.getAllByRole("listbox")[0].children[0] ;
-    
-    // Set values for all mandatory input and test if save button is enabled
-    fireEvent.change(nameInput, { target: { value: 'Test SU 01' } });
-    expect(nameInput.value).toBe("Test SU 01");
-    fireEvent.change(descInput, { target: { value: 'Test SU 01' } });
-    expect(descInput.value).toBe("Test SU 01");
-    
-    // After selecting values for all dropdowns
-    await act(async () => {
-        fireEvent.click(projInput);
-    });
-    const schedulingSetInput = content.getAllByRole("listbox")[1].children[0] ;
-    expect(content.queryAllByText('Select Project').length).toBe(1);
-    expect(content.queryAllByText('high').length).toBe(3);
-    
-    await act(async () => {
-        fireEvent.click(schedulingSetInput);
-    });
-    expect(content.queryAllByText('Select Scheduling Set').length).toBe(1);
-    expect(content.queryAllByText('Test Scheduling Set').length).toBe(3);
-    expect(content.queryAllByText('Select Strategy').length).toBe(2);
-    expect(content.queryAllByText('Simple Observation').length).toBe(0);
-    expect(content.queryAllByText('Dutch').length).toBe(1);
-    //jest.setTimeout(30000);
-    const selectStationGroup = content.getAllByRole("listbox")[3].children[0]
-    await act( async() => {
-            fireEvent.click(selectStationGroup);
-            await new Promise((r) => setTimeout(r, 300));
-        });
-    expect(content.queryAllByText('Dutch').length).toBe(3);
-    expect(screen.queryAllByPlaceholderText('Max No. of Missing Stations'))
-    const missingStationeInput = screen.queryAllByPlaceholderText('Max No. of Missing Stations')[0]
-    fireEvent.change(missingStationeInput, { target: { value: '' } });
-    expect(missingStationeInput.value).toBe("");
-    expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeTruthy();
-    fireEvent.change(missingStationeInput, { target: { value: '1' } });
-    expect(missingStationeInput.value).toBe("1");
-    const observStrategyInput = content.getAllByLabelText("Simple Observation");
-    await act( async() => {
-        fireEvent.click(observStrategyInput[observStrategyInput.length-1]);
-        await new Promise((r) => setTimeout(r, 1000));
-    });
-   
-    expect(content.queryAllByText('Select Strategy').length).toBe(1);
-    expect(content.queryAllByText('Simple Observation').length).toBe(2);
-    expect(content.queryAllByText('Station Groups').length).toBe(2);
-    expect(content.queryAllByText('Superterp').length).toBe(1);
-    expect(content.queryByText('Scheduling Constraints specification')).toBeInTheDocument(); // make sure Scheduling Constraint appear when page loading
-    expect(content.queryAllByText('dynamic').length).toBe(1); // In Scheduling Co nstraints, the scheduler type is set with default value 'dynamic'
-    expect(content.queryByText('Task Parameters')).toBeInTheDocument();
-    expect(content.queryByText('Target Pointing')).toBeInTheDocument();
-    expect(content.queryByText('Tile Beam')).toBeInTheDocument();
-    expect(content.queryAllByText('J2000').length).toBe(2); // As per the data provided it should contains 3 values
-    expect(content.queryByText('Degrees or Radian')).not.toBeInTheDocument();   // Make sure default values are loaded
-    expect(content.queryByText('Maximum number of stations that can be missed in the selected groups')).toBeInTheDocument();  //make sure station group is loaded
-    
-    expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy();
-    expect(content.queryByText('Success')).not.toBeInTheDocument();
-    await act(async () => {
-        fireEvent.click(content.queryByTestId('save-btn'));
-    });
-    expect(saveSUFromStrategySpy).toHaveBeenCalled();
-    expect(content.queryByText('Success')).toBeInTheDocument(); //check popup appear after create SU successfully
-}); 
-
 /*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;
@@ -269,41 +195,120 @@ it("creates new Scheduling Unit with default values", async() => {
     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 ------------------------");
+it("Test Simple Observation", async() => {
+    console.log("Test Simple Observation ------------------------");
+    
     let content;
     await act(async () => {
-        content =render(<Router><SchedulingUnitCreate  location={{pathname: '/schedulingunit/'}}/></Router>);
+        content = render(<Router><SchedulingUnitCreate  location={{pathname: '/schedulingunit/create'}}/></Router>);
         await new Promise((r) => setTimeout(r, 1000));
     });
-    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.getAllByLabelText("Simple Observation");
-    await act( async() => {
-        fireEvent.click(simpleObservStrategyInput[simpleObservStrategyInput.length-1]);
-        await new Promise((r) => setTimeout(r, 1000));
-    });
-    expect(screen.getByDisplayValue("dynamic")).toBeInTheDocument();
-    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");
+    const nameInput = content.queryByTestId('name');
+    const descInput = content.queryByTestId('description');
+    const projInput = content.getAllByRole("listbox")[0].children[0] ;
+    
+    expect(content.queryAllByText('Select Strategy').length).toBe(2);
+    expect(content.queryAllByText('Simple Observation').length).toBe(0);
+    expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeTruthy();
+    // expect(content.queryAllByText('Purpose').length).toBe(1);
+    const simpleObsStrategies = _.filter(SUServiceMock.getObservStrategies(), ["name", 'Simple Observation']);
+    for (const simpleObsStrategy of simpleObsStrategies) {
+        if (simpleObsStrategy.state !== "obsolete") {
+            const optionLabel = `${simpleObsStrategy.name} (${simpleObsStrategy.purpose}, ${simpleObsStrategy.state}, v${simpleObsStrategy.version})`;
+            console.log("Testing ", optionLabel);
+            // Set values for all mandatory input and test if save button is enabled
+            fireEvent.change(nameInput, { target: { value: 'Test SU 01' } });
+            expect(nameInput.value).toBe("Test SU 01");
+            fireEvent.change(descInput, { target: { value: 'Test SU 01' } });
+            expect(descInput.value).toBe("Test SU 01");
+            
+            // After selecting values for all dropdowns
+            await act(async () => {
+                fireEvent.click(projInput);
+            });
+            const schedulingSetInput = content.getAllByRole("listbox")[1].children[0] ;
+            expect(content.queryAllByText('Select Project').length).toBe(1);
+            expect(content.queryAllByText('high').length).toBe(3);
+            
+            await act(async () => {
+                fireEvent.click(schedulingSetInput);
+            });
+            expect(content.queryAllByText('Select Scheduling Set').length).toBe(1);
+            expect(content.queryAllByText('Test Scheduling Set').length).toBe(3);
+
+            //Checking default constraint values
+            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 templatePurpose = screen.getAllByText(simpleObsStrategy.purpose)[0];
+            const templateState = screen.getAllByText(simpleObsStrategy.state)[0];
+            await act( async() => {
+                fireEvent.click(templatePurpose);
+                fireEvent.click(templateState);
+                await new Promise((r) => setTimeout(r, 1000));
+            });
+            // expect(content.queryAllByText('Purpose').length).toBe(0);
+            expect(content.queryAllByText(optionLabel).length).toBe(1);
+            const observStrategyInput = screen.getAllByText(optionLabel);
+            await act( async() => {
+                fireEvent.click(observStrategyInput[0].parentElement);
+                await new Promise((r) => setTimeout(r, 1000));
+            });
+        
+            // expect(content.queryAllByText('Select Strategy').length).toBe(1);
+            // expect(content.queryAllByText(optionLabel).length).toBe(2);
+            expect(content.queryAllByText('Station Groups').length).toBe(2);
+            expect(content.queryAllByText('Superterp').length).toBe(1);
+            expect(content.queryByText('Scheduling Constraints specification')).toBeInTheDocument(); // make sure Scheduling Constraint appear when page loading
+            expect(screen.getByDisplayValue("dynamic")).toBeInTheDocument();
+            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");
+
+            expect(content.queryByText('Task Parameters')).toBeInTheDocument();
+            expect(content.queryByText('Target Pointing')).toBeInTheDocument();
+            expect(content.queryByText('Tile Beam')).toBeInTheDocument();
+            expect(content.queryAllByText('J2000').length).toBe(2); // As per the data provided it should contains 3 values
+            expect(content.queryByText('Degrees or Radian')).not.toBeInTheDocument();   // Make sure default values are loaded
+            expect(content.queryByText('Maximum number of stations that can be missed in the selected groups')).toBeInTheDocument();  //make sure station group is loaded
+            
+            expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy();
+            expect(content.queryByText('Success')).not.toBeInTheDocument();
+            await act(async () => {
+                fireEvent.click(content.queryByTestId('save-btn'));
+            });
+            expect(saveSUFromStrategySpy).toHaveBeenCalled();
+            expect(content.queryByText('Success')).toBeInTheDocument(); //check popup appear after create SU successfully
+            expect(screen.getByText("Yes")).toBeInTheDocument()
+            await act(async () => {
+                fireEvent.click(screen.getByText("Yes"));
+                await new Promise((r) => setTimeout(r, 1000));
+            });
+
+            // Reset the purpose and state filter selection
+            await act( async() => {
+                fireEvent.click(templatePurpose);
+                fireEvent.click(templateState);
+                await new Promise((r) => setTimeout(r, 1000));
+            });
+        }
+    }
 });
 
 it("Test 'IM LBA Survey - 3 Beams' strategy...", async() => {
-    console.log("Test 'IM LBA Survey - 3 Beams' strategy...");
     let content;
     await act(async () => {
         content =render(<Router><SchedulingUnitCreate  location={{pathname: '/schedulingunit/'}}/></Router>);
@@ -327,104 +332,124 @@ it("Test 'IM LBA Survey - 3 Beams' strategy...", async() => {
     const descInput = content.queryByTestId('description');
     const projInput = content.getAllByRole("listbox")[0].children[0] ;
     
-    // Set values for all mandatory input 
-    fireEvent.change(nameInput, { target: { value: 'Test SU1' } });
-    fireEvent.change(descInput, { target: { value: 'Test SU1' } });
-    await act(async () => {
-        fireEvent.click(projInput);
-    });
-    const schedulingSetInput = content.getAllByRole("listbox")[1].children[0] ;
-    await act(async () => {
-        fireEvent.click(schedulingSetInput);
-    });
-    const simpleObservStrategyInput = screen.getAllByLabelText("IM LBA Survey - 3 Beams");
-    console.log(simpleObservStrategyInput);
-    await act( async() => {
-        fireEvent.click(simpleObservStrategyInput[simpleObservStrategyInput.length-1]);
-        await new Promise((r) => setTimeout(r, 1000));
-    });
-    console.log("Checking Station Groups...");
-    // Check station group section
-    expect(screen.getAllByText("Dutch").length).toBe(2);
-    expect(screen.getAllByText("RS508,RS509").length).toBe(1);
-    expect(screen.getAllByText("RS310,RS210").length).toBe(1);
-    expect(screen.getAllByPlaceholderText("Max No. of Missing Stations")[0].value).toBe("4");
-    expect(screen.getAllByPlaceholderText("Max Number of Missing Stations").length).toBe(2);
-    expect(screen.getAllByPlaceholderText("Max Number of Missing Stations")[0].value).toBe("1");
-    expect(screen.getAllByPlaceholderText("Max Number of Missing Stations")[1].value).toBe("0");
-    // Check constraints
-    console.log("Checking strategy constraints ...");
-    expect(screen.getByDisplayValue("dynamic")).toBeInTheDocument();
-    expect(screen.getByLabelText("specification[sky][transit_offset][from]").value).toBe("-04:00:00");
-    expect(screen.getByLabelText("specification[sky][transit_offset][to]").value).toBe("04:00:00");
-    expect(screen.getByLabelText("specification[sky][min_distance][sun]").value).toBe("30.00");
-    expect(screen.getByLabelText("specification[sky][min_distance][moon]").value).toBe("30.00");
-    expect(screen.getByLabelText("specification[sky][min_distance][jupiter]").value).toBe("15.00");
-    expect(screen.getByLabelText("specification[sky][min_elevation][calibrator]").value).toBe("30.00");
-    expect(screen.getByLabelText("specification[sky][min_elevation][target]").value).toBe("50.00");
-    // Check Task parameters
-    console.log("Checking Task Parameters ...");
-    expect(screen.getByLabelText("specification[Duration]").value).toBe("00:02:00");
-    const runQASelect = screen.getAllByDisplayValue("true").find(select => select.name==="specification[Run ADDER QA]");
-    expect(runQASelect).not.toBeUndefined();
-    expect(screen.getByLabelText("specification[Observation description]")).toBeInTheDocument();
-    expect(screen.getByLabelText("specification[Observation description]").value).toBe("OOO.O Paaa+01 Paaa+02 Paaa+03");
-    expect(screen.getByLabelText("specification[Pipeline 1 description]").value).toBe("c17 oOOO.O Paaa+01");
-    expect(screen.getByLabelText("specification[Pipeline 2 description]").value).toBe("c17 oOOO.O Paaa+02");
-    expect(screen.getByLabelText("specification[Pipeline 3 description]").value).toBe("c17 oOOO.O Paaa+03");
-    expect(screen.getByLabelText("specification[Pipeline Calibrator description]").value).toBe("c17 oOOO.O 3Cabc");
-    expect(screen.getByLabelText("specification[Target Pointing 1][angle1]").value).toBe("02h31m49.09s");
-    expect(screen.getByLabelText("specification[Target Pointing 1][angle2]").value).toBe("89d15m50.8s");
-    expect(screen.getByLabelText("specification[Target Pointing 1][target]").value).toBe("Paaa+01");
-    expect(screen.getByLabelText("specification[Target Pointing 2][angle1]").value).toBe("02h31m49.09s");
-    expect(screen.getByLabelText("specification[Target Pointing 2][angle2]").value).toBe("89d15m50.8s");
-    expect(screen.getByLabelText("specification[Target Pointing 2][target]").value).toBe("Paaa+02");
-    expect(screen.getByLabelText("specification[Target Pointing 3][angle1]").value).toBe("02h31m49.09s");
-    expect(screen.getByLabelText("specification[Target Pointing 3][angle2]").value).toBe("89d15m50.8s");
-    expect(screen.getByLabelText("specification[Target Pointing 3][target]").value).toBe("Paaa+03");
-    expect(screen.getByLabelText("specification[Calibrator Pointing][angle1]").value).toBe("02h31m49.09s");
-    expect(screen.getByLabelText("specification[Calibrator Pointing][angle2]").value).toBe("89d15m50.8s");
-    expect(screen.getByLabelText("specification[Calibrator Pointing][target]").value).toBe("3Cabc");
-    expect(screen.getAllByDisplayValue("J2000").length).toBe(4);
-    expect(screen.getByLabelText("specification[Time averaging steps]").value).toBe("4");
-    expect(screen.getByLabelText("specification[Frequency averaging steps]").value).toBe("8");
-    expect(screen.getAllByDisplayValue("false").length).toBe(3);
-    const casAChecks = screen.getAllByText("CasA");
-    for (const checkbox of casAChecks) {
-        expect(checkbox.parentElement.firstChild.checked).toBeFalsy();
-    }
-    const cygAChecks = screen.getAllByText("CygA");
-    for (const checkbox of cygAChecks) {
-        expect(checkbox.parentElement.firstChild.checked).toBeFalsy();
-    }
-    const herAChecks = screen.getAllByText("HerA");
-    for (const checkbox of herAChecks) {
-        expect(checkbox.parentElement.firstChild.checked).toBeFalsy();
-    }
-    const hydraAChecks = screen.getAllByText("HydraA");
-    for (const checkbox of hydraAChecks) {
-        expect(checkbox.parentElement.firstChild.checked).toBeFalsy();
-    }
-    const tauAChecks = screen.getAllByText("TauA");
-    for (const checkbox of tauAChecks) {
-        expect(checkbox.parentElement.firstChild.checked).toBeFalsy();
-    }
-    const virAChecks = screen.getAllByText("VirA");
-    for (const checkbox of virAChecks) {
-        expect(checkbox.parentElement.firstChild.checked).toBeFalsy();
-    }
+    const lbaObsStrategies = _.filter(SUServiceMock.getObservStrategies(), ["name", 'IM LBA Survey - 3 Beams']);
+    for (const lbaObsStrategy of lbaObsStrategies) {
+        if (lbaObsStrategy.state !== "obsolete") {
+            const optionLabel = `${lbaObsStrategy.name} (${lbaObsStrategy.purpose}, ${lbaObsStrategy.state}, v${lbaObsStrategy.version})`;
+            console.log("Testing ", optionLabel);
+            // Set values for all mandatory input 
+            fireEvent.change(nameInput, { target: { value: 'Test SU1' } });
+            fireEvent.change(descInput, { target: { value: 'Test SU1' } });
+            await act(async () => {
+                fireEvent.click(projInput);
+            });
+            const schedulingSetInput = content.getAllByRole("listbox")[1].children[0] ;
+            await act(async () => {
+                fireEvent.click(schedulingSetInput);
+            });
+            const templatePurpose = screen.getAllByText(lbaObsStrategy.purpose)[0];
+            const templateState = screen.getAllByText(lbaObsStrategy.state)[0];
+            await act( async() => {
+                fireEvent.click(templatePurpose);
+                fireEvent.click(templateState);
+                await new Promise((r) => setTimeout(r, 1000));
+            });
+            expect(content.queryAllByText(optionLabel).length).toBe(1);
+            const observStrategyInput = screen.getAllByText(optionLabel);
+            await act( async() => {
+                fireEvent.click(observStrategyInput[0].parentElement);
+                await new Promise((r) => setTimeout(r, 1000));
+            });
+            console.log("Checking Station Groups...");
+            // Check station group section
+            expect(screen.getAllByText("Dutch").length).toBe(2);
+            expect(screen.getAllByText("RS508,RS509").length).toBe(1);
+            expect(screen.getAllByText("RS310,RS210").length).toBe(1);
+            expect(screen.getAllByPlaceholderText("Max No. of Missing Stations")[0].value).toBe("4");
+            expect(screen.getAllByPlaceholderText("Max Number of Missing Stations").length).toBe(2);
+            expect(screen.getAllByPlaceholderText("Max Number of Missing Stations")[0].value).toBe("1");
+            expect(screen.getAllByPlaceholderText("Max Number of Missing Stations")[1].value).toBe("0");
+            // Check constraints
+            console.log("Checking strategy constraints ...");
+            expect(screen.getByDisplayValue("dynamic")).toBeInTheDocument();
+            expect(screen.getByLabelText("specification[sky][transit_offset][from]").value).toBe("-04:00:00");
+            expect(screen.getByLabelText("specification[sky][transit_offset][to]").value).toBe("04:00:00");
+            expect(screen.getByLabelText("specification[sky][min_distance][sun]").value).toBe("30.00");
+            expect(screen.getByLabelText("specification[sky][min_distance][moon]").value).toBe("30.00");
+            expect(screen.getByLabelText("specification[sky][min_distance][jupiter]").value).toBe("15.00");
+            expect(screen.getByLabelText("specification[sky][min_elevation][calibrator]").value).toBe("30.00");
+            expect(screen.getByLabelText("specification[sky][min_elevation][target]").value).toBe("50.00");
+            // Check Task parameters
+            console.log("Checking Task Parameters ...");
+            expect(screen.getByLabelText("specification[Duration]").value).toBe("00:02:00");
+            const runQASelect = screen.getAllByDisplayValue("true").find(select => select.name==="specification[Run ADDER QA]");
+            expect(runQASelect).not.toBeUndefined();
+            expect(screen.getByLabelText("specification[Observation description]")).toBeInTheDocument();
+            expect(screen.getByLabelText("specification[Observation description]").value).toBe("OOO.O Paaa+01 Paaa+02 Paaa+03");
+            expect(screen.getByLabelText("specification[Pipeline 1 description]").value).toBe("c17 oOOO.O Paaa+01");
+            expect(screen.getByLabelText("specification[Pipeline 2 description]").value).toBe("c17 oOOO.O Paaa+02");
+            expect(screen.getByLabelText("specification[Pipeline 3 description]").value).toBe("c17 oOOO.O Paaa+03");
+            expect(screen.getByLabelText("specification[Pipeline Calibrator description]").value).toBe("c17 oOOO.O 3Cabc");
+            expect(screen.getByLabelText("specification[Target Pointing 1][angle1]").value).toBe("02h31m49.09s");
+            expect(screen.getByLabelText("specification[Target Pointing 1][angle2]").value).toBe("89d15m50.8s");
+            expect(screen.getByLabelText("specification[Target Pointing 1][target]").value).toBe("Paaa+01");
+            expect(screen.getByLabelText("specification[Target Pointing 2][angle1]").value).toBe("02h31m49.09s");
+            expect(screen.getByLabelText("specification[Target Pointing 2][angle2]").value).toBe("89d15m50.8s");
+            expect(screen.getByLabelText("specification[Target Pointing 2][target]").value).toBe("Paaa+02");
+            expect(screen.getByLabelText("specification[Target Pointing 3][angle1]").value).toBe("02h31m49.09s");
+            expect(screen.getByLabelText("specification[Target Pointing 3][angle2]").value).toBe("89d15m50.8s");
+            expect(screen.getByLabelText("specification[Target Pointing 3][target]").value).toBe("Paaa+03");
+            expect(screen.getByLabelText("specification[Calibrator Pointing][angle1]").value).toBe("02h31m49.09s");
+            expect(screen.getByLabelText("specification[Calibrator Pointing][angle2]").value).toBe("89d15m50.8s");
+            expect(screen.getByLabelText("specification[Calibrator Pointing][target]").value).toBe("3Cabc");
+            expect(screen.getAllByDisplayValue("J2000").length).toBe(4);
+            expect(screen.getByLabelText("specification[Time averaging steps]").value).toBe("4");
+            expect(screen.getByLabelText("specification[Frequency averaging steps]").value).toBe("8");
+            expect(screen.getAllByDisplayValue("false").length).toBe(3);
+            const casAChecks = screen.getAllByText("CasA");
+            for (const checkbox of casAChecks) {
+                expect(checkbox.parentElement.firstChild.checked).toBeFalsy();
+            }
+            const cygAChecks = screen.getAllByText("CygA");
+            for (const checkbox of cygAChecks) {
+                expect(checkbox.parentElement.firstChild.checked).toBeFalsy();
+            }
+            const herAChecks = screen.getAllByText("HerA");
+            for (const checkbox of herAChecks) {
+                expect(checkbox.parentElement.firstChild.checked).toBeFalsy();
+            }
+            const hydraAChecks = screen.getAllByText("HydraA");
+            for (const checkbox of hydraAChecks) {
+                expect(checkbox.parentElement.firstChild.checked).toBeFalsy();
+            }
+            const tauAChecks = screen.getAllByText("TauA");
+            for (const checkbox of tauAChecks) {
+                expect(checkbox.parentElement.firstChild.checked).toBeFalsy();
+            }
+            const virAChecks = screen.getAllByText("VirA");
+            for (const checkbox of virAChecks) {
+                expect(checkbox.parentElement.firstChild.checked).toBeFalsy();
+            }
 
-    // Check save button state and click to save
-    console.log("Checking Save button...");
-    console.log(content.queryByTestId('save-btn').hasAttribute("disabled"));
-    expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy();
-    expect(content.queryByText('Success')).not.toBeInTheDocument();
-    console.log("Firing Click Event...");
-    await act(async () => {
-        fireEvent.click(content.queryByTestId('save-btn'));
-        await new Promise((r) => setTimeout(r, 2000));
-    });
-    console.log("Checking service calls..");
-    expect(saveSUFromStrategySpy).toHaveBeenCalled();
-    expect(content.queryByText('Success')).toBeInTheDocument();
+            // Check save button state and click to save
+            console.log("Checking Save button...");
+            expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy();
+            expect(content.queryByText('Success')).not.toBeInTheDocument();
+            console.log("Firing Click Event...");
+            await act(async () => {
+                fireEvent.click(content.queryByTestId('save-btn'));
+                await new Promise((r) => setTimeout(r, 2000));
+            });
+            console.log("Checking service calls..");
+            expect(saveSUFromStrategySpy).toHaveBeenCalled();
+            expect(content.queryByText('Success')).toBeInTheDocument();
+
+            // Reset the purpose and state filter selection
+            await act( async() => {
+                fireEvent.click(templatePurpose);
+                fireEvent.click(templateState);
+                await new Promise((r) => setTimeout(r, 1000));
+            });
+        }
+    }
 });
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js
index 8511072d1b1..3bf32d994c1 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js
@@ -3007,10 +3007,10 @@ export class SchedulingSetCreate extends Component {
     }
 
     getStrategyFilterOptions(filterValues, filterId) {  
-        if (filterValues.data.results) {
+        if (filterValues) {
             let optionList = [];
-            filterValues.data.results.forEach(choice => {
-                const tmpVar = {name: _.startCase(choice.value), value: choice.value};
+            filterValues.forEach(choice => {
+                const tmpVar = {name: choice.value, value: choice.value};
                 if(filterId === 'purpose') {
                     optionList.push(tmpVar);
                 }
@@ -3128,7 +3128,7 @@ export class SchedulingSetCreate extends Component {
                                             selectedItemsLabel="{0} Selected"
                                             onChange={(e) => {this.setObservStrateyFilters(e.value, 'state')}} 
                                             placeholder="State" />
-                                    <Dropdown inputId="observStrategy" optionLabel="name" optionValue="id" 
+                                    <Dropdown inputId="observStrategy" optionLabel="uniqueId" optionValue="id" 
                                             tooltip="Observation Strategy Template to be used to create the Scheduling Unit. Strategies already used in the Scheduling Set are in bold" tooltipOptions={this.tooltipOptions}
                                             value={this.state.observStrategy.id} 
                                             options={this.state.observStrategies} filter
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.test.js
index b345c49b763..d0d6302c6b3 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.test.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.test.js
@@ -4,6 +4,7 @@ import { act } from "react-dom/test-utils";
 import { render, cleanup, fireEvent, screen  } from '@testing-library/react';
 import '@testing-library/jest-dom/extend-expect';
 import '@testing-library/jest-dom'
+import _ from "lodash";
 
 import {SchedulingSetCreate} from './excelview.schedulingset';
 import ScheduleService from '../../services/schedule.service';
@@ -22,7 +23,8 @@ import AuthServiceMock from '../../__mocks__/auth.service.data';
 
 let projectListSpy, scheduleSetListSpy, observStrategiesSpy, taskTemplatesSpy, saveSUFromStrategySpy, updateSUSpy, createSUTasksSpy, 
 utilSpy, utcSpy, taskFilterDefSpy, suConstraintTemplateSpy,  allTaskRelationSpy, stationGroupSpy, stationSpy, 
-userPermissionSpy, authPermissionSpy,  scheduleSetByIdSpy;
+userPermissionSpy, authPermissionSpy,  scheduleSetByIdSpy, templatePurposesSpy, templateStatesSpy;
+jest.setTimeout(120000);
 
 beforeEach(() => {
     setMockSpy();
@@ -67,6 +69,12 @@ const setMockSpy = () => {
     taskFilterDefSpy = jest.spyOn(TaskService, 'getTaskFilterDefinition');
     taskFilterDefSpy.mockImplementation(() => { return Promise.resolve(TaskServiceMock.getTaskFilterDefinition)});
 
+    templatePurposesSpy = jest.spyOn(ScheduleService, 'getStrategyPurpose');
+    templatePurposesSpy.mockImplementation(() => { return Promise.resolve(SUServiceMock.templatePurposes)});
+
+    templateStatesSpy = jest.spyOn(ScheduleService, 'getStrategyState');
+    templateStatesSpy.mockImplementation(() => { return Promise.resolve(SUServiceMock.templateStates)});
+
     suConstraintTemplateSpy = jest.spyOn(ScheduleService, 'getSchedulingConstraintTemplates');
     suConstraintTemplateSpy.mockImplementation(() => { return Promise.resolve(SUServiceMock.getSUCTemplates())});
 
@@ -170,35 +178,59 @@ it("renders AG grid loaded in SU Set create Page", async() => {
     
     expect(content.queryByTestId('copyHeaderOnly')).toBe(null);
 
-    const observStrategyInput = content.getAllByLabelText("Simple Observation");
-    await act( async() => {
-        fireEvent.click(observStrategyInput[observStrategyInput.length-1]);
-        await new Promise((r) => setTimeout(r, 2000));
-    });
-    expect(content.queryAllByText('Simple Observation').length).toBe(2);
-
-    expect(content.queryByTestId('copyHeaderOnly')).not.toBe(null);     
-    expect(screen.getAllByLabelText('Press SPACE to select this row.').length).toBe(33);
-    expect(screen.getByPlaceholderText("Enter No. of SU (1 to 500)").value).toBe("10");
-    const noOfSUEl = screen.getByLabelText("50");
-    await act( async() => {
-        fireEvent.click(noOfSUEl);
-        await new Promise((r) => setTimeout(r, 1000));
-    });
-    expect(screen.getByPlaceholderText("Enter No. of SU (1 to 500)").value).toBe("50");
-    expect(screen.getAllByLabelText('Press SPACE to select this row.').length).toBe(36);
-    // expect(content.queryAllByRole('row').length).toBe(48);
-
-    expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy();
-
-    expect(content.queryByText('No valid Scheduling Unit found !')).not.toBeInTheDocument();
-    // await act(async () => {
-    //     fireEvent.click(content.queryByTestId('save-btn'));
-    //     await new Promise((r) => setTimeout(r, 1000));
-    // });
-    // console.log(screen.getAllByRole("gridcell").length);
-    // for (const cell of screen.getAllByRole("gridcell")) {
-    //     console.log(cell.getAttribute("col-id"));
+    const simpleObsStrategies = _.filter(SUServiceMock.getObservStrategies(), strategy => {
+                                            return strategy.name==='Simple Observation' && strategy.state!=="obsolete" });
+    const simpleObsStrategy = simpleObsStrategies.length>0?simpleObsStrategies[0]:null
+    // for (const simpleObsStrategy of simpleObsStrategies) {
+        if (simpleObsStrategy) {
+            const optionLabel = `${simpleObsStrategy.name} (${simpleObsStrategy.purpose}, ${simpleObsStrategy.state}, v${simpleObsStrategy.version})`;
+            console.log("Rendering ", optionLabel);
+
+            const templatePurpose = screen.getAllByText(simpleObsStrategy.purpose)[0];
+            const templateState = screen.getAllByText(simpleObsStrategy.state)[0];
+            await act( async() => {
+                fireEvent.click(templatePurpose);
+                fireEvent.click(templateState);
+                await new Promise((r) => setTimeout(r, 1000));
+            });
+            // expect(content.queryAllByText(optionLabel).length).toBe(1);
+            const observStrategyInput = screen.getAllByText(optionLabel);
+            await act( async() => {
+                // fireEvent.click(observStrategyInput[index]);
+                fireEvent.click(observStrategyInput[0].parentElement);
+                await new Promise((r) => setTimeout(r, 1000));
+            });
+            // expect(content.queryByTestId('copyHeaderOnly')).not.toBe(null);     
+            // expect(screen.getAllByLabelText('Press SPACE to select this row.').length).toBe(33);
+            expect(screen.getByPlaceholderText("Enter No. of SU (1 to 500)").value).toBe("10");
+            const noOfSUEl = screen.getByLabelText("50");
+            await act( async() => {
+                fireEvent.click(noOfSUEl);
+                await new Promise((r) => setTimeout(r, 1000));
+            });
+            expect(screen.getByPlaceholderText("Enter No. of SU (1 to 500)").value).toBe("50");
+            expect(screen.getAllByLabelText('Press SPACE to select this row.').length).toBe(36);
+            // expect(content.queryAllByRole('row').length).toBe(48);
+
+            expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy();
+
+            expect(content.queryByText('No valid Scheduling Unit found !')).not.toBeInTheDocument();
+            // await act(async () => {
+            //     fireEvent.click(content.queryByTestId('save-btn'));
+            //     await new Promise((r) => setTimeout(r, 1000));
+            // });
+            // console.log(screen.getAllByRole("gridcell").length);
+            // for (const cell of screen.getAllByRole("gridcell")) {
+            //     console.log(cell.getAttribute("col-id"));
+            // }
+            // expect(content.queryByText('No valid Scheduling Unit found !')).toBeInTheDocument(); //check popup appear after create SU successfully
+
+            // Reset the purpose and state filter selection
+            await act( async() => {
+                fireEvent.click(templatePurpose);
+                fireEvent.click(templateState);
+                await new Promise((r) => setTimeout(r, 1000));
+            });
+        }
     // }
-    // expect(content.queryByText('No valid Scheduling Unit found !')).toBeInTheDocument(); //check popup appear after create SU successfully
 });
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js b/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js
index 0504ff45909..53dd3e62fe2 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js
@@ -682,7 +682,12 @@ const ScheduleService = {
     getObservationStrategies: async function () {
         try {
             const response = await axios.get('/api/scheduling_unit_observing_strategy_template/?ordering=name');
-            return response.data.results;
+            let strategies = response.data.results;
+            _.map(strategies, (strategy) => { 
+                strategy.uniqueId = `${strategy.name} (${strategy.purpose_value}, ${strategy.state_value}, v${strategy.version})`;
+                return strategy;
+            });
+            return strategies;
         } catch (error) {
             console.error(error);
             return [];
@@ -1235,20 +1240,20 @@ const ScheduleService = {
         return response.data.results;
     },
     getStrategyPurpose: async() => {
-        let response = {}
+        let response = [];
         try {
             const url = `/api/template_purpose`
-            response = await axios.get(url);
+            response = (await axios.get(url)).data.results;
         } catch(error) {
             console.error('[schedule.services.template_purpose]',error);
         }
         return response;
     },
     getStrategyState: async() => {
-        let response = {}
+        let response = [];
         try {
             const url = `/api/template_state`
-            response = await axios.get(url);
+            response = (await axios.get(url)).data.results;
         } catch(error) {
             console.error('[schedule.services.template_state]',error);
         }
-- 
GitLab