From a2bd14eefe4713420502dab6b42be605d1025d41 Mon Sep 17 00:00:00 2001 From: Alex Wagner Date: Fri, 28 Aug 2026 11:49:36 +0200 Subject: [PATCH] fix gen5 pairing test pinning a stale present() signature The test read AccessorySetup.swift as source text and asserted the exact lines `present(items, allowGen4Retry: true)` and `self.present([items[0]], allowGen4Retry: false)`. Both calls gained a `known:` parameter when present() started forwarding the pre-picker accessory list, so the full-line match no longer held and the test failed deterministically on main. Only the first was ever reported, since it aborts the test body before the second runs. Match by shape instead: the invariant is that the widened list is presented WITH the Gen 4 retry armed and the single-item retry targets items[0] with the retry disarmed, whatever else rides along in between. Verified the regexes still fail on a disarmed widened list, a retry target that is not items[0], and a retry that re-arms itself. Every other pinned literal in the file was re-checked against its source and still holds. --- test/gen5_pairing_filter_test.dart | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/gen5_pairing_filter_test.dart b/test/gen5_pairing_filter_test.dart index 75436d9d..a1d41f2f 100644 --- a/test/gen5_pairing_filter_test.dart +++ b/test/gen5_pairing_filter_test.dart @@ -170,8 +170,22 @@ void main() { // must be items[0] — the WHOOP 4.0 (gen4) descriptor built first in // `items`, so a rejection of the widened list falls back to exactly // what already ships. - expect(swift, contains('present(items, allowGen4Retry: true)')); - expect(swift, contains('self.present([items[0]], allowGen4Retry: false)')); + // Matched by shape, not by full line: `present` has picked up extra + // parameters before (`known:`) and a pinned literal silently drifts out + // of lockstep with the source it is supposed to guard. What matters is + // the argument the retry hinges on, whatever else rides along. + expect( + swift, + matches(RegExp(r'present\(\s*items\s*,[^)]*allowGen4Retry:\s*true')), + reason: 'the widened list must be presented WITH the Gen 4 retry armed', + ); + expect( + swift, + matches( + RegExp(r'present\(\s*\[items\[0\]\]\s*,[^)]*allowGen4Retry:\s*false')), + reason: 'the single-item retry must be items[0] and must NOT retry ' + 'again, or a rejected list loops', + ); // items[0] must be the FIRST registry-driven item (gen4 — kBandRegistry // lists it before gen5, see _registry.dart), not the appended gen5-only // fallback items (member UUID / name substring).