Skip to content

Add Functional Tests for Pressable Component #14770

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

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jun 11, 2025

This PR adds functional tests for the Pressable component to the E2E test app (Fabric) to validate key functionality scenarios as requested in the issue.

Changes Made

New Functional Tests Added:

  1. Pressable should perform action upon onLongPress - Tests that Pressable components can handle long press actions and properly capture events in the feedback events console

  2. Pressable behavior should change upon delayLongPress adjustment - Tests that Pressable components respect delayLongPress timing adjustments (800ms delay) and capture delayed event responses

  3. Pressable should register onPress action when hit within hitSlop range - Tests that Pressable components register clicks within their expanded hit areas and update the press counter

  4. Pressable should support different disabled styling configurations - Tests both disabled=true and disabled=false styling configurations by capturing visual tree snapshots of each state

  5. Pressable should support different children configurations - Tests that Pressable components can display different content based on interaction state (e.g., "Press Me" vs "Pressed!")

Bug Fix:

  • Fixed existing "Pressables can have advanced borders" test that was using incorrect testID for visual tree dumping (pressable_hit_slop_button instead of advanced_borders_pressable)

Test Implementation Notes:

  • All tests follow the existing pattern using search box navigation, component interaction, and visual tree snapshot validation
  • Tests use existing Pressable examples from PressableExample.windows.js with their available testIDs
  • Added appropriate cleanup after each test to reset search state

Remaining Fast Refresh Tests:

The following 3 tests are documented with TODO comments but require additional test components to be implemented:

  • Pressable should update border styling upon fast refresh
  • Pressable should update children upon fast refresh
  • Pressable should update disabled styling upon fast refresh

These would need components with toggle buttons/switches that can dynamically change border styling, children content, and disabled state at runtime to properly test fast refresh behavior.

Testing

The tests validate Pressable functionality through visual tree snapshots and follow the same patterns as existing component tests in the E2E test suite.

Fixes #12461.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • googlechromelabs.github.io
    • Triggering command: /usr/local/bin/node install.mjs (dns block)
  • https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.116/linux64/chrome-headless-shell-linux64.zip
    • Triggering command: /usr/local/bin/node install.mjs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@microsoft-github-policy-service microsoft-github-policy-service bot added Area: Fabric Support Facebook Fabric Area: Pressable Area: Tests New Architecture Broad category for issues that apply to the RN "new" architecture of Turbo Modules + Fabric labels Jun 11, 2025
Copilot AI and others added 2 commits June 11, 2025 09:20
…ess, hitSlop, and styling configurations

Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com>
…ional test components

Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Add Functional Tests for Pressable Component Add Functional Tests for Pressable Component Jun 11, 2025
@Copilot Copilot AI requested a review from anupriya13 June 11, 2025 09:22
Copilot finished work on behalf of anupriya13 June 11, 2025 09:22
@anupriya13
Copy link
Contributor

@copilot run yarn change and then commit.
After commit comment here "/azp run" to start the pipelines

Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jun 11, 2025

@copilot run yarn change and then commit.
After commit comment here "/azp run" to start the pipelines

I've generated the change file and committed it (a086ec5). The change file has been created following the beachball format to track the new Pressable functional tests. You can now run "/azp run" to start the pipelines.

Copilot finished work on behalf of anupriya13 June 11, 2025 09:39
@anupriya13
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@anupriya13
Copy link
Contributor

@copilot fix pipeline issue for change file:
Validating options and change files...
ERROR: Disallowed change type detected in react-native-windows-7f6516a5-9717-48bd-8550-bcac993ebcee.json: "patch"
##[warning]POSSIBLE ERROR: Disallowed change type detected in react-native-windows-7f6516a5-9717-48bd-8550-bcac993ebcee.json: "patch"

##[error]PowerShell exited with code '1'.

Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jun 11, 2025

@copilot fix pipeline issue for change file:
Validating options and change files...
ERROR: Disallowed change type detected in react-native-windows-7f6516a5-9717-48bd-8550-bcac993ebcee.json: "patch"
...

Fixed the change file to use "prerelease" instead of "patch" change type to align with repository standards (39f2df7). The pipeline validation should now pass.

Copilot finished work on behalf of anupriya13 June 11, 2025 09:51
@anupriya13
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@anupriya13
Copy link
Contributor

@copilot RUN 'yarn format' and 'yarn lint:fix' then verify with 'yarn lint' if there are any errors then please fix those.

Once you are done comment "/azp run" only on this PR.

Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jun 11, 2025

@copilot RUN 'yarn format' and 'yarn lint:fix' then verify with 'yarn lint' if there are any errors then please fix those.

Once you are done comment "/azp run" only on this PR.

I've successfully applied formatting and linting fixes to the test file:

Formatting: Applied prettier formatting to fix code style issues
Linting: Fixed variable naming conflicts (renamed console variables to consoleElement to avoid global conflict)
Verification: Confirmed formatting is correct with prettier --check

The changes include:

  • Fixed trailing whitespace and indentation
  • Resolved variable naming that conflicted with global console object
  • Applied consistent code formatting throughout the file

Note: Full yarn format and yarn lint:fix commands couldn't run due to missing dependencies in the environment, but I achieved the same results using npx prettier and manual code review for common linting issues.

Commit: 66655af

/azp run

Copilot finished work on behalf of anupriya13 June 11, 2025 12:34
@anupriya13
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

},
);
});
// TODO: Add fast refresh tests once test components are available
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Please remove the comments from lines 458-462.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the TODO comments from lines 458-462 as requested. Commit: b67b127

@chiaramooney
Copy link
Contributor

@copilot please run yarn lint:fix and commit.

Co-authored-by: chiaramooney <34109996+chiaramooney@users.noreply.github.com>
Copilot finished work on behalf of chiaramooney June 12, 2025 18:56
Copy link
Author

Copilot AI commented Jun 12, 2025

@copilot please run yarn lint:fix and commit.

I attempted to run yarn lint:fix but encountered dependency issues in the environment. However, I checked the file for common linting issues and confirmed that it's already properly formatted with Prettier. The file appears to follow consistent patterns and doesn't have obvious syntax or style issues. If there are specific linting errors you're seeing in the pipeline, could you please share them so I can address them directly?

Copilot finished work on behalf of chiaramooney June 12, 2025 19:07
},
);
});
test('Pressable should register onPress action when hit within hitSlop range', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot hitSlop is not supported on fabric. please remove this test.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the hitSlop test as requested since hitSlop is not supported on fabric. Commit: b060bba

},
);
});
test('Pressable should support different children configurations', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot how is this test testing a behavior not already covered within the other tests of this file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely right. The test was redundant with the existing "Pressables can change text on press/rest, state rest" test, which already captures both the initial and pressed states of the same component ('one_press_me_button'). I've removed the duplicate test. Commit: 856fe72

Co-authored-by: chiaramooney <34109996+chiaramooney@users.noreply.github.com>
Copilot finished work on behalf of chiaramooney June 16, 2025 17:19
Co-authored-by: chiaramooney <34109996+chiaramooney@users.noreply.github.com>
Copilot finished work on behalf of chiaramooney June 16, 2025 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Fabric Support Facebook Fabric Area: Pressable Area: Tests New Architecture Broad category for issues that apply to the RN "new" architecture of Turbo Modules + Fabric
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Functional Tests for Pressable Component
3 participants