-
Notifications
You must be signed in to change notification settings - Fork 702
CONSOLE-5292: Migrate OLM enabled tests to playwright #16450
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
Open
Cragsmann
wants to merge
2
commits into
openshift:main
Choose a base branch
from
Cragsmann:CONSOLE-5292-Migrate-OLM-enabled-tests-to-playwright
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import type { Locator, Page } from '@playwright/test'; | ||
| import { expect } from '@playwright/test'; | ||
|
|
||
| import BasePage from './base-page'; | ||
|
|
||
| export class DetailsPage extends BasePage { | ||
| private readonly pageHeading = this.page.locator('[data-test="page-heading"]'); | ||
| private readonly resourceTitle = this.page.locator('[data-test-id="resource-title"]'); | ||
| private readonly skeletonDetailView = this.page.getByTestId('skeleton-detail-view'); | ||
| private readonly actionsMenuButton = this.page.locator('[data-test-id="actions-menu-button"]'); | ||
|
|
||
| constructor(page: Page) { | ||
| super(page); | ||
| } | ||
|
|
||
| async isLoaded(): Promise<void> { | ||
| await expect(this.skeletonDetailView).not.toBeAttached({ timeout: 30_000 }); | ||
| await expect(this.resourceTitle).not.toBeEmpty({ timeout: 30_000 }); | ||
| } | ||
|
|
||
| async titleShouldContain(title: string): Promise<void> { | ||
| await expect(this.pageHeading).toBeAttached({ timeout: 30_000 }); | ||
| await expect(this.pageHeading).toContainText(title, { timeout: 30_000 }); | ||
| } | ||
|
|
||
| async sectionHeaderShouldExist(heading: string): Promise<void> { | ||
| await expect(this.page.locator(`[data-test-section-heading="${heading}"]`)).toBeAttached(); | ||
| } | ||
|
|
||
| async selectTab(name: string): Promise<void> { | ||
| const tab = this.page.locator(`[data-test-id="horizontal-link-${name}"]`); | ||
| await expect(tab).toBeAttached(); | ||
| await this.robustClick(tab); | ||
| await this.waitForLoadingComplete(); | ||
| } | ||
|
|
||
| async clickPageActionFromDropdown(actionID: string): Promise<void> { | ||
| await this.robustClick(this.actionsMenuButton); | ||
| await this.robustClick(this.page.locator(`[data-test-action="${actionID}"]:not([disabled])`)); | ||
| } | ||
|
|
||
| async clickPageActionButton(action: string): Promise<void> { | ||
| const actionButton = this.page.locator('[data-test-id="details-actions"]', { | ||
| hasText: action, | ||
| }); | ||
| await this.robustClick(actionButton); | ||
| } | ||
|
|
||
| sectionHeading(name: string): Locator { | ||
| return this.page.locator(`[data-test-section-heading="${name}"]`); | ||
| } | ||
|
|
||
| detailsItemLabel(name: string): Locator { | ||
| return this.page.locator(`[data-test-selector="details-item-label__${name}"]`); | ||
| } | ||
|
|
||
| detailsItemValue(name: string): Locator { | ||
| return this.page.locator(`[data-test-selector="details-item-value__${name}"]`); | ||
| } | ||
|
|
||
| horizontalNavTab(tabId: string): Locator { | ||
| return this.page.locator(`[data-test-id="horizontal-link-${tabId}"]`); | ||
| } | ||
|
|
||
| breadcrumb(index: number): Locator { | ||
| return this.page.locator(`[data-test-id="breadcrumb-link-${index}"]`); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import type { Locator, Page } from '@playwright/test'; | ||
| import { expect } from '@playwright/test'; | ||
|
|
||
| import BasePage from './base-page'; | ||
|
|
||
| export class ListPage extends BasePage { | ||
| private readonly pageHeading = this.page.locator('[data-test="page-heading"]'); | ||
| private readonly nameFilterInput = this.page.getByTestId('name-filter-input'); | ||
|
|
||
| constructor(page: Page) { | ||
| super(page); | ||
| } | ||
|
|
||
| async titleShouldHaveText(title: string): Promise<void> { | ||
| await expect(this.pageHeading).toHaveText(title); | ||
| } | ||
|
|
||
| async filterByName(name: string): Promise<void> { | ||
| await this.nameFilterInput.fill(name); | ||
| } | ||
|
|
||
| resourceRow(name: string): Locator { | ||
| return this.page.locator(`[data-test-rows="resource-row"]`, { hasText: name }); | ||
| } | ||
|
|
||
| async rowShouldExist(name: string): Promise<void> { | ||
| await expect(this.resourceRow(name)).toBeAttached(); | ||
| } | ||
|
|
||
| async rowShouldNotExist(name: string): Promise<void> { | ||
| await expect(this.resourceRow(name)).not.toBeAttached(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import type { Page } from '@playwright/test'; | ||
| import { expect } from '@playwright/test'; | ||
|
|
||
| import BasePage from './base-page'; | ||
|
|
||
| export class ModalPage extends BasePage { | ||
| private readonly cancelButton = this.page.locator('[data-test-id="modal-cancel-action"]'); | ||
| private readonly submitBtn = this.page.locator('button[type=submit]'); | ||
| private readonly modalTitle = this.page.locator('[data-test-id="modal-title"]'); | ||
|
|
||
| constructor(page: Page) { | ||
| super(page); | ||
| } | ||
|
|
||
| async shouldBeOpened(): Promise<void> { | ||
| await this.cancelButton.scrollIntoViewIfNeeded({ timeout: 20_000 }); | ||
| await expect(this.cancelButton).toBeVisible(); | ||
| } | ||
|
|
||
| async shouldBeClosed(): Promise<void> { | ||
| await expect(this.cancelButton).not.toBeAttached(); | ||
| } | ||
|
|
||
| async submit(force = false): Promise<void> { | ||
| await this.robustClick(this.submitBtn, { force }); | ||
| } | ||
|
|
||
| async cancel(force = false): Promise<void> { | ||
| await this.robustClick(this.cancelButton, { force }); | ||
| } | ||
|
|
||
| async modalTitleShouldContain(title: string): Promise<void> { | ||
| await expect(this.modalTitle).toContainText(title); | ||
| } | ||
|
|
||
| async submitShouldBeDisabled(): Promise<void> { | ||
| await expect(this.submitBtn).toBeDisabled(); | ||
| } | ||
|
|
||
| async submitShouldBeEnabled(): Promise<void> { | ||
| await expect(this.submitBtn).not.toBeDisabled(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import type { Page } from '@playwright/test'; | ||
|
|
||
| import BasePage from './base-page'; | ||
|
|
||
| export class NavPage extends BasePage { | ||
| private readonly sidebar = this.page.locator('#page-sidebar'); | ||
|
|
||
| constructor(page: Page) { | ||
| super(page); | ||
| } | ||
|
|
||
| async clickNavLink(path: string[]): Promise<void> { | ||
| if (path.length === 2) { | ||
| const parentButton = this.sidebar.getByRole('button', { name: path[0], exact: true }); | ||
| const isExpanded = | ||
| (await parentButton.getAttribute('aria-expanded').catch(() => null)) === 'true'; | ||
| if (!isExpanded) { | ||
| await this.robustClick(parentButton); | ||
| } | ||
| const childLink = this.sidebar | ||
| .getByRole('region', { name: path[0] }) | ||
| .getByRole('link', { name: path[1], exact: true }); | ||
| await this.robustClick(childLink); | ||
| } else { | ||
| const targetButton = this.sidebar.getByRole('button', { name: path[0], exact: true }); | ||
| await this.robustClick(targetButton); | ||
| } | ||
| await this.waitForLoadingComplete(); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle empty successful PATCH responses before JSON parsing.
Line 546 unconditionally parses
body; a valid 2xx response with an empty body will throw and incorrectly fail the patch flow.Proposed fix
res.on('end', () => { if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) { - resolve(JSON.parse(body)); + if (!body.trim()) { + resolve({}); + return; + } + resolve(JSON.parse(body)); } else { const msg = `Merge patch failed: HTTP ${res.statusCode} ${body.substring(0, 500)}`; reject(new Error(msg)); } });📝 Committable suggestion
🤖 Prompt for AI Agents