[Java] Reformated Design Strategies to Use Codeblocks#2308
Conversation
👷 Deploy request for selenium-dev pending review.Visit the deploys page to approve it
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||
|
Better implementation of #2301 |
|
Failures are unrelated to this pr |
| } | ||
| } | ||
|
|
||
| // class IssueList extends LoadableComponent<IssueList> { |
There was a problem hiding this comment.
can we remove commented code (or) is this intensional ?
There was a problem hiding this comment.
This is intentional so that there aren't failures, but the code is referenced in the docs. They were in their own codeblocks in docs and I pulled them out so we could better switch b/w languages for examples
There was a problem hiding this comment.
I can look into tweaking the docs a bit so these commented sections aren't necessary sometime soon
| } | ||
| } | ||
|
|
||
| // public class FooTest { |
|
Superseeded by #2732 |
…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]
…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
User description
Updated Design Strategies to use codeblock design for java examples and future
Types of changes
Checklist
PR Type
Enhancement, Documentation
Description
Refactored Java code examples in design strategies documentation to use code blocks
gh-codeblockreferences for maintainabilityAdded comprehensive Java example file
BestPractices.javafor code block inclusionImproved code snippet maintainability and translation readiness in documentation
Changes walkthrough 📝
BestPractices.java
Add comprehensive Java design strategies example fileexamples/java/src/test/java/dev/selenium/design_strategies/BestPractices.java
examples
EditIssue,IssueList,EditIssueBetter,ProjectPage,SecuredPage,ActionBot, and test classdesign_strategies.en.md
Refactor Java code examples to use code blocks in English docwebsite_and_docs/content/documentation/test_practices/design_strategies.en.md
gh-codeblockreferences to newJava file
documentation
design_strategies.ja.md
Refactor Java code examples to use code blocks in Japanese docwebsite_and_docs/content/documentation/test_practices/design_strategies.ja.md
gh-codeblockreferences to newJava file
design_strategies.pt-br.md
Refactor Java code examples to use code blocks in Portuguese docwebsite_and_docs/content/documentation/test_practices/design_strategies.pt-br.md
gh-codeblockreferences to newJava file
design_strategies.zh-cn.md
Refactor Java code examples to use code blocks in Chinese docwebsite_and_docs/content/documentation/test_practices/design_strategies.zh-cn.md
gh-codeblockreferences to newJava file