Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions docs/api/playwright/global-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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" }],
});
```
12 changes: 7 additions & 5 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]

Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down
7 changes: 4 additions & 3 deletions src/playwright/base-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlaywrightTestConfig, "projects"> = {},
overrides: Pick<PlaywrightTestConfig, "projects" | "globalSetup"> = {},
): PlaywrightTestConfig {
return baseDefineConfig({
...baseConfig,
projects: overrides.projects,
...(overrides.globalSetup && { globalSetup: overrides.globalSetup }),
});
}
Loading