Skip to content

Commit 28d7b95

Browse files
committed
chore(app-defaults): add e2e tests
This change adds some e2e tests to the app-defaults workspace that start up RHDH using the new frontend system and validates that app login and scm authentication function as expected. rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
1 parent c63e18d commit 28d7b95

11 files changed

Lines changed: 2285 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
playwright-report/
3+
node_modules/.cache/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
compressionLevel: mixed
2+
3+
enableGlobalCache: false
4+
5+
nodeLinker: node-modules
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { createEslintConfig } from "@red-hat-developer-hub/e2e-test-utils/eslint";
2+
3+
export default [
4+
...createEslintConfig(import.meta.dirname),
5+
{
6+
files: ["**/*.spec.ts"],
7+
rules: {
8+
"playwright/expect-expect": [
9+
"warn",
10+
{ assertFunctionNames: ["verifyHeading"] },
11+
],
12+
},
13+
},
14+
];
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "app-defaults-e2e-tests",
3+
"version": "1.0.0",
4+
"private": true,
5+
"type": "module",
6+
"engines": {
7+
"node": ">=22",
8+
"yarn": ">=3"
9+
},
10+
"packageManager": "yarn@4.12.0",
11+
"description": "E2E tests for app-defaults (app-auth, app-integrations) with app-next",
12+
"scripts": {
13+
"test": "playwright test",
14+
"report": "playwright show-report",
15+
"test:ui": "playwright test --ui",
16+
"test:headed": "playwright test --headed",
17+
"lint:check": "eslint .",
18+
"lint:fix": "eslint . --fix",
19+
"prettier:check": "prettier --check .",
20+
"prettier:fix": "prettier --write .",
21+
"tsc:check": "tsc --noEmit",
22+
"check": "yarn tsc:check && yarn lint:check && yarn prettier:check"
23+
},
24+
"devDependencies": {
25+
"@eslint/js": "10.0.1",
26+
"@playwright/test": "1.59.1",
27+
"@red-hat-developer-hub/e2e-test-utils": "1.1.30",
28+
"@types/node": "25.5.2",
29+
"dotenv": "17.4.1",
30+
"eslint": "10.2.0",
31+
"eslint-plugin-check-file": "3.3.1",
32+
"eslint-plugin-playwright": "2.10.1",
33+
"prettier": "3.8.1",
34+
"typescript": "6.0.2",
35+
"typescript-eslint": "8.58.1"
36+
}
37+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineConfig } from "@red-hat-developer-hub/e2e-test-utils/playwright-config";
2+
import dotenv from "dotenv";
3+
4+
dotenv.config({ path: `${import.meta.dirname}/.env` });
5+
6+
/**
7+
* app-defaults workspace: app-next + app-auth + app-integrations plugins.
8+
*/
9+
export default defineConfig({
10+
projects: [
11+
{
12+
name: "app-defaults-app-next",
13+
},
14+
],
15+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
auth:
2+
providers:
3+
github:
4+
production:
5+
clientId: ${VAULT_GITHUB_APP_CLIENT_ID}
6+
clientSecret: ${VAULT_GITHUB_APP_CLIENT_SECRET}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
plugins:
2+
- package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-app-auth:bs_1.49.4__0.0.1!red-hat-developer-hub-backstage-plugin-app-auth
3+
disabled: false
4+
- package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-app-integrations:bs_1.49.4__0.0.1!red-hat-developer-hub-backstage-plugin-app-integrations
5+
disabled: false
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: rhdh-secrets
5+
type: Opaque
6+
stringData:
7+
APP_CONFIG_app_packageName: app-next
8+
ENABLE_STANDARD_MODULE_FEDERATION: "true"
9+
VAULT_GITHUB_APP_CLIENT_ID: $VAULT_GITHUB_APP_CLIENT_ID
10+
VAULT_GITHUB_APP_CLIENT_SECRET: $VAULT_GITHUB_APP_CLIENT_SECRET
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { test, expect } from "@red-hat-developer-hub/e2e-test-utils/test";
2+
3+
test.describe("app-defaults plugins (app-next + OIDC + GitHub integration)", () => {
4+
test.beforeAll(async ({ rhdh }) => {
5+
await rhdh.configure({ auth: "keycloak" });
6+
await rhdh.deploy();
7+
});
8+
9+
test.beforeEach(async ({ loginHelper }) => {
10+
await loginHelper.loginAsKeycloakUser();
11+
});
12+
13+
test("loads Catalog after OIDC login", async ({ uiHelper }) => {
14+
await uiHelper.dismissQuickstartIfVisible();
15+
await uiHelper.openSidebar("Catalog");
16+
await uiHelper.verifyHeading(/catalog/i);
17+
});
18+
19+
test("catalog API responds for authenticated session", async ({ page }) => {
20+
// Use in-page fetch with credentials so session cookies match browser auth (page.request can 401 on some RHDH setups).
21+
await page.goto("/catalog");
22+
const result = await page.evaluate(async () => {
23+
const res = await fetch(
24+
`${window.location.origin}/api/catalog/entities?limit=5&filter=kind=component`,
25+
{ credentials: "include" },
26+
);
27+
const text = await res.text();
28+
return { ok: res.ok, status: res.status, text };
29+
});
30+
expect(
31+
result.ok,
32+
`HTTP ${result.status}: ${result.text.slice(0, 500)}`,
33+
).toBeTruthy();
34+
});
35+
36+
/**
37+
* After OIDC app login, connect a GitHub session for SCM (session auth API):
38+
* Settings → Authentication Providers → GitHub row → **Sign in**. Backstage opens GitHub OAuth in a popup.
39+
*/
40+
test("GitHub session sign-in from Authentication Providers", async ({
41+
page,
42+
uiHelper,
43+
}) => {
44+
await uiHelper.dismissQuickstartIfVisible();
45+
await page.goto("/settings/auth-providers");
46+
const authProvidersTab = page.getByRole("tab", {
47+
name: /authentication providers/i,
48+
});
49+
await expect(authProvidersTab).toBeVisible();
50+
await expect(authProvidersTab).toHaveAttribute("aria-selected", "true");
51+
52+
const githubRow = page
53+
.getByRole("listitem")
54+
.filter({ hasText: /^GitHub$/ });
55+
const signInButton = githubRow.getByRole("button", {
56+
name: /^sign in$/i,
57+
});
58+
await expect(signInButton).toBeVisible();
59+
60+
const [popup] = await Promise.all([
61+
page.waitForEvent("popup"),
62+
signInButton.click(),
63+
]);
64+
await expect(popup).toHaveURL(/github\.com/, { timeout: 60_000 });
65+
await popup.close();
66+
});
67+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "@red-hat-developer-hub/e2e-test-utils/tsconfig",
3+
"include": ["**/*.ts"]
4+
}

0 commit comments

Comments
 (0)