From 91675ffb3014ea59d7634600c0d9383b5875899c Mon Sep 17 00:00:00 2001 From: ngqile Date: Tue, 1 Dec 2026 19:53:22 +0800 Subject: [PATCH] fix: no empty row in the company dropdowns Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM --- .../app/companyScope.forms.test.tsx | 15 +++++++++++++++ .../app/components/events/EventForm.tsx | 7 ++----- .../app/components/users/UserForm.tsx | 5 +---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/solvway-admin-portal/app/companyScope.forms.test.tsx b/solvway-admin-portal/app/companyScope.forms.test.tsx index a17926c..7efb4aa 100644 --- a/solvway-admin-portal/app/companyScope.forms.test.tsx +++ b/solvway-admin-portal/app/companyScope.forms.test.tsx @@ -107,6 +107,13 @@ describe("UserForm company", () => { await user.click(screen.getByRole("button", { name: /create|save/i })); expect(await screen.findByText("Choose a company.")).toBeInTheDocument(); }); + it("lists only the company codes and Super admin in the Company menu, with no blank option", async () => { + mocks.useCompanyScope.mockReturnValue(scope(undefined)); + const user = userEvent.setup(); + render(); + await user.click(await screen.findByRole("combobox", { name: "Company" })); + expect((await screen.findAllByRole("option")).map((o) => o.textContent)).toEqual(["INS", "CV", "Super admin (no company)"]); + }); }); describe("EventForm company", () => { @@ -163,4 +170,12 @@ describe("EventForm company required", () => { expect(onSubmit).not.toHaveBeenCalled(); expect(await screen.findByText("Choose a company.")).toBeInTheDocument(); }); + + it("lists only the company codes in the Company menu, with no blank option", async () => { + mocks.useCompanyScope.mockReturnValue(scope(undefined)); + const user = userEvent.setup(); + render(); + await user.click(await screen.findByRole("combobox", { name: "Company" })); + expect((await screen.findAllByRole("option")).map((o) => o.textContent)).toEqual(["INS", "CV"]); + }); }); diff --git a/solvway-admin-portal/app/components/events/EventForm.tsx b/solvway-admin-portal/app/components/events/EventForm.tsx index b6118a3..52cd5f6 100644 --- a/solvway-admin-portal/app/components/events/EventForm.tsx +++ b/solvway-admin-portal/app/components/events/EventForm.tsx @@ -16,8 +16,6 @@ import { useT } from "@/app/lib/i18n/MessagesProvider"; import type { AdminEvent, AdminEventPayload, SalespersonOption } from "@/app/lib/types"; import type { ApiError } from "@/app/lib/clientApi"; -// Radix Select rejects "" as an item value, so "no company" is this sentinel, mapped back to "". -const NONE = "none"; interface SalespersonOptionExtended extends SalespersonOption { active: boolean; @@ -184,9 +182,9 @@ export function EventForm({ initial, onSubmit, submitLabel }: EventFormProps) {
setCompany(v === NONE ? "" : v)} disabled={saving}> +