Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions packages/platform-android/src/__tests__/fill-diagnostics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function node(overrides: Partial<AndroidFillVerificationNode>): AndroidFillVerif
password: false,
inputMethodOwned: false,
area: 0,
hintShowing: false,
placeholder: null,
...overrides,
};
}
Expand Down Expand Up @@ -85,3 +87,25 @@ test('buildFillFailureDetails redacts common masked field glyphs', () => {
assert.doesNotMatch(JSON.stringify(details), /Secret123|\*|•|●/);
}
});

// A field whose value the app rewrites, or an empty field dumping its hint as `text`, fails with the
// raw dump text as `actual`. The node facts say whether that text was the field's placeholder.
test('buildFillFailureDetails carries the hint-showing fact and the placeholder on the observed node', () => {
const details = buildFillFailureDetails('Acme Ltd', {
ok: false,
actual: 'e.g. Merchant',
reason: 'text_mismatch',
targetInput: node({ text: 'e.g. Merchant', hintShowing: true, placeholder: 'e.g. Merchant' }),
actualInput: node({
text: 'e.g. Merchant',
focused: true,
hintShowing: true,
placeholder: 'e.g. Merchant',
}),
});

assert.equal(details.expected, 'Acme Ltd');
assert.equal(details.actual, 'e.g. Merchant');
assert.equal(details.actualInput?.hintShowing, true);
assert.equal(details.actualInput?.placeholder, 'e.g. Merchant');
});
14 changes: 14 additions & 0 deletions packages/platform-android/src/__tests__/text-input-fill.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,20 @@ test('verifyAndroidFilledTextInHierarchy treats hint-only text as an empty value
);
assert.equal(verification.ok, false);
assert.equal(verification.actual, 'Search settings');
// The failure names the placeholder the dump text was, so "actual" is not read as a typed value.
assert.equal(verification.actualInput?.hintShowing, true);
});

test('verifyAndroidFilledTextInHierarchy carries the helper hint onto the observed node', () => {
const verification = verifyAndroidFilledTextInHierarchy(
'<?xml version="1.0" encoding="UTF-8"?><hierarchy><node package="com.example" class="android.widget.EditText" text="Acme" hint="e.g. Merchant" hint-showing="false" focused="true" bounds="[0,0][200,100]"/></hierarchy>',
10,
10,
'Acme Ltd',
);
assert.equal(verification.ok, false);
assert.equal(verification.actualInput?.placeholder, 'e.g. Merchant');
assert.equal(verification.actualInput?.hintShowing, false);
});

test('verifyAndroidFilledTextInHierarchy still refuses a non-empty field for an empty expectation', () => {
Expand Down
7 changes: 7 additions & 0 deletions packages/platform-android/src/fill-diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ export type AndroidFillVerificationNode = {
password: boolean;
inputMethodOwned: boolean;
area: number;
/**
* Helper-only fact: the node's dump `text` is its HINT, so the field itself is empty. Reported on
* a mismatch so a placeholder read as the value is visible in the failure, not only in the log.
*/
hintShowing: boolean;
/** The field's hint text when the helper supplied it, whether or not it is showing. */
placeholder: string | null;
};

export type FillFailureReason = 'ime_capture' | 'masked_unverified' | 'text_mismatch';
Expand Down
3 changes: 1 addition & 2 deletions packages/platform-android/src/fill-verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export type { AndroidFillVerification } from './fill-diagnostics.ts';

type AndroidFillVerificationCandidate = AndroidFillVerificationNode & {
editText: boolean;
// Helper-only fact: the node's dump text is its HINT, so the field itself is empty.
hintShowing: boolean;
};

type AndroidTextAtPointInspection = {
Expand Down Expand Up @@ -410,6 +408,7 @@ function androidFillCandidateFromNode(
area,
editText: isEditTextClass(node.className ?? ''),
hintShowing: node.hintShowing === true,
placeholder: node.hint ?? null,
};
}

Expand Down
Loading