-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add conditional (non-attribute) selectors to ElementQueries (#1784
) 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
- Loading branch information
Showing
20 changed files
with
1,711 additions
and
89 deletions.
There are no files selected for viewing
269 changes: 240 additions & 29 deletions
269
vaadin-testbench-core-junit5/src/test/java/com/vaadin/testbench/ElementQueryTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
268 changes: 240 additions & 28 deletions
268
vaadin-testbench-core/src/test/java/com/vaadin/testbench/ElementQueryTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
vaadin-testbench-integration-tests-junit5/frontend/label-placeholder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { html, LitElement } from 'lit'; | ||
import { customElement, property } from 'lit/decorators.js'; | ||
|
||
@customElement('label-placeholder') | ||
class LabelPlaceholder extends LitElement { | ||
@property({ type: String }) | ||
label!: string; | ||
|
||
@property({ type: String }) | ||
placeholder!: string; | ||
|
||
render() { | ||
return html` | ||
<div> | ||
<div id="label">${this.label}</div> | ||
<div id="placeholder">${this.placeholder}</div> | ||
<slot></slot> | ||
</div> | ||
`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...-testbench-integration-tests-junit5/src/main/java/com/vaadin/testUI/LabelPlaceholder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.vaadin.testUI; | ||
|
||
import com.vaadin.flow.component.HasLabel; | ||
import com.vaadin.flow.component.HasPlaceholder; | ||
import com.vaadin.flow.component.HasText; | ||
import com.vaadin.flow.component.Tag; | ||
import com.vaadin.flow.component.dependency.JsModule; | ||
import com.vaadin.flow.component.littemplate.LitTemplate; | ||
|
||
@Tag(LabelPlaceholder.TAG) | ||
@JsModule(LabelPlaceholder.JS_MODULE) | ||
public class LabelPlaceholder extends LitTemplate | ||
implements HasLabel, HasPlaceholder, HasText { | ||
public static final String TAG = "label-placeholder"; | ||
public static final String JS_MODULE = "./" + TAG + ".ts"; | ||
|
||
public LabelPlaceholder() { | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.