fix: show org create/update error without added quotes (#15323)

This commit is contained in:
Akshit Sharma
2026-10-23 06:22:21 +00:00
committed by GitHub
parent 9f0251bcc4
commit 2ca68021d2
2 changed files with 21 additions and 6 deletions
@@ -229,6 +229,23 @@ describe("AddUpdateOrganization", () => {
expect(toast).toHaveBeenCalledWith(expect.objectContaining({ variant: "error" }));
});
it("shows the server message verbatim without added quotes", async () => {
vi.spyOn(orgService, "create").mockRejectedValueOnce({
response: { data: { message: "Organization creation failed." } },
});
const wrapper = mountComp();
await getNameInput(wrapper).setValue("Err Org");
await submitForm(wrapper);
expect(toast).toHaveBeenCalledWith(
expect.objectContaining({
variant: "error",
message: "Organization creation failed.",
}),
);
});
it("renames the organization in update mode", async () => {
const wrapper = mountComp({ modelValue: { id: "123", name: "Acme" } });
await getNameInput(wrapper).setValue("Acme Renamed");
@@ -225,12 +225,10 @@ export default defineComponent({
toast({
variant: "error",
message: raw(
JSON.stringify(
err?.response?.data["message"] ||
(organizationId
? this.t("iam.addUpdateOrganization.updateFailed")
: this.t("iam.addUpdateOrganization.createFailed")),
),
err?.response?.data["message"] ||
(organizationId
? this.t("iam.addUpdateOrganization.updateFailed")
: this.t("iam.addUpdateOrganization.createFailed")),
),
});
}