From ea5ddc0ed58dcf9c2f452c32fef460758eb07c05 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Mon, 27 Nov 2023 16:29:43 -0300 Subject: [PATCH] fix(components): fix dropdown component id attribute to include index for uniqueness fix(components): fix dict component id attribute to include index for uniqueness fix(components): fix code area component id attribute to include id for uniqueness fix(modals): fix edit node modal dict component id attribute to include id for uniqueness fix(modals): fix dict area modal save button data-testid attribute for testing fix(pages): fix node toolbar component class name for more options button fix(types): add id property to dropdown component type fix(types): add id property to dict component type feat(tests): add end-to-end test for dropdown component feat(tests): add end-to-end test for dict component feat(tests): add end-to-end test for node toolbar component feat(tests): add end-to-end test for nested component feat(tests): add input component test feat(tests): add toggle component test --- .../components/parameterComponent/index.tsx | 2 + .../components/codeAreaComponent/index.tsx | 1 + .../src/components/dictComponent/index.tsx | 4 +- .../components/dropdownComponent/index.tsx | 8 +- .../src/modals/EditNodeModal/index.tsx | 6 +- .../src/modals/dictAreaModal/index.tsx | 1 + .../components/nodeToolbarComponent/index.tsx | 5 +- src/frontend/src/types/components/index.ts | 2 + .../end-to-end/dropdownComponent.spec.ts | 104 ++++++++ .../tests/end-to-end/nestedComponent.spec.ts | 239 ++++++++++++++++++ .../tests/onlyFront/inputComponent.spec.ts | 8 +- .../tests/onlyFront/toggleComponent.spec.ts | 14 +- 12 files changed, 376 insertions(+), 18 deletions(-) create mode 100644 src/frontend/tests/end-to-end/dropdownComponent.spec.ts create mode 100644 src/frontend/tests/end-to-end/nestedComponent.spec.ts diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index adbdc15fe..ed4c11722 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -422,6 +422,7 @@ export default function ParameterComponent({ options={data.node.template[name].options} onSelect={handleOnNewValue} value={data.node.template[name].value ?? "Choose an option"} + id={"dropdown-" + index} /> {data.node?.template[name].refresh && ( @@ -513,6 +514,7 @@ export default function ParameterComponent({ data.node!.template[name].value = newValue; handleOnNewValue(newValue); }} + id="div-dict-input" /> ) : left === true && type === "dict" ? ( diff --git a/src/frontend/src/components/codeAreaComponent/index.tsx b/src/frontend/src/components/codeAreaComponent/index.tsx index 8c459f64b..98683f071 100644 --- a/src/frontend/src/components/codeAreaComponent/index.tsx +++ b/src/frontend/src/components/codeAreaComponent/index.tsx @@ -45,6 +45,7 @@ export default function CodeAreaComponent({
{ if (disabled) { @@ -30,7 +31,7 @@ export default function DictComponent({ )} > { -
+
{ @@ -45,6 +46,7 @@ export default function DictComponent({ : "input-disable pointer-events-none cursor-pointer" } placeholder="Click to edit your dictionary..." + data-testid="dict-input" />
diff --git a/src/frontend/src/components/dropdownComponent/index.tsx b/src/frontend/src/components/dropdownComponent/index.tsx index d6fcec772..abcbfb6d8 100644 --- a/src/frontend/src/components/dropdownComponent/index.tsx +++ b/src/frontend/src/components/dropdownComponent/index.tsx @@ -11,6 +11,7 @@ export default function Dropdown({ editNode = false, numberOfOptions = 0, apiModal = false, + id = "", }: DropDownComponentType): JSX.Element { let [internalValue, setInternalValue] = useState( value === "" || !value ? "Choose an option" : value @@ -33,13 +34,17 @@ export default function Dropdown({ <>
- + {internalValue} @@ -86,6 +91,7 @@ export default function Dropdown({ selected ? "font-semibold" : "font-normal", "block truncate " )} + data-testid={`${option}-${id ?? ""}-option`} > {option} diff --git a/src/frontend/src/modals/EditNodeModal/index.tsx b/src/frontend/src/modals/EditNodeModal/index.tsx index 908c013a5..d2bfb960e 100644 --- a/src/frontend/src/modals/EditNodeModal/index.tsx +++ b/src/frontend/src/modals/EditNodeModal/index.tsx @@ -248,9 +248,9 @@ const EditNodeModal = forwardRef( disabled={disabled} editNode={true} value={ - myData.current.node!.template[ + myData?.current?.node!.template[ templateParam - ].value.toString() === "{}" + ]?.value?.toString() === "{}" ? { yourkey: "value", } @@ -264,6 +264,7 @@ const EditNodeModal = forwardRef( ].value = newValue; handleOnNewValue(newValue, templateParam); }} + id="editnode-div-dict-input" />
) : myData.current.node?.template[templateParam] @@ -371,6 +372,7 @@ const EditNodeModal = forwardRef( templateParam ].value ?? "Choose an option" } + id={"dropdown-edit-" + index} >
) : myData.current.node?.template[templateParam] diff --git a/src/frontend/src/modals/dictAreaModal/index.tsx b/src/frontend/src/modals/dictAreaModal/index.tsx index 9cc525b48..8a59344fe 100644 --- a/src/frontend/src/modals/dictAreaModal/index.tsx +++ b/src/frontend/src/modals/dictAreaModal/index.tsx @@ -54,6 +54,7 @@ export default function DictAreaModal({ />