@bigbinary/neeto-playwright-commons 1.24.0 → 1.24.1

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.
package/index.js CHANGED
@@ -116132,14 +116132,24 @@ class GooglePage extends IntegrationBase {
116132
116132
  await this.page.waitForLoadState("load", { timeout: 25000 });
116133
116133
  await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.myAccount));
116134
116134
  };
116135
- this.enterTotpCode = (locator) => expect(async () => {
116136
- const totpToken = this.totp.generate({ timestamp: Date.now() + 5000 });
116137
- await this.page.getByLabel(GOOGLE_LOGIN_TEXTS.enterCode).fill(totpToken);
116138
- expect(this.totp.validate({ token: totpToken })).not.toBeNull();
116139
- await this.page.locator(GOOGLE_LOGIN_SELECTORS.totpNext).click();
116140
- await expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.wrongCode)).toBeHidden({ timeout: 15000 });
116141
- await expect(locator).toBeHidden({ timeout: 10000 });
116142
- }).toPass({ timeout: 50000 });
116135
+ this.enterTotpCode = async (locator) => {
116136
+ let previousToken = null;
116137
+ await expect(async () => {
116138
+ let totpToken = this.totp.generate({ timestamp: Date.now() });
116139
+ if (totpToken === previousToken) {
116140
+ const remainingTime = this.totp.remaining({ timestamp: Date.now() });
116141
+ // eslint-disable-next-line playwright/no-wait-for-timeout
116142
+ await this.page.waitForTimeout(remainingTime + 500); // Wait for the remaining time plus a small buffer (500ms) to ensure new token
116143
+ totpToken = this.totp.generate({ timestamp: Date.now() });
116144
+ }
116145
+ previousToken = totpToken;
116146
+ await this.page.getByLabel(GOOGLE_LOGIN_TEXTS.enterCode).fill(totpToken);
116147
+ expect(this.totp.validate({ token: totpToken })).not.toBeNull();
116148
+ await this.page.locator(GOOGLE_LOGIN_SELECTORS.totpNext).click();
116149
+ await expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.wrongCode)).toBeHidden({ timeout: 10000 });
116150
+ await expect(locator).toBeHidden({ timeout: 10000 });
116151
+ }).toPass({ timeout: 2 * 60 * 1000 });
116152
+ };
116143
116153
  this.logoutFromGoogle = async () => {
116144
116154
  await this.page.goto(THIRD_PARTY_ROUTES.google.myAccount, {
116145
116155
  timeout: 20000,