Playwright E2E Testing for Kubernetes Dashboard Extension
This extension runs inside Podman Desktop as a webview. E2E tests launch Podman Desktop via Electron, install the extension from an OCI image, then interact with the extension's webview UI.
Project Structure
tests/playwright/
├── src/
│ ├── extension.spec.ts # Main E2E spec file
│ └── ...
├── resources/
│ └── envtest-kubeconfig # Test kubeconfig (copied from /tmp/)
├── playwright.config.ts # Playwright configuration
└── package.json
Prerequisites
E2E tests require a local Kubernetes API server via envtest (Kubebuilder):
- Install
setup-envtest:go install sigs.k8s.io/controller-runtime/tools/setup-envtest@release-0.24 - Install
envtest-start:go install github.com/feloy/envtest-start@latest - Set up assets and start:
export KUBEBUILDER_ASSETS=$(setup-envtest use -p path) envtest-start --fake-kubelet & - Copy kubeconfig:
cp /tmp/envtest-kubeconfig tests/resources/
Running Tests
# Set the Podman Desktop binary path
export PODMAN_DESKTOP_BINARY=/path/to/podman-desktop
# First run (installs extension)
pnpm test:e2e
# Subsequent runs (skip install)
EXTENSION_PREINSTALLED=true pnpm test:e2e
Test Framework
Tests use @podman-desktop/tests-playwright which provides:
test— Extended Playwright test with Podman Desktop fixturesexpect/playExpect— AssertionsRunnerOptions— Test runner configurationPreferencesPage,NavigationBar, etc. — Page objects
Spec File Pattern
import { test, expect as playExpect, RunnerOptions } from '@podman-desktop/tests-playwright';
test.beforeAll(async ({ runner, welcomePage }) => {
test.setTimeout(80_000);
runner.setVideoAndTraceName('kubernetes-dashboard-e2e');
await welcomePage.handleWelcomePage(true);
});
test.describe('Feature group', { tag: ['@integration'] }, () => {
test('should do something', async ({ navigationBar }) => {
const dashboardPage = await navigationBar.openDashboard();
// interact with pages
});
});
CI Integration
E2E tests are not run by default on PRs. Add the area/ci/e2e label to
trigger them. The CI workflow is in .github/workflows/e2e-tests.yaml.
Test Tags
@integration— Full integration tests (requires auth)@anonymous— Tests that run without Kubernetes authentication