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
3 changes: 3 additions & 0 deletions workspaces/app-defaults/e2e-tests/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
playwright-report/
node_modules/.cache/
5 changes: 5 additions & 0 deletions workspaces/app-defaults/e2e-tests/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
compressionLevel: mixed

enableGlobalCache: false

nodeLinker: node-modules
14 changes: 14 additions & 0 deletions workspaces/app-defaults/e2e-tests/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { createEslintConfig } from "@red-hat-developer-hub/e2e-test-utils/eslint";

export default [
...createEslintConfig(import.meta.dirname),
{
files: ["**/*.spec.ts"],
rules: {
"playwright/expect-expect": [
"warn",
{ assertFunctionNames: ["verifyHeading"] },
],
},
},
];
37 changes: 37 additions & 0 deletions workspaces/app-defaults/e2e-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "app-defaults-e2e-tests",
"version": "1.0.0",
"private": true,
"type": "module",
"engines": {
"node": ">=22",
"yarn": ">=3"
},
"packageManager": "yarn@4.12.0",
"description": "E2E tests for app-defaults (app-auth, app-integrations) with app-next",
"scripts": {
"test": "playwright test",
"report": "playwright show-report",
"test:ui": "playwright test --ui",
"test:headed": "playwright test --headed",
"lint:check": "eslint .",
"lint:fix": "eslint . --fix",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write .",
"tsc:check": "tsc --noEmit",
"check": "yarn tsc:check && yarn lint:check && yarn prettier:check"
},
"devDependencies": {
"@eslint/js": "10.0.1",
"@playwright/test": "1.59.1",
"@red-hat-developer-hub/e2e-test-utils": "1.1.30",
"@types/node": "25.5.2",
"dotenv": "17.4.1",
"eslint": "10.2.0",
"eslint-plugin-check-file": "3.3.1",
"eslint-plugin-playwright": "2.10.1",
"prettier": "3.8.1",
"typescript": "6.0.2",
"typescript-eslint": "8.58.1"
}
}
15 changes: 15 additions & 0 deletions workspaces/app-defaults/e2e-tests/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from "@red-hat-developer-hub/e2e-test-utils/playwright-config";
import dotenv from "dotenv";

dotenv.config({ path: `${import.meta.dirname}/.env` });

/**
* app-defaults workspace: app-next + app-auth + app-integrations plugins.
*/
export default defineConfig({
projects: [
{
name: "app-defaults-app-next",
},
],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
auth:
providers:
github:
production:
clientId: ${VAULT_GITHUB_APP_CLIENT_ID}
clientSecret: ${VAULT_GITHUB_APP_CLIENT_SECRET}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
name: rhdh-secrets
type: Opaque
stringData:
APP_CONFIG_app_packageName: app-next
ENABLE_STANDARD_MODULE_FEDERATION: "true"
VAULT_GITHUB_APP_CLIENT_ID: $VAULT_GITHUB_APP_CLIENT_ID
VAULT_GITHUB_APP_CLIENT_SECRET: $VAULT_GITHUB_APP_CLIENT_SECRET
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { test, expect } from "@red-hat-developer-hub/e2e-test-utils/test";

test.describe("app-defaults plugins (app-next + OIDC + GitHub integration)", () => {
test.beforeAll(async ({ rhdh }) => {
await rhdh.configure({ auth: "keycloak" });
await rhdh.deploy();
});

test.beforeEach(async ({ loginHelper }) => {
await loginHelper.loginAsKeycloakUser();
});

test("loads Catalog after OIDC login", async ({ uiHelper }) => {
await uiHelper.dismissQuickstartIfVisible();
await uiHelper.openSidebar("Catalog");
await uiHelper.verifyHeading(/catalog/i);
});

test("catalog API responds for authenticated session", async ({ page }) => {
// Assert on the Catalog SPA's own GET to /api/catalog/* (same cookies/identity as the UI).
// Ad-hoc fetch()/page.request often 401 here: backend identity middleware matches app-issued requests.
const catalogApiOk = page.waitForResponse(
(response) => {
if (response.request().method() !== "GET") return false;
if (!response.url().includes("/api/catalog/")) return false;
const status = response.status();
return status >= 200 && status < 400;
},
{ timeout: 60_000 },
);
await page.goto("/catalog");
const response = await catalogApiOk;
expect(response.ok()).toBeTruthy();
});

/**
* After OIDC app login, connect a GitHub session for SCM (session auth API):
* Settings → Authentication Providers → GitHub row → **Sign in** → **Login Required** dialog → **Log in** → GitHub OAuth popup.
*/
test("GitHub session sign-in from Authentication Providers", async ({
page,
uiHelper,
}) => {
await uiHelper.dismissQuickstartIfVisible();
await page.goto("/settings/auth-providers");
const authProvidersTab = page.getByRole("tab", {
name: /authentication providers/i,
});
await expect(authProvidersTab).toBeVisible();
await expect(authProvidersTab).toHaveAttribute("aria-selected", "true");

// Row inner text includes title + description (not only "GitHub"), so /^GitHub$/ matches nothing.
const githubRow = page
.getByRole("listitem")
.filter({ hasText: /\bGitHub\b/ })
.first();
const signInButton = githubRow.getByRole("button", {
name: /^sign in$/i,
});
await expect(signInButton).toBeVisible();

await signInButton.click();

const loginRequiredDialog = page.getByRole("dialog", {
name: /login required/i,
});
await expect(loginRequiredDialog).toBeVisible();

const dialogLogInButton = loginRequiredDialog.getByRole("button", {
name: /^log in$/i,
});
await expect(dialogLogInButton).toBeVisible();

const [popup] = await Promise.all([
page.waitForEvent("popup", { timeout: 60_000 }),
dialogLogInButton.click(),
]);
await expect(popup).toHaveURL(/github\.com/, { timeout: 60_000 });
await popup.close();
});
});
4 changes: 4 additions & 0 deletions workspaces/app-defaults/e2e-tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "@red-hat-developer-hub/e2e-test-utils/tsconfig",
"include": ["**/*.ts"]
}
Loading