Skip to content

Commit 586b861

Browse files
authored
fix(keycloak): Switch keycloak sign in flow (#66)
* Switch keycloak sign in flow Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com> * Update docs about how to test locally with Overlays Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com> --------- Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
1 parent 39984e2 commit 586b861

4 files changed

Lines changed: 67 additions & 19 deletions

File tree

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.22] - Current
5+
## [1.1.23] - Current
6+
7+
### Fixed
8+
9+
- Fixed popup flow for Keycloak sign in. Before, if the popup opened fast, the "popup" event could fire before the listener was attached resulting in test hanging and timeouts.
10+
11+
## [1.1.22]
612

713
### Added
814

docs/overlay/tutorials/running-locally.md

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ yarn report
8686
### Report Location
8787

8888
Reports are saved to `playwright-report/`:
89+
8990
- `playwright-report/index.html` - HTML report
9091
- Test artifacts (screenshots, videos, traces)
9192

@@ -136,6 +137,50 @@ For failed tests, traces are automatically captured:
136137
npx playwright show-trace playwright-report/trace.zip
137138
```
138139

140+
## Test local changes to e2e-test-utils in Overlays
141+
142+
If you want to try your local changes to `@red-hat-developer-hub/e2e-test-utils` work for [Overlays](https://github.com/redhat-developer/rhdh-plugin-export-overlays):
143+
144+
1. Build the utils package:
145+
146+
```bash
147+
cd /Your/Path/Projects/rhdh-e2e-test-utils
148+
yarn build
149+
```
150+
151+
1. Point the Overlays workspace `e2e-test-utils` dependency to your local checkout:
152+
153+
```bash
154+
cd /Your/Path/Projects/rhdh-plugin-export-overlays/workspaces/<plugin>/e2e-tests
155+
```
156+
157+
Update `package.json`:
158+
159+
```json
160+
{
161+
"dependencies": {
162+
"@red-hat-developer-hub/e2e-test-utils": "file:/Your/Path/Projects/rhdh-e2e-test-utils"
163+
}
164+
}
165+
```
166+
167+
1. Reinstall dependencies and run tests:
168+
169+
```bash
170+
yarn install
171+
yarn test:headed
172+
```
173+
174+
When you change the utils package again, re-run `yarn build` in `rhdh-e2e-test-utils`, then run `yarn install` again in the overlay `e2e-tests` workspace.
175+
176+
### Troubleshooting local linking
177+
178+
If you see odd module-resolution issues while testing a locally linked `e2e-test-utils` package, try running the Overlays tests with:
179+
180+
```bash
181+
NODE_PRESERVE_SYMLINKS=1 yarn test:headed
182+
```
183+
139184
## Environment Variables
140185

141186
### Using .env File
@@ -151,11 +196,11 @@ SKIP_KEYCLOAK_DEPLOYMENT=false
151196

152197
### Common Variables
153198

154-
| Variable | Description | Default |
155-
|----------|-------------|---------|
156-
| `RHDH_VERSION` | RHDH version to deploy | `next` (latest) |
157-
| `INSTALLATION_METHOD` | `helm` or `operator` | `helm` |
158-
| `SKIP_KEYCLOAK_DEPLOYMENT` | Skip Keycloak deployment entirely (for guest auth) | `false` |
199+
| Variable | Description | Default |
200+
| -------------------------- | -------------------------------------------------- | --------------- |
201+
| `RHDH_VERSION` | RHDH version to deploy | `next` (latest) |
202+
| `INSTALLATION_METHOD` | `helm` or `operator` | `helm` |
203+
| `SKIP_KEYCLOAK_DEPLOYMENT` | Skip Keycloak deployment entirely (for guest auth) | `false` |
159204

160205
See [Environment Variables Reference](/overlay/reference/environment-variables) for all available variables.
161206

@@ -251,7 +296,7 @@ test("screenshot test", async ({ page }) => {
251296

252297
```typescript
253298
test("console test", async ({ page }) => {
254-
page.on("console", msg => console.log(msg.text()));
299+
page.on("console", (msg) => console.log(msg.text()));
255300
await page.goto("/");
256301
});
257302
```

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.22",
3+
"version": "1.1.23",
44
"description": "Test utilities for RHDH E2E tests",
55
"license": "Apache-2.0",
66
"repository": {

src/playwright/helpers/common.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,11 @@ export class LoginHelper {
7878
await this.page.waitForTimeout(3_000);
7979
}
8080

81-
async logintoKeycloak(userid: string, password: string) {
82-
await new Promise<void>((resolve) => {
83-
this.page.once("popup", async (popup) => {
84-
await popup.waitForLoadState();
85-
await popup.locator("#username").fill(userid);
86-
await popup.locator("#password").fill(password);
87-
await popup.locator("#kc-login").click();
88-
resolve();
89-
});
90-
});
81+
async logintoKeycloak(popup: Page, userid: string, password: string) {
82+
await popup.waitForLoadState();
83+
await popup.locator("#username").fill(userid);
84+
await popup.locator("#password").fill(password);
85+
await popup.locator("#kc-login").click();
9186
}
9287

9388
async loginAsKeycloakUser(
@@ -96,8 +91,10 @@ export class LoginHelper {
9691
) {
9792
await this.page.goto("/");
9893
await this.uiHelper.waitForLoad(240000);
94+
const popupPromise = this.page.waitForEvent("popup");
9995
await this.uiHelper.clickButton("Sign In");
100-
await this.logintoKeycloak(userid, password);
96+
const popup = await popupPromise;
97+
await this.logintoKeycloak(popup, userid, password);
10198
await this.page.waitForSelector("nav a", { timeout: 10_000 });
10299
}
103100

0 commit comments

Comments
 (0)