Skip to content

Commit 721189f

Browse files
matt2eclaude
andcommitted
test(composer): label control-character cases by code point
Addresses the review of 666d1c6e. The rightArrowCharacters table in EditableInput.test.tsx held the bare characters U+001D and U+F703, so the "never runs a typed conversion" case interpolated a glyphless character with %s and the two generated names read identically, the failing run reporting "never runs a typed conversion for the control character " with nothing after it. The "either form" loop above it and the MessageComposer caret-key case passed the raw character as the expect message, so a failure there could not say which form broke either. rightArrowCharacters is now a labelled-tuple table in the shape of controlKeys, "Right Arrow's layout translation U+001D" and "Right Arrow's function-key character U+F703", and both consumers destructure it: the it.each case name becomes "never runs a typed conversion for %s committed as text" and the loop passes the label as each assertion's message, including the waitFor expectation that had none. The MessageComposer loop iterates the same labelled pairs and names the form on the prevented check and on the three assertions after it. The browser spec already stringified its message and is unchanged. No assertion, input or expected value changes. Both composer suites pass (2 files, 264 tests), the four relabelled cases reporting distinct names; tsc --noEmit is clean; biome check --error-on-warnings passes, reporting only its pre-existing note that biome.json names schema 2.5.12 while 2.5.14 is installed. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Matt Toohey <[email protected]>
1 parent 06b1a54 commit 721189f

2 files changed

Lines changed: 27 additions & 16 deletions

File tree

‎src/features/messages/EditableInput.test.tsx‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,8 +1238,13 @@ const controlKeys = [
12381238
["Page Up's function-key character U+F72C", "\uF72C"],
12391239
["Page Down's function-key character U+F72D", "\uF72D"],
12401240
] as const;
1241-
/** Right Arrow committed as text in both forms the host can produce. */
1242-
const rightArrowCharacters = ["\u001D", "\uF703"] as const;
1241+
/** Right Arrow committed as text in both forms the host can produce. Each
1242+
* carries a label because neither character has a glyph: interpolated raw
1243+
* into a case name or an assertion message they read identically. */
1244+
const rightArrowCharacters = [
1245+
["Right Arrow's layout translation U+001D", "\u001D"],
1246+
["Right Arrow's function-key character U+F703", "\uF703"],
1247+
] as const;
12431248
const caretKeys = [
12441249
"ArrowRight",
12451250
"ArrowLeft",
@@ -1391,13 +1396,15 @@ it.each([
13911396
expect(snapshot(h), key).toEqual(before);
13921397
expect(h.input.selectionStart, key).toBe(h.input.selectionEnd);
13931398
}
1394-
for (const character of rightArrowCharacters) {
1399+
for (const [label, character] of rightArrowCharacters) {
13951400
act(() => h.input.setSelectionRange(start, start));
1396-
expect(nativeInsert(h.input, character), character).toBe(false);
1397-
expect(snapshot(h), character).toEqual(before);
1398-
expect(nativeInsert(h.input, character, false), character).toBe(true);
1399-
await waitFor(() => expect(h.input.textContent).not.toContain(character));
1400-
expect(snapshot(h), character).toEqual(before);
1401+
expect(nativeInsert(h.input, character), label).toBe(false);
1402+
expect(snapshot(h), label).toEqual(before);
1403+
expect(nativeInsert(h.input, character, false), label).toBe(true);
1404+
await waitFor(() =>
1405+
expect(h.input.textContent, label).not.toContain(character),
1406+
);
1407+
expect(snapshot(h), label).toEqual(before);
14011408
}
14021409
expect(h.input).toHaveValue(value);
14031410
expect(h.draft().recipients.map((item) => item.name)).toEqual(
@@ -1407,8 +1414,8 @@ it.each([
14071414
);
14081415

14091416
it.each(rightArrowCharacters)(
1410-
"never runs a typed conversion for the control character %s",
1411-
async (character) => {
1417+
"never runs a typed conversion for %s committed as text",
1418+
async (_label, character) => {
14121419
const h = mount();
14131420
await h.user.keyboard("**a*");
14141421
const before = snapshot(h);

‎src/features/messages/MessageComposer.test.tsx‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -804,8 +804,12 @@ it("keeps a composed message unchanged through caret keys at its end and refuses
804804
expect(h.input().innerHTML).toBe(html);
805805
expect(h.messages.send).not.toHaveBeenCalled();
806806
// The desktop build committed Right Arrow's raw keyboard-layout translation
807-
// U+001D; AppKit's function-key character for the key is U+F703.
808-
for (const character of ["\u001D", "\uF703"]) {
807+
// U+001D; AppKit's function-key character for the key is U+F703. Neither
808+
// has a glyph, so each assertion names its form rather than the character.
809+
for (const [label, character] of [
810+
["Right Arrow's layout translation U+001D", "\u001D"],
811+
["Right Arrow's function-key character U+F703", "\uF703"],
812+
] as const) {
809813
let prevented = false;
810814
act(() => {
811815
h.input().focus();
@@ -818,10 +822,10 @@ it("keeps a composed message unchanged through caret keys at its end and refuses
818822
}),
819823
);
820824
});
821-
expect(prevented, character).toBe(true);
822-
expect(h.input()).toHaveValue("Hello!\nacascac\naa a\nacacs\n");
823-
expect(h.input().innerHTML).toBe(html);
824-
expect(h.messages.send).not.toHaveBeenCalled();
825+
expect(prevented, label).toBe(true);
826+
expect(h.input(), label).toHaveValue("Hello!\nacascac\naa a\nacacs\n");
827+
expect(h.input().innerHTML, label).toBe(html);
828+
expect(h.messages.send, label).not.toHaveBeenCalled();
825829
}
826830
});
827831

0 commit comments

Comments
 (0)