From 4c537728cf02a4e7d1eabd7546d2e3d2f06a1bfc Mon Sep 17 00:00:00 2001
From: Mauricio Lauffer <443888+mauriciolauffer@users.noreply.github.com>
Date: Fri, 22 May 2026 11:55:58 +1000
Subject: [PATCH 01/14] feat: add support to RecordReplay pressEnterKey
---
.../webapp/controller/Main.controller.js | 7 +
.../webapp/test/e2e/interaction.test.js | 154 ++++++++++++++++++
examples/ui5-js-app/webapp/view/Main.view.xml | 8 +
package.json | 4 +-
4 files changed, 171 insertions(+), 2 deletions(-)
diff --git a/examples/ui5-js-app/webapp/controller/Main.controller.js b/examples/ui5-js-app/webapp/controller/Main.controller.js
index 9d442ed4..70c3833a 100644
--- a/examples/ui5-js-app/webapp/controller/Main.controller.js
+++ b/examples/ui5-js-app/webapp/controller/Main.controller.js
@@ -49,6 +49,13 @@ sap.ui.define(
onSearch(oEvent) {
this.getView().byId("idSearchResult").setText(oEvent.getSource().getValue())
},
+ onKeepFocusInputChange(oEvent) {
+ this.getView().byId("idKeepFocusResult").setText(oEvent.getSource().getValue())
+ },
+ onClearTextInputChange(oEvent) {
+ console.log(oEvent.getSource().getValue())
+ this.getView().byId("idClearTextResult").setText(oEvent.getSource().getValue())
+ },
onTest(oEvent) {
this.onBoo(oEvent)
},
diff --git a/examples/ui5-js-app/webapp/test/e2e/interaction.test.js b/examples/ui5-js-app/webapp/test/e2e/interaction.test.js
index b619e8e8..73b9d5ab 100644
--- a/examples/ui5-js-app/webapp/test/e2e/interaction.test.js
+++ b/examples/ui5-js-app/webapp/test/e2e/interaction.test.js
@@ -68,4 +68,158 @@ describe("interaction + binding", () => {
expect(await ui5Input.getProperty("value")).toEqual(inputText)
})
+
+ it("enterText() with pressEnterKey:true triggers search event", async () => {
+ const searchFieldSelector = {
+ selector: {
+ id: "idSearchfield",
+ viewName: viewName,
+ interaction: "focus"
+ }
+ }
+ const searchResultSelector = {
+ selector: {
+ id: "idSearchResult",
+ viewName: viewName
+ }
+ }
+
+ const searchTerm = "Alice"
+ const searchField = await browser.asControl(searchFieldSelector)
+ await searchField.enterText(searchTerm, { pressEnterKey: true })
+
+ const searchResult = await browser.asControl(searchResultSelector)
+ expect(await searchResult.getProperty("text")).toEqual(searchTerm)
+ })
+
+ it("enterText() with pressEnterKey:false does not trigger search event", async () => {
+ const searchFieldSelector = {
+ selector: {
+ id: "idSearchfield",
+ viewName: viewName
+ }
+ }
+ const searchResultSelector = {
+ selector: {
+ id: "idSearchResult",
+ viewName: viewName
+ }
+ }
+
+ // capture the current search result before typing (set by the previous test)
+ const searchResult = await browser.asControl(searchResultSelector)
+ const previousResult = await searchResult.getProperty("text")
+
+ const searchTerm = "Charlie"
+ const searchField = await browser.asControl(searchFieldSelector)
+ // pressEnterKey:false — text is entered but Enter is not pressed, so onSearch is not fired
+ await searchField.enterText(searchTerm, { pressEnterKey: false, keepFocus: true })
+
+ // result text must remain unchanged since the search event was not triggered
+ expect(await searchResult.getProperty("text")).toEqual(previousResult)
+ })
+
+ it("enterText() with keepFocus:false blurs the input and triggers change event", async () => {
+ const inputSelector = {
+ selector: {
+ id: "idKeepFocusInput",
+ viewName: viewName,
+ interaction: "focus"
+ }
+ }
+ const resultSelector = {
+ selector: {
+ id: "idKeepFocusResult",
+ viewName: viewName
+ }
+ }
+
+ const inputText = "keep focus off"
+ const input = await browser.asControl(inputSelector)
+ // keepFocus:false (default) — focus is removed after enterText, which fires the change event
+ await input.enterText(inputText, { keepFocus: false })
+
+ const result = await browser.asControl(resultSelector)
+ expect(await result.getProperty("text")).toEqual(inputText)
+ })
+
+ it("enterText() with keepFocus:true retains focus and does not trigger change event", async () => {
+ const inputSelector = {
+ selector: {
+ id: "idKeepFocusInput",
+ viewName: viewName,
+ interaction: "focus"
+ }
+ }
+ const resultSelector = {
+ selector: {
+ id: "idKeepFocusResult",
+ viewName: viewName
+ }
+ }
+
+ // capture current result (set by previous test)
+ const result = await browser.asControl(resultSelector)
+ const previousResult = await result.getProperty("text")
+
+ const inputText = "keep focus on"
+ const input = await browser.asControl(inputSelector)
+ // keepFocus:true — focus is retained after enterText, so no blur occurs and change event does not fire
+ await input.enterText(inputText, { keepFocus: true })
+
+ // result text must remain unchanged since the change event was not triggered
+ expect(await result.getProperty("text")).toEqual(previousResult)
+ })
+
+ it("enterText() with clearTextFirst:true replaces existing input value", async () => {
+ const inputSelector = {
+ selector: {
+ id: "idClearTextInput",
+ viewName: viewName,
+ interaction: "focus"
+ }
+ }
+ const resultSelector = {
+ selector: {
+ id: "idClearTextResult",
+ viewName: viewName
+ }
+ }
+
+ const appendedText = " World"
+ const input = await browser.asControl(inputSelector)
+ // clearTextFirst:true (default) — existing "Hello" is cleared before typing, so only appended text remains
+ await input.enterText(appendedText, { clearTextFirst: true })
+
+ const result = await browser.asControl(resultSelector)
+ expect(await result.getProperty("text")).toEqual(appendedText)
+ })
+
+ it.skip("enterText() with clearTextFirst:false appends to existing input value", async () => {
+ // TODO: perhaps capture UI5 event in a browser.execute command to ensure whether this has been triggered
+ const inputSelector = {
+ selector: {
+ id: "idClearTextInput",
+ viewName: viewName,
+ interaction: "focus"
+ }
+ }
+ const resultSelector = {
+ selector: {
+ id: "idClearTextResult",
+ viewName: viewName
+ }
+ }
+
+ const initialText = "Hello"
+ const appendedText = " World"
+ // restore a known value first (clearTextFirst:true so we start clean)
+ const input = await browser.asControl(inputSelector)
+ await input.enterText(initialText, { clearTextFirst: true })
+ // clearTextFirst:false — existing "Hello" is kept and new text is appended after it
+ await input.enterText(appendedText, { clearTextFirst: false })
+
+ const result = await browser.asControl(resultSelector)
+ expect(await result.getProperty("text")).toEqual(initialText + appendedText)
+ })
})
diff --git a/examples/ui5-js-app/webapp/view/Main.view.xml b/examples/ui5-js-app/webapp/view/Main.view.xml
index 09fb4082..84147aec 100644
--- a/examples/ui5-js-app/webapp/view/Main.view.xml
+++ b/examples/ui5-js-app/webapp/view/Main.view.xml
@@ -61,6 +61,14 @@
+
+
+
+
+
+
+
+