diff --git a/docs/api/playwright/global-setup.md b/docs/api/playwright/global-setup.md index 420e1fe..4386728 100644 --- a/docs/api/playwright/global-setup.md +++ b/docs/api/playwright/global-setup.md @@ -56,14 +56,15 @@ Create your own that calls the default: ```typescript // global-setup.ts -import { globalSetup as defaultSetup } from "@red-hat-developer-hub/e2e-test-utils/playwright-config"; +import { type FullConfig } from "@playwright/test"; +import defaultSetup from "@red-hat-developer-hub/e2e-test-utils/global-setup"; -export default async function globalSetup() { +export default async function globalSetup(config: FullConfig) { // Your custom setup console.log("Custom setup starting..."); // Call default setup - await defaultSetup(); + await defaultSetup(config); // More custom setup console.log("Custom setup complete"); @@ -73,9 +74,10 @@ export default async function globalSetup() { ```typescript // playwright.config.ts import { defineConfig } from "@red-hat-developer-hub/e2e-test-utils/playwright-config"; +import { fileURLToPath } from "url"; export default defineConfig({ - globalSetup: require.resolve("./global-setup"), + globalSetup: fileURLToPath(new URL("./global-setup.ts", import.meta.url)), projects: [{ name: "my-plugin" }], }); ``` diff --git a/docs/changelog.md b/docs/changelog.md index 41a6393..d6b43d9 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. +## [1.1.35] + +### Fixed + +- **Export `globalSetup` and allow override in `defineConfig`**: Added missing `./global-setup` export to `package.json` and updated `defineConfig` to accept `globalSetup` parameter. Custom global setup functions can now properly import and extend the default setup. Documentation updated with correct ESM import syntax using `fileURLToPath(new URL(...))` instead of `require.resolve()`. +- **Normalize `-dynamic` suffix in `extractPluginName`**: Plugins whose metadata `dynamicArtifact` is a local path (ending in `-dynamic`) were not matched during PR OCI resolution or config injection, because the metadata map key included the `-dynamic` suffix while OCI URL lookups did not. `extractPluginName` now strips the `-dynamic` suffix so local paths and OCI refs for the same logical plugin produce the same key. ([RHDHBUGS-2987](https://issues.redhat.com/browse/RHDHBUGS-2987)) + ## [1.1.34] - Current ### Added @@ -21,11 +28,6 @@ All notable changes to this project will be documented in this file. - **Automatic Vault secret loading for local development**: Set `VAULT=1` or `VAULT=true` to automatically fetch secrets from HashiCorp Vault during global setup. Handles OIDC login, fetches global and per-workspace secrets, and injects them into `process.env`. Only secret key names are logged, never values. Configurable via `VAULT_ADDR` and `VAULT_BASE_PATH` env vars. Logs a Slack channel (`#rhdh-e2e-tests`) when permission is denied. -## [1.1.32] - -### Fixed - -- **Normalize `-dynamic` suffix in `extractPluginName`**: Plugins whose metadata `dynamicArtifact` is a local path (ending in `-dynamic`) were not matched during PR OCI resolution or config injection, because the metadata map key included the `-dynamic` suffix while OCI URL lookups did not. `extractPluginName` now strips the `-dynamic` suffix so local paths and OCI refs for the same logical plugin produce the same key. ([RHDHBUGS-2987](https://issues.redhat.com/browse/RHDHBUGS-2987)) ## [1.1.31] diff --git a/package.json b/package.json index 884f180..fdc9e53 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@red-hat-developer-hub/e2e-test-utils", - "version": "1.1.34", + "version": "1.1.35", "description": "Test utilities for RHDH E2E tests", "license": "Apache-2.0", "repository": { @@ -52,6 +52,10 @@ "./orchestrator": { "types": "./dist/deployment/orchestrator/index.d.ts", "default": "./dist/deployment/orchestrator/index.js" + }, + "./global-setup": { + "types": "./dist/playwright/global-setup.d.ts", + "default": "./dist/playwright/global-setup.js" } }, "publishConfig": { diff --git a/src/playwright/base-config.ts b/src/playwright/base-config.ts index 398ed13..f24df6d 100644 --- a/src/playwright/base-config.ts +++ b/src/playwright/base-config.ts @@ -41,16 +41,17 @@ export const baseConfig: PlaywrightTestConfig = { /** * Defines a workspace-specific config by merging with base config. - * Only allows overriding the projects configuration. - * @param overrides - Object containing projects to override + * Allows overriding the projects and globalSetup configuration. + * @param overrides - Object containing projects and optionally globalSetup to override * @returns Merged Playwright configuration */ export function defineConfig( - overrides: Pick = {}, + overrides: Pick = {}, ): PlaywrightTestConfig { return baseDefineConfig({ ...baseConfig, projects: overrides.projects, + ...(overrides.globalSetup && { globalSetup: overrides.globalSetup }), }); }