diff --git a/frontend/__tests__/components/ui/form/LabeledField.spec.tsx b/frontend/__tests__/components/ui/form/LabeledField.spec.tsx new file mode 100644 index 000000000000..ccaa134351da --- /dev/null +++ b/frontend/__tests__/components/ui/form/LabeledField.spec.tsx @@ -0,0 +1,57 @@ +import { render, screen } from "@solidjs/testing-library"; +import { describe, it, expect } from "vitest"; + +import { LabeledField } from "../../../../src/ts/components/ui/form/LabeledField"; + +describe("LabeledField", () => { + it("renders label text correctly", () => { + render(() => ( + + + + )); + + expect(screen.getByText("test label")).toBeInTheDocument(); + }); + + it("renders children correctly", () => { + render(() => ( + +
child content
+
+ )); + + expect(screen.getByTestId("child")).toBeInTheDocument(); + }); + + it("renders subtext when provided", () => { + render(() => ( + + + + )); + + expect(screen.getByText("helper text")).toBeInTheDocument(); + }); + + it("links label to input when id is provided", () => { + const { container } = render(() => ( + + + + )); + + const label = container.querySelector("label"); + expect(label).toHaveAttribute("for", "test-id"); + }); + + it("applies custom class to wrapper", () => { + const { container } = render(() => ( + + + + )); + + expect(container.firstChild).toHaveClass("custom-wrapper-class"); + }); +}); diff --git a/frontend/src/ts/components/modals/CustomGeneratorModal.tsx b/frontend/src/ts/components/modals/CustomGeneratorModal.tsx index e743fb83dc00..0c5b83362820 100644 --- a/frontend/src/ts/components/modals/CustomGeneratorModal.tsx +++ b/frontend/src/ts/components/modals/CustomGeneratorModal.tsx @@ -7,6 +7,7 @@ import { AnimatedModal } from "../common/AnimatedModal"; import { Button } from "../common/Button"; import { Separator } from "../common/Separator"; import { InputField } from "../ui/form/InputField"; +import { LabeledField } from "../ui/form/LabeledField"; import { SubmitButton } from "../ui/form/SubmitButton"; import { TextareaField } from "../ui/form/TextareaField"; import SlimSelect from "../ui/SlimSelect"; @@ -159,9 +160,8 @@ export function CustomGeneratorModal(props: { }} class="grid gap-4" > -
-
presets
-
+ +
-
+
Enter characters or strings separated by spaces. Random combinations will be generated using these inputs.
-
-
character set
+ )} -
+
-
-
min length
+ {(field) => } -
-
-
max length
+ + {(field) => } -
+
-
-
word count
+ {(field) => } -
+
{ '"Set" replaces the current custom text with generated words, "Add" appends generated words to the current custom text.' diff --git a/frontend/src/ts/components/modals/QuoteReportModal.tsx b/frontend/src/ts/components/modals/QuoteReportModal.tsx index 0de7c72fae9f..e52ea8a1a8c4 100644 --- a/frontend/src/ts/components/modals/QuoteReportModal.tsx +++ b/frontend/src/ts/components/modals/QuoteReportModal.tsx @@ -19,6 +19,7 @@ import { removeLanguageSize } from "../../utils/strings"; import { AnimatedModal } from "../common/AnimatedModal"; import { Button } from "../common/Button"; import { Separator } from "../common/Separator"; +import { LabeledField } from "../ui/form/LabeledField"; import { fieldMandatory } from "../ui/form/utils"; import SlimSelect from "../ui/SlimSelect"; @@ -133,17 +134,15 @@ export function QuoteReportModal(): JSXElement {
Please add comments in English only. -
- +
{quoteText()}
-
+ ( -
- + -
+ )} /> () }} children={(field) => ( -
- +