Skip to content

Commit 7d05a4e

Browse files
committed
refactor, address reviews, fix bugs
1 parent 02cac00 commit 7d05a4e

File tree

6 files changed

+36
-33
lines changed

6 files changed

+36
-33
lines changed

playwright.config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ try {
7272
)
7373
: []
7474
)
75-
],
76-
screenshot: 'only-on-failure',
77-
video: 'retain-on-failure',
75+
]
7876
}));
7977
}
8078

src/ui/common.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,21 @@ export async function checkWebsiteStatus(
1616
}
1717

1818
export async function waitForPageLoad(page: Page, name: string) {
19-
await page.getByRole('progressbar').waitFor({ state: 'hidden', timeout: 20000 });
19+
const progressBars = page.getByRole('progressbar');
20+
// Get all progressbar elements and wait until all are hidden
21+
const bars = await progressBars.all();
22+
if (bars.length > 0) {
23+
await Promise.all(
24+
bars.map(bar => expect(bar).toBeHidden({ timeout: 10000 }))
25+
);
26+
}
2027

21-
await expect(page.getByTestId('sidebar-root')).toBeAttached();
22-
23-
await page.getByRole('heading', { name: name }).waitFor({ state: 'visible', timeout: 20000 });
28+
await expect(page.getByTestId('sidebar-root')).toBeAttached({ timeout: 5000 });
29+
await expect(page.getByRole('heading', { name: name })).toBeVisible({ timeout: 20000 });
2430
await page.waitForLoadState();
25-
await page.waitForTimeout(500);
31+
}
2632

33+
export async function openTab(page: Page, tabName: string) {
34+
const tab = page.getByRole('tablist').getByText(tabName);
35+
await tab.click();
2736
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
2-
* Git-related Page Objects
2+
* Dependencies Page Objects
33
*
4-
* Contains locators for Git provider UI elements (GitHub, GitLab)
4+
* Contains locators for Dependencies tab UI elements
55
*/
66
export const DependenciesPO = {
7-
titelsArray: ['Depends on components', 'Depends on resources', 'Has subcomponents', 'Provided APIs', 'Consumed APIs'],
7+
titles: ['Depends on components', 'Depends on resources', 'Has subcomponents', 'Provided APIs', 'Consumed APIs'],
88
relationsTitle: 'Relations',
99
}

src/ui/plugins/dependencies/dependenciesUiPlugin.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
import { expect, Page } from '@playwright/test';
22
import { DependenciesPO } from '../../page-objects/dependencies_po';
3+
import { waitForPageLoad } from '../../common';
34

45
export class DependenciesUiPlugin {
56
private readonly componentName: string;
6-
private readonly sourceRepoUrl: string;
7-
private readonly gitOpsRepoUrl: string;
87

98
constructor(
109
componentName: string,
11-
sourceRepoUrl: string,
12-
gitOpsRepoUrl: string
1310
) {
1411
this.componentName = componentName;
15-
this.sourceRepoUrl = sourceRepoUrl;
16-
this.gitOpsRepoUrl = gitOpsRepoUrl;
1712
}
1813

1914
async checkAllBoxesPresent(page: Page) {
20-
for (const title of DependenciesPO.titelsArray) {
15+
for (const title of DependenciesPO.titles) {
2116
await expect(page.getByRole('heading', { name: title })).toBeVisible();
2217
}
2318
}
@@ -36,6 +31,6 @@ export class DependenciesUiPlugin {
3631
const nodeLocator = page.getByTestId("node").filter({ hasText: `${this.componentName}-gitops` });
3732
await expect(nodeLocator).toBeVisible();
3833
await nodeLocator.click();
39-
await expect(page.getByRole('heading', { name: this.componentName })).toBeVisible();
34+
await waitForPageLoad(page, `${this.componentName}-gitops`);
4035
}
4136
}

src/ui/uiComponent.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ export class UiComponent {
6969
testItem.getRegistryType(),
7070
component.getRegistry()
7171
);
72-
const dependencies = new DependenciesUiPlugin(
73-
name,
74-
component.getGit().getSourceRepoUrl(),
75-
component.getGit().getGitOpsRepoUrl()
76-
);
72+
const dependencies = new DependenciesUiPlugin(name);
7773
return new UiComponent(component, git, docs, registry, dependencies);
7874
}
7975

@@ -134,7 +130,7 @@ export class UiComponent {
134130
*
135131
* @returns The DependenciesUiPlugin instance for UI automation
136132
*/
137-
getDependencies(): DependenciesUiPlugin {
133+
public getDependencies(): DependenciesUiPlugin {
138134
return this.dependencies
139135
}
140136
}

tests/ui/ui.test.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createBasicFixture } from '../../src/utils/test/fixtures';
22
import { UiComponent } from '../../src/ui/uiComponent';
33
import { CommonPO } from '../../src/ui/page-objects/common_po';
4-
import { waitForPageLoad } from '../../src/ui/common';
4+
import { openTab, waitForPageLoad } from '../../src/ui/common';
55
import { DependenciesUiPlugin } from '../../src/ui/plugins/dependencies/dependenciesUiPlugin';
66

77
/**
@@ -36,7 +36,7 @@ test.describe('RHTAP UI Test Suite', () => {
3636
});
3737

3838
test.describe('Go to home page', () => {
39-
test('open developer hub and log in', async ({ page }) => {
39+
test('open developer hub', async ({ page }) => {
4040
await page.goto(component.getCoreComponent().getDeveloperHub().getUrl(), {
4141
timeout: 20000,
4242
});
@@ -56,8 +56,6 @@ test.describe('RHTAP UI Test Suite', () => {
5656
}
5757

5858
await page.goto(component.getComponentUrl(), { timeout: 20000 });
59-
60-
await page.waitForLoadState('domcontentloaded');
6159
await waitForPageLoad(page, component.getCoreComponent().getName());
6260

6361
await component.getGit()!.checkViewSourceLink(page);
@@ -165,16 +163,23 @@ test.describe('RHTAP UI Test Suite', () => {
165163
}, {timeout: 30000});
166164

167165
await test.step('Check gitops git link', async () => {
168-
await component.getGit()?.checkViewSourceLink(page);
166+
// Skip test for not yet supported git providers
167+
if (component.getGit() === undefined) {
168+
console.warn(`Skipping Git test as testing ${component.getCoreComponent().getGit().getGitType()} is not supported`);
169+
test.skip();
170+
return;
171+
}
172+
await component.getGit()!.checkViewSourceLink(page);
169173
});
170174

171-
await test.step('Check CI tab', async () => {
175+
await test.step('Check Gitops CI tab', async () => {
172176
// TBD
173177
});
174178

175-
await test.step('Test Docs', async () => {
179+
await test.step('Test Gitops Docs', async () => {
176180
const docsPlugin = component.getDocs();
177-
await page.goto(`${component.getComponentUrl()}/docs`, { timeout: 20000 });
181+
await openTab(page, 'Docs');
182+
await waitForPageLoad(page, `${component.getCoreComponent().getName()}-gitops`);
178183
await docsPlugin.checkArticle(page);
179184
});
180185
});

0 commit comments

Comments
 (0)