Skip to content

docs: add Playwright page object design conventions - #1154

Open
mrrajan wants to merge 1 commit into
guacsec:mainfrom
mrrajan:TC-5191
Open

docs: add Playwright page object design conventions#1154
mrrajan wants to merge 1 commit into
guacsec:mainfrom
mrrajan:TC-5191

Conversation

@mrrajan

@mrrajan mrrajan commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Add two E2E testing conventions to CONVENTIONS.md under the Playwright section:

  • No explicit timeouts in shared page objects (Playwright auto-waiting handles element readiness)
  • Composition over conditional expansion in page object methods (single responsibility)

Implements TC-5191

Summary by Sourcery

Document Playwright page object design conventions for shared UI components.

Documentation:

  • Add guidance to avoid explicit timeouts in shared Playwright page objects and delegate async waits to page-specific objects.
  • Clarify that page object methods should follow single-responsibility principles, favoring composition over conditional logic in action methods.

Document two E2E testing conventions identified during TC-3811
verification: no explicit timeouts in shared page objects, and
composition over conditional expansion in page object methods.

Implements TC-5191

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assisted-by: Claude Code
@sourcery-ai

sourcery-ai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates testing conventions documentation to add two Playwright page object design rules around timeouts and method responsibilities.

Flow diagram for Playwright page object design conventions

flowchart TD
  PageObjectMethod["Designing a Playwright page object method"]

  PageObjectMethod --> TimeoutDecision["Need to wait for async UI change?"]
  TimeoutDecision -->|Yes| SpecificPageObjectWait["Add wait in specific page object (e.g., SbomListPage)"]
  TimeoutDecision -->|No| NoWaitNeeded["Rely on Playwright auto-waiting"]

  SpecificPageObjectWait --> SharedObjects["Shared objects: Table, Toolbar, Pagination, Navigation"]
  SharedObjects --> NoTimeout["Do not add timeout parameters in shared objects"]

  PageObjectMethod --> ResponsibilityCheck["Does the method do more than one thing?"]
  ResponsibilityCheck -->|Yes| SplitMethods["Split into multiple single-responsibility methods"]
  ResponsibilityCheck -->|No| KeepMethodSimple["Keep method focused (e.g., clearAllFilters only clears filters)"]
Loading

File-Level Changes

Change Details Files
Document new Playwright page object conventions regarding timeouts and composition of methods.
  • Add a rule that shared page objects must not use explicit timeout parameters and should rely on Playwright auto-waiting, with async waits placed in feature-specific page objects instead of shared infrastructure.
  • Add a rule that page object methods should follow single-responsibility, avoiding conditional guards inside action methods and delegating existence checks to callers.
CONVENTIONS.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The rule about no explicit timeouts in shared page objects could benefit from clarifying acceptable exceptions (e.g., using expect timeouts or handling known slow backends) to avoid confusion in edge cases.
  • For the composition guideline, consider explicitly distinguishing between page objects and higher-level test helpers so it’s clear where conditional guards or orchestration logic are expected to live instead of in simple action methods.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The rule about no explicit timeouts in shared page objects could benefit from clarifying acceptable exceptions (e.g., using `expect` timeouts or handling known slow backends) to avoid confusion in edge cases.
- For the composition guideline, consider explicitly distinguishing between page objects and higher-level test helpers so it’s clear where conditional guards or orchestration logic are expected to live instead of in simple action methods.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.30%. Comparing base (058cf8b) to head (103317a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1154      +/-   ##
==========================================
- Coverage   53.33%   53.30%   -0.04%     
==========================================
  Files         270      270              
  Lines        5880     5878       -2     
  Branches     1842     1848       +6     
==========================================
- Hits         3136     3133       -3     
+ Misses       2443     2441       -2     
- Partials      301      304       +3     
Flag Coverage Δ
e2e 70.95% <ø> (-0.07%) ⬇️
unit 7.02% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant