Skip to content

Commit 31e08d6

Browse files
committed
test(console): pin the refusal marks against the widgets' aria-invalid=false default
Claude-Session: https://claude.ai/code/session_01JQwxbX1Zhx8ST6DDF1AGvD Co-authored-by: Claude <noreply@anthropic.com>
1 parent f936b92 commit 31e08d6

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

‎ui/apps/console/src/components/FormPage.refusalMarks-27417.test.tsx‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ describe('#27417 — a server refusal naming fields marks each of them', () => {
178178
expect(describedText(name)).toContain('Name must be at most 3 characters');
179179
expect(describedText(email)).toContain('Email is not a valid email address');
180180
// The row the refusal does not name stays unmarked.
181-
expect(screen.getByLabelText('Company')).not.toHaveAttribute('aria-invalid');
181+
expect(screen.getByLabelText('Company')).not.toHaveAttribute('aria-invalid', 'true');
182182
// The banner and the toast are unchanged.
183183
expect(vi.mocked(toast.error)).toHaveBeenCalledTimes(1);
184184
expect(String(vi.mocked(toast.error).mock.calls[0][0])).toContain('Submit failed (400)');
@@ -202,7 +202,7 @@ describe('#27417 — a server refusal naming fields marks each of them', () => {
202202
const name = screen.getByLabelText('Name');
203203
await waitFor(() => expect(name).toHaveAttribute('aria-invalid', 'true'));
204204
expect(screen.getByLabelText('Email')).toHaveAttribute('aria-invalid', 'true');
205-
expect(screen.getByLabelText('Company')).not.toHaveAttribute('aria-invalid');
205+
expect(screen.getByLabelText('Company')).not.toHaveAttribute('aria-invalid', 'true');
206206
expect(describedText(name)).toContain('Name must be at most 3 characters');
207207
});
208208

@@ -221,7 +221,7 @@ describe('#27417 — a server refusal naming fields marks each of them', () => {
221221
const email = screen.getByLabelText('Email');
222222
await waitFor(() => expect(email).toHaveAttribute('aria-invalid', 'true'));
223223
expect(describedText(email)).toContain('An inquiry with this email already exists.');
224-
expect(screen.getByLabelText('Name')).not.toHaveAttribute('aria-invalid');
224+
expect(screen.getByLabelText('Name')).not.toHaveAttribute('aria-invalid', 'true');
225225
});
226226

227227
it('an edit to a marked row clears its mark and leaves the others', async () => {
@@ -234,7 +234,7 @@ describe('#27417 — a server refusal naming fields marks each of them', () => {
234234
await waitFor(() => expect(name).toHaveAttribute('aria-invalid', 'true'));
235235

236236
await userEvent.type(name, '!');
237-
expect(name).not.toHaveAttribute('aria-invalid');
237+
expect(name).not.toHaveAttribute('aria-invalid', 'true');
238238
expect(screen.queryByText('Name must be at most 3 characters')).toBeNull();
239239
expect(screen.getByLabelText('Email')).toHaveAttribute('aria-invalid', 'true');
240240
});
@@ -250,9 +250,10 @@ describe('#27417 — a refusal naming no field marks none', () => {
250250

251251
expect(await screen.findByText(/Invalid inquiry status transition\./)).toBeInTheDocument();
252252
for (const label of ['Name', 'Email', 'Company']) {
253-
expect(screen.getByLabelText(label)).not.toHaveAttribute('aria-invalid');
254-
expect(screen.getByLabelText(label)).not.toHaveAttribute('aria-describedby');
253+
expect(screen.getByLabelText(label)).not.toHaveAttribute('aria-invalid', 'true');
255254
}
255+
// No row was given a reason to point at.
256+
expect(document.querySelectorAll('[id$="-error"]')).toHaveLength(0);
256257
});
257258

258259
it('a field the form does not draw marks nothing', async () => {
@@ -267,8 +268,8 @@ describe('#27417 — a refusal naming no field marks none', () => {
267268
await fillAndSubmit({ Name: 'Ada', Email: 'ada@example.com' });
268269

269270
await waitFor(() => expect(vi.mocked(toast.error)).toHaveBeenCalledTimes(1));
270-
expect(screen.getByLabelText('Name')).not.toHaveAttribute('aria-invalid');
271-
expect(screen.getByLabelText('Email')).not.toHaveAttribute('aria-invalid');
271+
expect(screen.getByLabelText('Name')).not.toHaveAttribute('aria-invalid', 'true');
272+
expect(screen.getByLabelText('Email')).not.toHaveAttribute('aria-invalid', 'true');
272273
expect(screen.queryByText('Company is required')).toBeNull();
273274
});
274275
});
@@ -289,7 +290,7 @@ describe('#27417 — the client required refusal marks the missing fields', () =
289290
expect(email).toHaveAttribute('aria-invalid', 'true');
290291
expect(describedText(name)).toBe('Name is required');
291292
expect(describedText(email)).toBe('Email is required');
292-
expect(screen.getByLabelText('Company')).not.toHaveAttribute('aria-invalid');
293+
expect(screen.getByLabelText('Company')).not.toHaveAttribute('aria-invalid', 'true');
293294
});
294295
});
295296

@@ -308,7 +309,7 @@ describe('#27417 — a faulted visibleWhen marks its row and points it at the ba
308309
const company = screen.getByLabelText('Company');
309310
expect(company).toHaveAttribute('aria-invalid', 'true');
310311
expect(company.getAttribute('aria-describedby')).toBe(banner.id);
311-
expect(screen.getByLabelText('Name')).not.toHaveAttribute('aria-invalid');
312+
expect(screen.getByLabelText('Name')).not.toHaveAttribute('aria-invalid', 'true');
312313
warn.mockRestore();
313314
});
314315
});

0 commit comments

Comments
 (0)