rhdh-e2e-test-utils 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,6 +21,7 @@ A comprehensive test utility package for Red Hat Developer Hub (RHDH) end-to-end
21
21
  - [Environment Variables](#environment-variables)
22
22
  - [Examples](#examples)
23
23
  - [Development](#development)
24
+ - [Testing Local Changes in Consumer Projects](#testing-local-changes-in-consumer-projects)
24
25
 
25
26
  ## Overview
26
27
 
@@ -562,6 +563,80 @@ yarn build
562
563
  | `yarn prettier:check` | Check code formatting |
563
564
  | `yarn prettier:fix` | Auto-fix code formatting |
564
565
 
566
+ ### Testing Local Changes in Consumer Projects
567
+
568
+ When developing features or fixes in `rhdh-e2e-test-utils`, you can test your local changes in a consumer project (e.g., a plugin's e2e-tests) before publishing.
569
+
570
+ #### 1. Build your local changes
571
+
572
+ ```bash
573
+ cd /path/to/rhdh-e2e-test-utils
574
+ yarn build
575
+ ```
576
+
577
+ #### 2. Update the consumer project's package.json
578
+
579
+ In your e2e-tests project, update the dependency to point to your local package using the `file:` protocol:
580
+
581
+ ```json
582
+ "rhdh-e2e-test-utils": "file:/path/to/rhdh-e2e-test-utils"
583
+ ```
584
+
585
+ Example:
586
+ ```json
587
+ "rhdh-e2e-test-utils": "file:/Users/yourname/Documents/rhdh/rhdh-e2e-test-utils"
588
+ ```
589
+
590
+ #### 3. Install dependencies in the consumer project
591
+
592
+ ```bash
593
+ yarn install
594
+ ```
595
+
596
+ #### 4. Run tests with NODE_PRESERVE_SYMLINKS
597
+
598
+ When running tests with a local symlinked package, you **must** set the `NODE_PRESERVE_SYMLINKS` environment variable:
599
+
600
+ ```bash
601
+ NODE_PRESERVE_SYMLINKS=1 yarn test
602
+ NODE_PRESERVE_SYMLINKS=1 yarn test:headed
603
+ NODE_PRESERVE_SYMLINKS=1 yarn test:ui
604
+ ```
605
+
606
+ > **Why is NODE_PRESERVE_SYMLINKS needed?**
607
+ >
608
+ > When using local packages via `file:` protocol, the package manager creates a symlink. Node.js follows symlinks by default and tries to resolve peer dependencies (like `@playwright/test`) from the original package location. This causes duplicate Playwright instances which fails with:
609
+ > ```
610
+ > Error: Requiring @playwright/test second time
611
+ > ```
612
+ > Setting `NODE_PRESERVE_SYMLINKS=1` tells Node.js to resolve dependencies from the symlink location (your project's `node_modules`) instead of the original package location.
613
+
614
+ #### 5. Rebuild after making changes
615
+
616
+ When you make further changes to `rhdh-e2e-test-utils`, rebuild before running tests:
617
+
618
+ ```bash
619
+ cd /path/to/rhdh-e2e-test-utils
620
+ yarn build
621
+ ```
622
+
623
+ Then run your tests again in the consumer project (no need to reinstall).
624
+
625
+ #### 6. Restore the published version
626
+
627
+ After testing, restore the published version in the consumer project's `package.json`:
628
+
629
+ ```json
630
+ "rhdh-e2e-test-utils": "^1.0.0"
631
+ ```
632
+
633
+ Then run:
634
+ ```bash
635
+ yarn install
636
+ ```
637
+
638
+ You can now run tests normally without `NODE_PRESERVE_SYMLINKS`.
639
+
565
640
  ### CI/CD
566
641
 
567
642
  The project includes GitHub Actions workflows:
@@ -0,0 +1,6 @@
1
+ app:
2
+ baseUrl: "${RHDH_BASE_URL}"
3
+ backend:
4
+ baseUrl: "${RHDH_BASE_URL}"
5
+ cors:
6
+ origin: "${RHDH_BASE_URL}"
@@ -0,0 +1,2 @@
1
+ includes:
2
+ - dynamic-plugins.default.yaml
@@ -0,0 +1,7 @@
1
+ apiVersion: v1
2
+ kind: Secret
3
+ metadata:
4
+ name: rhdh-secrets
5
+ type: Opaque
6
+ stringData:
7
+ RHDH_BASE_URL: $RHDH_BASE_URL
@@ -2,9 +2,9 @@ import path from "path";
2
2
  // Navigate from dist/deployment/rhdh/ to package root
3
3
  const PACKAGE_ROOT = path.resolve(import.meta.dirname, "../../..");
4
4
  export const DEFAULT_CONFIG_PATHS = {
5
- appConfig: path.join(PACKAGE_ROOT, "src/deployment/rhdh/config/app-config-rhdh.yaml"),
6
- secrets: path.join(PACKAGE_ROOT, "src/deployment/rhdh/config/rhdh-secrets.yaml"),
7
- dynamicPlugins: path.join(PACKAGE_ROOT, "src/deployment/rhdh/config/dynamic-plugins.yaml"),
5
+ appConfig: path.join(PACKAGE_ROOT, "dist/deployment/rhdh/config/app-config-rhdh.yaml"),
6
+ secrets: path.join(PACKAGE_ROOT, "dist/deployment/rhdh/config/rhdh-secrets.yaml"),
7
+ dynamicPlugins: path.join(PACKAGE_ROOT, "dist/deployment/rhdh/config/dynamic-plugins.yaml"),
8
8
  helm: {
9
9
  valueFile: path.join(PACKAGE_ROOT, "src/deployment/rhdh/helm/value_file.yaml"),
10
10
  },
@@ -0,0 +1,7 @@
1
+ upstream:
2
+ backstage:
3
+ extraAppConfig:
4
+ - configMapRef: app-config-rhdh
5
+ filename: app-config-rhdh.yaml
6
+ extraEnvVarsSecrets:
7
+ - rhdh-secrets
@@ -0,0 +1,21 @@
1
+ apiVersion: rhdh.redhat.com/v1alpha3
2
+ kind: Backstage
3
+ metadata:
4
+ name: developer-hub
5
+ spec:
6
+ application:
7
+ appConfig:
8
+ configMaps:
9
+ - name: app-config-rhdh
10
+ mountPath: /opt/app-root/src
11
+ extraFiles:
12
+ mountPath: /opt/app-root/src
13
+ replicas: 1
14
+ route:
15
+ enabled: true
16
+ dynamicPluginsConfigMapName: dynamic-plugins
17
+ extraEnvs:
18
+ secrets:
19
+ - name: rhdh-secrets
20
+ database:
21
+ enableLocalDb: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhdh-e2e-test-utils",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Test utilities for RHDH E2E tests",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -31,13 +31,10 @@
31
31
  },
32
32
  "files": [
33
33
  "dist",
34
- "tsconfig.base.json",
35
- "src/deployment/rhdh/config",
36
- "src/deployment/rhdh/helm",
37
- "src/deployment/rhdh/operator"
34
+ "tsconfig.base.json"
38
35
  ],
39
36
  "scripts": {
40
- "build": "yarn clean && tsc -p tsconfig.build.json",
37
+ "build": "yarn clean && tsc -p tsconfig.build.json && cp -r src/deployment/rhdh/config src/deployment/rhdh/helm src/deployment/rhdh/operator dist/deployment/rhdh/",
41
38
  "check": "yarn typecheck && yarn lint:check && yarn prettier:check",
42
39
  "clean": "rm -rf dist",
43
40
  "lint:check": "eslint . --ignore-pattern dist --ignore-pattern README.md",