Skip to content

Commit 4aca0ed

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 4aca0ed

11 files changed

Lines changed: 2286 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: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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 catalogOrigin = new URL(page.url()).origin;
23+
const result = await page.evaluate(async (origin: string) => {
24+
const res = await fetch(
25+
`${origin}/api/catalog/entities?limit=5&filter=kind=component`,
26+
{ credentials: "include" },
27+
);
28+
const text = await res.text();
29+
return { ok: res.ok, status: res.status, text };
30+
}, catalogOrigin);
31+
expect(
32+
result.ok,
33+
`HTTP ${result.status}: ${result.text.slice(0, 500)}`,
34+
).toBeTruthy();
35+
});
36+
37+
/**
38+
* After OIDC app login, connect a GitHub session for SCM (session auth API):
39+
* Settings → Authentication Providers → GitHub row → **Sign in**. Backstage opens GitHub OAuth in a popup.
40+
*/
41+
test("GitHub session sign-in from Authentication Providers", async ({
42+
page,
43+
uiHelper,
44+
}) => {
45+
await uiHelper.dismissQuickstartIfVisible();
46+
await page.goto("/settings/auth-providers");
47+
const authProvidersTab = page.getByRole("tab", {
48+
name: /authentication providers/i,
49+
});
50+
await expect(authProvidersTab).toBeVisible();
51+
await expect(authProvidersTab).toHaveAttribute("aria-selected", "true");
52+
53+
const githubRow = page
54+
.getByRole("listitem")
55+
.filter({ hasText: /^GitHub$/ });
56+
const signInButton = githubRow.getByRole("button", {
57+
name: /^sign in$/i,
58+
});
59+
await expect(signInButton).toBeVisible();
60+
61+
const [popup] = await Promise.all([
62+
page.waitForEvent("popup"),
63+
signInButton.click(),
64+
]);
65+
await expect(popup).toHaveURL(/github\.com/, { timeout: 60_000 });
66+
await popup.close();
67+
});
68+
});
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)