Skip to content

Run tests in selectable_region_context_menu_test.dart#185380

Merged
auto-submit[bot] merged 3 commits intoflutter:masterfrom
Renzo-Olivares:selectable-region-context-menu-test-fix
Apr 24, 2026
Merged

Run tests in selectable_region_context_menu_test.dart#185380
auto-submit[bot] merged 3 commits intoflutter:masterfrom
Renzo-Olivares:selectable-region-context-menu-test-fix

Conversation

@Renzo-Olivares
Copy link
Copy Markdown
Contributor

Fixes an issue where selectable_region_context_menu_test.dart tests were being skipped.

flutter test --platform=chrome /..../selectable_region_context_menu_test.dart always defaults to TargetPlatform.android and tests were being explicitly skipped on TargetPlatform.android since they do not support the browser context menu at this time. Because TargetPlatform.android is the default then that means every tests in this file was being skipped.

This change fixes the issue by leveraging the variant member of testWidgets instead of the skip member that was being used to explicitly skip tests on TargetPlatform.android. Now we run tests on TargetPlatform.android but only for the supported variants (linux, mac, windows, fuschia).

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@Renzo-Olivares Renzo-Olivares added the CICD Run CI/CD label Apr 21, 2026
@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label Apr 21, 2026
@Renzo-Olivares Renzo-Olivares marked this pull request as ready for review April 22, 2026 23:10
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the platform-specific testing logic in selectable_region_context_menu_test.dart by replacing a boolean check with TargetPlatformVariant. Feedback indicates that several tests now lack the necessary skip condition for non-web environments, which will lead to failures due to package:web dependencies. It is also suggested to use a final variable for the variant definition instead of a getter to optimize performance by avoiding redundant allocations.


final int numberOfStyleElements = getNumberOfStyleElements();
expect(numberOfStyleElements, 1);
}, variant: _browserContextMenuEnabledVariants);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The removal of the kIsWeb check will cause this test to fail when run on the VM because it depends on package:web (e.g., web.HTMLElement). Please restore the skip condition to ensure it only runs in a browser environment. The // [intended] comment is also standard practice in this repository for intentional skips. Alternatively, if this file is intended to be web-only, you could add @TestOn('browser') at the top of the file.

  }, variant: _browserContextMenuEnabledVariants, skip: !kIsWeb); // [intended]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@TestOn('browser') // This file contains web-only library.
library;

already exists at the top of file.


final int numberOfStyleElements = getNumberOfStyleElements();
expect(numberOfStyleElements, 1);
}, variant: _browserContextMenuEnabledVariants);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The removal of the kIsWeb check will cause this test to fail when run on the VM because it depends on package:web. Please restore the skip condition to ensure it only runs on the web.

  }, variant: _browserContextMenuEnabledVariants, skip: !kIsWeb); // [intended]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@TestOn('browser') // This file contains web-only library.
library;

already exists at the top of file.

expect(selectWordEvent, isNotNull);
expect((selectWordEvent!.globalPosition.dx - 200).abs() < precisionErrorTolerance, isTrue);
expect((selectWordEvent.globalPosition.dy - 300).abs() < precisionErrorTolerance, isTrue);
}, variant: _browserContextMenuEnabledVariants);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The removal of the kIsWeb check will cause this test to fail when run on the VM because it depends on package:web. Please restore the skip condition to ensure it only runs on the web.

  }, variant: _browserContextMenuEnabledVariants, skip: !kIsWeb); // [intended]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@TestOn('browser') // This file contains web-only library.
library;

already exists at the top of file.

element.dispatchEvent(event);
expect(event.defaultPrevented, isTrue);
}
}, variant: _browserContextMenuEnabledVariants);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The removal of the kIsWeb check will cause this test to fail when run on the VM because it depends on package:web. Please restore the skip condition to ensure it only runs on the web.

  }, variant: _browserContextMenuEnabledVariants, skip: !kIsWeb); // [intended]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@TestOn('browser') // This file contains web-only library.
library;

already exists at the top of file.

Comment on lines +30 to +32
TargetPlatformVariant get _browserContextMenuEnabledVariants => TargetPlatformVariant(
<TargetPlatform>{...TargetPlatformVariant.desktop().values, TargetPlatform.fuchsia},
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Defining the variant as a final variable is preferred over a getter to avoid redundant allocations of the TargetPlatformVariant and its underlying Set on every test case execution.

final TargetPlatformVariant _browserContextMenuEnabledVariants = TargetPlatformVariant(
  <TargetPlatform>{...TargetPlatformVariant.desktop().values, TargetPlatform.fuchsia},
);
References
  1. Suggest simplification and refactoring to enhance maintainability. (link)

@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 23, 2026
@Renzo-Olivares Renzo-Olivares added CICD Run CI/CD labels Apr 23, 2026
@fluttergithubbot
Copy link
Copy Markdown
Contributor

An existing Git SHA, b850ed19b0e9e2b98927474766bb7d1af9c34b24, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@Renzo-Olivares Renzo-Olivares force-pushed the selectable-region-context-menu-test-fix branch from b850ed1 to 5c2d61c Compare April 23, 2026 17:14
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Apr 23, 2026
@Renzo-Olivares Renzo-Olivares added the CICD Run CI/CD label Apr 23, 2026
TargetPlatform.linux,
TargetPlatform.macOS,
TargetPlatform.windows,
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if we should do something like:

const TargetPlatformVariant _browserContextMenuEnabledVariants = TargetPlatformVariant(
  TargetPlatform.values
    .where((platform) => 
      platform != TargetPlatform.android && 
      platform != TargetPlatform.iOS
    )
    .toSet(),
);

This would make sure this opt-out continues to work even if we add more TargetPlatforms in the future. I don't feel strongly though, I'd be happy with the current approach too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point sgtm!

loic-sharma
loic-sharma previously approved these changes Apr 23, 2026
Copy link
Copy Markdown
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

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

Re-LGTM

@Renzo-Olivares Renzo-Olivares added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Apr 24, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 24, 2026
@auto-submit
Copy link
Copy Markdown
Contributor

auto-submit Bot commented Apr 24, 2026

autosubmit label was removed for flutter/flutter/185380, because - The status or check suite Windows framework_tests_misc has failed. Please fix the issues identified (or deflake) before re-applying this label.

@Renzo-Olivares Renzo-Olivares added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 24, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants