Give builder fields persistent labels, treat description as optional, and validate save-progress email with a real form.
Name stays required; description is a labelled optional textarea. Email uses native validity and form submit. Drop the dead workshop link and fix a few copy errors. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import { describe, it, expect } from "vitest";
|
||||
import { renderWithProviders as render, screen } from "../utils/test-utils";
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { CreateFlowTextFieldScreen } from "../../app/(app)/create/screens/text/CreateFlowTextFieldScreen";
|
||||
import { CREATE_FLOW_COMMUNITY_SAVE_FORM_ID } from "../../app/(app)/create/utils/createFlowPaths";
|
||||
|
||||
describe("CreateFlowTextFieldScreen (community name)", () => {
|
||||
it("renders main heading", () => {
|
||||
@@ -10,6 +11,7 @@ describe("CreateFlowTextFieldScreen (community name)", () => {
|
||||
messageNamespace="create.community.communityName"
|
||||
stateField="title"
|
||||
maxLength={48}
|
||||
required
|
||||
/>,
|
||||
);
|
||||
expect(
|
||||
@@ -19,19 +21,63 @@ describe("CreateFlowTextFieldScreen (community name)", () => {
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders description and text field", () => {
|
||||
it("renders description and a labelled text field", () => {
|
||||
render(
|
||||
<CreateFlowTextFieldScreen
|
||||
messageNamespace="create.community.communityName"
|
||||
stateField="title"
|
||||
maxLength={48}
|
||||
required
|
||||
/>,
|
||||
);
|
||||
expect(
|
||||
screen.getByText("This will be the name of your community"),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByPlaceholderText("Enter community name"),
|
||||
screen.getByText("This will be the name of your community."),
|
||||
).toBeInTheDocument();
|
||||
const input = screen.getByRole("textbox", { name: "Community name" });
|
||||
expect(input).toBeInTheDocument();
|
||||
expect(input).toHaveAttribute("placeholder", "Enter community name");
|
||||
expect(input).toBeRequired();
|
||||
});
|
||||
});
|
||||
|
||||
describe("CreateFlowTextFieldScreen (community description)", () => {
|
||||
it("uses a textarea and treats the field as optional", () => {
|
||||
render(
|
||||
<CreateFlowTextFieldScreen
|
||||
messageNamespace="create.community.communityContext"
|
||||
stateField="communityContext"
|
||||
maxLength={200}
|
||||
multiline
|
||||
/>,
|
||||
);
|
||||
expect(
|
||||
screen.getByText(/Optional\. Write a short paragraph/i),
|
||||
).toBeInTheDocument();
|
||||
const field = screen.getByRole("textbox", {
|
||||
name: "Community description",
|
||||
});
|
||||
expect(field.tagName).toBe("TEXTAREA");
|
||||
expect(field).not.toBeRequired();
|
||||
});
|
||||
});
|
||||
|
||||
describe("CreateFlowTextFieldScreen (save progress email)", () => {
|
||||
it("uses a labelled email field with native email attributes", () => {
|
||||
render(
|
||||
<CreateFlowTextFieldScreen
|
||||
messageNamespace="create.community.communitySave"
|
||||
stateField="communitySaveEmail"
|
||||
maxLength={254}
|
||||
inputType="email"
|
||||
showCharacterCount={false}
|
||||
/>,
|
||||
);
|
||||
const input = screen.getByRole("textbox", { name: "Email address" });
|
||||
expect(input).toHaveAttribute("type", "email");
|
||||
expect(input).toHaveAttribute("autocomplete", "email");
|
||||
expect(input).toHaveAttribute("inputmode", "email");
|
||||
expect(input).toHaveAttribute("name", "email");
|
||||
expect(input).toHaveAttribute("form", CREATE_FLOW_COMMUNITY_SAVE_FORM_ID);
|
||||
expect(input).toBeRequired();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user