Move Design Strategies Java examples into tested gh-codeblock refs#2732
Conversation
Redo of #2308 by Simon Benzer (@shbenzer): moves the inline Java code fences in the Loadable Component / Bot Pattern walkthrough into a real, compiling, tested source file, and points design_strategies.en/ ja/pt-br/zh-cn.md at it via gh-codeblock instead of duplicating the snippets inline. Along the way this fixes bugs that were already present in the inline snippets (a stray extra ')' in setTitle, and setSeleniumVersion assigning the wrong field via a copy-pasted variable name), and adds a JUnit5 test (marked @disabled, since it would otherwise exercise live GitHub/Google sign-in flows) that wires the nested-components example end-to-end to prove it actually compiles and type-checks. Co-authored-by: Simon Benzer <simonhbenzer@gmail.com> Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
PR Summary by QodoMove Design Strategies Java docs to tested gh-codeblock snippets
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
✅ Deploy Preview for selenium-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review by Qodo
Context used✅ Compliance rules (platform):
10 rules 1.
|
…word
- EditIssue now actually loads its parent component (optional parent
field + overloaded constructor), matching what the doc narrative
already claimed ("EditIssue.get() will cause all its dependencies
to load too"). Previously the demo just called securedPage.get()
manually before constructing a parent-less EditIssue.
- isLoaded() checked url.endsWith("/new"), but load() navigates to a
URL with a query string, so that check could never pass. Switched
to url.contains("/issues/new").
- Replaced the "top secret" password placeholder with a value that
can't be mistaken for a real credential.
- The "load method in EditIssue now looks like" doc snippet now
references the real, correct load() method via gh-codeblock instead
of staying inline, since the code finally matches what it describes.
|
Code review by qodo was updated up to the latest commit 54431e9 |
- Rename NestedComponentsExample -> NestedComponentsExampleTest. Maven Surefire's default include patterns only match **/Test*.java, **/*Test.java, **/*Tests.java, **/*TestCase.java, and this module has no custom <includes> override, so the old name meant the @disabled test was invisible to a plain `mvn test` (never discovered, never even reported as skipped). - Wrap every new Java gh-codeblock reference in the design strategies walkthrough in a tabpane (Python/Java/CSharp/Ruby/JavaScript/Kotlin, badge-code for the unimplemented languages), matching this repo's documented style guide ("the code itself should be placed inside code tabs") and the exact convention already used two sections below in the same file's "## Example" section.
|
Code review by qodo was updated up to the latest commit 2b5636b |
|
Code review by qodo was updated up to the latest commit c6b8c2e |
- IssueList.isLoaded() only checked url.contains("/issues"), which is
also true for /issues/new -- so IssueList could report itself
loaded while actually on the EditIssue page. Now also requires the
URL not contain "/issues/", excluding /issues/new and /issues/<id>.
- The "basic Page Object" doc snippet renders as class EditIssueBasic,
but the surrounding prose only ever says "EditIssue" -- added a
short clause naming the class explicitly and explaining it becomes
the EditIssue LoadableComponent in the next section, in all four
languages.
Left two other findings from the same review as-is:
- "Missing license header": only 3 of 60 Java example files in this
repo have this header and nothing enforces it, so not an actual
convention to follow.
- "tabpane missing langEqualsHeader": the suggested langEqualsHeader
+ per-tab text=true would break the badge-code tabs, which need
text=true too since they're shortcodes, not raw code. The uniform
tabpane text=true already matches this exact file's own pre-existing
"## Example" section, which mixes gh-codeblock and badge-code the
same way.
|
Code review by qodo was updated up to the latest commit fc8680d |
|
Code review by qodo was updated up to the latest commit 4b98ecc |
…2732) * Move Design Strategies Java examples into tested gh-codeblock refs Redo of #2308 by Simon Benzer (@shbenzer): moves the inline Java code fences in the Loadable Component / Bot Pattern walkthrough into a real, compiling, tested source file, and points design_strategies.en/ ja/pt-br/zh-cn.md at it via gh-codeblock instead of duplicating the snippets inline. Along the way this fixes bugs that were already present in the inline snippets (a stray extra ')' in setTitle, and setSeleniumVersion assigning the wrong field via a copy-pasted variable name), and adds a JUnit5 test (marked @disabled, since it would otherwise exercise live GitHub/Google sign-in flows) that wires the nested-components example end-to-end to prove it actually compiles and type-checks. Co-authored-by: Simon Benzer <simonhbenzer@gmail.com> Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Address Qodo review: real nesting, fix isLoaded check, drop fake password - EditIssue now actually loads its parent component (optional parent field + overloaded constructor), matching what the doc narrative already claimed ("EditIssue.get() will cause all its dependencies to load too"). Previously the demo just called securedPage.get() manually before constructing a parent-less EditIssue. - isLoaded() checked url.endsWith("/new"), but load() navigates to a URL with a query string, so that check could never pass. Switched to url.contains("/issues/new"). - Replaced the "top secret" password placeholder with a value that can't be mistaken for a real credential. - The "load method in EditIssue now looks like" doc snippet now references the real, correct load() method via gh-codeblock instead of staying inline, since the code finally matches what it describes. * Address second Qodo review: test discovery + style guide compliance - Rename NestedComponentsExample -> NestedComponentsExampleTest. Maven Surefire's default include patterns only match **/Test*.java, **/*Test.java, **/*Tests.java, **/*TestCase.java, and this module has no custom <includes> override, so the old name meant the @disabled test was invisible to a plain `mvn test` (never discovered, never even reported as skipped). - Wrap every new Java gh-codeblock reference in the design strategies walkthrough in a tabpane (Python/Java/CSharp/Ruby/JavaScript/Kotlin, badge-code for the unimplemented languages), matching this repo's documented style guide ("the code itself should be placed inside code tabs") and the exact convention already used two sections below in the same file's "## Example" section. * Address third Qodo review: tighten IssueList check, clarify naming - IssueList.isLoaded() only checked url.contains("/issues"), which is also true for /issues/new -- so IssueList could report itself loaded while actually on the EditIssue page. Now also requires the URL not contain "/issues/", excluding /issues/new and /issues/<id>. - The "basic Page Object" doc snippet renders as class EditIssueBasic, but the surrounding prose only ever says "EditIssue" -- added a short clause naming the class explicitly and explaining it becomes the EditIssue LoadableComponent in the next section, in all four languages. Left two other findings from the same review as-is: - "Missing license header": only 3 of 60 Java example files in this repo have this header and nothing enforces it, so not an actual convention to follow. - "tabpane missing langEqualsHeader": the suggested langEqualsHeader + per-tab text=true would break the badge-code tabs, which need text=true too since they're shortcodes, not raw code. The uniform tabpane text=true already matches this exact file's own pre-existing "## Example" section, which mixes gh-codeblock and badge-code the same way. --------- Co-authored-by: Simon Benzer <simonhbenzer@gmail.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> [deploy site] 00bfd1e
Thanks for contributing to the Selenium site and documentation!
A PR well described will help maintainers to review and merge it quickly
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, and help reviewers by making them as simple and short as possible.
Description
Redo of #2308 by @shbenzer. Moves the inline Java code fences in the "Loadable Component" / "Bot Pattern" walkthrough (
design_strategies.en/ja/pt-br/zh-cn.md) into a real, compiling source file (examples/java/src/test/java/dev/selenium/design_strategies/BestPractices.java), referenced from the docs viagh-codeblockinstead of duplicated inline snippets.#2308 had the same goal but had drifted out of sync with trunk and had a few issues (a truncated code block, a class renamed mid-narrative, a reference into dead/commented-out code, and an unrelated malformed line-range on the Python tab). This redoes it from scratch against current trunk with those fixed:
)insetTitle, andsetSeleniumVersionwriting to the wrong field via a copy-pasted variable name (logOutputinstead ofseleniumVersion).ProjectPage→SecuredPage→EditIssue) end-to-end, so the type-level correctness of the whole example is actually verified by the build. It's marked@Disabledsince running it would exercise live GitHub/Google sign-in flows against real external sites.mvn test-compileandmvn testthat everything compiles and the disabled test is properly skipped (not silently ignored).gh-codeblockline range against the final file content to make sure each one shows exactly the intended snippet.Motivation and Context
Keeps the Java examples in this doc consistent with how other docs in this repo already work (tested source +
gh-codeblock, rather than inline snippets that can silently drift or contain uncaught bugs), and fixes latent bugs in the existing content along the way.Types of changes
Checklist