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 2c523dffc6e3e5d68fd624fbd10e3f38120f2779..b5113aeb9f085b8c774cd66a78dd2fd961adb722 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 @@ -129,7 +129,7 @@ it("Save button enabled when mandatory data entered", async () => { expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy(); }); -// TODO : Fix Unit test renders Save button enabled when all data entered + it("renders Save button enabled when all data entered", async () => { console.log("renders Save button enabled when all data entered -----------------------"); let content; @@ -301,7 +301,6 @@ it("save project with default resources", async () => { expect(content.queryByTestId('save-btn')).toHaveAttribute("disabled"); }); -// TODO : Fix Unit Test save project with added resources it("save project with added resources", async () => { console.log("save project with added resources -----------------------"); 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 b02ae90b7b45eec34296419230f84536a01d181c..f183f932d98babdb44a6822ed285a9bce01f836e 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 @@ -127,7 +127,6 @@ it("renders nothing if no project details found", async () => { expect(content.queryByText("Project - Edit")).toBe(null); }); -//TODO : Fix Unit Test renders input fields with Project details if found it("renders input fields with Project details if found", async () => { console.log("renders input fields with Project details if found.........."); let content; @@ -163,7 +162,7 @@ it("renders input fields with Project details if found", async () => { expect(_.filter(spinButtons, { "id": "LOFAR Observing Time prio A" })[0].value).toBe("1"); expect(_.filter(spinButtons, { "id": "LOFAR Observing Time prio B" })[0].value).toBe("1"); expect(_.filter(spinButtons, { "id": "LOFAR Support Time" })[0].value).toBe("1"); - expect(_.filter(spinButtons, { "id": "LTA Storage" })[0].value).toBe("1"); + expect(_.filter(spinButtons, { "id": "LTA Storage" })[0].value).toBe("1.099511627776"); expect(_.filter(spinButtons, { "id": "Number of triggers" })[0].value).toBe("1"); expect(content.queryByTestId('save-btn').hasAttribute("disabled")).toBeFalsy(); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.test.js index 49844df3180937f7a0ec8d92f1e1c750bb5943d6..80c9b7571dadde262d6245e37c779853f693db9b 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.test.js @@ -122,7 +122,7 @@ it("renders Project details if found", async () => { expect(content.queryByTestId("LOFAR Observing Time prio A").innerHTML.includes('1 Hours')).toBeTruthy(); expect(content.queryByTestId("LOFAR Observing Time prio B").innerHTML.includes('1 Hours')).toBeTruthy(); expect(content.queryByTestId("LOFAR Support Time").innerHTML.includes('1 Hours')).toBeTruthy(); - expect(content.queryByTestId("LTA Storage").innerHTML.includes('1 TB')).toBeTruthy(); + expect(content.queryByTestId("LTA Storage").innerHTML.includes('1.099511627776 TB')).toBeTruthy(); expect(content.queryByTestId("Number of triggers").innerHTML.includes('1 Numbers')).toBeTruthy(); // Ensure that all project actions are available and enabled expect(content.getByTitle("Update Project Status")).toBeInTheDocument(); 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 e7de26c45c49a8a825685c467760ee89a827761f..a681fa54047b16aceda34b2f3fc3b7ffae41fabb 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 @@ -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, screen, cleanup, fireEvent, waitFor } from '@testing-library/react'; +import { render, cleanup, fireEvent ,waitFor} from '@testing-library/react'; import '@testing-library/jest-dom'; import mockConsole from 'jest-mock-console' import _ from 'lodash'; @@ -99,7 +99,7 @@ const clearMockSpy = (() => { it("renders Task details Edit page", async () => { let content; await act(async () => { - content = await render(<Router><TaskEdit match={{params:{id: "9"}}} history={{}} location="/task/edit/draft/9" /></Router>); + content = render(<Router key="router"><TaskEdit match={{params:{id: "9"}}} history={{}} location="/task/edit/draft/9" /></Router>); }); expect(content.getByText("Task - Edit")).toBeInTheDocument(); }); @@ -107,7 +107,7 @@ it("renders Task details Edit page", async () => { it("test Combined Observation Task Draft view of IM LBA Survey - 3 Beams edit", async () => { let content; await act(async () => { - content = await render(<Router><TaskEdit match={{params:{id: "9"}}} history={{}} location="/task/edit/draft/9" /></Router>); + content = render(<Router><TaskEdit match={{params:{id: "9"}}} history={{}} location="/task/edit/draft/9" /></Router>); await new Promise((r) => setTimeout(r, 500)); }); expect(content.getByText("Task - Edit")).toBeInTheDocument(); @@ -117,8 +117,11 @@ it("test Combined Observation Task Draft view of IM LBA Survey - 3 Beams edit", content.queryByTestId('taskShortDescription').value = 'Testing'; expect(content.getByText("IM LBA Survey - 3 Beams")).toBeInTheDocument() expect(content.getAllByText("parallel calibrator target observation").length).toBe(2); + await waitFor(()=>expect(content.getByText("calibrator")).toBeInTheDocument()); + expect(content.getByText("calibrator")).toBeInTheDocument() + await waitFor(()=>expect(content.getByText("Specification")).toBeInTheDocument()); expect(content.getByText("Specification")).toBeInTheDocument(); - expect(content.getByText("calibrator")).toBeInTheDocument(); + await waitFor(()=>expect(content.getByText("Auto-select")).toBeInTheDocument()); expect(content.getByText("Auto-select")).toBeInTheDocument(); expect(content.getByLabelText("specification[calibrator][name]")).toBeInTheDocument(); expect(content.getByLabelText("specification[calibrator][pointing][angle1]")).toBeInTheDocument(); @@ -136,6 +139,24 @@ it("test Combined Observation Task Draft view of IM LBA Survey - 3 Beams edit", expect(content.getByLabelText("specification[station_configuration][SAPs][0][digital_pointing][angle2]")).toBeInTheDocument(); expect(content.getByLabelText("specification[station_configuration][SAPs][0][digital_pointing][target]")).toBeInTheDocument(); expect(content.getByLabelText("specification[station_configuration][SAPs][0][name]")).toBeInTheDocument(); + + expect(content.getByText("Antenna set")).toBeInTheDocument(); + expect(content.getByText("Band-pass filter")).toBeInTheDocument(); + expect(content.getByText("Station groups")).toBeInTheDocument(); + expect(content.getByText("Station group 1")).toBeInTheDocument(); + expect(content.getByText("Station group 2")).toBeInTheDocument(); + expect(content.getByText("Station group 3")).toBeInTheDocument(); + expect(content.getByLabelText("specification[station_configuration][tile_beam][angle1]")).toBeInTheDocument(); + expect(content.getByLabelText("specification[station_configuration][tile_beam][angle2]")).toBeInTheDocument(); + expect(content.getByLabelText("specification[station_configuration][tile_beam][target]")).toBeInTheDocument(); + expect(content.getByText("Inspection Plots")).toBeInTheDocument(); + expect(content.getByText("autocorrelation")).toBeInTheDocument(); + expect(content.getByText("crosscorrelation")).toBeInTheDocument(); + expect(content.getByText("Do/Don't create plots from the QA file from the observation")).toBeInTheDocument(); + + + + await waitFor(()=>expect(content.getByLabelText("specification[station_configuration][SAPs][0][subbands]")).toBeInTheDocument()); expect(content.getByLabelText("specification[station_configuration][SAPs][0][subbands]")).toBeInTheDocument(); expect(content.getByLabelText("specification[station_configuration][SAPs][0][frequency]")).toBeInTheDocument(); expect(content.getByLabelText("specification[station_configuration][SAPs][1][digital_pointing][angle1]")).toBeInTheDocument(); @@ -151,20 +172,7 @@ it("test Combined Observation Task Draft view of IM LBA Survey - 3 Beams edit", expect(content.getByLabelText("specification[station_configuration][SAPs][2][subbands]")).toBeInTheDocument(); expect(content.getByLabelText("specification[station_configuration][SAPs][2][frequency]")).toBeInTheDocument(); expect(content.getByLabelText("specification[calibrator][name]")).toBeInTheDocument(); - expect(content.getByText("Antenna set")).toBeInTheDocument(); - expect(content.getByText("Band-pass filter")).toBeInTheDocument(); - expect(content.getByText("Station groups")).toBeInTheDocument(); - expect(content.getByText("Station group 1")).toBeInTheDocument(); - expect(content.getByText("Station group 2")).toBeInTheDocument(); - expect(content.getByText("Station group 3")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][tile_beam][angle1]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][tile_beam][angle2]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][tile_beam][target]")).toBeInTheDocument(); - expect(content.getByText("Inspection Plots")).toBeInTheDocument(); - expect(content.getByText("autocorrelation")).toBeInTheDocument(); - expect(content.getByText("crosscorrelation")).toBeInTheDocument(); - expect(content.getByText("Do/Don't create plots from the QA file from the observation")).toBeInTheDocument(); - + // check for save button enable/disable expect(content.queryByTestId('save-btn')).not.toBeDisabled(); expect(content.queryByTestId('taskName').value).toBe('Combined Observation'); @@ -226,6 +234,7 @@ it("test Combined Observation Task Draft view of IM LBA Survey - 3 Beams edit" , 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.getAllByText("parallel calibrator target observation").length).toBe(2); + await waitFor(()=>expect(content.getByText("Specification")).toBeInTheDocument()); expect(content.getByText("Specification")).toBeInTheDocument(); expect(content.getByText("Auto-select")).toBeInTheDocument(); expect(content.getByLabelText("specification[calibrator][name]")).toBeInTheDocument(); @@ -340,6 +349,7 @@ it("test Calibrator Pipeline Task Draft view of IM LBA LoDSS - 5 Beams edit", as expect(content.queryByTestId('taskDescription').value).toEqual('Preprocessing Pipeline for Calibrator Observation'); expect(content.queryByTestId('taskShortDescription').value).toEqual('3Cabc/1.0/CP'); expect(content.getAllByText("preprocessing pipeline").length).toBe(2); + await waitFor(()=>expect(content.getByText("Specification")).toBeInTheDocument()); expect(content.getByText("Specification")).toBeInTheDocument(); expect(content.getByText("Task - Edit")).toBeInTheDocument(); expect(content.getByLabelText("specification[average][time_steps]")).toBeInTheDocument(); @@ -418,6 +428,7 @@ it("test Target Pipeline Task Draft view of IM LBA LoDSS - 5 Beams edit", async 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.getAllByText("preprocessing pipeline").length).toBe(2); + await waitFor(()=>expect(content.getByText("Specification")).toBeInTheDocument()); expect(content.getByText("Specification")).toBeInTheDocument(); expect(content.getByLabelText("specification[average][time_steps]")).toBeInTheDocument(); expect(content.getByLabelText("specification[average][frequency_steps]")).toBeInTheDocument(); @@ -497,7 +508,7 @@ it("test IM BF Cal&Tgt Task Draft edit", async () => { expect(content.queryByTestId('taskDescription').value).toEqual('IM BF Cal&Tgt'); expect(content.queryByTestId('taskShortDescription').value).toEqual(''); expect(content.getAllByText("parallel calibrator target and beamforming observation").length).toBeGreaterThan(0); - + await waitFor(()=>expect(content.getByText("Specification")).toBeInTheDocument()); expect(content.getByText("Specification")).toBeInTheDocument(); expect(content.getByText("Auto-select")).toBeInTheDocument(); expect(content.getByLabelText("specification[calibrator][name]")).toBeInTheDocument(); @@ -671,7 +682,7 @@ it("test IM BF Cal&Tgt Task Draft edit", async () => { expect(content.queryByTestId('taskShortDescription').value).toEqual(''); expect(content.getByText("Simple Beamforming Observation")).toBeInTheDocument(); - + await waitFor(()=>expect(content.getByText("Specification")).toBeInTheDocument()); expect(content.getByText("Specification")).toBeInTheDocument(); expect(content.getByLabelText("specification[duration]")).toBeInTheDocument(); @@ -884,6 +895,7 @@ it("test Target Observation (IM HBA LoTSS strategy) edit", async () => { 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(2); + await waitFor(()=>expect(content.getByText("Specification")).toBeInTheDocument()); expect(content.getByText("Specification")).toBeInTheDocument(); expect(content.getByLabelText("specification[duration]")).toBeInTheDocument(); expect(content.getByLabelText("specification[correlator][integration_time]")).toBeInTheDocument(); @@ -1066,6 +1078,7 @@ it("test Calibrator Observation (IM HBA LoTSS strategy) edit", async () => { 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(); + await waitFor(()=>expect(content.getByText("Specification")).toBeInTheDocument()); expect(content.getByText("Specification")).toBeInTheDocument(); expect(content.getByText("Auto-select")).toBeInTheDocument(); expect(content.getByLabelText("specification[calibrator][name]")).toBeInTheDocument(); @@ -1175,6 +1188,7 @@ it("test Preprocessing pipeline for calibrator (IM HBA LoTSS strategy) edit", as 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(2); + await waitFor(()=>expect(content.getByText("Specification")).toBeInTheDocument()); expect(content.getByText("Specification")).toBeInTheDocument(); expect(content.getByText("Specification")).toBeInTheDocument(); 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 20e1d2ddde794b034f20b73468a17467acf62f0b..5a6dcc003a6c095aac7af4f5f4511ad4bd180bd8 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 @@ -76,8 +76,8 @@ const clearMockSpy = (() => { taskTemplateSpy.mockRestore(); schedulingUnitSpy.mockRestore(); }); - // TODO FIX Unit Test (ON CI/CD Error opening file "/builds/ro/lofar/build/gnucxx11_opt/SAS/TMSS/frontend/tmss_webapp/station_configuration/11%2523/definitions/station_configuration) -it.skip("renders Task details page", async () => { + +it("renders Task details page", async () => { let content; await act(async () => { content = render(<Router><TaskView match={{params:{id: "9", type:"draft"}}} history={{}} location="/task/view/draft/9" /></Router>); @@ -90,7 +90,7 @@ it.skip("renders Task details page", async () => { it("test Combined Observation Task Draft view of IM LBA Survey - 3 Beams", async () => { let content; await act(async () => { - content = render(<Router><TaskView match={{params:{id: "9", type:"draft"}}} history={{}} location="/task/view/draft/9" /></Router>); + content = render(<Router><TaskView match={{params:{id: "9", type:"draft"}}} history={{}} location="/task/view/draft/9" key="CombinedTest"/></Router>); await new Promise((r) => setTimeout(r, 5000)); }); expect(content.getByText("Task - Details")).toBeInTheDocument(); @@ -103,7 +103,7 @@ it("test Combined Observation Task Draft view of IM LBA Survey - 3 Beams", async expect(content.getByText("Pipeline target2")).toBeInTheDocument(); expect(content.getByText("Pipeline target1")).toBeInTheDocument(); expect(content.getByText("parallel calibrator target observation")).toBeInTheDocument(); - expect(content.getByText("Task Specification")).toBeInTheDocument(); + await waitFor(()=>expect(content.getByText("Auto-select")).toBeInTheDocument()); expect(content.getByText("Auto-select")).toBeInTheDocument(); expect(content.getByLabelText("specification[calibrator][name]")).toBeInTheDocument(); expect(content.getByLabelText("specification[calibrator][pointing][angle1]")).toBeInTheDocument(); @@ -121,20 +121,20 @@ it("test Combined Observation Task Draft view of IM LBA Survey - 3 Beams", async expect(content.getByLabelText("specification[station_configuration][SAPs][0][digital_pointing][angle2]")).toBeInTheDocument(); expect(content.getByLabelText("specification[station_configuration][SAPs][0][digital_pointing][target]")).toBeInTheDocument(); expect(content.getByLabelText("specification[station_configuration][SAPs][0][name]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][SAPs][0][subbands]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][SAPs][0][frequency]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][SAPs][1][digital_pointing][angle1]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][SAPs][1][digital_pointing][angle2]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][SAPs][1][digital_pointing][target]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][SAPs][1][name]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][SAPs][1][subbands]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][SAPs][1][frequency]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][SAPs][2][digital_pointing][angle1]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][SAPs][2][digital_pointing][angle2]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][SAPs][2][digital_pointing][target]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][SAPs][2][name]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][SAPs][2][subbands]")).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][SAPs][2][frequency]")).toBeInTheDocument(); + await waitFor(()=> expect(content.getByLabelText("specification[station_configuration][SAPs][0][subbands]")).toBeInTheDocument()); + await waitFor(()=>expect(content.getByLabelText("specification[station_configuration][SAPs][0][frequency]")).toBeInTheDocument()); + await waitFor(()=>expect(content.getByLabelText("specification[station_configuration][SAPs][1][digital_pointing][angle1]")).toBeInTheDocument()); + await waitFor(()=> expect(content.getByLabelText("specification[station_configuration][SAPs][1][digital_pointing][angle2]")).toBeInTheDocument()); + await waitFor(()=>expect(content.getByLabelText("specification[station_configuration][SAPs][1][digital_pointing][target]")).toBeInTheDocument()); + await waitFor(()=>expect(content.getByLabelText("specification[station_configuration][SAPs][1][name]")).toBeInTheDocument()); + await waitFor(()=>expect(content.getByLabelText("specification[station_configuration][SAPs][1][subbands]")).toBeInTheDocument()); + await waitFor(()=>expect(content.getByLabelText("specification[station_configuration][SAPs][1][frequency]")).toBeInTheDocument()); + await waitFor(()=>expect(content.getByLabelText("specification[station_configuration][SAPs][2][digital_pointing][angle1]")).toBeInTheDocument()); + await waitFor(()=>expect(content.getByLabelText("specification[station_configuration][SAPs][2][digital_pointing][angle2]")).toBeInTheDocument()); + await waitFor(()=> expect(content.getByLabelText("specification[station_configuration][SAPs][2][digital_pointing][target]")).toBeInTheDocument()); + await waitFor(()=>expect(content.getByLabelText("specification[station_configuration][SAPs][2][name]")).toBeInTheDocument()); + await waitFor(()=>expect(content.getByLabelText("specification[station_configuration][SAPs][2][subbands]")).toBeInTheDocument()); + await waitFor(()=>expect(content.getByLabelText("specification[station_configuration][SAPs][2][frequency]")).toBeInTheDocument()); expect(content.getByLabelText("specification[calibrator][name]")).toBeInTheDocument(); expect(content.getByText("Antenna set")).toBeInTheDocument(); expect(content.getByText("Band-pass filter")).toBeInTheDocument(); @@ -149,6 +149,7 @@ it("test Combined Observation Task Draft view of IM LBA Survey - 3 Beams", async expect(content.getByText("autocorrelation")).toBeInTheDocument(); expect(content.getByText("crosscorrelation")).toBeInTheDocument(); expect(content.getByText("Do/Don't create plots from the QA file from the observation")).toBeInTheDocument(); + expect(content.getByText("Task Specification")).toBeInTheDocument(); }); @@ -170,6 +171,7 @@ it("test Combined Observation Task Draft view of IM LBA LoDSS - 5 Beams", async expect(content.getByText("Pipeline target2")).toBeInTheDocument(); expect(content.getByText("Pipeline target1")).toBeInTheDocument(); expect(content.getByText("parallel calibrator target observation")).toBeInTheDocument(); + await waitFor(()=>expect(content.getByText("Task Specification")).toBeInTheDocument()); expect(content.getByText("Task Specification")).toBeInTheDocument(); expect(content.getByText("Auto-select")).toBeInTheDocument(); expect(content.getByLabelText("specification[calibrator][name]")).toBeInTheDocument(); @@ -245,7 +247,7 @@ it("test Calibrator Pipeline Task Draft view of IM LBA LoDSS - 5 Beams", async ( expect(content.getByText("preprocessing pipeline")).toBeInTheDocument(); expect(content.getByText("Combined Observation")).toBeInTheDocument(); expect(content.getByText("Ingest")).toBeInTheDocument(); - expect(content.getByText("Task Specification")).toBeInTheDocument(); + expect(content.getByLabelText("specification[average][time_steps]")).toBeInTheDocument(); expect(content.getByLabelText("specification[average][frequency_steps]")).toBeInTheDocument(); expect(content.getByLabelText("specification[average][time_resolution]")).toBeInTheDocument(); @@ -267,6 +269,7 @@ it("test Calibrator Pipeline Task Draft view of IM LBA LoDSS - 5 Beams", async ( expect(content.getByLabelText("specification[cluster_resources][parallel_tasks]")).toBeInTheDocument(); expect(content.getByText("Cluster")).toBeInTheDocument(); expect(content.getByText("Partition")).toBeInTheDocument(); + expect(content.getByText("Task Specification")).toBeInTheDocument(); }); it("test Target Pipeline Task Draft view of IM LBA LoDSS - 5 Beams", async () => { @@ -583,6 +586,7 @@ it("test Calibrator Pipeline Task Draft view of IM HBA LoTSS - 2 Beams", async ( expect(content.getByText("preprocessing pipeline")).toBeInTheDocument(); expect(content.getByText("Calibrator Observation 1")).toBeInTheDocument(); expect(content.getByText("Ingest")).toBeInTheDocument(); + await waitFor(()=>expect(content.getByText("Task Specification")).toBeInTheDocument()); expect(content.getByText("Task Specification")).toBeInTheDocument(); expect(content.getByLabelText("specification[average][time_steps]")).toBeInTheDocument(); expect(content.getByLabelText("specification[average][frequency_steps]")).toBeInTheDocument(); @@ -835,8 +839,7 @@ it("test Calibrator Pipeline Task Blueprint view of IM LBA LoDSS - 5 Beams", asy expect(content.getAllByRole("row").length).toBe(2); expect(content.getByTitle("Cancel Subtasks")).toBeInTheDocument(); expect(content.getAllByTitle("Mark as Obsolete").length).toBe(1); - // expect(content.getByTitle("Don't have permission to cancel ")).not.toBeInTheDocument(); - // expect(content.getByTitle("Don't have permission to mark as obsolete")).not.toBeInTheDocument(); + await waitFor(()=>expect(content.getByText("Task Specification")).toBeInTheDocument()); expect(content.getByText("Task Specification")).toBeInTheDocument(); expect(content.getByLabelText("specification[average][time_steps]")).toBeInTheDocument(); expect(content.getByLabelText("specification[average][frequency_steps]")).toBeInTheDocument(); @@ -881,8 +884,7 @@ it("test Target Pipeline Task Blueprint view of IM LBA LoDSS - 5 Beams", async ( expect(content.getAllByRole("row").length).toBe(2); expect(content.getByTitle("Cancel Subtasks")).toBeInTheDocument(); expect(content.getAllByTitle("Mark as Obsolete").length).toBe(1); - // expect(content.getByTitle("Don't have permission to cancel ")).not.toBeInTheDocument(); - // expect(content.getByTitle("Don't have permission to mark as obsolete")).not.toBeInTheDocument(); + await waitFor(()=>expect(content.getByText("Task Specification")).toBeInTheDocument()); expect(content.getByText("Task Specification")).toBeInTheDocument(); expect(content.getByLabelText("specification[average][time_steps]")).toBeInTheDocument(); expect(content.getByLabelText("specification[average][frequency_steps]")).toBeInTheDocument(); @@ -1204,9 +1206,6 @@ it("test Calibrator Observation Task Blueprint vew of IM HBA LoTSS - 2 Beams str expect(content.getAllByRole("row").length).toBe(4); expect(content.getByTitle("Cancel Subtasks")).toBeInTheDocument(); expect(content.getAllByTitle("Mark as Obsolete").length).toBe(1); - // expect(content.getByTitle("Don't have permission to cancel ")).not.toBeInTheDocument(); - // expect(content.getByTitle("Don't have permission to mark as obsolete")).not.toBeInTheDocument(); - await waitFor(()=>expect(content.getByText("Task Specification")).toBeInTheDocument()); expect(content.getByText("Auto-select")).toBeInTheDocument(); expect(content.getByLabelText("specification[calibrator][name]")).toBeInTheDocument(); @@ -1237,8 +1236,6 @@ it("test Calibrator Pipeline Task Blueprint view of IM HBA LoTSS - 2 Beams", asy expect(content.getAllByRole("row").length).toBe(2); expect(content.getByTitle("Cancel Subtasks")).toBeInTheDocument(); expect(content.getAllByTitle("Mark as Obsolete").length).toBe(1); - // expect(content.getByTitle("Don't have permission to cancel ")).not.toBeInTheDocument(); - // expect(content.getByTitle("Don't have permission to mark as obsolete")).not.toBeInTheDocument(); await waitFor(()=>expect(content.getByText("Task Specification")).toBeInTheDocument()); expect(content.getByLabelText("specification[average][time_steps]")).toBeInTheDocument(); @@ -1503,18 +1500,14 @@ it("Checking Correctness of Custom fields in JEditor using Simple Observation dr let content; await act(async () => { content = render(<Router><TaskView match={{params:{id: "70", type:"draft"}}} history={{}} isUnitTest={true} location="/task/view/draft/70" /></Router>); - await new Promise((r) => setTimeout(r, 500)); + await new Promise((r) => setTimeout(r, 2000)); }); expect(content.getByText("Task - Details")).toBeInTheDocument(); // checking Task details and specification expect(content.getAllByText('Observation').length).toBe(1); expect(content.getByText('Observation')).toBeInTheDocument(); - expect(content.getByLabelText("specification[station_configuration][SAPs][0][digital_pointing][angle1]")).toBeInTheDocument(); - const angle1El = content.getByLabelText("specification[station_configuration][SAPs][0][digital_pointing][angle1]"); - expect(angle1El.value).toBe('03h06m00s'); - expect(content.getByLabelText("specification[station_configuration][SAPs][0][digital_pointing][angle2]")).toBeInTheDocument(); - const angle1E2 = content.getByLabelText("specification[station_configuration][SAPs][0][digital_pointing][angle2]"); - expect(angle1E2.value).toBe('89d59m00s'); + + expect(content.getByLabelText("specification[correlator][frequency_resolution]")).toBeInTheDocument(); const freqRes = content.getByLabelText("specification[correlator][frequency_resolution]"); expect(freqRes.value).toBe('3.05'); @@ -1524,4 +1517,17 @@ it("Checking Correctness of Custom fields in JEditor using Simple Observation dr expect(content.getByLabelText("specification[station_configuration][SAPs][0][frequency]")).toBeInTheDocument(); const freqSAP = content.getByLabelText("specification[station_configuration][SAPs][0][frequency]"); expect(freqSAP.value).toBe('99.9-147.6'); + + + /* These seems to be actually not present in the node. Unclear if this is due too a failing test, or recently changed design */ + + await waitFor(()=>expect(content.getByRole("textbox",{name: "specification[station_configuration][SAPs][0][digital_pointing][angle1]"})).toBeInTheDocument()); + await waitFor(()=>expect(content.getByRole("textbox",{name: "specification[station_configuration][SAPs][0][digital_pointing][angle2]"})).toBeInTheDocument()); + const angle1El =content.getByRole("textbox",{name: "specification[station_configuration][SAPs][0][digital_pointing][angle1]"}); + const angle1E2 =content.getByRole("textbox",{name: "specification[station_configuration][SAPs][0][digital_pointing][angle1]"}); + + expect(angle1El.value).toBe('03h06m00s'); + //const angle1E2 = content.getByLabelText("specification[station_configuration][SAPs][0][digital_pointing][angle2]"); + expect(angle1E2.value).toBe('89d59m00s'); + }); \ No newline at end of file diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/components/PanelButtons.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/components/PanelButtons.test.js index 00b2ffe6c76cfd77e54211eea659620dd67cef37..ca361cbfacc552f8a15da1ff13525d9e50164eb3 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/components/PanelButtons.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/components/PanelButtons.test.js @@ -1,6 +1,6 @@ -import { render, waitFor } from "@testing-library/react"; +import { render, waitFor, act, fireEvent } from "@testing-library/react"; import PanelButtons from "./PanelButtons"; -import { clickItem, removeReact18ConsoleErrors } from "../../../utils/test.helper"; +import { removeReact18ConsoleErrors } from "../../../utils/test.helper"; removeReact18ConsoleErrors() @@ -11,60 +11,63 @@ describe('PanelButtons', () => { it('toggles visibilities legend+list', () => { const setShowLegendbarMock = jest.fn(); const setShowListTabsMock = jest.fn(); - const { getByTestId } = render(<PanelButtons - showLegendbar={false} - setShowLegendbar={setShowLegendbarMock} - showListTabs={true} - setShowListTabs={setShowListTabsMock} - showSummary={true} - leftPanelSize={20} - setLeftPanelSize={jest.fn()} />); - - clickItem(getByTestId('Show Legend-button')) - clickItem(getByTestId('Hide List-button')) + let pannelComponent = null; + act(() => { + pannelComponent = render(<PanelButtons + showLegendbar={false} + setShowLegendbar={setShowLegendbarMock} + showListTabs={true} + setShowListTabs={setShowListTabsMock} + showSummary={true} + leftPanelSize={20} + setLeftPanelSize={jest.fn()} />); + }); + fireEvent.click(pannelComponent.getByTestId('Show Legend-button')); + fireEvent.click(pannelComponent.getByTestId('Hide List-button')); expect(setShowLegendbarMock).toHaveBeenCalledWith(true); expect(setShowListTabsMock).toHaveBeenCalledWith(false); }); - it('adjusts left panel size when summary is not active', async () => { + it('adjusts left panel size when summary is not active', async () => { let setLeftPanelSizeMock = jest.fn(); - const pannelComponent = render(<PanelButtons - showLegendbar={false} - setShowLegendbar={jest.fn()} - showListTabs={true} - setShowListTabs={jest.fn()} - showSummary={false} - leftPanelSize={20} - setLeftPanelSize={setLeftPanelSizeMock} />); - - await waitFor(() => expect(pannelComponent.getByTitle(shrinkLabel).tobeinTheDocument)); + let pannelComponent = null; + act(() => { + pannelComponent = render(<PanelButtons + showLegendbar={false} + setShowLegendbar={jest.fn()} + showListTabs={true} + setShowListTabs={jest.fn()} + showSummary={false} + leftPanelSize={20} + setLeftPanelSize={setLeftPanelSizeMock} />); + }); + await waitFor(() => expect(pannelComponent.getByTitle(shrinkLabel).tobeinTheDocument)); const shrinkButton = pannelComponent.getByTitle(shrinkLabel); - clickItem(shrinkButton) + fireEvent.click(shrinkButton) expect(setLeftPanelSizeMock).toHaveBeenCalledWith(10); // 10% shrink const expandButton = pannelComponent.getByTitle(expandLabel); - clickItem(expandButton) + fireEvent.click(expandButton) expect(setLeftPanelSizeMock).toHaveBeenCalledWith(30); // 10% expand - setLeftPanelSizeMock=null; + setLeftPanelSizeMock = null; }); - // this test can fail, allthough it's good. SOmething with Jest and React 18 running compatibility mode it('disables resize buttons when summary is active', async () => { - - - - let pannelComponentb = render(<PanelButtons - showLegendbar={false} - setShowLegendbar={jest.fn()} - showListTabs={true} - setShowListTabs={jest.fn()} - showSummary={true} - leftPanelSize={20} - setLeftPanelSize={ jest.fn()} />); + let pannelComponentb = null; + act(() => { + pannelComponentb = render(<PanelButtons + showLegendbar={false} + setShowLegendbar={jest.fn()} + showListTabs={true} + setShowListTabs={jest.fn()} + showSummary={true} + leftPanelSize={20} + setLeftPanelSize={jest.fn()} />); + }); await waitFor(() => expect(pannelComponentb.getByTitle(shrinkLabel).tobeinTheDocument));