diff --git a/SAS/TMSS/frontend/tmss_webapp/src/components/Spreadsheet/CustomDateComp.js b/SAS/TMSS/frontend/tmss_webapp/src/components/Spreadsheet/CustomDateComp.js index b17a2f03255cac0797ce600681b7fda83213a7b5..e4da6eb4f894186113911871b7787075e99bfb5f 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/components/Spreadsheet/CustomDateComp.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/components/Spreadsheet/CustomDateComp.js @@ -76,7 +76,7 @@ export default class CustomDateComp extends Component { return this.state.systemTime?( <> <button class="p-button p-component p-button-icon-only" onClick={() => {this.updateDateChanges(null)}} - title="Clear" style={{left: '190px'}}> + title="Clear" style={{left: '200px', height: '22px'}}> <i class="fas fa-times"></i> </button> <Flatpickr diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/create.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/create.test.js index 471c1e5f83ef951db5f8ea55b8b4ff4e0f83a143..9428ff318ba3a4b8d47bde0210557cfc81b122b3 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/create.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/create.test.js @@ -53,6 +53,7 @@ it("renders without crashing with all back-end data loaded", async () => { expect(content.queryAllByText('Add Resources').length).toBe(2); // Resource Dropdown loaded successfully const spinButtons = content.queryAllByRole("spinbutton"); expect(_.filter(spinButtons, {"id": "LOFAR Observing Time"})[0].value).toBe("0"); + fireEvent.click(screen.getAllByText("Add Resources")[0].parentElement.parentElement.parentElement.children[3]); expect(content.queryByText('CEP Storage')).toBeInTheDocument(); // Resources other than Default Resources listed in dropdown expect(content.queryByPlaceholderText('CEP Storage')).toBe(null); // No resources other than Default Resources listed to get input }); @@ -74,16 +75,24 @@ it("Save button enabled when mandatory data entered", async () => { }); const nameInput = content.queryByTestId('name'); const descInput = content.queryByTestId('description'); - const startInput = content.getByPlaceholderText('Enter Start Date'); - const stopInput = content.getByPlaceholderText('Enter Stop Date'); + // const startInput = content.getByPlaceholderText('Enter Start Date'); + // const stopInput = content.getByPlaceholderText('Enter Stop Date'); - fireEvent.blur(startInput, { target: { value: '2022-01-27' } }); - fireEvent.change(startInput, { target: { value: '2022-01-27' } }); - expect(startInput.value).toBe("2022-01-27"); + // fireEvent.change(startInput, { target: { value: '2022-01-27' } }); + // fireEvent.blur(startInput, { target: { value: '2022-01-27' } }); + // expect(startInput.value).toBe("2022-01-27"); + // Select the cycle start date from calendar + fireEvent.click(screen.getByTestId("start").children[1]); + fireEvent.click(screen.getAllByText("1")[0]); + await new Promise((r) => setTimeout(r, 1000)); + + // fireEvent.blur(stopInput,{ target: { value: '2022-01-28' } }); + // fireEvent.change(stopInput,{ target: { value: '2022-01-28' } }); + // expect(stopInput.value).toBe("2022-01-28"); + // Select the cycle stop date from calendar + fireEvent.click(screen.getByTestId("stop").children[1]); + fireEvent.click(screen.getAllByText("2")[0]); - fireEvent.blur(stopInput,{ target: { value: '2022-01-28' } }); - fireEvent.change(stopInput,{ target: { value: '2022-01-28' } }); - expect(stopInput.value).toBe("2022-01-28"); fireEvent.change(nameInput, { target: { value: 'Cycle-12' } }); expect(nameInput.value).toBe("Cycle-12"); @@ -104,21 +113,22 @@ it("save cycle with mandatory fields", async () => { const nameInput = content.queryByTestId('name'); const descInput = content.queryByTestId('description'); - const startInput = content.getByPlaceholderText('Enter Start Date'); - const stopInput = content.getByPlaceholderText('Enter Stop Date'); fireEvent.change(nameInput, { target: { value: 'Cycle-12' } }); expect(nameInput.value).toBe("Cycle-12"); fireEvent.change(descInput, { target: { value: 'Cycle-12' } }); expect(descInput.value).toBe("Cycle-12"); - fireEvent.blur(startInput, { target: { value: '2022-01-27' } }); - fireEvent.change(startInput, { target: { value: '2022-01-27' } }); - expect(startInput.value).toBe("2022-01-27"); + // Select the cycle start date from calendar + fireEvent.click(screen.getByTestId("start").children[1]); + fireEvent.click(screen.getAllByText("1")[0]); + await new Promise((r) => setTimeout(r, 1000)); + + // Select the cycle stop date from calendar + fireEvent.click(screen.getByTestId("stop").children[1]); + fireEvent.click(screen.getAllByText("2")[0]); + - fireEvent.blur(stopInput,{ target: { value: '2022-01-28' } }); - fireEvent.change(stopInput,{ target: { value: '2022-01-28' } }); - expect(stopInput.value).toBe("2022-01-28"); await new Promise((r) => setTimeout(r, 500)); expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy(); expect(content.queryByTestId('cycleId').value).toBe(""); @@ -142,8 +152,6 @@ it("save cycle with default resources", async () => { const nameInput = content.queryByTestId('name'); const descInput = content.queryByTestId('description'); - const startInput = content.getByPlaceholderText('Enter Start Date'); - const stopInput = content.getByPlaceholderText('Enter Stop Date'); const spinButtons = content.queryAllByRole("spinbutton"); fireEvent.change(nameInput, { target: { value: 'Cycle-12' } }); @@ -151,13 +159,15 @@ it("save cycle with default resources", async () => { fireEvent.change(descInput, { target: { value: 'Cycle-12' } }); expect(descInput.value).toBe("Cycle-12"); - fireEvent.blur(startInput, { target: { value: '2022-01-27' } }); - fireEvent.change(startInput, { target: { value: '2022-01-27' } }); - expect(startInput.value).toBe("2022-01-27"); + // Select the cycle start date from calendar + fireEvent.click(screen.getByTestId("start").children[1]); + fireEvent.click(screen.getAllByText("1")[0]); + await new Promise((r) => setTimeout(r, 1000)); + + // Select the cycle stop date from calendar + fireEvent.click(screen.getByTestId("stop").children[1]); + fireEvent.click(screen.getAllByText("2")[0]); - fireEvent.blur(stopInput,{ target: { value: '2022-01-28' } }); - fireEvent.change(stopInput,{ target: { value: '2022-01-28' } }); - expect(stopInput.value).toBe("2022-01-28"); await new Promise((r) => setTimeout(r, 500)); expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy(); expect(content.queryByTestId('cycleId').value).toBe(""); @@ -207,8 +217,6 @@ it("save cycle with added resources", async () => { const nameInput = content.queryByTestId('name'); const descInput = content.queryByTestId('description'); - const startInput = content.getByPlaceholderText('Enter Start Date'); - const stopInput = content.getByPlaceholderText('Enter Stop Date'); let spinButtons = content.queryAllByRole("spinbutton"); fireEvent.change(nameInput, { target: { value: 'Cycle-12' } }); @@ -216,13 +224,15 @@ it("save cycle with added resources", async () => { fireEvent.change(descInput, { target: { value: 'Cycle-12' } }); expect(descInput.value).toBe("Cycle-12"); - fireEvent.blur(startInput, { target: { value: '2022-01-27' } }); - fireEvent.change(startInput, { target: { value: '2022-01-27' } }); - expect(startInput.value).toBe("2022-01-27"); + // Select the cycle start date from calendar + fireEvent.click(screen.getByTestId("start").children[1]); + fireEvent.click(screen.getAllByText("1")[0]); + await new Promise((r) => setTimeout(r, 1000)); + + // Select the cycle stop date from calendar + fireEvent.click(screen.getByTestId("stop").children[1]); + fireEvent.click(screen.getAllByText("2")[0]); - fireEvent.blur(stopInput,{ target: { value: '2022-01-28' } }); - fireEvent.change(stopInput,{ target: { value: '2022-01-28' } }); - expect(stopInput.value).toBe("2022-01-28"); await new Promise((r) => setTimeout(r, 500)); expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy(); @@ -255,10 +265,10 @@ it("save cycle with added resources", async () => { // Before selecting New Resource expect(content.queryAllByText('Add Resources').length).toBe(2); - expect(content.queryAllByText('CEP Storage').length).toBe(1); - expect(content.getAllByRole("listbox")[0].children.length).toBe(3); + expect(content.queryAllByText('CEP Storage').length).toBe(0); expect(content.queryByPlaceholderText('CEP Storage')).toBe(null); - const addResourceInput = content.getAllByRole("listbox")[0].children[0] ; + fireEvent.click(screen.getAllByText("Add Resources")[0].parentElement.parentElement.parentElement.children[3]); + const addResourceInput = screen.getAllByText("CEP Storage")[0] ; fireEvent.click(addResourceInput); // After selecting New Resource expect(content.queryAllByText('Add Resources').length).toBe(1); @@ -293,9 +303,9 @@ it("remove default resource and added resource", async () => { // Before selecting New Resource expect(content.queryAllByText('Add Resources').length).toBe(2); - expect(content.getAllByRole("listbox")[0].children.length).toBe(3); expect(content.queryByPlaceholderText('Support hours')).toBe(null); - const addResourceInput = content.getAllByRole("listbox")[0].children[0] ; + fireEvent.click(screen.getAllByText("Add Resources")[0].parentElement.parentElement.parentElement.children[3]); + const addResourceInput = screen.getAllByText("CEP Storage")[0]; fireEvent.click(addResourceInput); // After selecting New Resource expect(content.queryAllByText('Add Resources').length).toBe(1); @@ -318,6 +328,6 @@ it("remove default resource and added resource", async () => { const removeResourceBtn = content.queryByTestId('CEP Storage-btn'); fireEvent.click(removeResourceBtn); expect(content.queryAllByText('Add Resources').length).toBe(2); - expect(content.queryAllByText('CEP Storage').length).toBe(1); - expect(content.getAllByRole("listbox")[0].children.length).toBe(4); -}); \ No newline at end of file + await new Promise((r) => setTimeout(r, 200)); + expect(content.queryAllByText('CEP Storage').length).toBe(0); +}); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.test.js index e35bd57ad7319f70ae3615e601719dcf938c7735..7085591a552b2346f03af56db9fc2c268c57642f 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.test.js @@ -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, cleanup, fireEvent, screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import _ from 'lodash'; @@ -79,10 +79,14 @@ it("renders without crashing with all back-end data loaded", async () => { const spinButtons = content.queryAllByRole("spinbutton"); expect(content.queryByText('Project - Add')).not.toBe(null); // Page loaded successfully expect(projectCategoriesSpy).toHaveBeenCalled(); // Mock Spy called successfully + fireEvent.click(screen.getAllByText("Select Project Category")[0].parentElement.parentElement.parentElement.children[3]); expect(content.queryByText('Regular')).toBeInTheDocument(); // Project Category Dropdown loaded successfully + fireEvent.click(screen.getAllByText("Select Period Category")[0].parentElement.parentElement.parentElement.children[3]); expect(content.queryByText('Single Cycle')).toBeInTheDocument(); // Period Category Dropdown loaded successfully + fireEvent.click(screen.getAllByRole("listbox")[0].parentElement.parentElement); expect(content.queryByText('Cycle-0')).toBeInTheDocument(); // Cycle multi-select loaded successfully expect(content.queryAllByText('Add Resources').length).toBe(2); // Resource Dropdown loaded successfully + fireEvent.click(screen.getAllByText("Add Resources")[0].parentElement.parentElement.parentElement.children[3]); expect(content.queryByText('LOFAR Observing Time Commissioning')).toBeInTheDocument(); // Resources other than Default Resources listed in dropdown expect(_.filter(spinButtons, {"id": "LOFAR Observing Time Commissioning"}).length).toBe(0); // No resources other than Default Resources listed to get input expect(_.filter(spinButtons, {"id": "LOFAR Observing Time"})[0].value).toBe("1"); // Default Resource Listed with default value @@ -134,53 +138,55 @@ it("renders Save button enabled when all data entered", async () => { const rankInput = spinButtons.filter(function(element) { return element.id==="proj-rank"})[0]; const trigPrioInput = spinButtons.filter(function(element) { return element.id==="trig_prio"})[0]; const trigger = content.getByLabelText(/trigger/i); - const projCatInput = content.getAllByRole("listbox")[0].children[0] ; - const projPeriodInput = content.getAllByRole("listbox")[1].children[0] ; - const cycleInput = content.getAllByRole("listbox")[2].children[0] ; - fireEvent.change(nameInput, { target: { value: 'OSR' } }); - expect(nameInput.value).toBe("OSR"); - - fireEvent.change(descInput, { target: { value: 'OSR' } }); - expect(descInput.value).toBe("OSR"); - - fireEvent.change(rankInput, { target: { value: 1 } }); - expect(rankInput.value).toBe("1"); - - expect(trigPrioInput.value).toBe("1000"); // Check for default value - fireEvent.change(trigPrioInput, { target: { value: 100 } }); - expect(trigPrioInput.value).toBe("100"); // Check for new value - - fireEvent.click(trigger); - expect(trigger.hasAttribute("checked")).toBeTruthy(); - - // Before selecting Project Category - expect(content.queryAllByText('Select Project Category').length).toBe(2); - expect(content.queryAllByText('Regular').length).toBe(1); - expect(content.getAllByRole("listbox")[0].children.length).toBe(2); - fireEvent.click(projCatInput); - // After selecting Project Category - expect(content.queryAllByText('Select Project Category').length).toBe(1); - expect(content.queryAllByText('Regular').length).toBe(3); - - // Before selecting Period Category - expect(content.queryAllByText('Select Period Category').length).toBe(2); - expect(content.queryAllByText('Single Cycle').length).toBe(1); - expect(content.getAllByRole("listbox")[1].children.length).toBe(2); - fireEvent.click(projPeriodInput); - // After selecting Period Category - expect(content.queryAllByText('Select Period Category').length).toBe(1); - expect(content.queryAllByText('Single Cycle').length).toBe(3); - - // Before selecting Cycle - expect(content.queryAllByText('Cycle-0').length).toBe(1); - expect(content.getAllByRole("listbox")[2].children.length).toBe(2); - fireEvent.click(cycleInput); - // After selecting Cycle - expect(content.queryAllByText('Cycle-0').length).toBe(2); - await new Promise((r) => setTimeout(r, 1000)); - expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy(); - // }); + fireEvent.change(nameInput, { target: { value: 'OSR' } }); + expect(nameInput.value).toBe("OSR"); + + fireEvent.change(descInput, { target: { value: 'OSR' } }); + expect(descInput.value).toBe("OSR"); + + fireEvent.change(rankInput, { target: { value: 1 } }); + expect(rankInput.value).toBe("1"); + + expect(trigPrioInput.value).toBe("1000"); // Check for default value + fireEvent.change(trigPrioInput, { target: { value: 100 } }); + expect(trigPrioInput.value).toBe("100"); // Check for new value + + fireEvent.click(trigger); + expect(trigger.hasAttribute("checked")).toBeTruthy(); + + // Before selecting Project Category + expect(content.queryAllByText('Select Project Category').length).toBe(2); + expect(content.queryAllByText('Regular').length).toBe(0); + // expect(content.getAllByRole("listbox")[0].children.length).toBe(2); + // After selecting Project Category + fireEvent.click(screen.getAllByText("Select Project Category")[0].parentElement.parentElement.parentElement.children[3]); + const projCatInput = screen.getAllByText("Regular")[0]; + fireEvent.click(projCatInput); + expect(content.queryAllByText('Select Project Category').length).toBe(1); + expect(content.queryAllByText('Regular').length).toBe(3); + + // Before selecting Period Category + expect(content.queryAllByText('Select Period Category').length).toBe(2); + expect(content.queryAllByText('Single Cycle').length).toBe(0); + // expect(content.getAllByRole("listbox")[1].children.length).toBe(2); + // After selecting Period Category + fireEvent.click(screen.getAllByText("Select Period Category")[0].parentElement.parentElement.parentElement.children[3]); + const projPeriodInput = screen.getAllByText("Single Cycle")[0]; + fireEvent.click(projPeriodInput); + expect(content.queryAllByText('Select Period Category').length).toBe(1); + expect(content.queryAllByText('Single Cycle').length).toBe(3); + + // Before selecting Cycle + expect(content.queryAllByText('Cycle-0').length).toBe(0); + // expect(content.getAllByRole("listbox")[2].children.length).toBe(2); + // After selecting Cycle + fireEvent.click(screen.getAllByRole("listbox")[0].parentElement.parentElement); + const cycleInput = screen.getAllByText("Cycle-0")[0]; + fireEvent.click(cycleInput); + expect(content.queryAllByText('Cycle-0').length).toBe(2); + await new Promise((r) => setTimeout(r, 1000)); + expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy(); }); it("save project with mandatory fields", async () => { @@ -327,10 +333,10 @@ it("save project with added resources", async () => { // Before selecting New Resource expect(content.queryAllByText('Add Resources').length).toBe(2); - expect(content.queryAllByText('LOFAR Observing Time Commissioning').length).toBe(1); - expect(content.getAllByRole("listbox")[4].children.length).toBe(2); + expect(content.queryAllByText('LOFAR Observing Time Commissioning').length).toBe(0); expect(_.filter(spinButtons, {"id": "LOFAR Observing Time Commissioning"}).length).toBe(0); - const addResourceInput = content.getAllByRole("listbox")[4].children[1] ; + fireEvent.click(screen.getAllByText("Add Resources")[0].parentElement.parentElement.parentElement.children[3]); + const addResourceInput = screen.getAllByText('LOFAR Observing Time Commissioning')[0]; fireEvent.click(addResourceInput); // After selecting New Resource expect(content.queryAllByText('Add Resources').length).toBe(1); @@ -365,10 +371,13 @@ it("remove default resource and added resource", async () => { // Before selecting New Resource expect(content.queryAllByText('Add Resources').length).toBe(2); - expect(content.queryAllByText('LOFAR Observing Time Commissioning').length).toBe(1); - expect(content.getAllByRole("listbox")[4].children.length).toBe(2); + expect(content.queryAllByText('LOFAR Observing Time Commissioning').length).toBe(0); expect(content.queryByPlaceholderText('LOFAR Observing Time Commissioning')).toBe(null); - const addResourceInput = content.getAllByRole("listbox")[4].children[1] ; + await act(async () => { + fireEvent.click(screen.getAllByText("Add Resources")[0].parentElement.parentElement.parentElement.children[3]); + }); + await new Promise((r) => setTimeout(r, 1000)); + const addResourceInput = screen.getAllByText("LOFAR Observing Time Commissioning")[0] ; fireEvent.click(addResourceInput); // After selecting New Resource expect(content.queryAllByText('Add Resources').length).toBe(1); @@ -395,5 +404,4 @@ it("remove default resource and added resource", async () => { fireEvent.click(removeResourceBtn); expect(content.queryAllByText('Add Resources').length).toBe(2); expect(content.queryAllByText('LOFAR Observing Time Commissioning').length).toBe(1); - expect(content.getAllByRole("listbox")[4].children.length).toBe(3); }); \ No newline at end of file diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/edit.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/edit.test.js index 128a48cb41305cac2c8b820ea1ad6cc1b775b1d1..935141feecb87385fdaee67ae5a449c06c3c2c04 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/edit.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/edit.test.js @@ -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 } from '@testing-library/react'; +import { render, cleanup, fireEvent, screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import _ from 'lodash'; @@ -143,16 +143,16 @@ it("renders input fields with Project details if found", async () => { const trigger = content.getAllByLabelText(/trigger/i).filter((element) => { return element.id==="trigger"})[0]; expect(trigger.hasAttribute("checked")).toBeFalsy(); - const projCatInput = content.getAllByRole("listbox")[0].children[0] ; + // const projCatInput = content.getAllByRole("listbox")[0].children[0] ; expect(content.queryAllByText('Select Project Category').length).toBe(2); - expect(content.queryAllByText('Regular').length).toBe(1); + expect(content.queryAllByText('Regular').length).toBe(0); - const projPeriodInput = content.getAllByRole("listbox")[1].children[0] ; + // const projPeriodInput = content.getAllByRole("listbox")[1].children[0] ; expect(content.queryAllByText('Select Period Category').length).toBe(2); - expect(content.queryAllByText('Single Cycle').length).toBe(1); + expect(content.queryAllByText('Single Cycle').length).toBe(0); - const cycleInput = content.getAllByRole("listbox")[2] ; - expect(content.queryAllByText('Cycle 0').length).toBe(1); + // const cycleInput = content.getAllByRole("listbox")[2] ; + expect(content.queryAllByText('Cycle 0').length).toBe(0); expect(_.filter(spinButtons, {"id": "CEP Processing Time"})[0].value).toBe("1"); expect(_.filter(spinButtons, {"id": "LOFAR Observing Time"})[0].value).toBe("1"); @@ -208,21 +208,23 @@ it("save Project after editing fields", async () => { fireEvent.click(trigger); expect(trigger.hasAttribute("checked")).toBeTruthy(); - const projCatInput = content.getAllByRole("listbox")[0].children[1] ; + fireEvent.click(screen.getAllByText("Select Project Category")[0].parentElement.parentElement.parentElement.children[3]); + const projCatInput = screen.getAllByText("User Shared Support")[0]; fireEvent.click(projCatInput); // After selecting Project Category expect(content.queryAllByText('Select Project Category').length).toBe(1); expect(content.queryAllByText('Regular').length).toBe(1); expect(content.queryAllByText('User Shared Support').length).toBe(3); - const projPeriodInput = content.getAllByRole("listbox")[1].children[1] ; + fireEvent.click(screen.getAllByText("Select Period Category")[0].parentElement.parentElement.parentElement.children[3]); + const projPeriodInput = screen.getAllByText("Long Term")[0]; fireEvent.click(projPeriodInput); expect(content.queryAllByText('Select Period Category').length).toBe(1); expect(content.queryAllByText('Single Cycle').length).toBe(1); expect(content.queryAllByText('Long Term').length).toBe(3); - - const oldCycleInput = content.getAllByRole("listbox")[2].children[2] ; - const newCycleInput = content.getAllByRole("listbox")[2].children[0] ; + fireEvent.click(screen.getAllByRole("listbox")[0].parentElement.parentElement); + const oldCycleInput = screen.getAllByText("Cycle-0")[0]; + const newCycleInput = screen.getAllByText("Cycle 0")[0]; fireEvent.click(oldCycleInput); fireEvent.click(newCycleInput); // After selecting Cycle @@ -269,7 +271,8 @@ it("save Project after adding, modifying and deleting resources", async () => { expect(content.queryByTestId("name").value).toBe('OSR-11'); // Adding new resource - const addResourceInput = content.getAllByRole("listbox")[4].children[0] ; + fireEvent.click(screen.getAllByText("Add Resources")[0].parentElement.parentElement.parentElement.children[3]); + const addResourceInput = screen.getAllByText("CEP Storage")[0]; fireEvent.click(addResourceInput); // After selecting New Resource expect(content.queryAllByText('Add Resources').length).toBe(1); 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 d198a6d3d9c4d9d163744e0383d0cffd0a03c905..65dfd0bd3db86aa4131cb3ef655e80c598abeb56 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js @@ -719,7 +719,7 @@ export class SchedulingUnitCreate extends Component { */ reset() { const schedulingSets = this.state.schedulingSets; - this.nameInput.element.focus(); + this.nameInput.focus(); const selectedProject = this.props.match?.params?.project; this.setState({ 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 239c78fc52ed7c4102c31fbde3a1a7c9ecb43010..dd82c1689bca2e904d106963370abc8042b44db8 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 @@ -161,15 +161,19 @@ it(" 1. renders SU create page with all fields and default values", async() => { fireEvent.change(descInputEl, { target: { value: 'SU High 1 Desc' } }); expect(descInputEl.value).toBe("SU High 1 Desc"); - const projInputEl = content.getAllByRole("listbox")[0].children[0] ; + fireEvent.click(screen.getAllByText("Select Project")[1]); + + const projInputEl = screen.getByText("high"); await act(async () => { fireEvent.click(projInputEl); await new Promise((r) => setTimeout(r, 500)); }); - expect(content.queryAllByText("high").length).toBe(3); + expect(content.queryAllByText("high").length).toBe(2); expect(scheduleSetListSpy).toHaveBeenCalled(); // Mock Spy called successfully - const suSetInputEl = content.getAllByRole("listbox")[1].children[0] ; + fireEvent.click(screen.getAllByText("Select Scheduling Set")[1]); + expect(content.queryAllByText("Test Scheduling Set").length).toBe(1); + const suSetInputEl = screen.getByText("Test Scheduling Set"); fireEvent.click(suSetInputEl); expect(content.queryAllByText("Test Scheduling Set").length).toBe(1); expect(content.queryByTestId('save-btn')).toHaveAttribute("disabled"); @@ -213,7 +217,7 @@ it(" 3. Test IM LBA Strategy Group(s) ", async() => { expect(screen.getByLabelText("specification[time][before]").value).toBe(""); const nameInput = content.queryByTestId('name'); const descInput = content.queryByTestId('description'); - const projInput = content.getAllByRole("listbox")[0].children[0] ; + // const projInput = content.getAllByRole("listbox")[0].children[0] ; let strategyCount = 0; const strategy_Templates_Group = await Promise.resolve(SUServiceMock.getObservStrategiesDataMapper().LBA_Strategy_Group); for (const strategy of observationStrategTemplate) { @@ -231,21 +235,32 @@ it(" 3. Test IM LBA Strategy Group(s) ", async() => { // Set values for all mandatory input fireEvent.change(nameInput, { target: { value: strategy.name } }); fireEvent.change(descInput, { target: { value: strategy.name } }); + fireEvent.click(screen.getAllByText("Select Project")[1]); + const projInput = screen.getByText("high"); await act(async () => { fireEvent.click(projInput); }); - const schedulingSetInput = content.getAllByRole("listbox")[1].children[0] ; + fireEvent.click(screen.getAllByText("Select Scheduling Set")[1]); + const schedulingSetInput = screen.getByText("Test Scheduling Set"); await act(async () => { fireEvent.click(schedulingSetInput); }); + fireEvent.click(screen.getAllByText("Purpose")[0]); const templatePurpose = screen.getAllByText(strategy.purpose)[0]; - const templateState = screen.getAllByText(strategy.state)[0]; await act( async() => { fireEvent.click(templatePurpose); + await new Promise((r) => setTimeout(r, 500)); + }); + // fireEvent.click(screen.getAllByText("State")[0]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[1]); + const templateState = screen.getAllByText(strategy.state)[0]; + await act( async() => { fireEvent.click(templateState); - await new Promise((r) => setTimeout(r, 1000)); + await new Promise((r) => setTimeout(r, 200)); }); - expect(content.queryAllByText(optionLabel).length).toBe(1); + + // expect(content.queryAllByText(optionLabel).length).toBe(1); + fireEvent.click(screen.getAllByText("Select Strategy")[0]); const observStrategyInput = screen.getAllByText(optionLabel); await act( async() => { fireEvent.click(observStrategyInput[0].parentElement); @@ -336,7 +351,7 @@ it(" 3. Test IM LBA Strategy Group(s) ", async() => { // 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(); + // expect(content.queryByText('Success')).not.toBeInTheDocument(); console.log("Firing Click Event..."); await act(async () => { fireEvent.click(content.queryByTestId('save-btn')); @@ -352,11 +367,14 @@ it(" 3. Test IM LBA Strategy Group(s) ", async() => { }); // Reset the purpose and state filter selection await act( async() => { - fireEvent.click(templatePurpose); - fireEvent.click(templateState); + fireEvent.click(screen.getAllByText(strategy.purpose)[0]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.purpose)[1]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[2]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.state)[0]); await new Promise((r) => setTimeout(r, 1000)); }); - console.log("************************ (",strategyCount,") Tested the Strategy - ", optionLabel,' ***********************') } } // tmp => strategy name check @@ -381,7 +399,6 @@ it(" 4. Test Simple Observation Strategy Group(s)", async() => { expect(screen.getByLabelText("specification[time][before]").value).toBe(""); const nameInput = content.queryByTestId('name'); const descInput = content.queryByTestId('description'); - const projInput = content.getAllByRole("listbox")[0].children[0] ; const strategy_Templates_Group = await Promise.resolve(SUServiceMock.getObservStrategiesDataMapper().Simple_Strategy_Group); let strategyCount = 0; for (const strategy of observationStrategTemplate) { @@ -398,21 +415,32 @@ it(" 4. Test Simple Observation Strategy Group(s)", async() => { // Set values for all mandatory input fireEvent.change(nameInput, { target: { value: strategy.name } }); fireEvent.change(descInput, { target: { value: strategy.name } }); + fireEvent.click(screen.getAllByText("Select Project")[1]); + const projInput = screen.getByText("high"); await act(async () => { fireEvent.click(projInput); }); - const schedulingSetInput = content.getAllByRole("listbox")[1].children[0] ; + fireEvent.click(screen.getAllByText("Select Scheduling Set")[1]); + const schedulingSetInput = screen.getByText("Test Scheduling Set"); await act(async () => { fireEvent.click(schedulingSetInput); }); + fireEvent.click(screen.getAllByText("Purpose")[0]); const templatePurpose = screen.getAllByText(strategy.purpose)[0]; - const templateState = screen.getAllByText(strategy.state)[0]; await act( async() => { fireEvent.click(templatePurpose); + await new Promise((r) => setTimeout(r, 500)); + }); + // fireEvent.click(screen.getAllByText("State")[0]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[1]); + const templateState = screen.getAllByText(strategy.state)[0]; + await act( async() => { fireEvent.click(templateState); - await new Promise((r) => setTimeout(r, 1000)); + await new Promise((r) => setTimeout(r, 200)); }); - expect(content.queryAllByText(optionLabel).length).toBe(1); + + // expect(content.queryAllByText(optionLabel).length).toBe(1); + fireEvent.click(screen.getAllByText("Select Strategy")[0]); const observStrategyInput = screen.getAllByText(optionLabel); await act( async() => { fireEvent.click(observStrategyInput[0].parentElement); @@ -507,8 +535,12 @@ it(" 4. Test Simple Observation Strategy Group(s)", async() => { }); // Reset the purpose and state filter selection await act( async() => { - fireEvent.click(templatePurpose); - fireEvent.click(templateState); + fireEvent.click(screen.getAllByText(strategy.purpose)[0]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.purpose)[1]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[2]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.state)[0]); await new Promise((r) => setTimeout(r, 1000)); }); console.log("************************ (",strategyCount,") Tested the Strategy - ", optionLabel,' ***********************') @@ -534,7 +566,6 @@ it(" 5. Test IM HBA Strategy Group(s) ", async() => { expect(screen.getByLabelText("specification[time][before]").value).toBe(""); const nameInput = content.queryByTestId('name'); const descInput = content.queryByTestId('description'); - const projInput = content.getAllByRole("listbox")[0].children[0] ; const strategy_Templates_Group = await Promise.resolve(SUServiceMock.getObservStrategiesDataMapper().HBA_Strategy_Group); let strategyCount = 0; for (const strategy of observationStrategTemplate) { @@ -552,21 +583,32 @@ it(" 5. Test IM HBA Strategy Group(s) ", async() => { // Set values for all mandatory input fireEvent.change(nameInput, { target: { value: strategy.name } }); fireEvent.change(descInput, { target: { value: strategy.name } }); + fireEvent.click(screen.getAllByText("Select Project")[1]); + const projInput = screen.getByText("high"); await act(async () => { fireEvent.click(projInput); }); - const schedulingSetInput = content.getAllByRole("listbox")[1].children[0] ; + fireEvent.click(screen.getAllByText("Select Scheduling Set")[1]); + const schedulingSetInput = screen.getByText("Test Scheduling Set"); await act(async () => { fireEvent.click(schedulingSetInput); }); + fireEvent.click(screen.getAllByText("Purpose")[0]); const templatePurpose = screen.getAllByText(strategy.purpose)[0]; - const templateState = screen.getAllByText(strategy.state)[0]; await act( async() => { fireEvent.click(templatePurpose); + await new Promise((r) => setTimeout(r, 500)); + }); + // fireEvent.click(screen.getAllByText("State")[0]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[1]); + const templateState = screen.getAllByText(strategy.state)[0]; + await act( async() => { fireEvent.click(templateState); - await new Promise((r) => setTimeout(r, 1000)); + await new Promise((r) => setTimeout(r, 200)); }); - expect(content.queryAllByText(optionLabel).length).toBe(1); + + // expect(content.queryAllByText(optionLabel).length).toBe(1); + fireEvent.click(screen.getAllByText("Select Strategy")[0]); const observStrategyInput = screen.getAllByText(optionLabel); await act( async() => { fireEvent.click(observStrategyInput[0].parentElement); @@ -661,8 +703,12 @@ it(" 5. Test IM HBA Strategy Group(s) ", async() => { }); // Reset the purpose and state filter selection await act( async() => { - fireEvent.click(templatePurpose); - fireEvent.click(templateState); + fireEvent.click(screen.getAllByText(strategy.purpose)[0]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.purpose)[1]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[2]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.state)[0]); await new Promise((r) => setTimeout(r, 1000)); }); @@ -690,7 +736,6 @@ it(" 6. Test Pulsar Timing Strategy Group(s) ", async() => { expect(screen.getByLabelText("specification[time][before]").value).toBe(""); const nameInput = content.queryByTestId('name'); const descInput = content.queryByTestId('description'); - const projInput = content.getAllByRole("listbox")[0].children[0] ; const strategy_Templates_Group = await Promise.resolve(SUServiceMock.getObservStrategiesDataMapper().Pulsar_Strategy_Group); let strategyCount = 0; for (const strategy of observationStrategTemplate) { @@ -708,21 +753,32 @@ it(" 6. Test Pulsar Timing Strategy Group(s) ", async() => { // Set values for all mandatory input fireEvent.change(nameInput, { target: { value: strategy.name } }); fireEvent.change(descInput, { target: { value: strategy.name } }); + fireEvent.click(screen.getAllByText("Select Project")[1]); + const projInput = screen.getByText("high"); await act(async () => { fireEvent.click(projInput); }); - const schedulingSetInput = content.getAllByRole("listbox")[1].children[0] ; + fireEvent.click(screen.getAllByText("Select Scheduling Set")[1]); + const schedulingSetInput = screen.getByText("Test Scheduling Set"); await act(async () => { fireEvent.click(schedulingSetInput); }); + fireEvent.click(screen.getAllByText("Purpose")[0]); const templatePurpose = screen.getAllByText(strategy.purpose)[0]; - const templateState = screen.getAllByText(strategy.state)[0]; await act( async() => { fireEvent.click(templatePurpose); + await new Promise((r) => setTimeout(r, 500)); + }); + // fireEvent.click(screen.getAllByText("State")[0]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[1]); + const templateState = screen.getAllByText(strategy.state)[0]; + await act( async() => { fireEvent.click(templateState); - await new Promise((r) => setTimeout(r, 1000)); + await new Promise((r) => setTimeout(r, 200)); }); - expect(content.queryAllByText(optionLabel).length).toBe(1); + + // expect(content.queryAllByText(optionLabel).length).toBe(1); + fireEvent.click(screen.getAllByText("Select Strategy")[0]); const observStrategyInput = screen.getAllByText(optionLabel); await act( async() => { fireEvent.click(observStrategyInput[0].parentElement); @@ -817,8 +873,12 @@ it(" 6. Test Pulsar Timing Strategy Group(s) ", async() => { }); // Reset the purpose and state filter selection await act( async() => { - fireEvent.click(templatePurpose); - fireEvent.click(templateState); + fireEvent.click(screen.getAllByText(strategy.purpose)[0]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.purpose)[1]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[2]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.state)[0]); await new Promise((r) => setTimeout(r, 1000)); }); @@ -845,7 +905,6 @@ it(" 7. Test Beamforming Strategy Group(s) ", async() => { expect(screen.getByLabelText("specification[time][before]").value).toBe(""); const nameInput = content.queryByTestId('name'); const descInput = content.queryByTestId('description'); - const projInput = content.getAllByRole("listbox")[0].children[0] ; const strategy_Templates_Group = await Promise.resolve(SUServiceMock.getObservStrategiesDataMapper().BF_Strategy_Group); let strategyCount = 0; for (const strategy of observationStrategTemplate) { @@ -862,21 +921,32 @@ it(" 7. Test Beamforming Strategy Group(s) ", async() => { // Set values for all mandatory input fireEvent.change(nameInput, { target: { value: strategy.name } }); fireEvent.change(descInput, { target: { value: strategy.name } }); + fireEvent.click(screen.getAllByText("Select Project")[1]); + const projInput = screen.getByText("high"); await act(async () => { fireEvent.click(projInput); }); - const schedulingSetInput = content.getAllByRole("listbox")[1].children[0] ; + fireEvent.click(screen.getAllByText("Select Scheduling Set")[1]); + const schedulingSetInput = screen.getByText("Test Scheduling Set"); await act(async () => { fireEvent.click(schedulingSetInput); }); + fireEvent.click(screen.getAllByText("Purpose")[0]); const templatePurpose = screen.getAllByText(strategy.purpose)[0]; - const templateState = screen.getAllByText(strategy.state)[0]; await act( async() => { fireEvent.click(templatePurpose); + await new Promise((r) => setTimeout(r, 500)); + }); + // fireEvent.click(screen.getAllByText("State")[0]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[1]); + const templateState = screen.getAllByText(strategy.state)[0]; + await act( async() => { fireEvent.click(templateState); - await new Promise((r) => setTimeout(r, 1000)); + await new Promise((r) => setTimeout(r, 200)); }); - expect(content.queryAllByText(optionLabel).length).toBe(1); + + // expect(content.queryAllByText(optionLabel).length).toBe(1); + fireEvent.click(screen.getAllByText("Select Strategy")[0]); const observStrategyInput = screen.getAllByText(optionLabel); await act( async() => { fireEvent.click(observStrategyInput[0].parentElement); @@ -975,8 +1045,12 @@ it(" 7. Test Beamforming Strategy Group(s) ", async() => { }); // Reset the purpose and state filter selection await act( async() => { - fireEvent.click(templatePurpose); - fireEvent.click(templateState); + fireEvent.click(screen.getAllByText(strategy.purpose)[0]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.purpose)[1]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[2]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.state)[0]); await new Promise((r) => setTimeout(r, 1000)); }); console.log("************************ (",strategyCount,") Tested the Strategy - ", optionLabel,' ***********************') @@ -1002,7 +1076,6 @@ it(" 8. Test COBALT Strategy Group(s) ", async() => { expect(screen.getByLabelText("specification[time][before]").value).toBe(""); const nameInput = content.queryByTestId('name'); const descInput = content.queryByTestId('description'); - const projInput = content.getAllByRole("listbox")[0].children[0] ; const strategy_Templates_Group = await Promise.resolve(SUServiceMock.getObservStrategiesDataMapper().COBALT_Strategy_Group); let strategyCount = 0; for (const strategy of observationStrategTemplate) { @@ -1019,21 +1092,32 @@ it(" 8. Test COBALT Strategy Group(s) ", async() => { // Set values for all mandatory input fireEvent.change(nameInput, { target: { value: strategy.name } }); fireEvent.change(descInput, { target: { value: strategy.name } }); + fireEvent.click(screen.getAllByText("Select Project")[1]); + const projInput = screen.getByText("high"); await act(async () => { fireEvent.click(projInput); }); - const schedulingSetInput = content.getAllByRole("listbox")[1].children[0] ; + fireEvent.click(screen.getAllByText("Select Scheduling Set")[1]); + const schedulingSetInput = screen.getByText("Test Scheduling Set"); await act(async () => { fireEvent.click(schedulingSetInput); }); + fireEvent.click(screen.getAllByText("Purpose")[0]); const templatePurpose = screen.getAllByText(strategy.purpose)[0]; - const templateState = screen.getAllByText(strategy.state)[0]; await act( async() => { fireEvent.click(templatePurpose); + await new Promise((r) => setTimeout(r, 500)); + }); + // fireEvent.click(screen.getAllByText("State")[0]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[1]); + const templateState = screen.getAllByText(strategy.state)[0]; + await act( async() => { fireEvent.click(templateState); - await new Promise((r) => setTimeout(r, 1000)); + await new Promise((r) => setTimeout(r, 200)); }); - expect(content.queryAllByText(optionLabel).length).toBe(1); + + // expect(content.queryAllByText(optionLabel).length).toBe(1); + fireEvent.click(screen.getAllByText("Select Strategy")[0]); const observStrategyInput = screen.getAllByText(optionLabel); await act( async() => { fireEvent.click(observStrategyInput[0].parentElement); @@ -1132,8 +1216,12 @@ it(" 8. Test COBALT Strategy Group(s) ", async() => { }); // Reset the purpose and state filter selection await act( async() => { - fireEvent.click(templatePurpose); - fireEvent.click(templateState); + fireEvent.click(screen.getAllByText(strategy.purpose)[0]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.purpose)[1]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[2]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.state)[0]); await new Promise((r) => setTimeout(r, 1000)); }); console.log("************************ (",strategyCount,") Tested the Strategy - ", optionLabel,' ***********************') @@ -1161,7 +1249,6 @@ it(" 3.1 Test IM HBA Strategy Group(s) ", async() => { expect(screen.getByLabelText("specification[time][before]").value).toBe(""); const nameInput = content.queryByTestId('name'); const descInput = content.queryByTestId('description'); - const projInput = content.getAllByRole("listbox")[0].children[0] ; let strategyCount = 0; for (const strategy of observationStrategTemplate) { if (strategy.name === 'IM HBA - 1 Beam' ) { @@ -1178,21 +1265,32 @@ it(" 3.1 Test IM HBA Strategy Group(s) ", async() => { // Set values for all mandatory input fireEvent.change(nameInput, { target: { value: strategy.name } }); fireEvent.change(descInput, { target: { value: strategy.name } }); + fireEvent.click(screen.getAllByText("Select Project")[1]); + const projInput = screen.getByText("high"); await act(async () => { fireEvent.click(projInput); }); - const schedulingSetInput = content.getAllByRole("listbox")[1].children[0] ; + fireEvent.click(screen.getAllByText("Select Scheduling Set")[1]); + const schedulingSetInput = screen.getByText("Test Scheduling Set"); await act(async () => { fireEvent.click(schedulingSetInput); }); + fireEvent.click(screen.getAllByText("Purpose")[0]); const templatePurpose = screen.getAllByText(strategy.purpose)[0]; - const templateState = screen.getAllByText(strategy.state)[0]; await act( async() => { fireEvent.click(templatePurpose); + await new Promise((r) => setTimeout(r, 500)); + }); + // fireEvent.click(screen.getAllByText("State")[0]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[1]); + const templateState = screen.getAllByText(strategy.state)[0]; + await act( async() => { fireEvent.click(templateState); - await new Promise((r) => setTimeout(r, 1000)); + await new Promise((r) => setTimeout(r, 200)); }); - expect(content.queryAllByText(optionLabel).length).toBe(1); + + // expect(content.queryAllByText(optionLabel).length).toBe(1); + fireEvent.click(screen.getAllByText("Select Strategy")[0]); const observStrategyInput = screen.getAllByText(optionLabel); await act( async() => { fireEvent.click(observStrategyInput[0].parentElement); @@ -1287,8 +1385,12 @@ it(" 3.1 Test IM HBA Strategy Group(s) ", async() => { }); // Reset the purpose and state filter selection await act( async() => { - fireEvent.click(templatePurpose); - fireEvent.click(templateState); + fireEvent.click(screen.getAllByText(strategy.purpose)[0]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.purpose)[1]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[2]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.state)[0]); await new Promise((r) => setTimeout(r, 1000)); }); @@ -1314,7 +1416,6 @@ it(" 3.2 Test IM HBA Strategy Group(s) ", async() => { expect(screen.getByLabelText("specification[time][before]").value).toBe(""); const nameInput = content.queryByTestId('name'); const descInput = content.queryByTestId('description'); - const projInput = content.getAllByRole("listbox")[0].children[0] ; let strategyCount = 0; for (const strategy of observationStrategTemplate) { if (strategy.name === 'IM RT HBA LoTSS' ) { @@ -1331,21 +1432,32 @@ it(" 3.2 Test IM HBA Strategy Group(s) ", async() => { // Set values for all mandatory input fireEvent.change(nameInput, { target: { value: strategy.name } }); fireEvent.change(descInput, { target: { value: strategy.name } }); + fireEvent.click(screen.getAllByText("Select Project")[1]); + const projInput = screen.getByText("high"); await act(async () => { fireEvent.click(projInput); }); - const schedulingSetInput = content.getAllByRole("listbox")[1].children[0] ; + fireEvent.click(screen.getAllByText("Select Scheduling Set")[1]); + const schedulingSetInput = screen.getByText("Test Scheduling Set"); await act(async () => { fireEvent.click(schedulingSetInput); }); + fireEvent.click(screen.getAllByText("Purpose")[0]); const templatePurpose = screen.getAllByText(strategy.purpose)[0]; - const templateState = screen.getAllByText(strategy.state)[0]; await act( async() => { fireEvent.click(templatePurpose); + await new Promise((r) => setTimeout(r, 500)); + }); + // fireEvent.click(screen.getAllByText("State")[0]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[1]); + const templateState = screen.getAllByText(strategy.state)[0]; + await act( async() => { fireEvent.click(templateState); - await new Promise((r) => setTimeout(r, 1000)); + await new Promise((r) => setTimeout(r, 200)); }); - expect(content.queryAllByText(optionLabel).length).toBe(1); + + // expect(content.queryAllByText(optionLabel).length).toBe(1); + fireEvent.click(screen.getAllByText("Select Strategy")[0]); const observStrategyInput = screen.getAllByText(optionLabel); await act( async() => { fireEvent.click(observStrategyInput[0].parentElement); @@ -1440,8 +1552,12 @@ it(" 3.2 Test IM HBA Strategy Group(s) ", async() => { }); // Reset the purpose and state filter selection await act( async() => { - fireEvent.click(templatePurpose); - fireEvent.click(templateState); + fireEvent.click(screen.getAllByText(strategy.purpose)[0]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.purpose)[1]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[2]); + await new Promise((r) => setTimeout(r, 200)); + fireEvent.click(screen.getAllByText(strategy.state)[0]); await new Promise((r) => setTimeout(r, 1000)); }); 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 6fa75aa39e3e0899ec0ad93b22d715ebf00e6fa3..bb6bd486b65c188dc3ea84b601aac0968594793d 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 @@ -138,24 +138,26 @@ it("renders SU Set create page with all fields and default values", async() => { //It is disabled before select any project expect(content.queryByTestId('addSet')).toHaveAttribute("disabled"); - - const projInputEl = content.getAllByRole("listbox")[0].children[0] ; + fireEvent.click(screen.getAllByText("Select Project")[1]); + + const projInputEl = screen.getByText("high"); await act( async() => { fireEvent.click(projInputEl); await new Promise((r) => setTimeout(r, 500)); }); - expect(content.queryAllByText("high").length).toBe(3); + expect(content.queryAllByText("high").length).toBe(2); expect(scheduleSetListSpy).toHaveBeenCalled(); // Mock Spy called successfully // It should be enabled after select project expect(content.queryByTestId('addSet').hasAttribute("disabled")).toBeFalsy(); - const suSetInputEl = content.getAllByRole("listbox")[1].children[0] ; + fireEvent.click(screen.getAllByText("Select Scheduling Set")[1]); expect(content.queryAllByText("Test Scheduling Set").length).toBe(1); + const suSetInputEl = screen.getByText("Test Scheduling Set"); await act( async() => { fireEvent.click(suSetInputEl); await new Promise((r) => setTimeout(r, 500)); }); - expect(content.queryAllByText("Test Scheduling Set").length).toBe(3); + expect(content.queryAllByText("Test Scheduling Set").length).toBe(2); expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy(); }); @@ -176,21 +178,28 @@ it("renders AG grid loaded in SU Set create Page", async() => { //It is disabled before select any project expect(content.queryByTestId('addSet')).toHaveAttribute("disabled"); - const projInputEl = content.getAllByRole("listbox")[0].children[0] ; + fireEvent.click(screen.getAllByText("Select Project")[1]); + + const projInputEl = screen.getByText("high"); expect(content.queryAllByText("high").length).toBe(1); await act( async() => { fireEvent.click(projInputEl); await new Promise((r) => setTimeout(r, 1000)); }); - expect(content.queryAllByText("high").length).toBe(3); + expect(content.queryAllByText("high").length).toBe(2); expect(scheduleSetListSpy).toHaveBeenCalled(); // Mock Spy called successfully // It should be enabled after select project expect(content.queryByTestId('addSet').hasAttribute("disabled")).toBeFalsy(); - const suSetInputEl = content.getAllByRole("listbox")[1].children[0] ; - fireEvent.click(suSetInputEl); - expect(content.queryAllByText("Test Scheduling Set").length).toBe(3); + fireEvent.click(screen.getAllByText("Select Scheduling Set")[1]); + expect(content.queryAllByText("Test Scheduling Set").length).toBe(1); + const suSetInputEl = screen.getByText("Test Scheduling Set"); + await act( async() => { + fireEvent.click(suSetInputEl); + await new Promise((r) => setTimeout(r, 500)); + }); + expect(content.queryAllByText("Test Scheduling Set").length).toBe(2); expect(content.queryByTestId('copyHeaderOnly')).toBe(null); @@ -201,15 +210,21 @@ it("renders AG grid loaded in SU Set create Page", async() => { if (simpleObsStrategy) { const optionLabel = `${simpleObsStrategy.name} (${simpleObsStrategy.purpose}, ${simpleObsStrategy.state}, v${simpleObsStrategy.version})`; console.log("Rendering ", optionLabel); - + fireEvent.click(screen.getAllByText("Purpose")[0]); const templatePurpose = screen.getAllByText(simpleObsStrategy.purpose)[0]; - const templateState = screen.getAllByText(simpleObsStrategy.state)[0]; await act( async() => { fireEvent.click(templatePurpose); + await new Promise((r) => setTimeout(r, 500)); + }); + // fireEvent.click(screen.getAllByText("State")[0]); + fireEvent.click(screen.getAllByRole("listbox")[1].parentElement.parentElement.children[1]); + const templateState = screen.getAllByText(simpleObsStrategy.state)[0]; + await act( async() => { fireEvent.click(templateState); - await new Promise((r) => setTimeout(r, 1000)); + await new Promise((r) => setTimeout(r, 200)); }); // expect(content.queryAllByText(optionLabel).length).toBe(1); + fireEvent.click(screen.getAllByText("Select Strategy")[0]); const observStrategyInput = screen.getAllByText(optionLabel); await act( async() => { // fireEvent.click(observStrategyInput[index]); @@ -217,15 +232,16 @@ it("renders AG grid loaded in SU Set create Page", async() => { 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.getAllByLabelText('Press SPACE to select this row.').length).toBe(30); expect(screen.getByPlaceholderText("Enter No. of SU (1 to 500)").value).toBe("10"); + fireEvent.click(screen.getByPlaceholderText("Enter No. of SU (1 to 500)").parentElement.children[3]); 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(screen.getAllByLabelText('Press SPACE to select this row.').length).toBe(33); // expect(content.queryAllByRole('row').length).toBe(48); expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy(); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.test.js index 0b206220451809e198d22db62e939e2fd58a46bd..e10fba5dd91eca7c7f878d7373593d5ef21527fc 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.test.js @@ -99,7 +99,7 @@ it("renders Task details Edit page", async () => { }); expect(content.getByText("Task - Edit")).toBeInTheDocument(); }); - + it("test Combined Observation Task Draft view of IM LBA Survey - 3 Beams edit", async () => { let content; await act(async () => { @@ -112,7 +112,7 @@ it("test Combined Observation Task Draft view of IM LBA Survey - 3 Beams edit", expect(content.queryByTestId('taskShortDescription').value).toEqual('OOO.O Paaa+01 Paaa+02 Paaa+03'); content.queryByTestId('taskShortDescription').value = 'Testing'; expect(content.getByText("IM LBA Survey - 3 Beams")).toBeInTheDocument() - expect(content.getAllByText("parallel calibrator target observation").length).toBe(4); + expect(content.getAllByText("parallel calibrator target observation").length).toBe(2); expect(content.getByText("Specification")).toBeInTheDocument(); expect(content.getByText("calibrator")).toBeInTheDocument(); expect(content.getByText("Auto-select")).toBeInTheDocument(); @@ -222,7 +222,7 @@ it("test Combined Observation Task Draft view of IM LBA LoDSS - 5 Beams edit" , expect(content.queryByTestId('taskName').value).toEqual('Combined Observation'); expect(content.queryByTestId('taskDescription').value).toEqual('Combined parallel Calibrator & Target Observation for LBA with 5 target beams'); expect(content.queryByTestId('taskShortDescription').value).toEqual('oXXX Paaa+01 3Cabc'); - expect(content.getByText("parallel target and beamforming observation")).toBeInTheDocument(); + expect(content.getAllByText("parallel calibrator target observation").length).toBe(2); expect(content.getByText("Specification")).toBeInTheDocument(); expect(content.getByText("Auto-select")).toBeInTheDocument(); expect(content.getByLabelText("specification[calibrator][name]")).toBeInTheDocument(); @@ -336,7 +336,7 @@ it("test Calibrator Pipeline Task Draft view of IM LBA LoDSS - 5 Beams edit", as expect(content.queryByTestId('taskName').value).toEqual('Calibrator Pipeline'); expect(content.queryByTestId('taskDescription').value).toEqual('Preprocessing Pipeline for Calibrator Observation'); expect(content.queryByTestId('taskShortDescription').value).toEqual('3Cabc/1.0/CP'); - expect(content.getByText("parallel target and beamforming observation")).toBeInTheDocument(); + expect(content.getAllByText("preprocessing pipeline").length).toBe(2); expect(content.getByText("Specification")).toBeInTheDocument(); expect(content.getByText("Task - Edit")).toBeInTheDocument(); expect(content.getByLabelText("specification[average][time_steps]")).toBeInTheDocument(); @@ -414,7 +414,7 @@ it("test Target Pipeline Task Draft view of IM LBA LoDSS - 5 Beams edit", async expect(content.queryByTestId('taskName').value).toEqual('Pipeline target1'); expect(content.queryByTestId('taskDescription').value).toEqual('Preprocessing Pipeline for Target Observation target1'); expect(content.queryByTestId('taskShortDescription').value).toEqual('Paaa+01/1.0/PP'); - expect(content.getByText("parallel target and beamforming observation")).toBeInTheDocument(); + expect(content.getAllByText("preprocessing pipeline").length).toBe(2); expect(content.getByText("Specification")).toBeInTheDocument(); expect(content.getByLabelText("specification[average][time_steps]")).toBeInTheDocument(); expect(content.getByLabelText("specification[average][frequency_steps]")).toBeInTheDocument(); @@ -880,7 +880,7 @@ it("test Target Observation (IM HBA LoTSS strategy) edit", async () => { expect(content.queryByTestId('taskName').value).toEqual('Target Observation'); expect(content.queryByTestId('taskDescription').value).toEqual('Target Observation for LoTSS scheduling unit. HBA_DUAL_INNER, 120-168 MHz, 1s, 64ch/sb'); expect(content.queryByTestId('taskShortDescription').value).toEqual('Paaa+01 & Paaa+02'); - expect(content.getAllByText("target observation").length).toBe(4); + expect(content.getAllByText("target observation").length).toBe(2); expect(content.getByText("Specification")).toBeInTheDocument(); expect(content.getByLabelText("specification[duration]")).toBeInTheDocument(); expect(content.getByLabelText("specification[correlator][integration_time]")).toBeInTheDocument(); @@ -1060,7 +1060,7 @@ it("test Calibrator Observation (IM HBA LoTSS strategy) edit", async () => { // checking Task details and specification expect(content.queryByTestId('taskName').value).toEqual('Calibrator Observation 1'); expect(content.queryByTestId('taskDescription').value).toEqual('Calibrator Observation 1. Before the Target Observation'); - expect(content.getAllByText("calibrator observation").length).toBe(5); + expect(content.getAllByText("calibrator observation").length).toBe(2); expect(content.queryByTestId('taskShortDescription').value).toEqual('Cal1 3Cabc'); expect(content.getByText("IM HBA LoTSS - 2 Beams")).toBeInTheDocument(); expect(content.getByText("Specification")).toBeInTheDocument(); @@ -1171,7 +1171,7 @@ it("test Preprocessing pipeline for calibrator (IM HBA LoTSS strategy) edit", as expect(content.queryByTestId('taskName').value).toEqual('Calibrator Pipeline 1'); expect(content.queryByTestId('taskDescription').value).toEqual('Preprocessing Pipeline for Calibrator Observation 1'); expect(content.queryByTestId('taskShortDescription').value).toEqual('Cal1 3Cabc/PP'); - expect(content.getAllByText("preprocessing pipeline").length).toBe(3); + expect(content.getAllByText("preprocessing pipeline").length).toBe(2); expect(content.getByText("Specification")).toBeInTheDocument(); expect(content.getByText("Specification")).toBeInTheDocument(); @@ -1617,4 +1617,4 @@ it("Checking Correctness of Custom fields in JEditor using Simple Beamforming Ob await new Promise((r) => setTimeout(r, 150)); }); expect(updateTaskSpy).toHaveBeenCalled(); -}); \ No newline at end of file +}); \ No newline at end of file diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/view.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/view.test.js index edeafb3a0b4fa0b3b3160034643745743ae42b5f..651e1e46f938a14d8ca6a7471941acb0783cce31 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/view.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/view.test.js @@ -813,8 +813,8 @@ it("test Calibrator Pipeline Task Blueprint view of IM LBA LoDSS - 5 Beams", asy expect(content.getByText("preprocessing pipeline")).toBeInTheDocument(); expect(content.getByText("Combined Observation")).toBeInTheDocument(); expect(content.getAllByText("Ingest").length).toBe(2); - expect(content.getAllByText("Process Start Time").length).toBe(3); - expect(content.getAllByText("Process End Time").length).toBe(3); + expect(content.getAllByText("Process Start Time").length).toBe(2); + expect(content.getAllByText("Process End Time").length).toBe(2); expect(content.getByText("Status")).toBeInTheDocument(); expect(content.getAllByRole("tablehead").length).toBe(13); expect(content.getAllByRole("row").length).toBe(2); @@ -859,8 +859,8 @@ it("test Target Pipeline Task Blueprint view of IM LBA LoDSS - 5 Beams", async ( expect(content.getByText("preprocessing pipeline")).toBeInTheDocument(); expect(content.getByText("Combined Observation")).toBeInTheDocument(); expect(content.getAllByText("Ingest").length).toBe(2); - expect(content.getAllByText("Process Start Time").length).toBe(3); - expect(content.getAllByText("Process End Time").length).toBe(3); + expect(content.getAllByText("Process Start Time").length).toBe(2); + expect(content.getAllByText("Process End Time").length).toBe(2); expect(content.getByText("Status")).toBeInTheDocument(); expect(content.getAllByRole("tablehead").length).toBe(13); expect(content.getAllByRole("row").length).toBe(2); @@ -905,8 +905,8 @@ it("test IM BF Cal&Tgt Task Blueprint view", async () => { expect(content.getByText("parallel calibrator target and beamforming observation")).toBeInTheDocument(); expect(content.getAllByText("Observation Start Time").length).toBe(1); expect(content.getAllByText("Observation End Time").length).toBe(1); - expect(content.getAllByText("Process Start Time").length).toBe(3); - expect(content.getAllByText("Process End Time").length).toBe(3); + expect(content.getAllByText("Process Start Time").length).toBe(2); + expect(content.getAllByText("Process End Time").length).toBe(2); expect(content.getByText("Status")).toBeInTheDocument(); expect(content.getAllByRole("tablehead").length).toBe(13); expect(content.getAllByRole("row").length).toBe(4); @@ -1009,8 +1009,8 @@ it("test Simple Beamforming Observation Task Blueprint view", async () => { expect(content.getByText("beamforming observation")).toBeInTheDocument(); expect(content.getAllByText("Observation Start Time").length).toBe(1); expect(content.getAllByText("Observation End Time").length).toBe(1); - expect(content.getAllByText("Process Start Time").length).toBe(3); - expect(content.getAllByText("Process End Time").length).toBe(3); + expect(content.getAllByText("Process Start Time").length).toBe(2); + expect(content.getAllByText("Process End Time").length).toBe(2); expect(content.getByText("Status")).toBeInTheDocument(); expect(content.getAllByRole("tablehead").length).toBe(13); expect(content.getAllByRole("row").length).toBe(2); @@ -1107,8 +1107,8 @@ it("test Target Observation Task Blueprint vew of IM HBA LoTSS - 2 Beams strateg expect(content.getByText("target observation")).toBeInTheDocument(); expect(content.getByText("Observation Start Time")).toBeInTheDocument(); expect(content.getByText("Observation End Time")).toBeInTheDocument(); - expect(content.getAllByText("Process Start Time").length).toBe(3); - expect(content.getAllByText("Process End Time").length).toBe(3); + expect(content.getAllByText("Process Start Time").length).toBe(2); + expect(content.getAllByText("Process End Time").length).toBe(2); expect(content.getByText("Status")).toBeInTheDocument(); expect(content.getAllByRole("tablehead").length).toBe(13); expect(content.getAllByRole("row").length).toBe(4); @@ -1181,8 +1181,8 @@ it("test Calibrator Observation Task Blueprint vew of IM HBA LoTSS - 2 Beams str expect(content.getByText("calibrator observation")).toBeInTheDocument(); expect(content.getByText("Observation Start Time")).toBeInTheDocument(); expect(content.getByText("Observation End Time")).toBeInTheDocument(); - expect(content.getAllByText("Process Start Time").length).toBe(3); - expect(content.getAllByText("Process End Time").length).toBe(3); + expect(content.getAllByText("Process Start Time").length).toBe(2); + expect(content.getAllByText("Process End Time").length).toBe(2); expect(content.getByText("Status")).toBeInTheDocument(); expect(content.getAllByRole("tablehead").length).toBe(13); expect(content.getAllByRole("row").length).toBe(4); @@ -1214,8 +1214,8 @@ it("test Calibrator Pipeline Task Blueprint view of IM HBA LoTSS - 2 Beams", asy expect(content.getByText("preprocessing pipeline")).toBeInTheDocument(); expect(content.getByText("Calibrator Observation 1")).toBeInTheDocument(); expect(content.getAllByText("Ingest").length).toBe(2); - expect(content.getAllByText("Process Start Time").length).toBe(3); - expect(content.getAllByText("Process End Time").length).toBe(3); + expect(content.getAllByText("Process Start Time").length).toBe(2); + expect(content.getAllByText("Process End Time").length).toBe(2); expect(content.getByText("Status")).toBeInTheDocument(); expect(content.getAllByRole("tablehead").length).toBe(13); expect(content.getAllByRole("row").length).toBe(2); @@ -1247,7 +1247,7 @@ it("test Calibrator Pipeline Task Blueprint view of IM HBA LoTSS - 2 Beams", asy expect(content.getByText("Cluster")).toBeInTheDocument(); expect(content.getByText("Partition")).toBeInTheDocument(); }); - + it("test Pulsar Pipeline Task Blueprint view", async () => { let content; await act(async () => { @@ -1261,8 +1261,8 @@ it("test Pulsar Pipeline Task Blueprint view", async () => { expect(content.getAllByText("Cleanup").length).toBe(2); // expect(content.getByText("oXXX Paaa+01 3Cabc")).toBeInTheDocument(); expect(content.getByText("pulsar pipeline")).toBeInTheDocument(); - expect(content.getAllByText("Process Start Time").length).toBe(3); - expect(content.getAllByText("Process End Time").length).toBe(3); + expect(content.getAllByText("Process Start Time").length).toBe(2); + expect(content.getAllByText("Process End Time").length).toBe(2); expect(content.getByText("Status")).toBeInTheDocument(); expect(content.getAllByRole("tablehead").length).toBe(13); expect(content.getAllByRole("row").length).toBe(2); @@ -1401,8 +1401,8 @@ it("test IM+BF Observation Task Blueprint vew of IM Solar Campaign strategy", as expect(content.getByText('IM+BF Observation')).toBeInTheDocument(); expect(content.getByText("Observation Start Time")).toBeInTheDocument(); expect(content.getByText("Observation End Time")).toBeInTheDocument(); - expect(content.getAllByText("Process Start Time").length).toBe(3); - expect(content.getAllByText("Process End Time").length).toBe(3); + expect(content.getAllByText("Process Start Time").length).toBe(2); + expect(content.getAllByText("Process End Time").length).toBe(2); expect(content.getByText("Status")).toBeInTheDocument(); expect(content.getAllByRole("tablehead").length).toBe(13); expect(content.getAllByRole("row").length).toBe(2);