Skip to content

Commit 2a1153f

Browse files
fix(tests): sync PromptForm placeholder assertions with redesigned UI
1 parent c38420b commit 2a1153f

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

__tests__/components/PromptForm.test.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ function renderWithAuth(user: object | null = { id: "user-1", email: "test@examp
5959
describe("PromptForm - rendering", () => {
6060
it("renders all form fields", () => {
6161
renderWithAuth();
62-
expect(screen.getByPlaceholderText("Give your prompt a name")).toBeInTheDocument();
63-
expect(screen.getByPlaceholderText("Paste or type your prompt here...")).toBeInTheDocument();
62+
expect(screen.getByPlaceholderText("Untitled prompt")).toBeInTheDocument();
63+
expect(screen.getByPlaceholderText("Write your prompt here...")).toBeInTheDocument();
6464
expect(screen.getByPlaceholderText("e.g. coding")).toBeInTheDocument();
6565
expect(screen.getByRole("button", { name: /save prompt/i })).toBeInTheDocument();
6666
});
@@ -75,8 +75,8 @@ describe("PromptForm - rendering", () => {
7575
describe("PromptForm - unauthenticated behavior", () => {
7676
it("redirects to /login on submit when user is not authenticated", async () => {
7777
renderWithAuth(null);
78-
await userEvent.type(screen.getByPlaceholderText("Give your prompt a name"), "Test Prompt");
79-
await userEvent.type(screen.getByPlaceholderText("Paste or type your prompt here..."), "Some content");
78+
await userEvent.type(screen.getByPlaceholderText("Untitled prompt"), "Test Prompt");
79+
await userEvent.type(screen.getByPlaceholderText("Write your prompt here..."), "Some content");
8080
await userEvent.click(screen.getByRole("button", { name: /save prompt/i }));
8181

8282
expect(mockPush).toHaveBeenCalledWith("/login");
@@ -93,8 +93,8 @@ describe("PromptForm - authenticated submission", () => {
9393

9494
it("calls addOptimistic and navigates home on valid submit", async () => {
9595
renderWithAuth();
96-
await userEvent.type(screen.getByPlaceholderText("Give your prompt a name"), "My Prompt");
97-
await userEvent.type(screen.getByPlaceholderText("Paste or type your prompt here..."), "Prompt content");
96+
await userEvent.type(screen.getByPlaceholderText("Untitled prompt"), "My Prompt");
97+
await userEvent.type(screen.getByPlaceholderText("Write your prompt here..."), "Prompt content");
9898
await userEvent.click(screen.getByRole("button", { name: /save prompt/i }));
9999

100100
expect(mockAddOptimistic).toHaveBeenCalledWith(
@@ -105,8 +105,8 @@ describe("PromptForm - authenticated submission", () => {
105105

106106
it("defaults collection to 'uncategorized' when left blank", async () => {
107107
renderWithAuth();
108-
await userEvent.type(screen.getByPlaceholderText("Give your prompt a name"), "Prompt");
109-
await userEvent.type(screen.getByPlaceholderText("Paste or type your prompt here..."), "Content");
108+
await userEvent.type(screen.getByPlaceholderText("Untitled prompt"), "Prompt");
109+
await userEvent.type(screen.getByPlaceholderText("Write your prompt here..."), "Content");
110110
await userEvent.click(screen.getByRole("button", { name: /save prompt/i }));
111111

112112
expect(mockAddOptimistic).toHaveBeenCalledWith(
@@ -116,8 +116,8 @@ describe("PromptForm - authenticated submission", () => {
116116

117117
it("uses the entered collection name when provided", async () => {
118118
renderWithAuth();
119-
await userEvent.type(screen.getByPlaceholderText("Give your prompt a name"), "Prompt");
120-
await userEvent.type(screen.getByPlaceholderText("Paste or type your prompt here..."), "Content");
119+
await userEvent.type(screen.getByPlaceholderText("Untitled prompt"), "Prompt");
120+
await userEvent.type(screen.getByPlaceholderText("Write your prompt here..."), "Content");
121121
await userEvent.type(screen.getByPlaceholderText("e.g. coding"), "engineering");
122122
await userEvent.click(screen.getByRole("button", { name: /save prompt/i }));
123123

@@ -128,8 +128,8 @@ describe("PromptForm - authenticated submission", () => {
128128

129129
it("calls savePrompt asynchronously after optimistic update", async () => {
130130
renderWithAuth();
131-
await userEvent.type(screen.getByPlaceholderText("Give your prompt a name"), "Prompt");
132-
await userEvent.type(screen.getByPlaceholderText("Paste or type your prompt here..."), "Content");
131+
await userEvent.type(screen.getByPlaceholderText("Untitled prompt"), "Prompt");
132+
await userEvent.type(screen.getByPlaceholderText("Write your prompt here..."), "Content");
133133
await userEvent.click(screen.getByRole("button", { name: /save prompt/i }));
134134

135135
await waitFor(() => {
@@ -141,8 +141,8 @@ describe("PromptForm - authenticated submission", () => {
141141

142142
it("calls refresh after savePrompt resolves", async () => {
143143
renderWithAuth();
144-
await userEvent.type(screen.getByPlaceholderText("Give your prompt a name"), "Prompt");
145-
await userEvent.type(screen.getByPlaceholderText("Paste or type your prompt here..."), "Content");
144+
await userEvent.type(screen.getByPlaceholderText("Untitled prompt"), "Prompt");
145+
await userEvent.type(screen.getByPlaceholderText("Write your prompt here..."), "Content");
146146
await userEvent.click(screen.getByRole("button", { name: /save prompt/i }));
147147

148148
await waitFor(() => expect(mockRefresh).toHaveBeenCalled());
@@ -153,17 +153,17 @@ describe("PromptForm - authenticated submission", () => {
153153
// PromptForm logs the error, silence it so Jest output stays clean
154154
jest.spyOn(console, "error").mockImplementation(() => {});
155155
renderWithAuth();
156-
await userEvent.type(screen.getByPlaceholderText("Give your prompt a name"), "Prompt");
157-
await userEvent.type(screen.getByPlaceholderText("Paste or type your prompt here..."), "Content");
156+
await userEvent.type(screen.getByPlaceholderText("Untitled prompt"), "Prompt");
157+
await userEvent.type(screen.getByPlaceholderText("Write your prompt here..."), "Content");
158158
await userEvent.click(screen.getByRole("button", { name: /save prompt/i }));
159159

160160
await waitFor(() => expect(mockRefresh).toHaveBeenCalled());
161161
});
162162

163163
it("generated prompt has a non-empty id and ISO timestamp", async () => {
164164
renderWithAuth();
165-
await userEvent.type(screen.getByPlaceholderText("Give your prompt a name"), "Prompt");
166-
await userEvent.type(screen.getByPlaceholderText("Paste or type your prompt here..."), "Content");
165+
await userEvent.type(screen.getByPlaceholderText("Untitled prompt"), "Prompt");
166+
await userEvent.type(screen.getByPlaceholderText("Write your prompt here..."), "Content");
167167
await userEvent.click(screen.getByRole("button", { name: /save prompt/i }));
168168

169169
const optimisticArg = mockAddOptimistic.mock.calls[0][0];

0 commit comments

Comments
 (0)