external-services-automation 1.0.35 → 1.0.37

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/README.md CHANGED
@@ -48,7 +48,6 @@ import {
48
48
  ExternalServicesWorld,
49
49
  LoginPage,
50
50
  RegisterPage,
51
- KindeAuthService,
52
51
  StripeService,
53
52
  GuerrillaMailService,
54
53
  GetTestMailService
@@ -58,14 +57,17 @@ import {
58
57
  ### Use Services and Page Objects
59
58
 
60
59
  ```typescript
61
- // Authentication with Kinde
62
- const authService = new KindeAuthService();
63
- await authService.login(email, password);
64
-
65
60
  // Payment processing with Stripe
66
61
  const stripeService = new StripeService();
67
62
  await stripeService.upgradeSubscription(planType);
68
63
 
64
+ // Email testing with GetTestMail
65
+ const mailService = new GetTestMailService(
66
+ process.env.TESTMAIL_API_KEY!,
67
+ process.env.TESTMAIL_NAMESPACE!
68
+ );
69
+ const email = mailService.createEmailAddress('test-user');
70
+
69
71
  // Page interactions
70
72
  const loginPage = new LoginPage(page);
71
73
  await loginPage.fillCredentials(email, password);
@@ -75,11 +77,6 @@ await loginPage.fillCredentials(email, password);
75
77
 
76
78
  ### Services
77
79
 
78
- #### KindeAuthService
79
- - `login(email: string, password: string)` - Authenticates user with Kinde
80
- - `register(email: string, firstName: string, lastName: string)` - Creates new account
81
- - `verifyEmail(code: string)` - Verifies email with confirmation code
82
-
83
80
  #### StripeService
84
81
  - `upgradeSubscription(planType: string)` - Upgrades subscription to specified plan
85
82
  - `updatePaymentMethod(cardDetails: object)` - Updates payment method
@@ -105,8 +102,7 @@ await loginPage.fillCredentials(email, password);
105
102
  #### GuerrillaMailService
106
103
  Temporary email service (free, but can be unstable):
107
104
  - `createMail(alias?)` - Creates temporary email address
108
- - `readMailBySubject(regex)` - Waits for email matching subject
109
- - `clearInbox()` - Cleans inbox
105
+ - `readMailBySubject(regex, timeoutMs?, pollMs?)` - Waits for email matching subject
110
106
 
111
107
  #### GetTestMailService ⭐ **Recommended**
112
108
  Professional temporary email service with reliable API:
@@ -126,15 +122,13 @@ See [GetTestMailService documentation](./docs/GetTestMailService.md) for detaile
126
122
  ```typescript
127
123
  // In your test files
128
124
  import { test, expect } from '@playwright/test';
129
- import { KindeAuthService, StripeService, GetTestMailService } from 'external-services-automation';
125
+ import { StripeService, GetTestMailService } from 'external-services-automation';
130
126
 
131
127
  test.describe('External Services Integration', () => {
132
- let authService: KindeAuthService;
133
128
  let stripeService: StripeService;
134
129
  let mailService: GetTestMailService;
135
130
 
136
131
  test.beforeEach(async () => {
137
- authService = new KindeAuthService();
138
132
  stripeService = new StripeService();
139
133
  mailService = new GetTestMailService(
140
134
  process.env.TESTMAIL_API_KEY!,
@@ -142,13 +136,13 @@ test.describe('External Services Integration', () => {
142
136
  );
143
137
  });
144
138
 
145
- test('should create account and upgrade subscription', async () => {
139
+ test('should handle email verification flow', async () => {
146
140
  // Create temporary email for account verification
147
141
  const tag = `signup-${Date.now()}`;
148
142
  const email = mailService.createEmailAddress(tag);
149
143
 
150
- // Register new account
151
- await authService.register(email, 'John', 'Doe');
144
+ // Register new account (your implementation)
145
+ await registerUser(email);
152
146
 
153
147
  // Wait for verification email and extract code
154
148
  const verificationEmail = await mailService.readMailBySubject(
@@ -157,20 +151,17 @@ test.describe('External Services Integration', () => {
157
151
  120000
158
152
  );
159
153
  const code = mailService.extractCode(verificationEmail);
160
- await authService.verifyEmail(code);
161
154
 
162
- // Upgrade subscription
155
+ // Confirm registration with code (your implementation)
156
+ await confirmRegistration(code);
157
+ });
158
+
159
+ test('should upgrade subscription', async () => {
163
160
  await stripeService.upgradeSubscription('premium');
164
161
 
165
- // Verify subscription status
166
162
  const subscription = await stripeService.getCurrentSubscription();
167
163
  expect(subscription.status).toBe('active');
168
164
  });
169
-
170
- test('should handle login with existing account', async () => {
171
- const result = await authService.login('user@example.com', 'password123');
172
- expect(result.success).toBe(true);
173
- });
174
165
  });
175
166
  ```
176
167
 
@@ -216,7 +207,7 @@ npm install external-services-automation
216
207
  ### Import Errors
217
208
  Make sure you're importing from the correct package name:
218
209
  ```typescript
219
- import { KindeAuthService } from 'external-services-automation';
210
+ import { StripeService, GetTestMailService } from 'external-services-automation';
220
211
  ```
221
212
 
222
213
  ### Missing Peer Dependencies
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export { KindeAuthService } from './services/KindeAuthService';
2
1
  export { StripeService } from './services/StripeService';
3
2
  export { GuerrillaMailService, GuerrillaEmail } from './services/GuerrillaMailService';
4
3
  export { GetTestMailService, TestMailEmail, TestMailResponse } from './services/GetTestMailService';
package/dist/index.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LeftPanelPage = exports.ConfirmUpdatePage = exports.UpdatePaymentMethodPage = exports.UpdateSubscriptionPage = exports.CurrentSubscriptionPage = exports.ConfirmCodePage = exports.PasswordSetupPage = exports.RegisterPage = exports.LoginPage = exports.GetTestMailService = exports.GuerrillaMailService = exports.StripeService = exports.KindeAuthService = void 0;
3
+ exports.LeftPanelPage = exports.ConfirmUpdatePage = exports.UpdatePaymentMethodPage = exports.UpdateSubscriptionPage = exports.CurrentSubscriptionPage = exports.ConfirmCodePage = exports.PasswordSetupPage = exports.RegisterPage = exports.LoginPage = exports.GetTestMailService = exports.GuerrillaMailService = exports.StripeService = void 0;
4
4
  // Export services
5
- var KindeAuthService_1 = require("./services/KindeAuthService");
6
- Object.defineProperty(exports, "KindeAuthService", { enumerable: true, get: function () { return KindeAuthService_1.KindeAuthService; } });
7
5
  var StripeService_1 = require("./services/StripeService");
8
6
  Object.defineProperty(exports, "StripeService", { enumerable: true, get: function () { return StripeService_1.StripeService; } });
9
7
  var GuerrillaMailService_1 = require("./services/GuerrillaMailService");
@@ -8,18 +8,12 @@ export interface GuerrillaEmail {
8
8
  }
9
9
  declare class GuerrillaMailService {
10
10
  private readonly API_URL;
11
- private readonly ip;
12
- private readonly agent;
13
11
  private seq;
14
- private emailAddress;
15
12
  private client;
16
13
  constructor();
17
14
  createMail(alias?: string): Promise<string>;
18
15
  readMailBySubject(subjectRegex: RegExp, timeoutMs?: number, pollMs?: number): Promise<GuerrillaEmail>;
19
- deleteMail(mailId: string): Promise<void>;
20
16
  private fetchEmail;
21
17
  static createIsolatedClient(): GuerrillaMailService;
22
- clearInbox(): Promise<void>;
23
18
  }
24
- export declare const email: GuerrillaMailService;
25
19
  export { GuerrillaMailService };
@@ -3,55 +3,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.GuerrillaMailService = exports.email = void 0;
6
+ exports.GuerrillaMailService = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const axios_cookiejar_support_1 = require("axios-cookiejar-support");
9
9
  const tough_cookie_1 = require("tough-cookie");
10
10
  class GuerrillaMailService {
11
11
  constructor() {
12
12
  this.API_URL = 'https://api.guerrillamail.com/ajax.php';
13
- this.ip = '127.0.0.1';
14
- this.agent = encodeURIComponent('qa-automation-utils/1.0');
15
13
  this.seq = 0;
16
- this.emailAddress = '';
17
14
  const jar = new tough_cookie_1.CookieJar();
18
15
  this.client = (0, axios_cookiejar_support_1.wrapper)(axios_1.default.create({
19
16
  jar,
20
17
  withCredentials: true,
21
18
  timeout: 30000,
22
- headers: {
23
- 'User-Agent': 'qa-automation-utils/1.0',
24
- },
25
19
  }));
26
20
  }
27
21
  async createMail(alias) {
22
+ const params = {
23
+ f: alias ? 'set_email_user' : 'get_email_address',
24
+ ip: '127.0.0.1',
25
+ agent: 'qa-automation',
26
+ };
28
27
  if (alias) {
29
- const { data } = await this.client.get(this.API_URL, {
30
- params: {
31
- f: 'set_email_user',
32
- email_user: alias,
33
- ip: this.ip,
34
- agent: this.agent,
35
- },
36
- });
37
- this.emailAddress = data.email_addr;
28
+ params.email_user = alias;
38
29
  }
39
- else {
40
- const { data } = await this.client.get(this.API_URL, {
41
- params: {
42
- f: 'get_email_address',
43
- ip: this.ip,
44
- agent: this.agent,
45
- },
46
- });
47
- this.emailAddress = data.email_addr;
48
- }
49
- return this.emailAddress;
30
+ const { data } = await this.client.get(this.API_URL, { params });
31
+ console.log('[GuerrillaMailService] Email created:', data.email_addr);
32
+ return data.email_addr;
50
33
  }
51
34
  async readMailBySubject(subjectRegex, timeoutMs = 60000, pollMs = 5000) {
52
35
  const start = Date.now();
53
36
  let attempt = 0;
54
- console.log('[GuerrillaMailService] Starting to wait for email with subject:', subjectRegex.toString());
37
+ console.log('[GuerrillaMailService] Waiting for email with subject:', subjectRegex.toString());
55
38
  while (Date.now() - start < timeoutMs) {
56
39
  attempt++;
57
40
  const elapsed = ((Date.now() - start) / 1000).toFixed(1);
@@ -59,8 +42,8 @@ class GuerrillaMailService {
59
42
  params: {
60
43
  f: 'check_email',
61
44
  seq: this.seq,
62
- ip: this.ip,
63
- agent: this.agent,
45
+ ip: '127.0.0.1',
46
+ agent: 'qa-automation',
64
47
  },
65
48
  });
66
49
  this.seq = data.seq ?? this.seq;
@@ -82,33 +65,21 @@ class GuerrillaMailService {
82
65
  subject: matches[0].mail_subject
83
66
  });
84
67
  matches.sort((a, b) => b.mail_timestamp - a.mail_timestamp);
85
- const mostRecent = matches[0];
86
- const full = await this.fetchEmail(mostRecent.mail_id);
87
- return full;
68
+ return await this.fetchEmail(matches[0].mail_id);
88
69
  }
89
70
  console.log(`[GuerrillaMailService] No match yet, waiting ${pollMs}ms...`);
90
71
  await new Promise(r => setTimeout(r, pollMs));
91
72
  }
92
- console.log('[GuerrillaMailService] Timeout reached after', attempt, 'attempts');
73
+ console.log('[GuerrillaMailService] Timeout after', attempt, 'attempts');
93
74
  throw new Error(`Timeout (${timeoutMs} ms) waiting for an email with subject matching ${subjectRegex}`);
94
75
  }
95
- async deleteMail(mailId) {
96
- await this.client.get(this.API_URL, {
97
- params: {
98
- f: 'del_email',
99
- email_ids: `[${mailId}]`,
100
- ip: this.ip,
101
- agent: this.agent,
102
- },
103
- });
104
- }
105
76
  async fetchEmail(mailId) {
106
77
  const { data } = await this.client.get(this.API_URL, {
107
78
  params: {
108
79
  f: 'fetch_email',
109
80
  email_id: mailId,
110
- ip: this.ip,
111
- agent: this.agent,
81
+ ip: '127.0.0.1',
82
+ agent: 'qa-automation',
112
83
  },
113
84
  });
114
85
  return data;
@@ -116,25 +87,5 @@ class GuerrillaMailService {
116
87
  static createIsolatedClient() {
117
88
  return new GuerrillaMailService();
118
89
  }
119
- async clearInbox() {
120
- const { data } = await this.client.get(this.API_URL, {
121
- params: {
122
- f: 'check_email',
123
- seq: this.seq,
124
- ip: this.ip,
125
- agent: this.agent,
126
- },
127
- });
128
- const list = data.list ?? [];
129
- for (const email of list) {
130
- try {
131
- await this.deleteMail(email.mail_id);
132
- }
133
- catch (error) {
134
- console.warn(`Could not delete email ${email.mail_id}:`, error);
135
- }
136
- }
137
- }
138
90
  }
139
91
  exports.GuerrillaMailService = GuerrillaMailService;
140
- exports.email = new GuerrillaMailService();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "external-services-automation",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "description": "External services automation library for Playwright and Cucumber",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,8 +0,0 @@
1
- import { GuerrillaEmail } from "./GuerrillaMailService";
2
- export declare class KindeAuthService {
3
- private emailClient?;
4
- constructor();
5
- createGuerrillaMail(): Promise<string>;
6
- getConfirmationCodeFromEmail(): Promise<string>;
7
- readEmailBySubject(subject: RegExp): Promise<GuerrillaEmail>;
8
- }
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KindeAuthService = void 0;
4
- const GuerrillaMailService_1 = require("./GuerrillaMailService");
5
- class KindeAuthService {
6
- constructor() {
7
- this.emailClient = GuerrillaMailService_1.GuerrillaMailService.createIsolatedClient();
8
- console.log('[KindeAuthService] Email client initialized');
9
- }
10
- async createGuerrillaMail() {
11
- return this.emailClient.createMail();
12
- }
13
- async getConfirmationCodeFromEmail() {
14
- console.log('[KindeAuthService] Waiting for verification code email...');
15
- const emailData = await this.emailClient.readMailBySubject(/Email verification code/i, 120000, // 2 minutes timeout
16
- 5000);
17
- console.log('[KindeAuthService] Email received:', {
18
- mailId: emailData.mail_id,
19
- subject: emailData.mail_subject,
20
- from: emailData.mail_from,
21
- bodyPreview: emailData.mail_body?.substring(0, 150)
22
- });
23
- const codeMatch = emailData.mail_body?.match(/\b\d{6}\b/);
24
- console.log('[KindeAuthService] Extracted code:', codeMatch?.[0]);
25
- return codeMatch[0];
26
- }
27
- async readEmailBySubject(subject) {
28
- console.log('[KindeAuthService] Waiting for email with subject:', subject.toString());
29
- const emailData = await this.emailClient.readMailBySubject(subject, 120000, // 2 minutes timeout
30
- 5000);
31
- console.log('[KindeAuthService] Email received:', {
32
- mailId: emailData.mail_id,
33
- subject: emailData.mail_subject,
34
- from: emailData.mail_from,
35
- bodyLength: emailData.mail_body?.length || 0
36
- });
37
- return emailData;
38
- }
39
- }
40
- exports.KindeAuthService = KindeAuthService;