Skip to content

Commit bd58c5d

Browse files
[release-1.5] chore(e2e): add/move Github login specific test case to github Auth provider test suite. (#2489)
* add github plugins tests * add github plugins tests * add github plugins tests * add github plugins tests * add github plugins tests * add github plugins tests * add github plugins tests * add github plugins tests * add github plugins tests * add github plugins tests * add github plugins tests * add github plugins tests - add github plugins * add github plugins tests - add github plugins * add github plugins tests - add github plugins * add github plugins tests - add github plugins * add github plugins tests - add github plugins * add github plugins tests - add github plugins * add github plugins tests * add github plugins tests * add github plugins tests --------- Co-authored-by: Subhash Khileri <[email protected]>
1 parent 3328f06 commit bd58c5d

File tree

5 files changed

+129
-31
lines changed

5 files changed

+129
-31
lines changed

.ibm/pipelines/value_files/values_showcase-auth-providers.yaml

+9-1
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,19 @@ upstream:
5454
privateKey: ${AUTH_ORG1_PRIVATE_KEY}
5555
webhookSecret: ${AUTH_ORG_WEBHOOK_SECRET}
5656
catalog:
57+
import:
58+
entityFilename: catalog-info.yaml
59+
# pullRequestBranchName: rhdh-integration
60+
pullRequestBranchName: backstage-integration
5761
locations:
5862
- type: url
5963
target: https://github.com/janus-qe/auth-providers/blob/main/location.yaml
64+
- type: url
65+
target: https://github.com/redhat-developer/rhdh/blob/main/catalog-entities/all.yaml
66+
- type: url
67+
target: https://github.com/redhat-developer/red-hat-developer-hub-software-templates/blob/main/templates.yaml
6068
rules:
61-
- allow: [Component, Group, User, Resource, Location, Template]
69+
- allow: [API, Component, Group, User, Resource, Location, System, Template]
6270
providers:
6371
githubOrg:
6472
- id: github

e2e-tests/playwright/e2e/github-happy-path.spec.ts e2e-tests/playwright/e2e/authProviders/github-happy-path.spec.ts

+114-23
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
import { test, expect, Page } from "@playwright/test";
2-
import { UIhelper } from "../utils/ui-helper";
3-
import { Common, setupBrowser } from "../utils/common";
4-
import { RESOURCES } from "../support/testData/resources";
2+
import { UIhelper } from "../../utils/ui-helper";
3+
import { Common, setupBrowser } from "../../utils/common";
4+
import { RESOURCES } from "../../support/testData/resources";
55
import {
66
BackstageShowcase,
77
CatalogImport,
8-
} from "../support/pages/catalog-import";
9-
import { TEMPLATES } from "../support/testData/templates";
8+
} from "../../support/pages/catalog-import";
9+
import { TEMPLATES } from "../../support/testData/templates";
10+
import { HelmActions } from "../../utils/helm";
11+
import * as constants from "../../utils/authenticationProviders/constants";
12+
import { LOGGER } from "../../utils/logger";
13+
import { waitForNextSync } from "../../utils/helper";
1014

1115
let page: Page;
1216

