Skip to content

Commit 6e7b928

Browse files
[e2e-tests] enable and migrate e2e-test ocm, dynamic plugins info (#954)
Signed-off-by: Subhash Khileri <[email protected]> Co-authored-by: David Festal <[email protected]>
1 parent 80afebe commit 6e7b928

File tree

6 files changed

+130
-133
lines changed

6 files changed

+130
-133
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,7 @@
11
import { test, expect } from '@playwright/test';
2+
import { plugins } from '../../support/testData/dynamic-plugins-info';
23

3-
const plugins = [
4-
{
5-
name: 'backstage-plugin-catalog-backend-module-github-dynamic',
6-
version: '0.4.4',
7-
platform: 'node',
8-
role: 'backend-plugin-module',
9-
},
10-
{
11-
name: 'backstage-plugin-catalog-backend-module-github-org-dynamic',
12-
version: '0.1.0',
13-
platform: 'node',
14-
role: 'backend-plugin-module',
15-
},
16-
{
17-
name: 'backstage-plugin-github-actions',
18-
version: '0.6.6',
19-
role: 'frontend-plugin',
20-
platform: 'web',
21-
},
22-
{
23-
name: 'backstage-plugin-github-issues',
24-
version: '0.2.14',
25-
role: 'frontend-plugin',
26-
platform: 'web',
27-
},
28-
{
29-
name: 'backstage-plugin-kubernetes-backend-dynamic',
30-
version: '0.13.0',
31-
platform: 'node',
32-
role: 'backend-plugin-module',
33-
},
34-
{
35-
name: 'roadiehq-scaffolder-backend-module-utils-dynamic',
36-
version: '1.10.4',
37-
platform: 'node',
38-
role: 'backend-plugin-module',
39-
},
40-
{
41-
name: '@janus-idp/backstage-plugin-keycloak-backend-dynamic',
42-
version: '1.7.9',
43-
platform: 'node',
44-
role: 'backend-plugin-module',
45-
},
46-
{
47-
name: '@janus-idp/backstage-plugin-ocm',
48-
version: '3.5.9',
49-
role: 'frontend-plugin',
50-
platform: 'web',
51-
},
52-
{
53-
name: '@janus-idp/backstage-plugin-ocm-backend-dynamic',
54-
version: '3.4.10',
55-
platform: 'node',
56-
role: 'backend-plugin',
57-
},
58-
{
59-
name: '@janus-idp/backstage-plugin-quay',
60-
version: '1.4.16',
61-
role: 'frontend-plugin',
62-
platform: 'web',
63-
},
64-
{
65-
name: '@janus-idp/backstage-scaffolder-backend-module-quay-dynamic',
66-
version: '1.2.4',
67-
platform: 'node',
68-
role: 'backend-plugin-module',
69-
},
70-
{
71-
name: '@janus-idp/backstage-scaffolder-backend-module-regex-dynamic',
72-
version: '1.2.4',
73-
platform: 'node',
74-
role: 'backend-plugin-module',
75-
},
76-
{
77-
name: 'roadiehq-backstage-plugin-github-pull-requests',
78-
version: '2.5.18',
79-
role: 'frontend-plugin',
80-
platform: 'web',
81-
},
82-
];
83-
84-
test.describe.skip('dynamic-plugins-info backend plugin', () => {
4+
test.describe('dynamic-plugins-info backend plugin', () => {
855
test('should lists all the dynamic plugins installed', async ({
866
request,
877
}) => {
@@ -90,6 +10,15 @@ test.describe.skip('dynamic-plugins-info backend plugin', () => {
9010
);
9111
const body = await response.json();
9212

93-
expect(body).toEqual(expect.arrayContaining(plugins));
13+
for (const plugin of plugins) {
14+
const isPluginIncluded = body.find(
15+
resPlugin =>
16+
resPlugin.name === plugin.name &&
17+
resPlugin.role === plugin.role &&
18+
resPlugin.platform === plugin.platform,
19+
);
20+
21+
expect(isPluginIncluded).toBeTruthy();
22+
}
9423
});
9524
});

e2e-tests/playwright/e2e/plugins/ocm.spec.ts

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test } from '@playwright/test';
1+
import { Page, chromium, firefox, test } from '@playwright/test';
22
import { Common } from '../../utils/Common';
33
import { UIhelper } from '../../utils/UIhelper';
44
import { Clusters } from '../../support/pages/Clusters';
@@ -11,24 +11,32 @@ const clusterDetails = {
1111
platform: 'IBM',
1212
cpuCores: '12',
1313
memorySize: '47 Gi',
14-
ocVersion: '4.13.23',
14+
ocVersion: /^\d+\.\d+\.\d+$/,
1515
};
1616

17-
test.describe.skip('Test OCM plugin', () => {
18-
test.beforeEach(async ({ page }) => {
17+
let page: Page;
18+
test.describe.serial('Test OCM plugin', () => {
19+
let uiHelper: UIhelper;
20+
let clusters: Clusters;
21+
22+
test.beforeAll(async ({ browserName }) => {
23+
const browserType = browserName === 'firefox' ? firefox : chromium;
24+
const browser = await browserType.launch();
25+
page = await browser.newPage();
26+
1927
const common = new Common(page);
28+
uiHelper = new UIhelper(page);
29+
clusters = new Clusters(page);
30+
2031
await common.loginAsGuest();
2132
});
22-
23-
test('Navigate to Clusters and Verify OCM Clusters', async ({ page }) => {
24-
const uiHelper = new UIhelper(page);
25-
const clusters = new Clusters(page);
26-
33+
test('Navigate to Clusters and Verify OCM Clusters', async () => {
2734
await uiHelper.openSidebar('Clusters');
28-
await uiHelper.verifyRowsInTable([
29-
clusterDetails.clusterName,
35+
await uiHelper.verifyRowInTableByUniqueText(clusterDetails.clusterName, [
3036
clusterDetails.status,
3137
clusterDetails.platform,
38+
]);
39+
await uiHelper.verifyRowInTableByUniqueText(clusterDetails.clusterName, [
3240
clusterDetails.ocVersion,
3341
]);
3442
await uiHelper.clickLink(clusterDetails.clusterName);
@@ -44,12 +52,7 @@ test.describe.skip('Test OCM plugin', () => {
4452
);
4553
});
4654

47-
test('Navigate to Catalog > resources and verify cluster', async ({
48-
page,
49-
}) => {
50-
const uiHelper = new UIhelper(page);
51-
const clusters = new Clusters(page);
52-
55+
test('Navigate to Catalog > resources and verify cluster', async () => {
5356
await uiHelper.openSidebar('Catalog');
5457
await uiHelper.selectMuiBox('Kind', 'Resource');
5558
await uiHelper.verifyRowsInTable([clusterDetails.clusterName]);

e2e-tests/playwright/support/pageObjects/global-obj.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export const UIhelperPO = {
88
MuiBoxLabel: 'div[class*="MuiBox-root"] label',
99
MuiTableCell: 'td[class*="MuiTableCell-root"]',
1010
MuiTableRow: 'tr[class*="MuiTableRow-root"]',
11-
MuiCardHeader: 'div[class*="MuiCardHeader-root"]',
11+
MuiCard: cardHeading =>
12+
`//div[contains(@class,'MuiCardHeader-root') and descendant::*[text()='${cardHeading}']]/..`,
1213
tabs: '[role="tab"]',
1314
rowByText: (text: string) => `tr:has(td:text-is("${text}"))`,
1415
};

e2e-tests/playwright/support/pages/Clusters.ts

+12-22
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,25 @@ export class Clusters {
1111
}
1212

1313
async verifyOCMLinksCardDetails() {
14-
const linksCard = await this.uiHelper.getMuiCard('Links');
15-
await this.uiHelper.verifyLink(`${linksCard} >> text=OpenShift Console`);
16-
await this.uiHelper.verifyLink(`${linksCard} >> text=OCM Console`);
17-
await this.uiHelper.verifyLink(
18-
`${linksCard} >> text=OpenShift Cluster Manager`,
14+
await this.uiHelper.verifyLinkinCard('Links', 'OpenShift Console', false);
15+
await this.uiHelper.verifyLinkinCard('Links', 'OCM Console', false);
16+
await this.uiHelper.verifyLinkinCard(
17+
'Links',
18+
'OpenShift Cluster Manager',
19+
false,
1920
);
2021
}
2122

2223
async verifyOCMAvailableCardDetails(cpuCores: string, memorySize: string) {
23-
const availableCard = await this.uiHelper.getMuiCard('Available');
24-
await this.uiHelper.verifyRowInTableByUniqueText(
25-
`${availableCard} >> text=CPU cores`,
26-
[cpuCores],
27-
);
28-
await this.uiHelper.verifyRowInTableByUniqueText(
29-
`${availableCard} >> text=Memory size`,
30-
[memorySize],
24+
await this.uiHelper.verifyTextinCard('Available', `CPU cores${cpuCores}`);
25+
await this.uiHelper.verifyTextinCard(
26+
'Available',
27+
`Memory size${memorySize}`,
3128
);
3229
}
3330

3431
async verifyOCMClusterInfo(clusterName: string, status: string) {
35-
const clusterInfoCard = await this.uiHelper.getMuiCard('Cluster Info');
36-
await this.uiHelper.verifyRowInTableByUniqueText(
37-
`${clusterInfoCard} >> text=Name`,
38-
[clusterName],
39-
);
40-
await this.uiHelper.verifyRowInTableByUniqueText(
41-
`${clusterInfoCard} >> text=Status`,
42-
[status],
43-
);
32+
await this.uiHelper.verifyTextinCard('Cluster Info', `Name${clusterName}`);
33+
await this.uiHelper.verifyTextinCard('Cluster Info', `Status${status}`);
4434
}
4535
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
export const plugins = [
2+
{
3+
name: 'backstage-plugin-catalog-backend-module-github-dynamic',
4+
platform: 'node',
5+
role: 'backend-plugin-module',
6+
},
7+
{
8+
name: 'backstage-plugin-catalog-backend-module-github-org-dynamic',
9+
platform: 'node',
10+
role: 'backend-plugin-module',
11+
},
12+
{
13+
name: 'backstage-plugin-github-actions',
14+
role: 'frontend-plugin',
15+
platform: 'web',
16+
},
17+
{
18+
name: 'backstage-plugin-github-issues',
19+
role: 'frontend-plugin',
20+
platform: 'web',
21+
},
22+
{
23+
name: 'backstage-plugin-kubernetes-backend-dynamic',
24+
platform: 'node',
25+
role: 'backend-plugin-module',
26+
},
27+
{
28+
name: 'roadiehq-scaffolder-backend-module-utils-dynamic',
29+
platform: 'node',
30+
role: 'backend-plugin-module',
31+
},
32+
{
33+
name: '@janus-idp/backstage-plugin-keycloak-backend-dynamic',
34+
platform: 'node',
35+
role: 'backend-plugin-module',
36+
},
37+
{
38+
name: '@janus-idp/backstage-plugin-ocm',
39+
role: 'frontend-plugin',
40+
platform: 'web',
41+
},
42+
{
43+
name: '@janus-idp/backstage-plugin-ocm-backend-dynamic',
44+
platform: 'node',
45+
role: 'backend-plugin',
46+
},
47+
{
48+
name: '@janus-idp/backstage-plugin-quay',
49+
role: 'frontend-plugin',
50+
platform: 'web',
51+
},
52+
{
53+
name: '@janus-idp/backstage-scaffolder-backend-module-quay-dynamic',
54+
platform: 'node',
55+
role: 'backend-plugin-module',
56+
},
57+
{
58+
name: '@janus-idp/backstage-scaffolder-backend-module-regex-dynamic',
59+
platform: 'node',
60+
role: 'backend-plugin-module',
61+
},
62+
{
63+
name: 'roadiehq-backstage-plugin-github-pull-requests',
64+
role: 'frontend-plugin',
65+
platform: 'web',
66+
},
67+
];

e2e-tests/playwright/utils/UIhelper.ts

+17-10
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,22 @@ export class UIhelper {
172172
}
173173
}
174174

175-
async getMuiCard(title: string) {
176-
const cardHeader = this.page
177-
.locator(UIhelperPO.MuiCardHeader)
178-
.locator(`text=${title}`);
179-
const card = cardHeader.locator(
180-
'xpath=ancestor::div[contains(@class, "MuiCard-root")]',
181-
);
182-
await card.scrollIntoViewIfNeeded();
183-
184-
return card;
175+
async verifyLinkinCard(cardHeading: string, linkText: string, exact = true) {
176+
const link = this.page
177+
.locator(UIhelperPO.MuiCard(cardHeading))
178+
.locator('a')
179+
.getByText(linkText, { exact: exact })
180+
.first();
181+
await link.scrollIntoViewIfNeeded();
182+
await expect(link).toBeVisible();
183+
}
184+
185+
async verifyTextinCard(cardHeading: string, text: string, exact = true) {
186+
const locator = this.page
187+
.locator(UIhelperPO.MuiCard(cardHeading))
188+
.getByText(text, { exact: exact })
189+
.first();
190+
await locator.scrollIntoViewIfNeeded();
191+
await expect(locator).toBeVisible();
185192
}
186193
}

0 commit comments

Comments
 (0)