vaadin / vaadin/browserless-test

Extract the browserless DSL into a BrowserlessDsl interface mixin

Open
#121 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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;
  • default methods delegating to the static helper: navigate (×4), find (×2), findInView, getCurrentView, fireShortcut, roundTrip, and the single-arg test(Y).

Supporting changes:

  • Rename the internal static helper BrowserlessDSLBrowserlessDslImpl (it is package-private / internal-only).
  • BaseBrowserlessTest implements BrowserlessDsl with currentUI() → existing verifyAndGetUI(); drop the moved bodies. roundTrip changes from protected static to the inherited public default (existing unqualified callers still compile; ComponentTester.roundTrip() calls the helper directly).
  • BrowserlessUIContext implements BrowserlessDsl with currentUI(){ activate(); return ui; }; drop the moved bodies.
  • Add a test proving the mixin works on a class that does not extend BaseBrowserlessTest, and document the currentUI() 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
  • BrowserlessDsl exists with the currentUI() hook + listed defaults.
  • BaseBrowserlessTest and BrowserlessUIContext implement 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.javaBrowserlessDslImpl.java; shared/.../BaseBrowserlessTest.java, shared/.../BrowserlessUIContext.java, shared/.../ComponentTester.java; new mixin test under junit6/src/test.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.