1317
// TODO: replace skip with serial
14-
test.describe.skip("GitHub Happy path", () => {
18+
test.describe.serial("GitHub Happy path", () => {
1519
//TODO: skipping due to RHIDP-4992
1620
let common: Common;
1721
let uiHelper: UIhelper;
1822
let catalogImport: CatalogImport;
1923
let backstageShowcase: BackstageShowcase;
24+
const syncTime = 60;
2025

2126
const component =
2227
"https://github.com/redhat-developer/rhdh/blob/main/catalog-entities/all.yaml";
@@ -28,12 +33,92 @@ test.describe.skip("GitHub Happy path", () => {
2833
common = new Common(page);
2934
catalogImport = new CatalogImport(page);
3035
backstageShowcase = new BackstageShowcase(page);
31-
await common.loginAsGithubUser();
3236
});
3337

34-
test.beforeEach(
35-
async () => await new Common(page).checkAndClickOnGHloginPopup(),
36-
);
38+
test("Setup Github authentication provider and wait for first sync", async () => {
39+
test.setTimeout(300 * 1000);
40+
41+
LOGGER.info(`Base Url is ${process.env.BASE_URL}`);
42+
LOGGER.info(
43+
"Execute testcase: Setup Github authentication provider and wait for first sync",
44+
);
45+
46+
await HelmActions.upgradeHelmChartWithWait(
47+
constants.AUTH_PROVIDERS_RELEASE,
48+
constants.AUTH_PROVIDERS_CHART,
49+
constants.AUTH_PROVIDERS_NAMESPACE,
50+
constants.AUTH_PROVIDERS_VALUES_FILE,
51+
constants.CHART_VERSION,
52+
constants.QUAY_REPO,
53+
constants.TAG_NAME,
54+
[
55+
"--set upstream.backstage.appConfig.signInPage=github",
56+
"--set upstream.backstage.appConfig.auth.environment=production",
57+
"--set upstream.backstage.appConfig.catalog.providers.githubOrg[0].orgs[0]=janus-qe",
58+
"--set upstream.backstage.appConfig.catalog.providers.microsoftGraphOrg=null",
59+
"--set upstream.backstage.appConfig.catalog.providers.keycloakOrg=null",
60+
"--set upstream.backstage.appConfig.auth.providers.microsoft=null",
61+
"--set upstream.backstage.appConfig.auth.providers.oidc=null",
62+
"--set upstream.backstage.appConfig.permission.enabled=false",
63+
"--set upstream.postgresql.primary.persistence.enabled=false",
64+
`--set-json global.dynamic.plugins='[
65+
{
66+
"package": "./dynamic-plugins/dist/backstage-plugin-scaffolder-backend-module-github-dynamic",
67+
"disabled": false
68+
},
69+
{
70+
"package": "./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-github-dynamic",
71+
"disabled": false,
72+
"pluginConfig": {
73+
"catalog": {
74+
"providers": {
75+
"github": {
76+
"my-test-org": {
77+
"organization": "janus-qe",
78+
"catalogPath": "/catalog-info.yaml",
79+
"schedule": {
80+
"frequency": {
81+
"minutes": 1
82+
},
83+
"timeout": {
84+
"minutes": 1
85+
},
86+
"initialDelay": {
87+
"seconds": 15
88+
}
89+
}
90+
}
91+
}
92+
}
93+
}
94+
}
95+
},
96+
{
97+
"package": "./dynamic-plugins/dist/backstage-community-plugin-github-issues",
98+
"disabled": false
99+
},
100+
{
101+
"package": "./dynamic-plugins/dist/roadiehq-backstage-plugin-github-pull-requests",
102+
"disabled": false
103+
},
104+
{
105+
"package": "./dynamic-plugins/dist/backstage-community-plugin-github-actions",
106+
"disabled": false
107+
},
108+
{
109+
"package": "./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-github-org-dynamic",
110+
"disabled": false
111+
}
112+
]'`,
113+
],
114+
);
115+
116+
await waitForNextSync("github", syncTime);
117+
});
118+
119+
test("Login as a Github user.", async () => {
120+
await common.loginAsGithubUser();
121+
});
37122

38123
test("Verify Profile is Github Account Name in the Settings page", async () => {
39124
await uiHelper.goToSettingsPage();
@@ -71,7 +156,7 @@ test.describe.skip("GitHub Happy path", () => {
71156

72157
await uiHelper.openSidebar("Catalog");
73158
await uiHelper.selectMuiBox("Kind", "User");
74-
await uiHelper.searchInputAriaLabel("rhdh");
159+
await uiHelper.searchInputPlaceholder("rhdh");
75160
await uiHelper.verifyRowsInTable(["rhdh-qe"]);
76161
});
77162

@@ -111,8 +196,10 @@ test.describe.skip("GitHub Happy path", () => {
111196
await common.clickOnGHloginPopup();
112197
const openIssues = await backstageShowcase.getGithubOpenIssues();
113198

114-
const issuesCountText = `All repositories (${openIssues.length} Issues)*`;
115-
await expect(page.locator(`text=${issuesCountText}`)).toBeVisible();
199+
const issuesCountText = new RegExp(
200+
`All repositories \\(${openIssues.length} Issue.*\\)`,
201+
);
202+
await expect(page.getByText(issuesCountText)).toBeVisible();
116203

117204
for (const issue of openIssues.slice(0, 5)) {
118205
await uiHelper.verifyText(issue.title.replace(/\s+/g, " "));
@@ -132,8 +219,7 @@ test.describe.skip("GitHub Happy path", () => {
132219
await backstageShowcase.verifyPRRows(closedPRs, 0, 5);
133220
});
134221

135-
// TODO https://issues.redhat.com/browse/RHIDP-3159 The last ~10 GitHub Pull Requests are missing from the list
136-
test.skip("Click on the arrows to verify that the next/previous/first/last pages of PRs are loaded", async () => {
222+
test("Click on the arrows to verify that the next/previous/first/last pages of PRs are loaded", async () => {
137223
console.log("Fetching all PRs from GitHub");
138224
const allPRs = await BackstageShowcase.getShowcasePRs("all", true);
139225

@@ -145,32 +231,37 @@ test.describe.skip("GitHub Happy path", () => {
145231
await backstageShowcase.clickNextPage();
146232
await backstageShowcase.verifyPRRows(allPRs, 5, 10);
147233

148-
const lastPagePRs = Math.floor((allPRs.length - 1) / 5) * 5;
234+
// const lastPagePRs = Math.floor((allPRs.length - 1) / 5) * 5;
235+
const lastPagePRs = 996; // redhat-developer/rhdh have more than 1000 PRs open/closed and by default the latest 1000 PR results are displayed.
149236

150237
console.log("Clicking on Last Page button");
151238
await backstageShowcase.clickLastPage();
152-
await backstageShowcase.verifyPRRows(allPRs, lastPagePRs, allPRs.length);
239+
await backstageShowcase.verifyPRRows(allPRs, lastPagePRs, 1000);
153240

154241
console.log("Clicking on Previous Page button");
155242
await backstageShowcase.clickPreviousPage();
156-
await backstageShowcase.verifyPRRows(allPRs, lastPagePRs - 5, lastPagePRs);
243+
await common.waitForLoad();
244+
await backstageShowcase.verifyPRRows(
245+
allPRs,
246+
lastPagePRs - 5,
247+
lastPagePRs - 1,
248+
);
157249
});
158250

159-
//FIXME
160-
test.skip("Verify that the 5, 10, 20 items per page option properly displays the correct number of PRs", async () => {
251+
test("Verify that the 5, 10, 20 items per page option properly displays the correct number of PRs", async () => {
161252
await uiHelper.openSidebar("Catalog");
253+
await uiHelper.clickByDataTestId("user-picker-all");
162254
await uiHelper.clickLink("Backstage Showcase");
163255
await common.clickOnGHloginPopup();
164256
await uiHelper.clickTab("Pull/Merge Requests");
165-
await uiHelper.clickButton("ALL", { force: false });
166-
const allPRs = await BackstageShowcase.getShowcasePRs("all");
257+
const allPRs = await BackstageShowcase.getShowcasePRs("open");
167258
await backstageShowcase.verifyPRRowsPerPage(5, allPRs);
168259
await backstageShowcase.verifyPRRowsPerPage(10, allPRs);
169260
await backstageShowcase.verifyPRRowsPerPage(20, allPRs);
170261
});
171262

172263
test("Verify that the CI tab renders 5 most recent github actions and verify the table properly displays the actions when page sizes are changed and filters are applied", async () => {
173-
await uiHelper.clickTab("CI");
264+
await page.locator("a").getByText("CI", { exact: true }).first().click();
174265
await common.checkAndClickOnGHloginPopup();
175266

176267
const workflowRuns = await backstageShowcase.getWorkflowRuns();

e2e-tests/playwright/support/pages/catalog-import.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ export class BackstageShowcase {
7171
paginated = false,
7272
) {
7373
return await APIHelper.getGitHubPRs(
74-
"janus-idp",
75-
"backstage-showcase",
74+
"redhat-developer",
75+
"rhdh",
7676
state,
7777
paginated,
7878
);
@@ -99,7 +99,7 @@ export class BackstageShowcase {
9999
await this.uiHelper.verifyText(allPRs[rows - 1].title, false);
100100
await this.uiHelper.verifyLink(allPRs[rows].number, {
101101
exact: false,
102-
notVisible: false,
102+
notVisible: true,
103103
});
104104

105105
const tableRows = this.page.locator(

e2e-tests/playwright/utils/common.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ export class Common {
7979
await this.page.waitForTimeout(60000);
8080
await this.page.fill("#app_totp", this.getGitHub2FAOTP(userid));
8181
}
82-
await expect(this.page.locator("#app_totp")).toBeHidden({
83-
timeout: 120000,
84-
});
82+
83+
await this.page.waitForTimeout(3_000);
8584
}
8685

8786
async logintoKeycloak(userid: string, password: string) {

e2e-tests/playwright/utils/ui-helper.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export class UIhelper {
135135
let linkLocator: Locator;
136136
let notVisibleCheck: boolean;
137137

138-
if (typeof arg === "string") {
138+
if (typeof arg != "object") {
139139
linkLocator = this.page
140140
.locator("a")
141141
.getByText(arg, { exact: options.exact })

0 commit comments

Comments
 (0)