Skip to content

Introduce Page Object Model for UI test suite (#600)#606

Merged
sharma1208 merged 3 commits into
OpenLiberty:mainfrom
sharma1208:pom-refactor
Jun 25, 2026
Merged

Introduce Page Object Model for UI test suite (#600)#606
sharma1208 merged 3 commits into
OpenLiberty:mainfrom
sharma1208:pom-refactor

Conversation

@sharma1208

Copy link
Copy Markdown
Contributor

Added src/test/pages/ to encapsulate VS Code UI interactions, and refactored the LSP/snippet/diagnostic, hover, and dev-mode action tests to use it. Assertions remain in the test files.

Page objects added:

  • EditorPage: open/clear a file, move cursor to end, replace text on a line, hover, and expose the raw editor for generic operations (getEditor).
  • ProblemsPage: hasDiagnostic() to check the Problems view for a message.
  • CodeAssistPage: insertSnippet() wrapping the content-assist trigger/select/ close flow, including the null guard and settle delay.
  • QuickFixPage: applyFix() wrapping the quick-fix menu keystroke and option selection.
  • DashboardPage: runAction()/getSection()/getProjectItem() wrapping the Liberty Tools sidebar section+item fetch and launchDashboardAction, with fresh re-fetch each call to avoid stale-element errors and the mac/non-mac action pairing hidden internally.

Tests refactored to use the page objects:

  • MavenTestLSPRestSnippetAndDiagnostic.ts
  • GradleTestLSPRestSnippetAndDiagnostic.ts
  • MavenTestLSPHover.ts / GradleTestLSPHover.ts
  • MavenTestDevModeActions.ts / GradleTestDevModeActions.ts

Test behavior is unchanged; existing test cases, timeouts, and logging are preserved.

#600

Add a page object layer under src/test/pages/ to encapsulate VS Code UI
interactions, and refactor the LSP/snippet/diagnostic, hover, and dev-mode
action tests to use it. Page objects expose intent-revealing methods and
return data; assertions remain in the test files.

Page objects added:
- EditorPage: open/clear a file, move cursor to end, replace text on a line,
  hover, and expose the raw editor for generic operations (getEditor).
- ProblemsPage: hasDiagnostic() to check the Problems view for a message.
- CodeAssistPage: insertSnippet() wrapping the content-assist trigger/select/
  close flow, including the null guard and settle delay.
- QuickFixPage: applyFix() wrapping the quick-fix menu keystroke and option
  selection.
- DashboardPage: runAction()/getSection()/getProjectItem() wrapping the
  Liberty Tools sidebar section+item fetch and launchDashboardAction, with
  fresh re-fetch each call to avoid stale-element errors and the mac/non-mac
  action pairing hidden internally.

Tests refactored to use the page objects:
- MavenTestLSPRestSnippetAndDiagnostic.ts
- GradleTestLSPRestSnippetAndDiagnostic.ts
- MavenTestLSPHover.ts / GradleTestLSPHover.ts
- MavenTestDevModeActions.ts / GradleTestDevModeActions.ts

UI mechanics (drivers, selectors, command IDs, section/item bookkeeping) move
out of the test files into the page objects. Test behavior is unchanged;
existing test cases, timeouts, and logging are preserved.
Comment thread src/test/pages/ProblemsPage.ts
@mattbsox mattbsox requested a review from goldenryan June 24, 2026 18:29

@goldenryan goldenryan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Awesome work on this :) Just one comment

Comment thread src/test/pages/EditorPage.ts
EditorPage now only models the page object (openFile, getEditor).
The utility methods clear, moveCursorToEnd, replaceTextWithinLineContaining,
and hoverOver have been moved to src/test/utils/editorUtils.ts as standalone
exported functions, per code review feedback.

@mattbsox mattbsox left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can add some missing file copyrights too

/*
 * IBM Confidential
 * Copyright IBM Corp. 2026
 */

@sharma1208 sharma1208 merged commit f69b066 into OpenLiberty:main Jun 25, 2026
14 of 16 checks passed
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.

3 participants