-
Notifications
You must be signed in to change notification settings - Fork 746
CONSOLE-5235: Migrate basic app Cypress e2e tests to Playwright #16431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { type Locator, expect } from '@playwright/test'; | ||
|
|
||
| import BasePage from './base-page'; | ||
|
|
||
| export class CatalogPage extends BasePage { | ||
| private readonly filterInput: Locator = this.page.getByPlaceholder('Filter by keyword'); | ||
|
|
||
| async navigateToCatalog(): Promise<void> { | ||
| await this.goTo('/catalog/all-namespaces'); | ||
| await expect(this.filterInput).toBeVisible({ timeout: 60_000 }); | ||
| } | ||
|
|
||
| async filterByKeyword(keyword: string): Promise<void> { | ||
| await this.filterInput.fill(keyword); | ||
| } | ||
|
|
||
| catalogItem(testId: string): Locator { | ||
| return this.page.getByTestId(testId); | ||
| } | ||
|
|
||
| catalogItemIcon(testId: string): Locator { | ||
| return this.catalogItem(testId).locator('img.catalog-tile-pf-icon'); | ||
| } | ||
|
Comment on lines
+6
to
+23
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win Prefer Line 6 ( As per coding guidelines: “Always use 🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. still better @stefanonardo here you could use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fsgreco the icon |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import type { Locator } from '@playwright/test'; | ||
| import { expect } from '@playwright/test'; | ||
|
|
||
| import BasePage from './base-page'; | ||
|
|
||
| export class LogsPage extends BasePage { | ||
| readonly lineCount: Locator = this.page.getByTestId('resource-log-no-lines'); | ||
| private readonly optionsToggle: Locator = this.page.getByTestId('resource-log-options-toggle'); | ||
| private readonly showFullLogOption: Locator = this.page.getByTestId('show-full-log'); | ||
| private readonly wrapLinesOption: Locator = this.page.getByTestId('wrap-lines'); | ||
| private readonly wrapCheckbox: Locator = this.wrapLinesOption.locator('input[type="checkbox"]'); | ||
| private readonly containerSelect: Locator = this.page.getByTestId('container-select'); | ||
| private readonly searchInput: Locator = this.page.getByPlaceholder('Search logs'); | ||
| readonly searchMatches: Locator = this.page.locator('.pf-m-match'); | ||
| readonly logText: Locator = this.page.locator('.pf-v6-c-log-viewer__text'); | ||
|
|
||
| async waitForLoaded(): Promise<void> { | ||
| await expect | ||
| .poll( | ||
| async () => { | ||
| if (await this.optionsToggle.isVisible().catch(() => false)) { | ||
| return true; | ||
| } | ||
| const tryAgain = this.page.getByRole('button', { name: 'Try again' }); | ||
| if (await tryAgain.isVisible().catch(() => false)) { | ||
| await this.page.reload({ waitUntil: 'domcontentloaded' }); | ||
| } | ||
| return false; | ||
| }, | ||
| { timeout: 30_000, intervals: [3_000] }, | ||
| ) | ||
| .toBe(true); | ||
| } | ||
|
|
||
| async toggleOptions(): Promise<void> { | ||
| await this.robustClick(this.optionsToggle); | ||
| } | ||
|
|
||
| async clickShowFullLog(): Promise<void> { | ||
| await this.toggleOptions(); | ||
| await this.robustClick(this.showFullLogOption); | ||
| } | ||
|
|
||
| async setWrap(enabled: boolean): Promise<void> { | ||
| await this.toggleOptions(); | ||
| if (enabled) { | ||
| await this.wrapCheckbox.check(); | ||
| } else { | ||
| await this.wrapCheckbox.uncheck(); | ||
| } | ||
| await this.toggleOptions(); | ||
| } | ||
|
|
||
| async isWrapChecked(): Promise<boolean> { | ||
| await this.toggleOptions(); | ||
| const checked = await this.wrapCheckbox.isChecked(); | ||
| await this.toggleOptions(); | ||
| return checked; | ||
| } | ||
|
|
||
| async selectContainer(name: string): Promise<void> { | ||
| await this.robustClick(this.containerSelect); | ||
| await this.robustClick(this.page.getByTestId(name)); | ||
| } | ||
|
|
||
| async searchLogs(text: string): Promise<void> { | ||
| await this.searchInput.fill(text); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.