external-services-automation 1.0.27 → 1.0.28

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.
@@ -5,8 +5,5 @@ export declare class ConfirmCodePage {
5
5
  readonly codeInput: Locator;
6
6
  readonly continueButton: Locator;
7
7
  constructor(page: Page);
8
- enterConfirmationCode(code: string): Promise<void>;
9
- clickContinue(): Promise<void>;
10
8
  submitConfirmationCode(code: string): Promise<void>;
11
- isOnConfirmCodePage(): Promise<void>;
12
9
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConfirmCodePage = void 0;
4
- const test_1 = require("@playwright/test");
5
4
  class ConfirmCodePage {
6
5
  constructor(page) {
7
6
  this.page = page;
@@ -9,20 +8,9 @@ class ConfirmCodePage {
9
8
  this.codeInput = page.locator('input[name="p_confirmation_code"]');
10
9
  this.continueButton = page.getByRole('button', { name: 'Continue' });
11
10
  }
12
- async enterConfirmationCode(code) {
11
+ async submitConfirmationCode(code) {
13
12
  await this.codeInput.fill(code);
14
- }
15
- async clickContinue() {
16
13
  await this.continueButton.click();
17
14
  }
18
- async submitConfirmationCode(code) {
19
- await this.enterConfirmationCode(code);
20
- await this.clickContinue();
21
- }
22
- async isOnConfirmCodePage() {
23
- await (0, test_1.expect)(this.pageTitle).toBeVisible();
24
- await (0, test_1.expect)(this.codeInput).toBeVisible();
25
- await (0, test_1.expect)(this.continueButton).toBeVisible();
26
- }
27
15
  }
28
16
  exports.ConfirmCodePage = ConfirmCodePage;
@@ -4,12 +4,9 @@ export declare class LoginPage {
4
4
  readonly emailInput: Locator;
5
5
  readonly nextButton: Locator;
6
6
  readonly passwordInput: Locator;
7
- readonly email_not_exists: Locator;
7
+ readonly emailErrorMessage: Locator;
8
8
  readonly createAccountLink: Locator;
9
9
  constructor(page: Page);
10
- navigate(): Promise<void>;
11
- enterEmail(email: string): Promise<void>;
12
- enterPassword(password: string): Promise<void>;
13
10
  getEmailNotExistsMessage(): Promise<string | null>;
14
11
  login(email: string, password?: string): Promise<void>;
15
12
  goToRegisterPage(): Promise<void>;
@@ -7,32 +7,18 @@ class LoginPage {
7
7
  this.emailInput = page.locator('#sign_up_sign_in_credentials_p_email');
8
8
  this.nextButton = page.locator('.kinde-button.kinde-button-variant-primary');
9
9
  this.passwordInput = page.locator('#verify_password_p_password');
10
- this.email_not_exists = page.locator('#sign_up_sign_in_credentials_p_email_error_msg');
10
+ this.emailErrorMessage = page.locator('#sign_up_sign_in_credentials_p_email_error_msg');
11
11
  this.createAccountLink = page.locator('//span[@class="signup-cta"]//a[text()="Sign up"]');
12
12
  }
13
- async navigate() {
14
- await this.page.goto('/login');
15
- }
16
- async enterEmail(email) {
17
- await this.emailInput.fill(email);
18
- await this.nextButton.click();
19
- await this.page.waitForTimeout(2000);
20
- }
21
- async enterPassword(password) {
22
- await this.passwordInput.fill(password);
23
- await this.nextButton.click();
24
- await this.page.waitForTimeout(3000);
25
- }
26
13
  async getEmailNotExistsMessage() {
27
- return await this.email_not_exists.textContent();
14
+ return await this.emailErrorMessage.textContent();
28
15
  }
29
16
  async login(email, password) {
30
- if (!email) {
31
- throw new Error(`${email} is not set`);
32
- }
33
- await this.enterEmail(email);
17
+ await this.emailInput.fill(email);
18
+ await this.nextButton.click();
34
19
  if (password) {
35
- await this.enterPassword(password);
20
+ await this.passwordInput.fill(password);
21
+ await this.nextButton.click();
36
22
  }
37
23
  }
38
24
  async goToRegisterPage() {
@@ -7,10 +7,6 @@ export declare class PasswordSetupPage {
7
7
  readonly continueButton: Locator;
8
8
  readonly dontUseMFAButton: Locator;
9
9
  constructor(page: Page);
10
- enterPassword(password: string): Promise<void>;
11
- enterConfirmPassword(password: string): Promise<void>;
12
- clickContinue(): Promise<void>;
13
- submitPasswordForm(password: string): Promise<void>;
14
- isOnPasswordSetupPage(): Promise<void>;
10
+ fillPassword(password: string): Promise<void>;
15
11
  dontUseMFA(): Promise<void>;
16
12
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PasswordSetupPage = void 0;
4
- const test_1 = require("@playwright/test");
5
4
  class PasswordSetupPage {
6
5
  constructor(page) {
7
6
  this.page = page;
@@ -11,26 +10,11 @@ class PasswordSetupPage {
11
10
  this.continueButton = page.getByRole('button', { name: 'Continue' });
12
11
  this.dontUseMFAButton = page.locator('//button[contains(text(), "multi-factor authentication")]');
13
12
  }
14
- async enterPassword(password) {
13
+ async fillPassword(password) {
15
14
  await this.passwordInput.fill(password);
16
- }
17
- async enterConfirmPassword(password) {
18
15
  await this.confirmPasswordInput.fill(password);
19
- }
20
- async clickContinue() {
21
16
  await this.continueButton.click();
22
17
  }
23
- async submitPasswordForm(password) {
24
- await this.enterPassword(password);
25
- await this.enterConfirmPassword(password);
26
- await this.clickContinue();
27
- }
28
- async isOnPasswordSetupPage() {
29
- await (0, test_1.expect)(this.pageTitle).toBeVisible();
30
- await (0, test_1.expect)(this.passwordInput).toBeVisible();
31
- await (0, test_1.expect)(this.confirmPasswordInput).toBeVisible();
32
- await (0, test_1.expect)(this.continueButton).toBeVisible();
33
- }
34
18
  async dontUseMFA() {
35
19
  await this.page.waitForTimeout(3000);
36
20
  if (await this.dontUseMFAButton.isVisible()) {
@@ -8,13 +8,5 @@ export declare class RegisterPage {
8
8
  readonly acceptPoliciesCheckbox: Locator;
9
9
  readonly createAccountButton: Locator;
10
10
  constructor(page: Page);
11
- navigate(): Promise<void>;
12
- enterFirstName(firstName: string): Promise<void>;
13
- enterLastName(lastName: string): Promise<void>;
14
- enterEmail(email: string): Promise<void>;
15
- checkMarketingOptIn(): Promise<void>;
16
- checkAcceptPolicies(): Promise<void>;
17
- clickCreateAccount(): Promise<void>;
18
- fillAndSubmitCreateAccountForm(firstName: string, lastName: string, email: string, acceptMarketing?: boolean): Promise<void>;
19
- isOnRegisterPage(): Promise<void>;
11
+ register(firstName: string, lastName: string, email: string, acceptMarketing?: boolean): Promise<void>;
20
12
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RegisterPage = void 0;
4
- const test_1 = require("@playwright/test");
5
4
  class RegisterPage {
6
5
  constructor(page) {
7
6
  this.page = page;
@@ -12,53 +11,15 @@ class RegisterPage {
12
11
  this.acceptPoliciesCheckbox = page.locator('input[name="p_has_clickwrap_accepted"]');
13
12
  this.createAccountButton = page.locator('//span[contains(text(), "account")]/parent::button');
14
13
  }
15
- async navigate() {
16
- await this.page.goto('/auth/register');
17
- await this.isOnRegisterPage();
18
- }
19
- async enterFirstName(firstName) {
14
+ async register(firstName, lastName, email, acceptMarketing = false) {
20
15
  await this.firstNameInput.fill(firstName);
21
- }
22
- async enterLastName(lastName) {
23
16
  await this.lastNameInput.fill(lastName);
24
- }
25
- async enterEmail(email) {
26
17
  await this.emailInput.fill(email);
27
- }
28
- async checkMarketingOptIn() {
29
- await this.marketingOptInCheckbox.check();
30
- }
31
- async checkAcceptPolicies() {
32
18
  await this.acceptPoliciesCheckbox.check();
33
- }
34
- async clickCreateAccount() {
35
- await this.createAccountButton.click();
36
- }
37
- async fillAndSubmitCreateAccountForm(firstName, lastName, email, acceptMarketing = false) {
38
- await this.enterFirstName(firstName);
39
- await this.enterLastName(lastName);
40
- await this.enterEmail(email);
41
19
  if (acceptMarketing) {
42
- await this.checkMarketingOptIn();
43
- }
44
- const checkboxCount = await this.acceptPoliciesCheckbox.count();
45
- if (checkboxCount > 0) {
46
- try {
47
- await this.checkAcceptPolicies();
48
- }
49
- catch (error) {
50
- // Ignore if checkbox is not interactable
51
- }
20
+ await this.marketingOptInCheckbox.check();
52
21
  }
53
- await this.clickCreateAccount();
54
- }
55
- async isOnRegisterPage() {
56
- await (0, test_1.expect)(this.firstNameInput).toBeVisible();
57
- await (0, test_1.expect)(this.lastNameInput).toBeVisible();
58
- await (0, test_1.expect)(this.emailInput).toBeVisible();
59
- await (0, test_1.expect)(this.marketingOptInCheckbox).toBeVisible();
60
- // await expect(this.acceptPoliciesCheckbox).toBeVisible();
61
- await (0, test_1.expect)(this.createAccountButton).toBeVisible();
22
+ await this.createAccountButton.click();
62
23
  }
63
24
  }
64
25
  exports.RegisterPage = RegisterPage;
@@ -1,14 +1,6 @@
1
- import { Page } from 'playwright/test';
2
- import { GuerrillaMailClient } from '../utils/temp-email-utils';
3
1
  export declare class KindeAuthService {
4
- private tempEmail?;
5
- private verificationCode?;
6
2
  private emailClient?;
7
- private loginPage;
8
- private registerPage;
9
- private confirmCodePage;
10
- private passwordSetupPage;
11
- constructor(page: Page);
12
- createAccountWithEmailVerification(referralCode?: string): Promise<GuerrillaMailClient>;
13
- deleteTemporaryEmail(): Promise<void>;
3
+ constructor();
4
+ createGuerrillaMail(): Promise<string>;
5
+ getConfirmationCodeFromEmail(): Promise<string>;
14
6
  }
@@ -1,57 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KindeAuthService = void 0;
4
- const ConfirmCodePage_1 = require("../pages/kinde/ConfirmCodePage");
5
- const LoginPage_1 = require("../pages/kinde/LoginPage");
6
- const PasswordSetupPage_1 = require("../pages/kinde/PasswordSetupPage");
7
- const RegisterPage_1 = require("../pages/kinde/RegisterPage");
8
4
  const temp_email_utils_1 = require("../utils/temp-email-utils");
9
5
  class KindeAuthService {
10
- constructor(page) {
11
- this.loginPage = new LoginPage_1.LoginPage(page);
12
- this.registerPage = new RegisterPage_1.RegisterPage(page);
13
- this.confirmCodePage = new ConfirmCodePage_1.ConfirmCodePage(page);
14
- this.passwordSetupPage = new PasswordSetupPage_1.PasswordSetupPage(page);
15
- }
16
- async createAccountWithEmailVerification(referralCode) {
17
- await this.loginPage.page.goto(referralCode || '/');
18
- await this.loginPage.goToRegisterPage();
19
- await this.registerPage.isOnRegisterPage();
6
+ constructor() {
20
7
  this.emailClient = temp_email_utils_1.GuerrillaMailClient.createIsolatedClient();
21
- this.tempEmail = await this.emailClient.createMail();
22
- const firstName = 'Test';
23
- const lastName = 'User';
24
- await this.registerPage.fillAndSubmitCreateAccountForm(firstName, lastName, this.tempEmail, false // Don't accept marketing emails
25
- );
26
- await this.confirmCodePage.isOnConfirmCodePage();
8
+ }
9
+ async createGuerrillaMail() {
10
+ return this.emailClient.createMail();
11
+ }
12
+ async getConfirmationCodeFromEmail() {
27
13
  const emailData = await this.emailClient.readMailBySubject(/Email verification code/i, 120000, // 2 minutes timeout
28
- 5000 // Check every 5 seconds
29
- );
14
+ 5000);
30
15
  const codeMatch = emailData.mail_body?.match(/\b\d{6}\b/);
31
- if (codeMatch) {
32
- this.verificationCode = codeMatch[0];
33
- await this.confirmCodePage.submitConfirmationCode(this.verificationCode);
34
- }
35
- else {
36
- throw new Error('Could not extract verification code from email');
37
- }
38
- await this.passwordSetupPage.isOnPasswordSetupPage();
39
- const password = 'TestPassword123!';
40
- await this.passwordSetupPage.submitPasswordForm(password);
41
- await this.passwordSetupPage.dontUseMFA();
42
- return this.emailClient;
43
- }
44
- async deleteTemporaryEmail() {
45
- if (this.tempEmail) {
46
- try {
47
- this.tempEmail = undefined;
48
- this.verificationCode = undefined;
49
- this.emailClient = undefined;
50
- }
51
- catch (error) {
52
- console.warn("Could not clean up temporary email:", error);
53
- }
54
- }
16
+ return codeMatch[0];
55
17
  }
56
18
  }
57
19
  exports.KindeAuthService = KindeAuthService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "external-services-automation",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "description": "External services automation library for Playwright and Cucumber",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",