Skip to content

Commit

Permalink
[e2e-tests] enable and migrate e2e-test ocm, dynamic plugins info (ja…
Browse files Browse the repository at this point in the history
…nus-idp#954)

Signed-off-by: Subhash Khileri <skhileri@redhat.com>
Co-authored-by: David Festal <dfestal@redhat.com>
  • Loading branch information
subhashkhileri and davidfestal committed Feb 15, 2024
1 parent 80afebe commit 6e7b928
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 133 deletions.
95 changes: 12 additions & 83 deletions e2e-tests/playwright/e2e/plugins/dynamic-plugins-info.spec.ts
Original file line number Diff line number Diff line change
@@ -1,87 +1,7 @@
import { test, expect } from '@playwright/test';
import { plugins } from '../../support/testData/dynamic-plugins-info';

const plugins = [
{
name: 'backstage-plugin-catalog-backend-module-github-dynamic',
version: '0.4.4',
platform: 'node',
role: 'backend-plugin-module',
},
{
name: 'backstage-plugin-catalog-backend-module-github-org-dynamic',
version: '0.1.0',
platform: 'node',
role: 'backend-plugin-module',
},
{
name: 'backstage-plugin-github-actions',
version: '0.6.6',
role: 'frontend-plugin',
platform: 'web',
},
{
name: 'backstage-plugin-github-issues',
version: '0.2.14',
role: 'frontend-plugin',
platform: 'web',
},
{
name: 'backstage-plugin-kubernetes-backend-dynamic',
version: '0.13.0',
platform: 'node',
role: 'backend-plugin-module',
},
{
name: 'roadiehq-scaffolder-backend-module-utils-dynamic',
version: '1.10.4',
platform: 'node',
role: 'backend-plugin-module',
},
{
name: '@janus-idp/backstage-plugin-keycloak-backend-dynamic',
version: '1.7.9',
platform: 'node',
role: 'backend-plugin-module',
},
{
name: '@janus-idp/backstage-plugin-ocm',
version: '3.5.9',
role: 'frontend-plugin',
platform: 'web',
},
{
name: '@janus-idp/backstage-plugin-ocm-backend-dynamic',
version: '3.4.10',
platform: 'node',
role: 'backend-plugin',
},
{
name: '@janus-idp/backstage-plugin-quay',
version: '1.4.16',
role: 'frontend-plugin',
platform: 'web',
},
{
name: '@janus-idp/backstage-scaffolder-backend-module-quay-dynamic',
version: '1.2.4',
platform: 'node',
role: 'backend-plugin-module',
},
{
name: '@janus-idp/backstage-scaffolder-backend-module-regex-dynamic',
version: '1.2.4',
platform: 'node',
role: 'backend-plugin-module',
},
{
name: 'roadiehq-backstage-plugin-github-pull-requests',
version: '2.5.18',
role: 'frontend-plugin',
platform: 'web',
},
];

test.describe.skip('dynamic-plugins-info backend plugin', () => {
test.describe('dynamic-plugins-info backend plugin', () => {
test('should lists all the dynamic plugins installed', async ({
request,
}) => {
Expand All @@ -90,6 +10,15 @@ test.describe.skip('dynamic-plugins-info backend plugin', () => {
);
const body = await response.json();

expect(body).toEqual(expect.arrayContaining(plugins));
for (const plugin of plugins) {
const isPluginIncluded = body.find(
resPlugin =>
resPlugin.name === plugin.name &&
resPlugin.role === plugin.role &&
resPlugin.platform === plugin.platform,
);

expect(isPluginIncluded).toBeTruthy();
}
});
});
37 changes: 20 additions & 17 deletions e2e-tests/playwright/e2e/plugins/ocm.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from '@playwright/test';
import { Page, chromium, firefox, test } from '@playwright/test';
import { Common } from '../../utils/Common';
import { UIhelper } from '../../utils/UIhelper';
import { Clusters } from '../../support/pages/Clusters';
Expand All @@ -11,24 +11,32 @@ const clusterDetails = {
platform: 'IBM',
cpuCores: '12',
memorySize: '47 Gi',
ocVersion: '4.13.23',
ocVersion: /^\d+\.\d+\.\d+$/,
};

test.describe.skip('Test OCM plugin', () => {
test.beforeEach(async ({ page }) => {
let page: Page;
test.describe.serial('Test OCM plugin', () => {
let uiHelper: UIhelper;
let clusters: Clusters;

test.beforeAll(async ({ browserName }) => {
const browserType = browserName === 'firefox' ? firefox : chromium;
const browser = await browserType.launch();
page = await browser.newPage();

const common = new Common(page);
uiHelper = new UIhelper(page);
clusters = new Clusters(page);

await common.loginAsGuest();
});

test('Navigate to Clusters and Verify OCM Clusters', async ({ page }) => {
const uiHelper = new UIhelper(page);
const clusters = new Clusters(page);

test('Navigate to Clusters and Verify OCM Clusters', async () => {
await uiHelper.openSidebar('Clusters');
await uiHelper.verifyRowsInTable([
clusterDetails.clusterName,
await uiHelper.verifyRowInTableByUniqueText(clusterDetails.clusterName, [
clusterDetails.status,
clusterDetails.platform,
]);
await uiHelper.verifyRowInTableByUniqueText(clusterDetails.clusterName, [
clusterDetails.ocVersion,
]);
await uiHelper.clickLink(clusterDetails.clusterName);
Expand All @@ -44,12 +52,7 @@ test.describe.skip('Test OCM plugin', () => {
);
});

test('Navigate to Catalog > resources and verify cluster', async ({
page,
}) => {
const uiHelper = new UIhelper(page);
const clusters = new Clusters(page);

test('Navigate to Catalog > resources and verify cluster', async () => {
await uiHelper.openSidebar('Catalog');
await uiHelper.selectMuiBox('Kind', 'Resource');
await uiHelper.verifyRowsInTable([clusterDetails.clusterName]);
Expand Down
3 changes: 2 additions & 1 deletion e2e-tests/playwright/support/pageObjects/global-obj.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export const UIhelperPO = {
MuiBoxLabel: 'div[class*="MuiBox-root"] label',
MuiTableCell: 'td[class*="MuiTableCell-root"]',
MuiTableRow: 'tr[class*="MuiTableRow-root"]',
MuiCardHeader: 'div[class*="MuiCardHeader-root"]',
MuiCard: cardHeading =>
`//div[contains(@class,'MuiCardHeader-root') and descendant::*[text()='${cardHeading}']]/..`,
tabs: '[role="tab"]',
rowByText: (text: string) => `tr:has(td:text-is("${text}"))`,
};
34 changes: 12 additions & 22 deletions e2e-tests/playwright/support/pages/Clusters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,25 @@ export class Clusters {
}

async verifyOCMLinksCardDetails() {
const linksCard = await this.uiHelper.getMuiCard('Links');
await this.uiHelper.verifyLink(`${linksCard} >> text=OpenShift Console`);
await this.uiHelper.verifyLink(`${linksCard} >> text=OCM Console`);
await this.uiHelper.verifyLink(
`${linksCard} >> text=OpenShift Cluster Manager`,
await this.uiHelper.verifyLinkinCard('Links', 'OpenShift Console', false);
await this.uiHelper.verifyLinkinCard('Links', 'OCM Console', false);
await this.uiHelper.verifyLinkinCard(
'Links',
'OpenShift Cluster Manager',
false,
);
}

async verifyOCMAvailableCardDetails(cpuCores: string, memorySize: string) {
const availableCard = await this.uiHelper.getMuiCard('Available');
await this.uiHelper.verifyRowInTableByUniqueText(
`${availableCard} >> text=CPU cores`,
[cpuCores],
);
await this.uiHelper.verifyRowInTableByUniqueText(
`${availableCard} >> text=Memory size`,
[memorySize],
await this.uiHelper.verifyTextinCard('Available', `CPU cores${cpuCores}`);
await this.uiHelper.verifyTextinCard(
'Available',
`Memory size${memorySize}`,
);
}

async verifyOCMClusterInfo(clusterName: string, status: string) {
const clusterInfoCard = await this.uiHelper.getMuiCard('Cluster Info');
await this.uiHelper.verifyRowInTableByUniqueText(
`${clusterInfoCard} >> text=Name`,
[clusterName],
);
await this.uiHelper.verifyRowInTableByUniqueText(
`${clusterInfoCard} >> text=Status`,
[status],
);
await this.uiHelper.verifyTextinCard('Cluster Info', `Name${clusterName}`);
await this.uiHelper.verifyTextinCard('Cluster Info', `Status${status}`);
}
}
67 changes: 67 additions & 0 deletions e2e-tests/playwright/support/testData/dynamic-plugins-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
export const plugins = [
{
name: 'backstage-plugin-catalog-backend-module-github-dynamic',
platform: 'node',
role: 'backend-plugin-module',
},
{
name: 'backstage-plugin-catalog-backend-module-github-org-dynamic',
platform: 'node',
role: 'backend-plugin-module',
},
{
name: 'backstage-plugin-github-actions',
role: 'frontend-plugin',
platform: 'web',
},
{
name: 'backstage-plugin-github-issues',
role: 'frontend-plugin',
platform: 'web',
},
{
name: 'backstage-plugin-kubernetes-backend-dynamic',
platform: 'node',
role: 'backend-plugin-module',
},
{
name: 'roadiehq-scaffolder-backend-module-utils-dynamic',
platform: 'node',
role: 'backend-plugin-module',
},
{
name: '@janus-idp/backstage-plugin-keycloak-backend-dynamic',
platform: 'node',
role: 'backend-plugin-module',
},
{
name: '@janus-idp/backstage-plugin-ocm',
role: 'frontend-plugin',
platform: 'web',
},
{
name: '@janus-idp/backstage-plugin-ocm-backend-dynamic',
platform: 'node',
role: 'backend-plugin',
},
{
name: '@janus-idp/backstage-plugin-quay',
role: 'frontend-plugin',
platform: 'web',
},
{
name: '@janus-idp/backstage-scaffolder-backend-module-quay-dynamic',
platform: 'node',
role: 'backend-plugin-module',
},
{
name: '@janus-idp/backstage-scaffolder-backend-module-regex-dynamic',
platform: 'node',
role: 'backend-plugin-module',
},
{
name: 'roadiehq-backstage-plugin-github-pull-requests',
role: 'frontend-plugin',
platform: 'web',
},
];
27 changes: 17 additions & 10 deletions e2e-tests/playwright/utils/UIhelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,22 @@ export class UIhelper {
}
}

async getMuiCard(title: string) {
const cardHeader = this.page
.locator(UIhelperPO.MuiCardHeader)
.locator(`text=${title}`);
const card = cardHeader.locator(
'xpath=ancestor::div[contains(@class, "MuiCard-root")]',
);
await card.scrollIntoViewIfNeeded();

return card;
async verifyLinkinCard(cardHeading: string, linkText: string, exact = true) {
const link = this.page
.locator(UIhelperPO.MuiCard(cardHeading))
.locator('a')
.getByText(linkText, { exact: exact })
.first();
await link.scrollIntoViewIfNeeded();
await expect(link).toBeVisible();
}

async verifyTextinCard(cardHeading: string, text: string, exact = true) {
const locator = this.page
.locator(UIhelperPO.MuiCard(cardHeading))
.getByText(text, { exact: exact })
.first();
await locator.scrollIntoViewIfNeeded();
await expect(locator).toBeVisible();
}
}

0 comments on commit 6e7b928

Please sign in to comment.