Skip to content

Commit 0eef3bb

Browse files
committed
test(ios): cover auto-submit of a digit-count field and frame the unnamed-successor limit
1 parent ef3bb3e commit 0eef3bb

2 files changed

Lines changed: 36 additions & 6 deletions

File tree

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ extension RunnerTests {
117117

118118
/// The input a text entry command bound to. XCUIElement exposes no per-instance id, and a query
119119
/// bound by index or point re-resolves to whatever input occupies that slot now, so element type
120-
/// plus identifier is the identity. It is unique only when the identifier is non-empty.
120+
/// plus identifier is the identity. It is unique only when the identifier is non-empty. Unlike
121+
/// `TextEntryElementIdentity` it leaves out the frame: it must hold across every post of a fill,
122+
/// while the field can still be moving with the keyboard.
121123
struct TextEntryInputIdentity: Equatable {
122124
let elementType: XCUIElement.ElementType
123125
let identifier: String

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+TextTypingTests.swift‎

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,40 @@ extension RunnerTests {
257257
XCTAssertEqual(editableTextValue(for: app.textFields.element(boundBy: 0), treatingPlaceholderAsEmpty: true), "")
258258
}
259259

260-
// The known limit: neither input has an identifier, and the successor takes the code field's index
261-
// in the query that bound it, so the remaining posts resolve to it. Refusing point and focus
262-
// re-resolution would not help, because the index-bound query itself returns the successor. The
263-
// command must still fail typed, never report success or repair into the successor.
260+
// A one-time-code field whose value is a digit-count summary auto-submits on the last digit and a
261+
// named input takes its place. The bound field is gone, so the fill is the plain unverified
262+
// "typed": no unconfirmed evidence read off the successor, and no text in it.
264263
@MainActor
265-
func testFillFailsTypedWhenAnIndistinguishableInputReplacesItMidDelivery() throws {
264+
func testFillIntoAutoSubmittingDigitCountFieldReportsNoEvidenceFromItsSuccessor() throws {
265+
let textField = try launchRemovableInputFixture(
266+
"--agent-device-text-entry-digit-count-value",
267+
"--agent-device-text-entry-auto-submit"
268+
)
269+
270+
let failureCountBefore = currentXCTestFailureCount()
271+
let response = executeTypeCommand(
272+
activeApp: app,
273+
command: try fillCommandFixture(commandId: "fill-digit-count-auto-submit", text: "123456", at: textField)
274+
)
275+
276+
XCTAssertFalse(didRecordXCTestFailure(since: failureCountBefore))
277+
XCTAssertTrue(response.ok, String(describing: response.error))
278+
XCTAssertEqual(response.data?.message, "typed")
279+
XCTAssertNil(response.data?.verification)
280+
XCTAssertFalse(textField.exists)
281+
let nextScreenField = app.textFields["agent-device-auto-submit-next-screen-input"]
282+
XCTAssertTrue(nextScreenField.exists)
283+
XCTAssertEqual(editableTextValue(for: nextScreenField, treatingPlaceholderAsEmpty: true), "")
284+
}
285+
286+
// Pins a known limit, not desired behavior: neither input has an identifier, and the successor
287+
// takes the code field's index in the query that bound it, so the remaining posts resolve to it
288+
// and land in the successor. Refusing point and focus re-resolution would not help, because the
289+
// index-bound query itself returns the successor. What must hold is a typed failure, never success
290+
// or a repair into the successor. The successor's "23456" records the wrong-target side effect; a
291+
// per-instance identity would make that assertion fail, and the test should then change with it.
292+
@MainActor
293+
func testFillPinsKnownLimitWhenAnIndistinguishableInputReplacesItMidDelivery() throws {
266294
let textField = try launchRemovableInputFixture(
267295
"--agent-device-text-entry-replace-after-input",
268296
"--agent-device-text-entry-unnamed-input"

0 commit comments

Comments
 (0)