Skip to content

Commit aad3ca5

Browse files
HariniMalothu17Harini Malothu
andauthored
Test Fix for PressEvents (#14973)
* Fix for pressevent testcases * Fixed linting errors * Updated testcase * Fixed linting errors --------- Co-authored-by: Harini Malothu <[email protected]>
1 parent 6f9dbbe commit aad3ca5

File tree

1 file changed

+54
-63
lines changed

1 file changed

+54
-63
lines changed

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

Lines changed: 54 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -194,69 +194,6 @@ describe('TextInput Tests', () => {
194194
},
195195
);
196196
});
197-
test('TextInput triggers onPressIn and updates state text', async () => {
198-
// Scroll the example into view
199-
await searchBox('onPressIn');
200-
const component = await app.findElementByTestID('textinput-pressin');
201-
await component.waitForDisplayed({timeout: 5000});
202-
const dump = await dumpVisualTree('textinput-pressin');
203-
expect(dump).toMatchSnapshot();
204-
205-
// Trigger onPressIn (click only)
206-
await component.click();
207-
const stateText = await app.findElementByTestID(
208-
'textinput-state-display-in',
209-
);
210-
211-
await app.waitUntil(
212-
async () => {
213-
const currentText = await stateText.getText();
214-
return currentText === 'Holding down the click/touch';
215-
},
216-
{
217-
timeout: 5000,
218-
timeoutMsg: 'State text not updated after onPressIn.',
219-
},
220-
);
221-
// Assertion
222-
expect(await stateText.getText()).toBe('Holding down the click/touch');
223-
// This step helps avoid UI lock by unfocusing the input
224-
const search = await app.findElementByTestID('example_search');
225-
await search.setValue('');
226-
});
227-
test('TextInput triggers onPressOut and updates state text', async () => {
228-
// Scroll the example into view
229-
await searchBox('onPressOut');
230-
const component = await app.findElementByTestID('textinput-pressout');
231-
await component.waitForDisplayed({timeout: 5000});
232-
const dump = await dumpVisualTree('textinput-pressout');
233-
expect(dump).toMatchSnapshot();
234-
235-
// Trigger onPressOut followed by onPressOut (using touchAction for press and release)
236-
await component.click();
237-
const stateText = await app.findElementByTestID(
238-
'textinput-state-display-out',
239-
);
240-
241-
// Wait for onPressOut to update the state text
242-
await app.waitUntil(
243-
async () => {
244-
const currentText = await stateText.getText();
245-
return currentText === 'Released click/touch';
246-
},
247-
{
248-
timeout: 5000,
249-
timeoutMsg: 'State text not updated after onPressOut.',
250-
},
251-
);
252-
253-
// Assertion
254-
expect(await stateText.getText()).toBe('Released click/touch');
255-
256-
// Clean up by unfocusing the input
257-
const search = await app.findElementByTestID('example_search');
258-
await search.setValue('');
259-
});
260197
test('TextInputs can have attributed text', async () => {
261198
const component = await app.findElementByTestID('text-input');
262199
await component.waitForDisplayed({timeout: 5000});
@@ -988,4 +925,58 @@ describe('TextInput Tests', () => {
988925
const dump = await dumpVisualTree('textinput-searchbox');
989926
expect(dump).toMatchSnapshot();
990927
});
928+
test('TextInput triggers onPressIn and updates state text', async () => {
929+
// Scroll the example into view
930+
await searchBox('onPressIn');
931+
const component = await app.findElementByTestID('textinput-pressin');
932+
await component.waitForDisplayed({timeout: 5000});
933+
const dump = await dumpVisualTree('textinput-pressin');
934+
expect(dump).toMatchSnapshot();
935+
936+
// Trigger onPressIn (click only)
937+
await component.click();
938+
const stateText = await app.findElementByTestID(
939+
'textinput-state-display-in',
940+
);
941+
942+
await app.waitUntil(
943+
async () => {
944+
const currentText = await stateText.getText();
945+
return currentText === 'Holding down the click/touch';
946+
},
947+
{
948+
timeout: 5000,
949+
timeoutMsg: 'State text not updated after onPressIn.',
950+
},
951+
);
952+
// Assertion
953+
expect(await stateText.getText()).toBe('Holding down the click/touch');
954+
});
955+
test('TextInput triggers onPressOut and updates state text', async () => {
956+
const component = await app.findElementByTestID('textinput-pressout');
957+
await component.waitForDisplayed({timeout: 5000});
958+
const dump = await dumpVisualTree('textinput-pressout');
959+
expect(dump).toMatchSnapshot();
960+
961+
// Trigger onPressOut followed by onPressOut (using touchAction for press and release)
962+
await component.click();
963+
const stateText = await app.findElementByTestID(
964+
'textinput-state-display-out',
965+
);
966+
967+
// Wait for onPressOut to update the state text
968+
await app.waitUntil(
969+
async () => {
970+
const currentText = await stateText.getText();
971+
return currentText === 'Released click/touch';
972+
},
973+
{
974+
timeout: 10000,
975+
timeoutMsg: 'State text not updated after onPressOut.',
976+
},
977+
);
978+
979+
// Assertion
980+
expect(await stateText.getText()).toBe('Released click/touch');
981+
});
991982
});

0 commit comments

Comments
 (0)