Skip to content

Commit 74723a1

Browse files
authored
feat(UIHelper): Add function to dismiss quickstart (#72)
This change adds a dismissQuickstartIfVisible function to UIHelper, used in at least one e2e test and could be helpful for other tests. This change also updates the vitepress config to reflect the newer package version this change introduces. Assisted-By: Cursor Desktop rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
1 parent dd7eccd commit 74723a1

File tree

8 files changed

+55
-3
lines changed

8 files changed

+55
-3
lines changed

docs/.vitepress/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default defineConfig({
3333
{ text: "Examples", link: "/examples/" },
3434
{ text: "Overlay Testing", link: "/overlay/" },
3535
{
36-
text: "v1.1.22",
36+
text: "v1.1.25",
3737
items: [{ text: "Changelog", link: "/changelog" }],
3838
},
3939
],

docs/api/helpers/ui-helper.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ async waitForLoad(timeout?: number): Promise<void>
2424
```
2525
Wait for page to fully load.
2626

27+
#### `dismissQuickstartIfVisible()`
28+
```typescript
29+
async dismissQuickstartIfVisible(options?: {
30+
waitHiddenMs?: number;
31+
}): Promise<void>
32+
```
33+
If the RHDH quickstart drawer is open, clicks its **Hide** button and waits for the control to disappear. Does nothing when the button is not visible. Use before catalog search or other UI that the drawer can cover. Default `waitHiddenMs` is `5000`.
34+
2735
### Verification Methods
2836

2937
#### `verifyHeading()`

docs/changelog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [1.1.24] - Current
5+
## [1.1.25] - Current
6+
7+
### Added
8+
9+
- **`UIhelper.dismissQuickstartIfVisible()`**: Optionally closes the RHDH quickstart drawer when its **Hide** control is visible, so e2e tests are not blocked by the overlay. Optional `waitHiddenMs` (default `5000`) controls how long to wait for the button to become hidden after click.
10+
11+
## [1.1.24]
612

713
### Added
814

docs/guide/helpers/ui-helper.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ await uiHelper.waitForLoad();
2929
await uiHelper.waitForLoad(10000); // Custom timeout
3030
```
3131

32+
### `dismissQuickstartIfVisible(options?)`
33+
34+
When the [quickstart](https://github.com/redhat-developer/rhdh-plugins/tree/main/workspaces/quickstart) plugin opens its drawer (for example after login), it can sit over the catalog, search field, or other controls. This method clicks **Hide** only if that button is visible, then waits for it to go away; otherwise it returns immediately.
35+
36+
```typescript
37+
await uiHelper.dismissQuickstartIfVisible();
38+
await uiHelper.dismissQuickstartIfVisible({ waitHiddenMs: 10_000 });
39+
```
40+
41+
Typical use is right after navigation or login, before assertions or interactions that need an unobstructed main view.
42+
3243
## Verification Methods
3344

3445
### `verifyHeading(heading, timeout?)`

docs/overlay/reference/patterns.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,16 @@ await uiHelper.searchInputPlaceholder("Search...", "query");
205205
await uiHelper.selectMuiBox("Category", "Option 1");
206206
```
207207

208+
### Dismiss quickstart drawer
209+
210+
When the RHDH quickstart plugin shows its drawer, it can cover catalog search and other controls. Call this after login or navigation if needed (it is a no-op when **Hide** is not visible):
211+
212+
```typescript
213+
await uiHelper.dismissQuickstartIfVisible();
214+
```
215+
216+
See [UIhelper](/guide/helpers/ui-helper) and [UIhelper API](/api/helpers/ui-helper).
217+
208218
## Table Patterns
209219

210220
### Verify Table Rows

docs/overlay/test-structure/spec-files.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ Common methods from `UIhelper`:
312312
| `clickButton(name)` | Click button by name |
313313
| `clickLink(text)` | Click link by text |
314314
| `waitForLoad()` | Wait for page load |
315+
| `dismissQuickstartIfVisible()` | Close quickstart drawer if **Hide** is visible |
315316

316317
See [UIhelper API](/api/helpers/ui-helper) for full reference.
317318

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@red-hat-developer-hub/e2e-test-utils",
3-
"version": "1.1.24",
3+
"version": "1.1.25",
44
"description": "Test utilities for RHDH E2E tests",
55
"license": "Apache-2.0",
66
"repository": {

src/playwright/helpers/ui-helper.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ export class UIhelper {
2323
}
2424
}
2525

26+
/**
27+
* Closes the quickstart drawer when the "Hide" button is visible (RHDH quickstart plugin),
28+
* so it does not cover catalog or other UI under test.
29+
*/
30+
async dismissQuickstartIfVisible(options?: { waitHiddenMs?: number }) {
31+
const waitHiddenMs = options?.waitHiddenMs ?? 5000;
32+
const quickstartHide = this.page.getByRole("button", { name: "Hide" });
33+
if (await quickstartHide.isVisible()) {
34+
await quickstartHide.click();
35+
await quickstartHide.waitFor({
36+
state: "hidden",
37+
timeout: waitHiddenMs,
38+
});
39+
}
40+
}
41+
2642
async verifyComponentInCatalog(kind: string, expectedRows: string[]) {
2743
await this.openSidebar("Catalog");
2844
await this.selectMuiBox("Kind", kind);

0 commit comments

Comments
 (0)