From cdceae901fb8f107bab6bba3bb24fa444ed07274 Mon Sep 17 00:00:00 2001 From: Minamoto Slava Date: Sat, 8 Aug 2026 22:04:14 +0900 Subject: [PATCH] fix(tests): stop AppKit rewriting the uppercase-key-equivalent fixture testUppercaseKeyEquivalentReportsImpliedShift built its menu item with the title "Paste and Match Style". AppKit recognises that as a standard menu item and, on NSMenu.addItem, rewrites it to the system-standard equivalent -- so the fixture's uppercase "V" + [.command, .option] became "v" + [.command, .shift] before collectKeyEquivalents ever ran, and the test asserted cmd+opt+shift+v against an actual cmd+shift+v. The rewrite keys off the title alone: the same key and mask under a custom title are untouched, and the stock title with an entirely different key is rewritten just the same. Rename the fixture item and say why, so the test exercises the implied-shift path it describes. Product code is unchanged -- chordSyntax was always correct; the fixture was being mutated out from under it. --- agtermTests/LiveMenuKeyEquivalentsTests.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/agtermTests/LiveMenuKeyEquivalentsTests.swift b/agtermTests/LiveMenuKeyEquivalentsTests.swift index 0485a01d9..68946fbc7 100644 --- a/agtermTests/LiveMenuKeyEquivalentsTests.swift +++ b/agtermTests/LiveMenuKeyEquivalentsTests.swift @@ -78,8 +78,13 @@ final class LiveMenuKeyEquivalentsTests: XCTestCase { // AppKit matches an uppercase key equivalent against the SHIFTED chord even with shift absent from // the mask, so lowercasing without adding shift would name a chord the item can never fire. + // + // The title must NOT be one AppKit recognises as a standard menu item ("Paste and Match Style" was, + // and is why this used to fail): `NSMenu.addItem` rewrites such an item to the system-standard + // equivalent, turning ⌥⌘V into ⇧⌘V before the code under test ever sees it — a fixture that + // silently stops testing what it says. The rewrite keys off the title alone, not the chord. func testUppercaseKeyEquivalentReportsImpliedShift() throws { - let file = menu("Edit", [item("Paste and Match Style", key: "V", mods: [.command, .option])]) + let file = menu("Edit", [item("Vendor Paste Special", key: "V", mods: [.command, .option])]) let found = try XCTUnwrap(ControlServer.collectKeyEquivalents(in: file, menu: "Edit").first)