Skip to content

Commit 837bdd1

Browse files
committed
fix(test-app): stop the form fixture placing its own placeholder in every fill
The `smoke:form-input` half of #1874 is not the commit deadline. This PR's own iOS lane reproduced it (run 32889322172) and the trace settles it: `wait start expectedLen=12`, then zero `[DEBUG-1874] poll` lines, then `wait outcome=notObserved elapsedMs=3608`. The wait never polled — it returned from the `textMatchesPlaceholder` guard, which refuses before polling because an empty text field renders its placeholder AS its accessibility value, so a match cannot prove a commit. `field-name`'s placeholder was "Ada Lovelace" and every checkout-form suite fills exactly "Ada Lovelace"; `field-email` had the same collision with "[email protected]". Twelve fills across eight files, so `fill` into those fields is unverifiable by contract. It looked intermittent only because the synthesized-replacement route is gated on `xCTestChannelPenalized` — it fires when the host is loaded — which is also why re-running a failed job on the same commit reproduced it identically. The collision also made the read-back assertions vacuous: `assertJsonContains( name, 'Ada Lovelace')` is satisfied by an empty field rendering the placeholder. Fixed in the fixture rather than in the values, because frozen replay-compat corpora carry the same fills and must not be edited. fixture-fill-placeholder-collision.test.ts guards the class: it fails on any repository fill whose value equals the target field's placeholder.
1 parent bf9a84f commit 837bdd1

2 files changed

Lines changed: 85 additions & 2 deletions

File tree

‎examples/test-app/src/screens/FormScreen.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export function FormScreen(props: FormScreenProps) {
108108
accessibilityLabel="Full name"
109109
label="Full name"
110110
onChangeText={(value) => props.onChange('name', value)}
111-
placeholder="Ada Lovelace"
111+
placeholder="Type your full name"
112112
testID="field-name"
113113
value={props.form.name}
114114
/>
@@ -119,7 +119,7 @@ export function FormScreen(props: FormScreenProps) {
119119
label="Email"
120120
onChangeText={(value) => props.onChange('email', value)}
121121
onSubmitEditing={() => Keyboard.dismiss()}
122-
placeholder="[email protected]"
122+
placeholder="Type your email"
123123
returnKeyType="done"
124124
testID="field-email"
125125
value={props.form.email}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import assert from 'node:assert/strict';
2+
import fs from 'node:fs';
3+
import path from 'node:path';
4+
import { fileURLToPath } from 'node:url';
5+
import { test } from 'vitest';
6+
7+
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
8+
const formScreenPath = path.join(repoRoot, 'examples/test-app/src/screens/FormScreen.tsx');
9+
10+
// #1874, `smoke:form-input` half: a `fill` whose value equals the target field's placeholder can
11+
// never be confirmed. An empty text field renders its placeholder AS its accessibility value, so
12+
// `element.value` is byte-identical whether the placeholder is showing or the committed text
13+
// happens to match it — `awaitSynthesizedReplacementCommitOutcome` refuses such a wait outright
14+
// (`textMatchesPlaceholder`), which is the documented contract, and the CLI reference says so.
15+
//
16+
// The fixture used to place `placeholder="Ada Lovelace"` on the field every suite fills with
17+
// "Ada Lovelace". That is only reachable on the synthesized-replacement route, which is gated on
18+
// `xCTestChannelPenalized` — i.e. it fires when the host is loaded — so it read as an intermittent
19+
// simulator flake for months rather than as a fixture that asks for the one thing `fill` cannot
20+
// verify. Frozen replay-compat corpora carry the same fill, so the collision has to be kept out of
21+
// the placeholders rather than out of the values.
22+
23+
type Field = { testID: string; placeholder: string };
24+
25+
/** (testID, placeholder) pairs from the fixture's form screen, in source order. */
26+
function fixtureFields(): Field[] {
27+
const source = fs.readFileSync(formScreenPath, 'utf8');
28+
const fields: Field[] = [];
29+
const blocks = source.split('<TextField').slice(1);
30+
for (const block of blocks) {
31+
const placeholder = /placeholder="([^"]*)"/.exec(block)?.[1];
32+
const testID = /testID="([^"]*)"/.exec(block)?.[1];
33+
if (placeholder !== undefined && testID !== undefined) fields.push({ testID, placeholder });
34+
}
35+
return fields;
36+
}
37+
38+
/** Every `fill` in the repository's replay scripts and live runners, as (testID, value). */
39+
function repositoryFills(): { source: string; testID: string; value: string }[] {
40+
const roots = ['examples/test-app/replays', 'test/integration', 'test/replay-compat'];
41+
const files: string[] = [];
42+
for (const root of roots) {
43+
const dir = path.join(repoRoot, root);
44+
if (!fs.existsSync(dir)) continue;
45+
for (const entry of fs.readdirSync(dir, { recursive: true, encoding: 'utf8' })) {
46+
if (/\.(ad|ts)$/.test(entry)) files.push(path.join(dir, entry));
47+
}
48+
}
49+
const fills: { source: string; testID: string; value: string }[] = [];
50+
for (const file of files) {
51+
const text = fs.readFileSync(file, 'utf8');
52+
// `fill id="field-name" "Ada Lovelace"` (.ad) and `['fill', 'id="field-name"', 'Ada Lovelace']`
53+
const patterns = [/fill\s+id="([^"]+)"\s+"([^"]*)"/g, /'fill',\s*'id="([^"]+)"',\s*'([^']*)'/g];
54+
for (const pattern of patterns) {
55+
for (const match of text.matchAll(pattern)) {
56+
fills.push({ source: path.relative(repoRoot, file), testID: match[1]!, value: match[2]! });
57+
}
58+
}
59+
}
60+
return fills;
61+
}
62+
63+
test('no fixture fill asks for a value the field renders as its own placeholder', () => {
64+
const fields = fixtureFields();
65+
assert.ok(fields.length > 0, 'the form fixture must expose placeheld text fields to check');
66+
67+
const placeholderByTestID = new Map(fields.map((field) => [field.testID, field.placeholder]));
68+
const collisions = repositoryFills()
69+
.filter(({ testID, value }) => {
70+
const placeholder = placeholderByTestID.get(testID);
71+
// Mirrors RunnerTests+TextEntry.swift `textMatchesPlaceholder`: trimmed, whole-value equality.
72+
return (
73+
placeholder !== undefined && placeholder.trim() === value.trim() && value.trim() !== ''
74+
);
75+
})
76+
.map(({ source, testID, value }) => `${source}: fill id="${testID}" "${value}"`);
77+
78+
assert.deepEqual(
79+
collisions,
80+
[],
81+
'change the fixture placeholder, not the filled value — frozen replay-compat corpora carry these fills',
82+
);
83+
});

0 commit comments

Comments
 (0)