Skip to content

Commit 67ccd1e

Browse files
Add helpers and pages and objects
1 parent fc8cb94 commit 67ccd1e

19 files changed

Lines changed: 2266 additions & 5 deletions

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
"./utils": {
2828
"types": "./dist/utils/index.d.ts",
2929
"default": "./dist/utils/index.js"
30+
},
31+
"./helpers": {
32+
"types": "./dist/playwright/helpers/index.d.ts",
33+
"default": "./dist/playwright/helpers/index.js"
34+
},
35+
"./pages": {
36+
"types": "./dist/playwright/pages/index.d.ts",
37+
"default": "./dist/playwright/pages/index.js"
3038
}
3139
},
3240
"files": [
@@ -58,6 +66,7 @@
5866
"@playwright/test": "^1.57.0"
5967
},
6068
"devDependencies": {
69+
"@backstage/catalog-model": "1.7.5",
6170
"@playwright/test": "^1.57.0",
6271
"@types/fs-extra": "^11.0.4",
6372
"@types/js-yaml": "^4.0.9",
@@ -74,6 +83,7 @@
7483
"fs-extra": "^11.3.2",
7584
"js-yaml": "^4.1.1",
7685
"lodash.mergewith": "^4.6.2",
86+
"otplib": "12.0.1",
7787
"prettier": "^3.7.4",
7888
"typescript": "^5.9.3",
7989
"typescript-eslint": "^8.48.1",

src/deployment/rhdh/deployment.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,22 +257,23 @@ export class RHDHDeployment {
257257
const base: DeploymentConfigBase = {
258258
version,
259259
namespace: input.namespace,
260-
appConfig: input.appConfig ?? `config/app-config-rhdh.yaml`,
261-
secrets: input.secrets ?? `config/rhdh-secrets.yaml`,
262-
dynamicPlugins: input.dynamicPlugins ?? `config/dynamic-plugins.yaml`,
260+
appConfig: input.appConfig ?? `tests/config/app-config-rhdh.yaml`,
261+
secrets: input.secrets ?? `tests/config/rhdh-secrets.yaml`,
262+
dynamicPlugins:
263+
input.dynamicPlugins ?? `tests/config/dynamic-plugins.yaml`,
263264
};
264265

265266
if (method === "helm") {
266267
return {
267268
...base,
268269
method,
269-
valueFile: input.valueFile ?? `config/value_file.yaml`,
270+
valueFile: input.valueFile ?? `tests/config/value_file.yaml`,
270271
};
271272
} else if (method === "operator") {
272273
return {
273274
...base,
274275
method,
275-
subscription: input.subscription ?? `config/subscription.yaml`,
276+
subscription: input.subscription ?? `tests/config/subscription.yaml`,
276277
};
277278
} else {
278279
throw new Error(`Invalid RHDH installation method: ${method}`);

src/eslint/base.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ export function createEslintConfig(tsconfigRootDir: string): Linter.Config[] {
7676
modifiers: ["public"],
7777
format: ["camelCase"],
7878
},
79+
// Allow HTTP headers in object literals which require specific formats
80+
{
81+
selector: "objectLiteralProperty",
82+
format: null,
83+
filter: {
84+
regex:
85+
"^(Accept|Authorization|Content-Type|X-GitHub-Api-Version|X-[A-Za-z-]+)$",
86+
match: true,
87+
},
88+
},
7989
],
8090
// Promise handling
8191
"@typescript-eslint/no-floating-promises": "error",

src/playwright/fixtures/test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { RHDHDeployment } from "../../deployment/rhdh/index.js";
22
import { test as base } from "@playwright/test";
3+
import { LoginHelper, UIhelper } from "../helpers/index.js";
34

45
type RHDHDeploymentTestFixtures = {
56
rhdh: RHDHDeployment;
7+
uiHelper: UIhelper;
8+
loginHelper: LoginHelper;
69
};
710

811
type RHDHDeploymentWorkerFixtures = {
@@ -42,6 +45,18 @@ export const test = base.extend<
4245
},
4346
{ auto: true, scope: "test" },
4447
],
48+
uiHelper: [
49+
async ({ page }, use) => {
50+
await use(new UIhelper(page));
51+
},
52+
{ scope: "test" },
53+
],
54+
loginHelper: [
55+
async ({ page }, use) => {
56+
await use(new LoginHelper(page));
57+
},
58+
{ scope: "test" },
59+
],
4560
baseURL: [
4661
async ({ rhdhDeploymentWorker }, use) => {
4762
await use(rhdhDeploymentWorker.rhdhUrl);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const baseApiUrl = "https://api.github.com";
2+
const perPage = 100;
3+
4+
const getRepoUrl = (owner: string, repo: string) =>
5+
`${baseApiUrl}/repos/${owner}/${repo}`;
6+
const getOrgUrl = (owner: string) => `${baseApiUrl}/orgs/${owner}`;
7+
8+
const backstageShowcaseAPI = getRepoUrl("janus-idp", "backstage-showcase");
9+
10+
export const GITHUB_API_ENDPOINTS = {
11+
pull: (owner: string, repo: string, state: "open" | "closed" | "all") =>
12+
`${getRepoUrl(owner, repo)}/pulls?per_page=${perPage}&state=${state}`,
13+
14+
issues: (state: string) =>
15+
`${backstageShowcaseAPI}/issues?per_page=${perPage}&sort=updated&state=${state}`,
16+
17+
workflowRuns: `${backstageShowcaseAPI}/actions/runs?per_page=${perPage}`,
18+
19+
deleteRepo: getRepoUrl,
20+
21+
mergePR: (owner: string, repoName: string, pullNumber: number) =>
22+
`${getRepoUrl(owner, repoName)}/pulls/${pullNumber}/merge`,
23+
24+
createRepo: (owner: string) => `${getOrgUrl(owner)}/repos`,
25+
26+
pullFiles: (owner: string, repoName: string, pr: number) =>
27+
`${getRepoUrl(owner, repoName)}/pulls/${pr}/files`,
28+
29+
contents: (owner: string, repoName: string) =>
30+
`${getRepoUrl(owner, repoName)}/contents`,
31+
};

0 commit comments

Comments
 (0)