Skip to content
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

[1874] Added key to widgets #1889

Merged
merged 2 commits into from
Feb 27, 2025
Merged

[1874] Added key to widgets #1889

merged 2 commits into from
Feb 27, 2025

Conversation

TheNoumanDev
Copy link
Member

Ticket: #1874

  • Used existing testId property in Ensemble widgets.
  • Wrap returned widget with KeyedSubtree, using testId as its key.

Example EDL:

Button:
  testId: navigate_button
  label: Navigate to Goodbye Screen
  onTap:
    navigateScreen:
      name: Goodbye

Example Flutter Test code:

final navigateButtonFinder = find.byKey(
          ValueKey('navigate_button'), 
          skipOffstage: false
        );
2025-02-26.04-56-25.mp4

@TheNoumanDev TheNoumanDev self-assigned this Feb 26, 2025
@TheNoumanDev TheNoumanDev added the enhancement New feature or request label Feb 26, 2025
@TheNoumanDev TheNoumanDev linked an issue Feb 26, 2025 that may be closed by this pull request
@sharjeelyunus
Copy link
Member

sharjeelyunus commented Feb 26, 2025

@TheNoumanDev can you suggest any framework which we can use to run these automated tests? Maybe we can add them to build system, or directly in the studio. End goal is after defining the test ids, user should have a way to run these tests

Even if not in studio or build system for now, but there should be a yaml way to define the test cases, user shouldn't have to wrote dart code to write the test cases

@TheNoumanDev
Copy link
Member Author

Above PR was for KPN Sports app, they have there our tests defined in dart, they wanted to access to ensemble widgets uisng key, thats why did that to unblock them, but yeah from products perspective, we should provide a proper testing environment in future but that would be a whole new feature being added to Ensemble, below is the basic flow we can start with if we want to:

  1. Test Definition Format: Create a comprehensive YAML format for defining tests that aligns with Ensemble's declarative approach:
test_suite:
  name: Login Flow Tests
  tests:
    - name: Successful Login
      setup:
        screen: LoginScreen
      steps:
        - action: enterText
          target: username_input
          value: "[email protected]"
        - action: enterText
          target: password_input
          value: "password123"
        - action: tap
          target: login_button
        - action: waitForNavigation
          timeout: 5 # seconds
        - action: expectVisible
          target: dashboard_welcome_text
          text: "Welcome, testuser!"
        - action: expectProperty
          target: error_message
          visible: false
  1. CI/CD Integration: Convert these YAML tests to Dart codeand then process in our CI/CD pipeline (e.g., CodeMagic), run them, and capture results.

  2. Test Results: Add a new "Tests" tab in Ensemble Studio where users can:

    • Edit test definitions in YAML (similar to how screens are defined)
    • Trigger test runs manually
    • View test results (pass/fail status and details)
  3. Future Enhancements:

    • Add a visual test editor that generates YAML (similar to the screen editor)
    • Provide more detailed test visualization with screenshots and failure details
    • Support for more complex test scenarios and environment configurations

    For now i will be merging this PR if that is fine?.
    CC: @sharjeelyunus

@TheNoumanDev TheNoumanDev merged commit 505e5cc into main Feb 27, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose widgets for automation testing
3 participants