Skip to content

Commit 0300efa

Browse files
Sign in the heading form test so the signed-out captcha does not block its submit (#154)
1 parent 3f487e6 commit 0300efa

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎apphelper/src/forms/components/__tests__/formHeadingsMarkdown.test.tsx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ const { get, post } = vi.hoisted(() => ({
1313

1414
vi.mock("@churchapps/helpers", async (importOriginal) => {
1515
const actual: any = await importOriginal();
16-
return { ...actual, ApiHelper: { ...actual.ApiHelper, get, post } };
16+
// Signed in, so the signed-out captcha does not block the submit.
17+
const ApiHelper = { ...actual.ApiHelper, get, post };
18+
Object.defineProperty(ApiHelper, "isAuthenticated", { get: () => true });
19+
return { ...actual, ApiHelper };
1720
});
1821

1922
import { QuestionEdit } from "../QuestionEdit";
@@ -53,8 +56,8 @@ describe("Heading questions", () => {
5356
});
5457
expect(container.textContent).toContain("About you");
5558

56-
const buttons = Array.from(container.querySelectorAll("button"));
57-
await act(async () => { buttons[buttons.length - 1].click(); });
59+
const submit = Array.from(container.querySelectorAll("button")).find((b) => b.textContent === "Submit")!;
60+
await act(async () => { submit.click(); });
5861

5962
expect(post).toHaveBeenCalledTimes(1);
6063
const submission = post.mock.calls[0][1][0];

0 commit comments

Comments
 (0)