vaadin / vaadin/browserless-test
Extract the browserless DSL into a BrowserlessDsl interface mixin
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1
- Forks
- 3
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 51
Description
Part of #120.
The DSL methods (navigate, find, findInView, getCurrentView, fireShortcut, roundTrip, test) are public instance methods on BaseBrowserlessTest, so a test can only get them by extending that class. Composition-style tests (already extending another base, or wanting the DSL on a helper) cannot. The same DSL is duplicated in BrowserlessUIContext.
Proposal
Introduce a public interface BrowserlessDsl (in com.vaadin.browserless, alongside TesterWrappers / Locators) with:
- a single SPI hook
UI currentUI()— implementors return the UI to operate on, performing any activation/validation; defaultmethods delegating to the static helper:navigate(×4),find(×2),findInView,getCurrentView,fireShortcut,roundTrip, and the single-argtest(Y).
Supporting changes:
- Rename the internal static helper
BrowserlessDSL→BrowserlessDslImpl(it is package-private / internal-only). BaseBrowserlessTest implements BrowserlessDslwithcurrentUI()→ existingverifyAndGetUI(); drop the moved bodies.roundTripchanges fromprotected staticto the inherited publicdefault(existing unqualified callers still compile;ComponentTester.roundTrip()calls the helper directly).BrowserlessUIContext implements BrowserlessDslwithcurrentUI()→{ activate(); return ui; }; drop the moved bodies.- Add a test proving the mixin works on a class that does not extend
BaseBrowserlessTest, and document thecurrentUI()contract + a raw-class usage example in the interface javadoc.
Out of scope (separate issues)
runPendingSignalsTasks (state-bound) → #125, test(Class, Y) (divergent semantics) → #124, and AbstractBrowserlessExtension migration → #123. Tracked under #120.
Non-breaking
Moved methods keep identical public signatures; subclass overrides still win over defaults; super.find(...) resolves through the inherited default. testingEngine() stays protected (not on the interface). Only residual: roundTrip protected static → public instance default.
Reference: proof-of-concept on branch refactor/browserless-dsl-mixin (commit 28c2818).
Acceptance criteria
-
BrowserlessDslexists with thecurrentUI()hook + listed defaults. -
BaseBrowserlessTestandBrowserlessUIContextimplement it and no longer declare the moved methods. - A raw-class (non-
BaseBrowserlessTest) test exercises the DSL via the mixin. - Full suite passes:
mvn -o -am -pl shared,junit6,spring,quarkus test.
Affected files
New shared/.../BrowserlessDsl.java; rename shared/.../BrowserlessDSL.java → BrowserlessDslImpl.java; shared/.../BaseBrowserlessTest.java, shared/.../BrowserlessUIContext.java, shared/.../ComponentTester.java; new mixin test under junit6/src/test.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the affected shared files, especially BaseBrowserlessTest.java, BrowserlessUIContext.java, BrowserlessDSL.java, and ComponentTester.java, then review the proof-of-concept branch for the intended interface shape. Add the raw-class mixin test under junit6/src/test and run mvn -o -am -pl shared,junit6,spring,quarkus test. Done means the listed acceptance criteria pass without breaking existing public signatures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100