Skip to content

Conversation

@nhudinh0309
Copy link

@nhudinh0309 nhudinh0309 commented Dec 12, 2025

This PR introduces a significant refactoring of the UI test helpers to improve code maintainability, reduce duplication, and provide more consistent test behavior.

What's Changed

New BasePage class - A foundational class that provides reusable Playwright interaction methods:

  • Click, hover, and fill operations with built-in waits
  • Common assertions (visibility, text content, count)
  • Configurable timeouts and retry logic
  • Consistent error handling

Refactored architecture - UiBaseLocators now extends BasePage, meaning all UI helpers automatically inherit these common methods. This creates a cleaner inheritance chain:
BasePage → UiBaseLocators → [Domain]UiHelper

Standardized timeouts - Added time constants to ConstantHelper for consistent wait durations across all helpers, making it easier to tune for different CI environments.

Stability improvements - Fixed various locator selectors and added strategic waits to reduce flaky tests in CI pipelines.

Why This Matters

This refactoring makes it significantly easier to:

  1. Add new UI helpers with consistent behavior
  2. Debug test failures (centralized wait/retry logic)
  3. Adjust timeouts globally when needed
  4. Maintain the codebase long-term

nhudinh0309 and others added 30 commits December 11, 2025 11:41
- Add wait-related methods to BasePage (waitForEnabled, waitForText, waitForURL, etc.)
- Add timeout and wait constants to ConstantHelper for consistent timing
- Refactor UiBaseLocators to use BasePage methods (click, enterText, isVisible, etc.)
- Replace hardcoded timeout values with ConstantHelper constants
- Export BasePage from index.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ation

- Organize 160+ locators into 25 logical region groups
- Organize 150+ methods into corresponding region groups
- Group related functionality: Core Actions, Folders, Navigation, Modals, Document Types, Properties, Validation, Media, Block Elements, etc.
- Improve code navigation and maintainability

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Replace #region/#endregion blocks with simple separator comments
- Format all comments as '// Comment here' with proper spacing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…tion

- Replace Playwright .click() with this.click() from BasePage
- Add treeItem locator for tree item elements
- Add getMenuItemByLabel() helper method to avoid repeated locator pattern
- Use template literals for cleaner string interpolation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Replace direct Playwright calls with BasePage wrapper methods (click, enterText, hover) across all UI helpers for consistency and maintainability. Also standardizes hardcoded timeout values to use ConstantHelper constants.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace direct Playwright calls with BasePage wrapper methods (click, enterText, hover, waitForVisible) across all remaining UI helpers. Standardizes hardcoded timeout values to use ConstantHelper constants and uses template literals for string concatenation.

Files refactored:
- DataTypeUiHelper.ts
- FormsUiHelper.ts
- ContentUiHelper.ts
- LogViewerUiHelper.ts
- PublishedStatusUiHelper.ts
- RedirectManagementUiHelper.ts
- HealthCheckUiHelper.ts
- ExamineManagementUiHelper.ts
- ProfilingUiHelper.ts
- ModelsBuilderUiHelper.ts
- TelemetryDataUiHelper.ts
- WelcomeDashboardUiHelper.ts
- InstallUiHelper.ts
- CurrentUserProfileUiHelper.ts
- MediaTypeUiHelper.ts
- WebhookUiHelper.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Further simplify text input methods by using enterText wrapper for remaining clear/fill patterns.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace clear/fill patterns with enterText wrapper for enterContentName, enterTextstring, and enterTextArea methods.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace expect().toBeVisible() calls with waitForVisible wrapper method for consistency. Also refactor ExternalLoginUiHelpers to use click and enterText methods.

Files updated:
- ExternalLoginUiHelpers.ts
- ContentUiHelper.ts
- UserGroupUiHelper.ts
- DictionaryUiHelper.ts
- MemberGroupUiHelper.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace hover + click patterns with the combined hoverAndClick wrapper method for cleaner code and consistent behavior when interacting with elements that appear on hover.

Files updated:
- ContentUiHelper.ts
- DataTypeUiHelper.ts
- FormsUiHelper.ts
- LanguageUiHelper.ts
- MediaUiHelper.ts
- UiBaseLocators.ts
- UserUiHelper.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace this.page.waitForLoadState() with this.waitForLoadState()
- Replace locator.press() with this.pressKey() for locator-based key presses
- Replace selectOption calls with selectByText/selectByValue/selectMultiple
- Simplify enterText patterns that use clear() before fill()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace expect().toBeVisible() with isVisible()/waitForVisible()
- Replace expect().toHaveText() with hasText()
- Replace expect().toContainText() with containsText()
- Replace expect().toHaveValue() with hasValue()
- Remove unused expect imports

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace toHaveCount assertions with hasCount() wrapper method from BasePage
and remove duplicate waitForCount method.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix isContentInTreeVisible to use getByLabel with exact match
- Fix typo in isChildContentInTreeVisible selector (extra bracket)
- Update doesBlockHaveIconColor to use color attribute selector
- Add wait after clicking confirm to publish button

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants