Skip to content

Commit 5cbd460

Browse files
committed
Merge branch 'main' into scorecard-file-level-checks
2 parents bdb9d29 + 3a17273 commit 5cbd460

File tree

1,416 files changed

+162516
-41266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,416 files changed

+162516
-41266
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
description: Legacy vs NFS app migration and e2e testing (all workspaces)
3+
globs: workspaces/**/*
4+
alwaysApply: false
5+
---
6+
7+
# Legacy App & NFS App Migration and E2E Testing
8+
9+
Use this when working on migration between a legacy frontend and an NFS (new frontend system) app in **any workspace**, or when adding or changing e2e tests.
10+
11+
## App layout (when a workspace has both)
12+
13+
- **Legacy app**: typically `packages/app-legacy` — original Backstage frontend. Started with e.g. `backstage-cli repo start packages/app-legacy packages/backend`.
14+
- **NFS app**: typically `packages/app` — app using the new frontend system. Default `yarn start` (repo start).
15+
16+
Root `package.json` scripts to support:
17+
18+
- `start:legacy` — run legacy app + backend.
19+
- `start` — run NFS app (repo start).
20+
- `test:e2e:legacy` — e2e against legacy (`APP_MODE=legacy playwright test`).
21+
- `test:e2e:nfs` — e2e against NFS (`APP_MODE=nfs playwright test`).
22+
- `test:e2e:all` — run both (`yarn test:e2e:legacy && yarn test:e2e:nfs`).
23+
24+
When changing app behavior or navigation, consider impact on **both** apps and run both e2e suites where both exist.
25+
26+
## APP_MODE and Playwright
27+
28+
- `APP_MODE=legacy` → use legacy start command (e.g. `yarn start:legacy`).
29+
- `APP_MODE=nfs` → use NFS start command (e.g. `yarn start`).
30+
- In `playwright.config.ts`: `const appMode = process.env.APP_MODE || 'legacy'` and `const startCommand = appMode === 'legacy' ? 'yarn start:legacy' : 'yarn start'`.
31+
32+
Keep artifacts per mode so results don’t collide:
33+
34+
- Reporter output: `e2e-test-report-${appMode}`.
35+
- Test output dir: `node_modules/.cache/e2e-test-results-${appMode}`.
36+
37+
## E2E layout (workspace-agnostic)
38+
39+
Two valid patterns in this repo:
40+
41+
1. **Workspace-root e2e** — `e2e-tests/` at the workspace root. Shared utils in `e2e-tests/utils/`. Best when the same tests run against both legacy and NFS via `APP_MODE`.
42+
2. **App-scoped e2e** — `packages/app/e2e-tests/` (and optionally `packages/app/e2e-tests/utils/`). Used by many workspaces that only have one app.
43+
44+
When migrating a workspace to support both legacy and NFS, consider moving e2e from `packages/app/e2e-tests/` to workspace-root `e2e-tests/` so one suite is driven by `APP_MODE`. Set `testDir: 'e2e-tests'` in Playwright config for root layout, or `testDir: 'packages/app/e2e-tests'` for app-scoped.
45+
46+
**Locale/config overrides**: Use a `test_yamls/` dir (under the chosen e2e dir or a known path) with `app-config-e2e-{locale}.yaml` (or similar) to override `app.baseUrl` and `backend` (port, CORS) per locale. Playwright `projects` and `webServer` entries should match those configs and ports.
47+
48+
## Translations and locales in E2E
49+
50+
- Prefer **translation keys** from the plugin (e.g. `translations.some.key`) over hardcoded UI strings so tests work in all supported locales.
51+
- Load messages from the plugin’s translation modules (e.g. ref + locale files). Use a small util (e.g. `getTranslations(locale)`) in `e2e-tests/utils/` or `packages/app/e2e-tests/utils/`. Use eslint-disable for relative monorepo imports only where necessary.
52+
- For template strings with placeholders, use a `replaceTemplate(template, { key: value })` helper (e.g. replacing `{{key}}`).
53+
- For non‑default locale, switch via UI (e.g. Settings → language) in a `switchToLocale(page, locale)` helper and keep selectors/key usage locale-agnostic.
54+
55+
## Port mapping (multi-locale e2e)
56+
57+
When running multiple frontends/backends (e.g. one per locale), keep a consistent mapping so test code and configs stay in sync. Example pattern: frontend 3000, 3001, … and backend 7007, 7008, … (e.g. `backendPort = frontendPort + 4007`). Document the mapping in the workspace or in a comment in Playwright config / events helper.
58+
59+
## E2E helpers and quality
60+
61+
- **Shared logic**: Put reusable flows (navigation, panels, tables, date pickers, etc.) in `utils/` under the chosen e2e dir. Use the same helpers for legacy and NFS runs.
62+
- **Accessibility**: Run axe (e.g. `@axe-core/playwright`) with wcag tags; attach results to `TestInfo`; filter known false positives so only real violations fail the run.
63+
- **Timing**: After actions that trigger async or analytics, wait appropriately (e.g. a short delay or wait for network/UI) before assertions.
64+
65+
## Migration runbook (adding legacy + NFS to a workspace)
66+
67+
When a workspace currently has only one app and you need to support both legacy and NFS with shared e2e:
68+
69+
1. **Create or rename app packages**
70+
- If the current app is the new frontend: rename/copy it to `packages/app-legacy` (or create a legacy app) and keep the NFS app as `packages/app`.
71+
- Ensure root `package.json` has `start:legacy` (e.g. `backstage-cli repo start packages/app-legacy packages/backend`) and `start` (repo start for NFS).
72+
73+
2. **Add e2e scripts and APP_MODE**
74+
- In workspace root `package.json`: `test:e2e:legacy` = `APP_MODE=legacy playwright test`, `test:e2e:nfs` = `APP_MODE=nfs playwright test`, `test:e2e:all` = run both in sequence.
75+
76+
3. **Update `playwright.config.ts`**
77+
- `const appMode = process.env.APP_MODE || 'legacy'`.
78+
- `const startCommand = appMode === 'legacy' ? 'yarn start:legacy' : 'yarn start'`.
79+
- Use `startCommand` in `webServer` (replace hardcoded `yarn start`). If multiple servers (e.g. locales), use an **array** of webServer entries, each with `command`, `url` (e.g. readiness), `timeout`, `cwd: __dirname`, and pass the right config per entry (e.g. `--config baseConfig --config testConfigDir/app-config-e2e-{locale}.yaml`).
80+
- `reporter` outputFolder and `outputDir`: suffix with `-${appMode}` so legacy and NFS results don’t overwrite each other.
81+
82+
4. **Optional: move e2e to workspace root**
83+
- Move `packages/app/e2e-tests/` → `e2e-tests/` (and `e2e-tests/utils/`). Update `testDir` in Playwright to `'e2e-tests'`. Fix imports in tests (paths to utils and to plugin code may need updating; use `__dirname`-based or relative paths as in the reference workspace).
84+
85+
5. **Locale configs (if you run multiple locales)**
86+
- Add `e2e-tests/test_yamls/app-config-e2e-{locale}.yaml` (or under your chosen e2e dir). Each file overrides `app.baseUrl` and `backend.baseUrl`, `backend.listen.port`, `backend.cors.origin` for that locale. Add one Playwright project per locale with matching `baseURL` and `locale`, and one webServer entry per locale with the matching config and readiness URL (e.g. backend port 7007, 7008, …).
87+
88+
6. **Update existing e2e tests**
89+
- Replace hardcoded UI strings with translation keys and a `getTranslations(locale)` (or equivalent) loaded in `beforeAll` from the plugin’s translation modules. Use `replaceTemplate` for `{{key}}` placeholders.
90+
- Ensure navigation and selectors work for **both** legacy and NFS (e.g. nav link text or structure may differ; prefer shared helpers that accept translated strings so one test runs in both modes).
91+
- Add explicit waits after actions that trigger analytics or async work (e.g. `waitForDataFlush()` or wait for network/UI) so assertions are stable.
92+
93+
**Reference implementation**: `workspaces/adoption-insights` — see `playwright.config.ts`, root `package.json` scripts, `e2e-tests/` layout, `e2e-tests/utils/` (translations, helpers, accessibility), and `e2e-tests/test_yamls/` for locale-specific configs.
94+
95+
## Running both modes in CI (recommended)
96+
97+
**Best approach — no CI workflow change:** Make the workspace’s `playwright` script run both modes when CI runs `yarn playwright test`. Then the existing `.github/workflows/ci.yml` step (“run playwright tests” with `yarn playwright test` in the workspace) automatically runs legacy and NFS e2e.
98+
99+
**How to do it (adoption-insights pattern):** In the workspace root `package.json`:
100+
101+
- `test:e2e:legacy` = `APP_MODE=legacy playwright test`
102+
- `test:e2e:nfs` = `APP_MODE=nfs playwright test`
103+
- `test:e2e:all` = `yarn test:e2e:legacy && yarn test:e2e:nfs`
104+
- **`playwright`** = script that runs both modes when CI runs `yarn playwright test`, and forwards other args (e.g. `install`) to npx:
105+
```json
106+
"playwright": "bash -c 'if [[ $@ == test ]]; then yarn test:e2e:all; else npx playwright \"$@\"; fi' _"
107+
```
108+
109+
With this, CI keeps running `yarn playwright test`; the workspace runs both legacy and NFS in one job. Reports stay split (`e2e-test-report-legacy`, `e2e-test-report-nfs`). See `workspaces/adoption-insights/package.json` for the full script.
110+
111+
**Alternative (two CI steps):** If you prefer not to override the `playwright` script, run two steps in the same job: `APP_MODE=legacy yarn playwright test` then `APP_MODE=nfs yarn playwright test`, and archive both report dirs as separate artifacts.
112+
113+
## Gotchas
114+
115+
- **webServer**: For multiple servers (e.g. one per locale), `webServer` must be an **array** of objects; a single object starts only one process. Each entry needs `cwd: __dirname` so the start command runs in the workspace root.
116+
- **baseURL vs backend port**: Projects’ `baseURL` is the frontend URL (e.g. 3000, 3001). Backend readiness URL in webServer is the backend port (e.g. 7007). Keep config yamls and projects in sync.
117+
- **Selectors**: Legacy and NFS UIs can differ (e.g. nav structure, class names). Prefer role-based or translated text selectors and shared helpers so the same test works for both.
118+
119+
## Checklist for migration / e2e work
120+
121+
- [ ] If the workspace has both legacy and NFS, changes work for both; run both e2e suites (`test:e2e:legacy`, `test:e2e:nfs`).
122+
- [ ] Playwright config uses `APP_MODE` to choose start command and to suffix report/output dirs when both modes exist.
123+
- [ ] E2E location is consistent: either workspace-root `e2e-tests/` or `packages/app/e2e-tests/`; shared utils live under that e2e dir.
124+
- [ ] When the plugin has i18n, e2e uses translation keys (and a `getTranslations`-style util) instead of hardcoded strings.
125+
- [ ] New locale or port: add the corresponding app-config override and a Playwright project + webServer entry with matching ports.
126+
- [ ] CI runs both modes: use the `playwright` script that runs `test:e2e:all` (see “Running both modes in CI”) so no workflow change is needed.

.github/CODEOWNERS

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
* @redhat-developer/rhdh-cope @redhat-developer/rhdh-security
1717

1818
/workspaces/adoption-insights @redhat-developer/rhdh-ui @rohitkrai03 @karthikjeeyar @eswaraiahsapram
19-
/workspaces/ai-integrations @redhat-developer/rhdh-ui @rohitkrai03 @karthikjeeyar @lucifergene @johnmcollier @gabemontero
19+
/workspaces/ai-integrations @redhat-developer/rhdh-ui @redhat-developer/rhdh-ai @rohitkrai03 @karthikjeeyar @lucifergene @johnmcollier @gabemontero
20+
/workspaces/app-defaults @redhat-developer/rhdh-ui @rohitkrai03 @christoph-jerolimov
2021
/workspaces/bulk-import @redhat-developer/rhdh-plugins @rm3l @redhat-developer/rhdh-ui @debsmita1 @its-mitesh-kumar
2122
/workspaces/extensions @redhat-developer/rhdh-ui @christoph-jerolimov @karthikjeeyar
2223
/workspaces/global-floating-action-button @redhat-developer/rhdh-ui @debsmita1 @divyanshiGupta
@@ -25,12 +26,13 @@
2526
/workspaces/lightspeed @redhat-developer/rhdh-ui @karthikjeeyar @rohitkrai03 @yangcao77
2627
/workspaces/mcp-integrations @johnmcollier @gabemontero @thepetk @redhat-developer/rhdh-ai
2728
/workspaces/openshift-image-registry @redhat-developer/rhdh-ui @divyanshiGupta @its-mitesh-kumar
28-
/workspaces/orchestrator @batzionb @mareklibra @gciavarrini
29+
/workspaces/orchestrator @lholmquist @lokanandaprabhu @redhat-developer/rhdh-plugins @karthikjeeyar @christoph-jerolimov
2930
/workspaces/quickstart @redhat-developer/rhdh-ui @divyanshiGupta @its-mitesh-kumar
30-
/workspaces/redhat-resource-optimization @ydayagi @mareklibra @batzionb @PreetiW @asmasarw
31+
/workspaces/cost-management @ydayagi @mareklibra @batzionb @PreetiW @asmasarw
3132
/workspaces/sandbox @lucifergene @rohitkrai03 @karthikjeeyar @xcoulon @alexeykazakov @mfrancisc @rsoaresd @jrosental @rajivnathan @MatousJobanek
3233
/workspaces/scorecard @redhat-developer/rhdh-plugins @redhat-developer/rhdh-ui @christoph-jerolimov @its-mitesh-kumar @eswaraiahsapram
3334
/workspaces/theme @redhat-developer/rhdh-ui @ciiay @logonoff
3435
/workspaces/translations @redhat-developer/rhdh-ui @ciiay @debsmita1 @karthikjeeyar
35-
/workspaces/konflux @rrosatti @sahil143 @testcara
36+
/workspaces/konflux @rrosatti @sahil143 @testcara @rakshett
3637
/workspaces/x2a @mareklibra @elai-shalev @eloycoto
38+
/workspaces/dcm @asmasarw @jkilzi
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"packageRules": [
3+
{
4+
"description": "all Cost Management minor updates",
5+
"matchFileNames": ["workspaces/cost-management/**"],
6+
"extends": [
7+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-minor-presets(Cost Management)"
8+
],
9+
"addLabels": ["team/cost-management", "cost-management"]
10+
},
11+
{
12+
"description": "all Cost Management patch updates",
13+
"matchFileNames": ["workspaces/cost-management/**"],
14+
"extends": [
15+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-patch-presets(Cost Management)"
16+
],
17+
"addLabels": ["team/cost-management", "cost-management"]
18+
},
19+
{
20+
"description": "all Cost Management dev dependency updates",
21+
"matchFileNames": ["workspaces/cost-management/**"],
22+
"extends": [
23+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-devdependency-presets(Cost Management)"
24+
],
25+
"addLabels": ["team/cost-management", "cost-management"]
26+
}
27+
]
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"packageRules": [
3+
{
4+
"description": "all Dcm minor updates",
5+
"matchFileNames": ["workspaces/dcm/**"],
6+
"extends": [
7+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-minor-presets(Dcm)"
8+
],
9+
"addLabels": ["team/rhdh", "dcm"]
10+
},
11+
{
12+
"description": "all Dcm patch updates",
13+
"matchFileNames": ["workspaces/dcm/**"],
14+
"extends": [
15+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-patch-presets(Dcm)"
16+
],
17+
"addLabels": ["team/rhdh", "dcm"]
18+
},
19+
{
20+
"description": "all Dcm dev dependency updates",
21+
"matchFileNames": ["workspaces/dcm/**"],
22+
"extends": [
23+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-devdependency-presets(Dcm)"
24+
],
25+
"addLabels": ["team/rhdh", "dcm"]
26+
}
27+
]
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"packageRules": [
3+
{
4+
"description": "all Konflux minor updates",
5+
"matchFileNames": ["workspaces/konflux/**"],
6+
"extends": [
7+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-minor-presets(Konflux)"
8+
],
9+
"addLabels": ["team/rhdh", "konflux"]
10+
},
11+
{
12+
"description": "all Konflux patch updates",
13+
"matchFileNames": ["workspaces/konflux/**"],
14+
"extends": [
15+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-patch-presets(Konflux)"
16+
],
17+
"addLabels": ["team/rhdh", "konflux"]
18+
},
19+
{
20+
"description": "all Konflux dev dependency updates",
21+
"matchFileNames": ["workspaces/konflux/**"],
22+
"extends": [
23+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-devdependency-presets(Konflux)"
24+
],
25+
"addLabels": ["team/rhdh", "konflux"]
26+
}
27+
]
28+
}

