Skip to content

Commit a72aa8a

Browse files
Add E2E test for TextInput onPressOut event in fabric
Co-authored-by: HariniMalothu17 <[email protected]>
1 parent e8b9967 commit a72aa8a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

packages/e2e-test-app-fabric/test/TextInputComponentTest.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,43 @@ describe('TextInput Tests', () => {
222222
const search = await app.findElementByTestID('example_search');
223223
await search.setValue('');
224224
});
225+
test('TextInput triggers onPressOut and updates state text', async () => {
226+
// Scroll the example into view
227+
await searchBox('onPressIn');
228+
const component = await app.findElementByTestID('textinput-press');
229+
await component.waitForDisplayed({timeout: 5000});
230+
const dump = await dumpVisualTree('textinput-press');
231+
expect(dump).toMatchSnapshot();
232+
233+
// Get reference to state display element
234+
const stateText = await app.findElementByTestID('textinput-state-display');
235+
236+
// Trigger onPressIn followed by onPressOut (using touchAction for press and release)
237+
await component.touchAction([
238+
{action: 'press', x: 0, y: 0},
239+
{action: 'wait', ms: 100},
240+
{action: 'release'},
241+
]);
242+
243+
// Wait for onPressOut to update the state text
244+
await app.waitUntil(
245+
async () => {
246+
const currentText = await stateText.getText();
247+
return currentText === 'Released click/touch';
248+
},
249+
{
250+
timeout: 5000,
251+
timeoutMsg: 'State text not updated after onPressOut.',
252+
},
253+
);
254+
255+
// Assertion
256+
expect(await stateText.getText()).toBe('Released click/touch');
257+
258+
// Clean up by unfocusing the input
259+
const search = await app.findElementByTestID('example_search');
260+
await search.setValue('');
261+
});
225262
test('TextInputs can have attributed text', async () => {
226263
const component = await app.findElementByTestID('text-input');
227264
await component.waitForDisplayed({timeout: 5000});

0 commit comments

Comments
 (0)