|
| 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 | + const response = await page.request.get( |
| 21 | + "/api/catalog/entities?limit=5&filter=kind=component", |
| 22 | + ); |
| 23 | + const body = await response.text(); |
| 24 | + expect(response.ok(), `HTTP ${response.status}: ${body}`).toBeTruthy(); |
| 25 | + }); |
| 26 | + |
| 27 | + /** |
| 28 | + * After OIDC app login, connect a GitHub session for SCM (session auth API): |
| 29 | + * Settings → Authentication Providers → GitHub row → **Sign in**. Backstage opens GitHub OAuth in a popup. |
| 30 | + */ |
| 31 | + test("GitHub session sign-in from Authentication Providers", async ({ |
| 32 | + page, |
| 33 | + uiHelper, |
| 34 | + }) => { |
| 35 | + await uiHelper.dismissQuickstartIfVisible(); |
| 36 | + await page.goto("/settings/auth-providers"); |
| 37 | + await expect( |
| 38 | + page.getByRole("heading", { name: /authentication providers/i }), |
| 39 | + ).toBeVisible(); |
| 40 | + |
| 41 | + const githubRow = page |
| 42 | + .getByRole("listitem") |
| 43 | + .filter({ hasText: /^GitHub$/ }); |
| 44 | + const signInButton = githubRow.getByRole("button", { |
| 45 | + name: /^sign in$/i, |
| 46 | + }); |
| 47 | + await expect(signInButton).toBeVisible(); |
| 48 | + |
| 49 | + const [popup] = await Promise.all([ |
| 50 | + page.waitForEvent("popup"), |
| 51 | + signInButton.click(), |
| 52 | + ]); |
| 53 | + await expect(popup).toHaveURL(/github\.com/, { timeout: 60_000 }); |
| 54 | + await popup.close(); |
| 55 | + }); |
| 56 | +}); |
0 commit comments