fix(site): scope TemplateSettingsPage validation error assertion to form (#22308)

The sonner migration (https://github.com/coder/coder/pull/22258) shows
validation errors in both the inline form field and a toast. Scoping the
assertion to the form element avoids flaky matches against the toast.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Zach
2026-02-25 13:15:03 -07:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 77006f241b
commit 4f1ddeeaad
@@ -8,7 +8,7 @@ import {
waitForLoaderToBeRemoved,
} from "testHelpers/renderHelpers";
import { server } from "testHelpers/server";
import { screen, waitFor } from "@testing-library/react";
import { screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { API, withDefaultFeatures } from "api/api";
import type { UpdateTemplateMeta } from "api/typesGenerated";
@@ -131,8 +131,11 @@ describe("TemplateSettingsPage", () => {
);
await fillAndSubmitForm(validFormValues);
await waitFor(() => expect(API.updateTemplateMeta).toBeCalledTimes(1));
const form = await screen.findByRole("form", {
name: /template settings/i,
});
expect(
await screen.findByText(
await within(form).findByText(
"This value is already in use and should be unique.",
),
).toBeInTheDocument();