@red-hat-developer-hub/e2e-test-utils 1.1.42 → 1.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,7 @@ export declare class LoginHelper {
11
11
  loginAsKeycloakUser(userid?: string, password?: string): Promise<void>;
12
12
  loginAsGithubUser(userid?: string): Promise<void>;
13
13
  checkAndReauthorizeGithubApp(): Promise<void>;
14
+ private handleGithubPopupReauth;
14
15
  googleSignIn(email: string): Promise<void>;
15
16
  checkAndClickOnGHloginPopup(force?: boolean): Promise<void>;
16
17
  getButtonSelector(label: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/playwright/helpers/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAOhE,qBAAa,WAAW;IACtB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,QAAQ,CAAC;gBAEP,IAAI,EAAE,IAAI;IAKhB,YAAY;IAcZ,OAAO;YAMC,aAAa;IAyCrB,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAO7D,mBAAmB,CACvB,MAAM,GAAE,MAAkC,EAC1C,QAAQ,GAAE,MAAkC;IAWxC,iBAAiB,CACrB,MAAM,GAAE,MAA+C;IA6BnD,4BAA4B;IAqB5B,YAAY,CAAC,KAAK,EAAE,MAAM;IA2B1B,2BAA2B,CAAC,KAAK,UAAQ;IAU/C,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAIxC,mBAAmB,IAAI,MAAM;IAIvB,mBAAmB;IAgBzB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAevC,eAAe,IAAI,MAAM;IAKnB,aAAa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M;IAKnB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;YAqCxC,sBAAsB;IAoD9B,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAYjE,2BAA2B,CAC/B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM;IAYb,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CA2C7D;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ;;;GAWtE"}
@@ -46,13 +46,15 @@ export class LoginHelper {
46
46
  }
47
47
  await this.page.click('[value="Sign in"]');
48
48
  await this.page.fill("#app_totp", this.getGitHub2FAOTP(userid));
49
- test.setTimeout(130000);
49
+ test.setTimeout(260_000);
50
50
  if ((await this.uiHelper.isTextVisible("The two-factor code you entered has already been used")) ||
51
51
  (await this.uiHelper.isTextVisible("too many codes have been submitted", 3000))) {
52
52
  await this.page.waitForTimeout(60000);
53
53
  await this.page.fill("#app_totp", this.getGitHub2FAOTP(userid));
54
54
  }
55
- await this.page.waitForTimeout(3_000);
55
+ await this.page
56
+ .getByRole("heading", { name: "Home" })
57
+ .waitFor({ timeout: 30_000 });
56
58
  }
57
59
  async logintoKeycloak(popup, userid, password) {
58
60
  await popup.waitForLoadState();
@@ -80,7 +82,23 @@ export class LoginHelper {
80
82
  await this.page.goto("/");
81
83
  await this.uiHelper.waitForLoad(12000);
82
84
  await this.uiHelper.clickButton("Sign In");
83
- await this.checkAndReauthorizeGithubApp();
85
+ // Wait for either: sidebar appears (auto-login) or popup opens (needs auth)
86
+ const navPromise = this.page
87
+ .waitForSelector("nav a", { timeout: 15_000 })
88
+ .then(() => "nav")
89
+ .catch(() => null);
90
+ const popupPromise = this.page
91
+ .waitForEvent("popup", { timeout: 15_000 })
92
+ .then((popup) => ({ popup }))
93
+ .catch(() => null);
94
+ const result = await Promise.race([navPromise, popupPromise]);
95
+ if (result === null) {
96
+ throw new Error("GitHub login failed: neither sidebar nor popup appeared after Sign In — session file may be stale");
97
+ }
98
+ if (typeof result === "object" && "popup" in result) {
99
+ // Popup opened — handle reauthorization
100
+ await this.handleGithubPopupReauth(result.popup);
101
+ }
84
102
  }
85
103
  else {
86
104
  // Perform login if no session file exists, then save the state
@@ -97,21 +115,24 @@ export class LoginHelper {
97
115
  async checkAndReauthorizeGithubApp() {
98
116
  await new Promise((resolve) => {
99
117
  this.page.once("popup", async (popup) => {
100
- await popup.waitForLoadState();
101
- // Check for popup closure for up to 10 seconds before proceeding
102
- for (let attempts = 0; attempts < 10 && !popup.isClosed(); attempts++) {
103
- await this.page.waitForTimeout(1000); // Using page here because if the popup closes automatically, it throws an error during the wait
104
- }
105
- const locator = popup.locator("button.js-oauth-authorize-btn");
106
- if (!popup.isClosed() && (await locator.isVisible())) {
107
- await popup.locator("body").click();
108
- await locator.waitFor();
109
- await locator.click();
110
- }
118
+ await this.handleGithubPopupReauth(popup);
111
119
  resolve();
112
120
  });
113
121
  });
114
122
  }
123
+ async handleGithubPopupReauth(popup) {
124
+ await popup.waitForLoadState();
125
+ // Check for popup closure for up to 10 seconds before proceeding
126
+ for (let attempts = 0; attempts < 10 && !popup.isClosed(); attempts++) {
127
+ await this.page.waitForTimeout(1000); // Using page here because if the popup closes automatically, it throws an error during the wait
128
+ }
129
+ const locator = popup.locator("button.js-oauth-authorize-btn");
130
+ if (!popup.isClosed() && (await locator.isVisible())) {
131
+ await popup.locator("body").click();
132
+ await locator.waitFor();
133
+ await locator.click();
134
+ }
135
+ }
115
136
  async googleSignIn(email) {
116
137
  await new Promise((resolve) => {
117
138
  this.page.once("popup", async (popup) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@red-hat-developer-hub/e2e-test-utils",
3
- "version": "1.1.42",
3
+ "version": "1.1.43",
4
4
  "description": "Test utilities for RHDH E2E tests",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {