-
Notifications
You must be signed in to change notification settings - Fork 748
OCPBUGS-111698: Migrate app/ Cypress e2e tests to Playwright #17015
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
Merged
openshift-merge-bot
merged 1 commit into
openshift:main
from
fsgreco:CONSOLE-5233-migrate-app-e2e
Aug 20, 2026
Merged
Changes from all commits
Commits
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
186 changes: 186 additions & 0 deletions
186
frontend/e2e/tests/console/app/admission-webhook-warning-notifications.spec.ts
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,186 @@ | ||
| import { test, expect } from '../../../fixtures'; | ||
| import { YamlEditorPage } from '../../../pages/yaml-editor-page'; | ||
|
|
||
| const POD_NAME = 'pod1'; | ||
| const DEPLOY_NAME = 'deploy1'; | ||
| const CONTAINER_NAME = 'container1'; | ||
| const WARNING_FOO = '299 - "[pod-must-have-label-foo] you must provide labels: {"foo"}"'; | ||
| const WARNING_BAR = '299 - "[deployment-must-have-label-bar] you must provide labels: {"bar"}"'; | ||
| const WARNING_ID = 'admission-webhook-warning'; | ||
| const LEARN_MORE_ID = 'admission-webhook-warning-learn-more'; | ||
|
|
||
| test.describe('Admission Webhook warning notification', () => { | ||
| let ns: string; | ||
|
|
||
| test.beforeAll(async ({ k8sClient }) => { | ||
| ns = `test-webhook-warn-${Date.now()}`; | ||
| await k8sClient.createNamespace(ns); | ||
| }); | ||
|
|
||
| test.afterAll(async ({ k8sClient }) => { | ||
| await k8sClient.deleteNamespace(ns); | ||
| }); | ||
|
|
||
| test('displays warning notification when creating a pod', async ({ page }) => { | ||
| const yamlEditorPage = new YamlEditorPage(page); | ||
|
|
||
| const podYaml = `apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: ${POD_NAME}-a | ||
| labels: | ||
| app: httpd | ||
| namespace: ${ns} | ||
| spec: | ||
| securityContext: | ||
| runAsNonRoot: true | ||
| seccompProfile: | ||
| type: RuntimeDefault | ||
| containers: | ||
| - name: ${CONTAINER_NAME} | ||
| image: 'image-registry.openshift-image-registry.svc:5000/openshift/httpd:latest' | ||
| ports: | ||
| - containerPort: 8080 | ||
| securityContext: | ||
| allowPrivilegeEscalation: false | ||
| capabilities: | ||
| drop: | ||
| - ALL`; | ||
|
|
||
| await yamlEditorPage.navigateToImportYaml(ns); | ||
| await yamlEditorPage.waitForEditorReady(); | ||
| await yamlEditorPage.setEditorContent(podYaml); | ||
|
|
||
| await page.route(`**/api/kubernetes/api/v1/namespaces/${ns}/pods`, async (route) => { | ||
| if (route.request().method() === 'POST') { | ||
| const response = await route.fetch(); | ||
| await route.fulfill({ | ||
| response, | ||
| headers: { ...response.headers(), Warning: WARNING_FOO }, | ||
| }); | ||
| } else { | ||
| await route.continue(); | ||
| } | ||
| }); | ||
|
|
||
| await yamlEditorPage.clickSave(); | ||
|
|
||
| await expect(page.getByTestId('section-heading-Pod details')).toBeVisible({ timeout: 30_000 }); | ||
| const warning = page.getByTestId(WARNING_ID); | ||
| await expect(warning).toContainText('Admission Webhook Warning', { timeout: 10_000 }); | ||
| await expect(warning).toContainText( | ||
| `Pod ${POD_NAME}-a violates policy ${WARNING_FOO}`, | ||
| ); | ||
| await expect(page.getByTestId(LEARN_MORE_ID)).toContainText('Learn more'); | ||
| await page.getByTestId(LEARN_MORE_ID).click(); | ||
| }); | ||
|
|
||
| test('displays warning notifications when creating bulk resources', async ({ page }) => { | ||
| const yamlEditorPage = new YamlEditorPage(page); | ||
|
|
||
| const bulkYaml = `apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: ${POD_NAME}-b | ||
| labels: | ||
| app: httpd | ||
| namespace: ${ns} | ||
| spec: | ||
| securityContext: | ||
| runAsNonRoot: true | ||
| seccompProfile: | ||
| type: RuntimeDefault | ||
| containers: | ||
| - name: ${CONTAINER_NAME} | ||
| image: 'image-registry.openshift-image-registry.svc:5000/openshift/httpd:latest' | ||
| ports: | ||
| - containerPort: 8080 | ||
| securityContext: | ||
| allowPrivilegeEscalation: false | ||
| capabilities: | ||
| drop: | ||
| - ALL | ||
| --- | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: ${DEPLOY_NAME} | ||
| namespace: ${ns} | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| app: deploy1 | ||
| replicas: 3 | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: deploy1 | ||
| spec: | ||
| containers: | ||
| - name: ${CONTAINER_NAME} | ||
| image: >- | ||
| image-registry.openshift-image-registry.svc:5000/openshift/httpd:latest | ||
| ports: | ||
| - containerPort: 8080 | ||
| protocol: TCP | ||
| env: | ||
| - name: app | ||
| value: frontennd | ||
| imagePullSecrets: [] | ||
| strategy: | ||
| type: RollingUpdate | ||
| rollingUpdate: | ||
| maxSurge: 25% | ||
| maxUnavailable: 25% | ||
| paused: false`; | ||
|
|
||
| await yamlEditorPage.navigateToImportYaml(ns); | ||
| await yamlEditorPage.waitForEditorReady(); | ||
| await yamlEditorPage.setEditorContent(bulkYaml); | ||
|
|
||
| await page.route(`**/api/kubernetes/api/v1/namespaces/${ns}/pods`, async (route) => { | ||
| if (route.request().method() === 'POST') { | ||
| const response = await route.fetch(); | ||
| await route.fulfill({ | ||
| response, | ||
| headers: { ...response.headers(), Warning: WARNING_FOO }, | ||
| }); | ||
| } else { | ||
| await route.continue(); | ||
| } | ||
| }); | ||
|
|
||
| await page.route( | ||
| `**/api/kubernetes/apis/apps/v1/namespaces/${ns}/deployments`, | ||
| async (route) => { | ||
| if (route.request().method() === 'POST') { | ||
| const response = await route.fetch(); | ||
| await route.fulfill({ | ||
| response, | ||
| headers: { ...response.headers(), Warning: WARNING_BAR }, | ||
| }); | ||
| } else { | ||
| await route.continue(); | ||
| } | ||
| }, | ||
| ); | ||
|
|
||
| await yamlEditorPage.clickSave(); | ||
|
|
||
| await expect(page.getByTestId('resources-successfully-created')).toContainText( | ||
| 'Resources successfully created', | ||
| { timeout: 30_000 }, | ||
| ); | ||
| const warning = page.getByTestId(WARNING_ID); | ||
| await expect(warning).toHaveCount(2, { timeout: 10_000 }); | ||
| await expect(warning.first()).toContainText('Admission Webhook Warning'); | ||
| await expect( | ||
| warning.filter({ hasText: `Pod ${POD_NAME}-b violates policy ${WARNING_FOO}` }), | ||
| ).toBeVisible(); | ||
| await expect( | ||
| warning.filter({ hasText: `Deployment ${DEPLOY_NAME} violates policy ${WARNING_BAR}` }), | ||
| ).toBeVisible(); | ||
| await expect(page.getByTestId(LEARN_MORE_ID).first()).toContainText('Learn more'); | ||
| await page.getByTestId(LEARN_MORE_ID).first().click(); | ||
| }); | ||
| }); |
105 changes: 105 additions & 0 deletions
105
frontend/e2e/tests/console/app/auth-multiuser-login.spec.ts
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,105 @@ | ||
| import { test, expect } from '../../../fixtures'; | ||
| import { performLogin } from '../../../setup/login-helper'; | ||
|
|
||
| const KUBEADMIN_IDP = 'kube:admin'; | ||
| const KUBEADMIN_USERNAME = 'kubeadmin'; | ||
|
|
||
| test.describe('Auth test', () => { | ||
| test.use({ storageState: { cookies: [], origins: [] } }); | ||
|
|
||
| test('logs in as test user via htpasswd identity provider', async ({ page }) => { | ||
| const htpasswdPassword = process.env.BRIDGE_HTPASSWD_PASSWORD; | ||
| const idp = process.env.BRIDGE_HTPASSWD_IDP || 'test'; | ||
| const username = process.env.BRIDGE_HTPASSWD_USERNAME || 'test'; | ||
| const baseURL = process.env.WEB_CONSOLE_URL || 'http://localhost:9000'; | ||
|
|
||
| test.skip(!htpasswdPassword, 'BRIDGE_HTPASSWD_PASSWORD not set'); | ||
|
|
||
| await performLogin(page, baseURL, username, htpasswdPassword, idp); | ||
| await expect(page).toHaveURL(new RegExp(baseURL.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')), { | ||
| timeout: 30_000, | ||
| }); | ||
|
|
||
| await test.step('Verify username is displayed', async () => { | ||
| await expect(page.getByTestId('user-dropdown-toggle')).toHaveText(username, { | ||
| timeout: 30_000, | ||
| }); | ||
| }); | ||
|
|
||
| await test.step('Switch to Admin perspective', async () => { | ||
| const toggle = page.getByTestId('perspective-switcher-toggle'); | ||
| await toggle.click(); | ||
| const adminOption = page | ||
| .getByTestId('perspective-switcher-menu-option') | ||
| .filter({ hasText: 'Core platform' }); | ||
| await adminOption.click(); | ||
| await expect(toggle).toContainText('Core platform', { timeout: 30_000 }); | ||
| }); | ||
|
|
||
| await test.step('Verify restricted admin nav items are not visible', async () => { | ||
| const sidebar = page.locator('#page-sidebar'); | ||
| await expect(sidebar).toBeVisible({ timeout: 30_000 }); | ||
|
|
||
| for (const section of ['Compute', 'Monitoring']) { | ||
| await expect(sidebar.getByRole('button', { name: section })).not.toBeAttached({ | ||
| timeout: 30_000, | ||
| }); | ||
| } | ||
|
|
||
| for (const link of [ | ||
| 'Cluster Status', | ||
| 'Cluster Settings', | ||
| 'Namespaces', | ||
| 'Custom Resource Definitions', | ||
| 'Software Catalog', | ||
| 'Persistent Volumes', | ||
| ]) { | ||
| await expect(sidebar.getByRole('link', { name: link })).not.toBeAttached(); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| test('logs in as kubeadmin user', async ({ page }) => { | ||
| const kubeadminPassword = process.env.BRIDGE_KUBEADMIN_PASSWORD; | ||
| const baseURL = process.env.WEB_CONSOLE_URL || 'http://localhost:9000'; | ||
|
|
||
| test.skip(!kubeadminPassword, 'BRIDGE_KUBEADMIN_PASSWORD not set'); | ||
|
|
||
| await performLogin(page, baseURL, KUBEADMIN_USERNAME, kubeadminPassword!, KUBEADMIN_IDP); | ||
| await expect(page.getByTestId('loading-indicator')).not.toBeAttached({ timeout: 30_000 }); | ||
|
|
||
| await test.step('Verify kubeadmin username', async () => { | ||
| await expect(page.getByTestId('user-dropdown-toggle')).toHaveText(KUBEADMIN_IDP, { | ||
| timeout: 30_000, | ||
| }); | ||
| }); | ||
|
|
||
| await test.step('Verify temporary admin notification', async () => { | ||
| await expect(page.getByTestId('global-notifications')).toContainText( | ||
| 'You are logged in as a temporary administrative user', | ||
| { timeout: 30_000 }, | ||
| ); | ||
| }); | ||
|
|
||
| await test.step('Verify Admin perspective and nav sections', async () => { | ||
| const toggle = page.getByTestId('perspective-switcher-toggle'); | ||
| await expect(toggle).toContainText('Core platform', { timeout: 30_000 }); | ||
|
|
||
| const sidebar = page.locator('#page-sidebar'); | ||
| await expect(sidebar.getByRole('button', { name: 'Compute' })).toBeVisible({ | ||
| timeout: 30_000, | ||
| }); | ||
| await expect(sidebar.getByRole('button', { name: 'Administration' })).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('Navigate to Cluster Settings', async () => { | ||
| const sidebar = page.locator('#page-sidebar'); | ||
| const adminSection = sidebar.getByRole('button', { name: 'Administration' }); | ||
| await adminSection.click(); | ||
| await sidebar.getByRole('link', { name: 'Cluster Settings' }).click(); | ||
| await expect(page.getByTestId('cluster-settings-page-heading')).toBeVisible({ | ||
| timeout: 30_000, | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Validate
namespacebefore building the URL.Line 15-16 inserts the argument directly into a path. Reject empty values,
/,.., and other non-DNS-label input before callinggoTo. This prevents unintended route traversal when a caller supplies an invalid namespace.Proposed fix
async navigateToImportYaml(namespace = 'default'): Promise<void> { + if ( + namespace.length > 63 || + !/^[a-z0-9]([-a-z0-9]*[a-z0-9])?$/.test(namespace) + ) { + throw new Error('Invalid namespace'); + } await this.goTo(`/k8s/ns/${namespace}/import`); }📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Path instructions