From 034f72183761cf12cbe13ad6f32bdd5b3dc308ce Mon Sep 17 00:00:00 2001 From: mcmcphillips Date: Wed, 11 Dec 2024 14:10:28 -0800 Subject: [PATCH] MAT-7792: add coverage --- .../functionBuilder/FunctionBuilder.test.tsx | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/CqlBuilderPanel/functionsSection/functionBuilder/FunctionBuilder.test.tsx b/src/CqlBuilderPanel/functionsSection/functionBuilder/FunctionBuilder.test.tsx index f90328c..b9e2a2e 100644 --- a/src/CqlBuilderPanel/functionsSection/functionBuilder/FunctionBuilder.test.tsx +++ b/src/CqlBuilderPanel/functionsSection/functionBuilder/FunctionBuilder.test.tsx @@ -519,6 +519,7 @@ describe("CQL Function Builder Tests", () => { }); expect(argumentNameInput.value).toBe("Test"); + // dataType const dataTypeDropdown = await screen.findByTestId( "arg-type-selector-input" ); @@ -526,20 +527,37 @@ describe("CQL Function Builder Tests", () => { target: { value: "Other" }, }); - // we now need to populate other textfield const otherNameInput = (await screen.findByTestId( "other-type-input" )) as HTMLInputElement; expect(otherNameInput).toBeInTheDocument(); - expect(otherNameInput.value).toBe(""); - fireEvent.change(otherNameInput, { + + // switch to blank other + fireEvent.change(dataTypeDropdown, { + target: { value: "Integer" }, + }); + await waitFor(() => { + expect(screen.queryByTestId("other-type-input")).not.toBeInTheDocument(); + }); + + // select other again + fireEvent.change(dataTypeDropdown, { target: { value: "Other" }, }); - expect(otherNameInput.value).toBe("Other"); + // other input appears + await waitFor(() => { + expect(screen.queryByTestId("other-type-input")).toBeInTheDocument(); + }); + // finda nd fill out other + const other = (await screen.findByTestId( + "other-type-input" + )) as HTMLInputElement; + fireEvent.change(other, { + target: { value: "test" }, + }); await waitFor(() => { const addButton = screen.getByTestId("function-argument-add-btn"); - expect(addButton).toBeInTheDocument(); expect(addButton).toBeEnabled(); fireEvent.click(addButton); }); @@ -563,7 +581,7 @@ describe("CQL Function Builder Tests", () => { functionsArguments: [ expect.objectContaining({ argumentName: "Test", - dataType: "Other", + dataType: "test", }), ], })