.github/renovate-presets/workspace/rhdh-redhat-resource-optimization-presets.json

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"packageRules": [
3+
{
4+
"description": "all X2a minor updates",
5+
"matchFileNames": ["workspaces/x2a/**"],
6+
"extends": [
7+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-minor-presets(X2a)"
8+
],
9+
"addLabels": ["team/rhdh", "x2a"]
10+
},
11+
{
12+
"description": "all X2a patch updates",
13+
"matchFileNames": ["workspaces/x2a/**"],
14+
"extends": [
15+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-patch-presets(X2a)"
16+
],
17+
"addLabels": ["team/rhdh", "x2a"]
18+
},
19+
{
20+
"description": "all X2a dev dependency updates",
21+
"matchFileNames": ["workspaces/x2a/**"],
22+
"extends": [
23+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-devdependency-presets(X2a)"
24+
],
25+
"addLabels": ["team/rhdh", "x2a"]
26+
}
27+
]
28+
}

.github/renovate.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
":pinDevDependencies",
1212
":pinDigest",
1313
"docker:pinDigests",
14-
"group:monorepos"
14+
"group:monorepos",
15+
":maintainLockFilesWeekly"
1516
],
1617
"labels": ["dependencies"],
1718
"postUpdateOptions": ["yarnDedupeHighest"],
@@ -54,7 +55,7 @@
5455
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-orchestrator-presets",
5556
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-sandbox-presets",
5657
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-openshift-image-registry-presets",
57-
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-redhat-resource-optimization-presets",
58+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-cost-management-presets",
5859
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-quickstart-presets",
5960
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-mcp-integrations-presets",
6061
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-repo-tools-presets",
@@ -64,7 +65,10 @@
6465
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-global-header-presets",
6566
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-lightspeed-presets",
6667
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-global-floating-action-button-presets",
67-
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-extensions-presets"
68+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-extensions-presets",
69+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-x2a-presets",
70+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-konflux-presets",
71+
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/workspace/rhdh-dcm-presets"
6872
]
6973
},
7074
{

0 commit comments

Comments
 (0)