Skip to content

Commit de897a0

Browse files
authored
chore(e2e): techdocs addons tests (#2385)
* Introduce more techdocs tests Signed-off-by: Dominika Zemanovicova <[email protected]> * Enable package contrib Signed-off-by: Dominika Zemanovicova <[email protected]> --------- Signed-off-by: Dominika Zemanovicova <[email protected]>
1 parent ff282f6 commit de897a0

File tree

5 files changed

+77
-6
lines changed

5 files changed

+77
-6
lines changed

.ibm/pipelines/value_files/sanity-check-plugins.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ global:
9191
disabled: false
9292
- package: ./dynamic-plugins/dist/backstage-plugin-techdocs
9393
disabled: false
94+
- package: ./dynamic-plugins/dist/backstage-plugin-techdocs-module-addons-contrib
95+
disabled: false
96+
pluginConfig:
97+
dynamicPlugins:
98+
frontend:
99+
backstage.plugin-techdocs-module-addons-contrib:
100+
techdocsAddons:
101+
- importName: ReportIssue
94102
- package: ./dynamic-plugins/dist/pagerduty-backstage-plugin
95103
disabled: false
96104
- package: ./dynamic-plugins/dist/pagerduty-backstage-plugin-backend-dynamic

.ibm/pipelines/value_files/values_showcase.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ global:
102102
disabled: false
103103
- package: ./dynamic-plugins/dist/backstage-community-plugin-tech-radar-backend-dynamic
104104
disabled: false
105+
- package: ./dynamic-plugins/dist/backstage-plugin-techdocs-module-addons-contrib
106+
disabled: false
107+
pluginConfig:
108+
dynamicPlugins:
109+
frontend:
110+
backstage.plugin-techdocs-module-addons-contrib:
111+
techdocsAddons:
112+
- importName: ReportIssue
105113
- package: ./dynamic-plugins/dist/backstage-community-plugin-acr
106114
disabled: false
107115
- package: ./dynamic-plugins/dist/backstage-community-plugin-scaffolder-backend-module-kubernetes-dynamic
+53-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
1-
import { test } from "@playwright/test";
1+
import { Page, test } from "@playwright/test";
22
import { UIhelper } from "../utils/ui-helper";
33
import { Common } from "../utils/common";
4+
import { expect } from "@playwright/test";
5+
import { Catalog } from "../support/pages/catalog";
46

57
test.describe("TechDocs", () => {
68
let common: Common;
79
let uiHelper: UIhelper;
10+
let catalog: Catalog;
11+
12+
async function docsTextHighlight(page: Page) {
13+
await page.evaluate(() => {
14+
const shadowRoot = document.querySelector(
15+
'[data-testid="techdocs-native-shadowroot"]',
16+
);
17+
const element =
18+
shadowRoot.shadowRoot.querySelector("article p").firstChild;
19+
const range = document.createRange();
20+
const selection = window.getSelection();
21+
range.setStart(element, 0);
22+
range.setEnd(element, 20);
23+
selection.removeAllRanges();
24+
selection.addRange(range);
25+
document.dispatchEvent(new Event("selectionchange"));
26+
});
27+
}
828

929
test.beforeEach(async ({ page }) => {
1030
uiHelper = new UIhelper(page);
1131
common = new Common(page);
32+
catalog = new Catalog(page);
1233
await common.loginAsGuest();
1334
});
1435

@@ -17,11 +38,41 @@ test.describe("TechDocs", () => {
1738
await uiHelper.openSidebar("Docs");
1839
});
1940

20-
test("Verify that TechDocs for Backstage Showcase works", async ({
41+
test("Verify that TechDocs Docs page for Backstage Showcase works", async ({
42+
page,
43+
}) => {
44+
await uiHelper.openSidebarButton("Favorites");
45+
await uiHelper.openSidebar("Docs");
46+
await page.getByRole("link", { name: "Backstage Showcase" }).click();
47+
await uiHelper.waitForTitle("Getting Started running RHDH", 1);
48+
});
49+
50+
test("Verify that TechDocs entity tab page for Backstage Showcase works", async () => {
51+
await catalog.goToByName("Backstage Showcase");
52+
await uiHelper.clickTab("Docs");
53+
await uiHelper.waitForTitle("Getting Started running RHDH", 1);
54+
});
55+
56+
test("Verify that TechDocs Docs page for ReportIssue addon works", async ({
2157
page,
2258
}) => {
2359
await uiHelper.openSidebarButton("Favorites");
2460
await uiHelper.openSidebar("Docs");
2561
await page.getByRole("link", { name: "Backstage Showcase" }).click();
62+
await page.waitForSelector("article a");
63+
await docsTextHighlight(page);
64+
const link = await page.waitForSelector("text=Open new Github issue");
65+
expect(await link?.isVisible()).toBeTruthy();
66+
});
67+
68+
test("Verify that TechDocs entity tab page for ReportIssue addon works", async ({
69+
page,
70+
}) => {
71+
await catalog.goToByName("Backstage Showcase");
72+
await uiHelper.clickTab("Docs");
73+
await page.waitForSelector("article a");
74+
await docsTextHighlight(page);
75+
const link = await page.waitForSelector("text=Open new Github issue");
76+
expect(await link?.isVisible()).toBeTruthy();
2677
});
2778
});

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ export class Catalog {
1818
await this.uiHelper.openSidebar("Catalog");
1919
}
2020

21+
async goToByName(name: string) {
22+
await this.go();
23+
await this.uiHelper.clickByDataTestId("user-picker-all");
24+
await this.uiHelper.clickLink(name);
25+
}
26+
2127
async goToBackstageJanusProjectCITab() {
2228
await this.goToBackstageJanusProject();
2329
await this.uiHelper.clickTab("CI");
@@ -26,9 +32,7 @@ export class Catalog {
2632
}
2733

2834
async goToBackstageJanusProject() {
29-
await this.uiHelper.openSidebar("Catalog");
30-
await this.uiHelper.clickByDataTestId("user-picker-all");
31-
await this.uiHelper.clickLink("backstage-janus");
35+
await this.goToByName("backstage-janus");
3236
}
3337

3438
async search(s: string) {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export class UIhelper {
315315
}
316316

317317
async clickTab(tabName: string) {
318-
const tabLocator = this.page.locator(`text="${tabName}"`);
318+
const tabLocator = this.page.getByRole("tab", { name: tabName });
319319
await tabLocator.waitFor({ state: "visible" });
320320
await tabLocator.click();
321321
}

0 commit comments

Comments
 (0)