Skip to content

Test Fix for PressEvents #14973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
117 changes: 54 additions & 63 deletions packages/e2e-test-app-fabric/test/TextInputComponentTest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,69 +194,6 @@ describe('TextInput Tests', () => {
},
);
});
test('TextInput triggers onPressIn and updates state text', async () => {
// Scroll the example into view
await searchBox('onPressIn');
const component = await app.findElementByTestID('textinput-pressin');
await component.waitForDisplayed({timeout: 5000});
const dump = await dumpVisualTree('textinput-pressin');
expect(dump).toMatchSnapshot();

// Trigger onPressIn (click only)
await component.click();
const stateText = await app.findElementByTestID(
'textinput-state-display-in',
);

await app.waitUntil(
async () => {
const currentText = await stateText.getText();
return currentText === 'Holding down the click/touch';
},
{
timeout: 5000,
timeoutMsg: 'State text not updated after onPressIn.',
},
);
// Assertion
expect(await stateText.getText()).toBe('Holding down the click/touch');
// This step helps avoid UI lock by unfocusing the input
const search = await app.findElementByTestID('example_search');
await search.setValue('');
});
test('TextInput triggers onPressOut and updates state text', async () => {
// Scroll the example into view
await searchBox('onPressOut');
const component = await app.findElementByTestID('textinput-pressout');
await component.waitForDisplayed({timeout: 5000});
const dump = await dumpVisualTree('textinput-pressout');
expect(dump).toMatchSnapshot();

// Trigger onPressOut followed by onPressOut (using touchAction for press and release)
await component.click();
const stateText = await app.findElementByTestID(
'textinput-state-display-out',
);

// Wait for onPressOut to update the state text
await app.waitUntil(
async () => {
const currentText = await stateText.getText();
return currentText === 'Released click/touch';
},
{
timeout: 5000,
timeoutMsg: 'State text not updated after onPressOut.',
},
);

// Assertion
expect(await stateText.getText()).toBe('Released click/touch');

// Clean up by unfocusing the input
const search = await app.findElementByTestID('example_search');
await search.setValue('');
});
test('TextInputs can have attributed text', async () => {
const component = await app.findElementByTestID('text-input');
await component.waitForDisplayed({timeout: 5000});
Expand Down Expand Up @@ -988,4 +925,58 @@ describe('TextInput Tests', () => {
const dump = await dumpVisualTree('textinput-searchbox');
expect(dump).toMatchSnapshot();
});
test('TextInput triggers onPressIn and updates state text', async () => {
// Scroll the example into view
await searchBox('onPressIn');
const component = await app.findElementByTestID('textinput-pressin');
await component.waitForDisplayed({timeout: 5000});
const dump = await dumpVisualTree('textinput-pressin');
expect(dump).toMatchSnapshot();

// Trigger onPressIn (click only)
await component.click();
const stateText = await app.findElementByTestID(
'textinput-state-display-in',
);

await app.waitUntil(
async () => {
const currentText = await stateText.getText();
return currentText === 'Holding down the click/touch';
},
{
timeout: 5000,
timeoutMsg: 'State text not updated after onPressIn.',
},
);
// Assertion
expect(await stateText.getText()).toBe('Holding down the click/touch');
});
test('TextInput triggers onPressOut and updates state text', async () => {
const component = await app.findElementByTestID('textinput-pressout');
await component.waitForDisplayed({timeout: 5000});
const dump = await dumpVisualTree('textinput-pressout');
expect(dump).toMatchSnapshot();

// Trigger onPressOut followed by onPressOut (using touchAction for press and release)
await component.click();
const stateText = await app.findElementByTestID(
'textinput-state-display-out',
);

// Wait for onPressOut to update the state text
await app.waitUntil(
async () => {
const currentText = await stateText.getText();
return currentText === 'Released click/touch';
},
{
timeout: 10000,
timeoutMsg: 'State text not updated after onPressOut.',
},
);

// Assertion
expect(await stateText.getText()).toBe('Released click/touch');
});
});
Loading