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

feat: add conditional (non-attribute) selectors to ElementQueries #1784

Merged
merged 17 commits into from
Apr 17, 2024

Conversation

joelpop
Copy link
Collaborator

@joelpop joelpop commented Apr 12, 2024

Description

In contrast to ComponentQuerys of unit testing TestBench, ElementQuerys in E2E testing TestBench have (up until now) only provided attribute-based selector methods. This was expanded upon in PR #1774 to provide selector methods for common attributes, such as those for class names, theme, and id. This PR adds condition-based selector methods to ElementQuery to mirror and expand upon those of ComponentQuery. Namely:

  • withCondition
  • withPropertyValue[Containing]
  • withLabel[Containing]
  • withPlaceholder[Containing]
  • withCaption[Containing]
  • withText[Containing]

Elements having their labels in their text (such as buttons) must implement a new, method-less interface HasLabelAsText in their element tester (such as NativeButtonElement for the NativeButton component and ButtonElement for the Button component) in order for the withCaption[Containing] selectors to work for them.

This PR brings the E2E testing selectors up to par with the unit testing selectors. The only one missing is withValue.

Fixes #1183 Add Additional Selectors

Type of change

  • Bugfix
  • Feature

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/guide/contributing/overview/
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

Additional for Feature type of change

  • Enhancement / new feature was discussed in a corresponding GitHub issue and Acceptance Criteria were created.

joelpop added 8 commits April 3, 2024 09:08
Adding CaptionComponent & CaptionElement for ITs.

Adding ITs.
Added more unit tests.
…dition

# Conflicts:
#	vaadin-testbench-core-junit5/src/test/java/com/vaadin/testbench/ElementQueryTest.java
#	vaadin-testbench-core/src/test/java/com/vaadin/testbench/ElementQueryTest.java
#	vaadin-testbench-integration-tests-junit5/frontend/template-view.ts
#	vaadin-testbench-integration-tests-junit5/src/test/java/com/vaadin/tests/ElementQueryIT.java
#	vaadin-testbench-integration-tests/frontend/template-view.ts
#	vaadin-testbench-integration-tests/src/test/java/com/vaadin/tests/ElementQueryIT.java
#	vaadin-testbench-shared/src/main/java/com/vaadin/testbench/ElementQuery.java
…r label.

Altered implementation of withCaption to support button text and prioritize labels over placeholders.

Expanded method documentation.

Added and updated unit and integration tests.
@joelpop joelpop requested review from mcollovati and mshabarov April 12, 2024 05:47
@joelpop joelpop self-assigned this Apr 12, 2024
@mcollovati mcollovati changed the title Feature: add conditional (non-attribute) selectors to ElementQueries feat: add conditional (non-attribute) selectors to ElementQueries Apr 12, 2024
joelpop added 2 commits April 12, 2024 10:57
Improved comparison documentation in ElementQuery.

Added slot to LabelPlaceholder component and support for setText/getText.

Added LabelPlaceholder components to test view via Flow.

Added and improved integration tests.

Simplified implementation (via SonarLint action) of HasPlaceholder's getPlaceholder implementation, which now mirrors that of HasLabel, HasLabelAsText, and HasHelper.
@joelpop joelpop requested a review from mcollovati April 13, 2024 06:14
@joelpop joelpop requested a review from mcollovati April 15, 2024 16:29
@joelpop joelpop requested a review from mcollovati April 16, 2024 17:49
@mcollovati mcollovati merged commit e6454a6 into main Apr 17, 2024
2 checks passed
@mcollovati mcollovati deleted the feature/#1183-withCondition branch April 17, 2024 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

Add additional selectors
2 participants