external-services-automation 1.0.14 → 1.0.16
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 +210 -210
- package/dist/pages/kinde/PasswordSetupPage.d.ts +0 -1
- package/dist/pages/kinde/PasswordSetupPage.js +2 -6
- package/dist/pages/stripe/UpdatePaymentMethodPage.js +0 -2
- package/dist/services/KindeAuthService.d.ts +1 -1
- package/dist/services/KindeAuthService.js +1 -0
- package/dist/utils/temp-email-utils.d.ts +0 -24
- package/dist/utils/temp-email-utils.js +2 -30
- package/package.json +43 -43
package/README.md
CHANGED
|
@@ -1,211 +1,211 @@
|
|
|
1
|
-
# External Services Automation Library
|
|
2
|
-
|
|
3
|
-
A TypeScript library for test automation with Playwright, focused on integrations with external services like Kinde (authentication) and Stripe (payments).
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
Install the package via npm:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install external-services-automation
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Setup
|
|
14
|
-
|
|
15
|
-
### Configure Your Test Framework
|
|
16
|
-
|
|
17
|
-
The library can be used with any test framework. Here's an example for Playwright:
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
// playwright.config.ts
|
|
21
|
-
import { defineConfig } from '@playwright/test';
|
|
22
|
-
|
|
23
|
-
export default defineConfig({
|
|
24
|
-
testDir: './tests',
|
|
25
|
-
use: {
|
|
26
|
-
baseURL: process.env.BASE_URL || 'https://your-app.com',
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Usage
|
|
32
|
-
|
|
33
|
-
### Import Components
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
import {
|
|
37
|
-
ExternalServicesWorld,
|
|
38
|
-
LoginPage,
|
|
39
|
-
RegisterPage,
|
|
40
|
-
KindeAuthService,
|
|
41
|
-
StripeService,
|
|
42
|
-
GuerrillaMailClient
|
|
43
|
-
} from 'external-services-automation';
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### Use Services and Page Objects
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
// Authentication with Kinde
|
|
50
|
-
const authService = new KindeAuthService();
|
|
51
|
-
await authService.login(email, password);
|
|
52
|
-
|
|
53
|
-
// Payment processing with Stripe
|
|
54
|
-
const stripeService = new StripeService();
|
|
55
|
-
await stripeService.upgradeSubscription(planType);
|
|
56
|
-
|
|
57
|
-
// Page interactions
|
|
58
|
-
const loginPage = new LoginPage(page);
|
|
59
|
-
await loginPage.fillCredentials(email, password);
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Available Components
|
|
63
|
-
|
|
64
|
-
### Services
|
|
65
|
-
|
|
66
|
-
#### KindeAuthService
|
|
67
|
-
- `login(email: string, password: string)` - Authenticates user with Kinde
|
|
68
|
-
- `register(email: string, firstName: string, lastName: string)` - Creates new account
|
|
69
|
-
- `verifyEmail(code: string)` - Verifies email with confirmation code
|
|
70
|
-
|
|
71
|
-
#### StripeService
|
|
72
|
-
- `upgradeSubscription(planType: string)` - Upgrades subscription to specified plan
|
|
73
|
-
- `updatePaymentMethod(cardDetails: object)` - Updates payment method
|
|
74
|
-
- `getCurrentSubscription()` - Retrieves current subscription details
|
|
75
|
-
|
|
76
|
-
### Page Objects
|
|
77
|
-
|
|
78
|
-
#### Kinde Pages
|
|
79
|
-
- **LoginPage** - Handles login form interactions
|
|
80
|
-
- **RegisterPage** - Manages account registration
|
|
81
|
-
- **ConfirmCodePage** - Email verification code entry
|
|
82
|
-
- **PasswordSetupPage** - Password creation and setup
|
|
83
|
-
|
|
84
|
-
#### Stripe Pages
|
|
85
|
-
- **CurrentSubscriptionPage** - Displays current subscription details
|
|
86
|
-
- **UpdateSubscriptionPage** - Subscription plan selection
|
|
87
|
-
- **UpdatePaymentMethodPage** - Payment method management
|
|
88
|
-
- **ConfirmUpdatePage** - Confirmation dialogs
|
|
89
|
-
- **LeftPanelPage** - Navigation and sidebar interactions
|
|
90
|
-
|
|
91
|
-
### Utilities
|
|
92
|
-
- **GuerrillaMailClient** - Temporary email handling for account verification
|
|
93
|
-
- `createTempEmail()` - Creates temporary email address
|
|
94
|
-
- `getVerificationCode()` - Retrieves verification emails
|
|
95
|
-
- `cleanup()` - Cleans up temporary email resources
|
|
96
|
-
|
|
97
|
-
### World Extension
|
|
98
|
-
- **ExternalServicesWorld** - Shared state management for test scenarios
|
|
99
|
-
|
|
100
|
-
## Example Implementation
|
|
101
|
-
|
|
102
|
-
```typescript
|
|
103
|
-
// In your test files
|
|
104
|
-
import { test, expect } from '@playwright/test';
|
|
105
|
-
import { KindeAuthService, StripeService, GuerrillaMailClient } from 'external-services-automation';
|
|
106
|
-
|
|
107
|
-
test.describe('External Services Integration', () => {
|
|
108
|
-
let authService: KindeAuthService;
|
|
109
|
-
let stripeService: StripeService;
|
|
110
|
-
let tempEmail: GuerrillaMailClient;
|
|
111
|
-
|
|
112
|
-
test.beforeEach(async () => {
|
|
113
|
-
authService = new KindeAuthService();
|
|
114
|
-
stripeService = new StripeService();
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test('should create account and upgrade subscription', async () => {
|
|
118
|
-
// Create temporary email for account verification
|
|
119
|
-
tempEmail = new GuerrillaMailClient();
|
|
120
|
-
const email = await tempEmail.createTempEmail();
|
|
121
|
-
|
|
122
|
-
// Register new account
|
|
123
|
-
await authService.register(email, 'John', 'Doe');
|
|
124
|
-
|
|
125
|
-
// Verify email
|
|
126
|
-
const verificationCode = await tempEmail.getVerificationCode();
|
|
127
|
-
await authService.verifyEmail(verificationCode);
|
|
128
|
-
|
|
129
|
-
// Upgrade subscription
|
|
130
|
-
await stripeService.upgradeSubscription('premium');
|
|
131
|
-
|
|
132
|
-
// Verify subscription status
|
|
133
|
-
const subscription = await stripeService.getCurrentSubscription();
|
|
134
|
-
expect(subscription.status).toBe('active');
|
|
135
|
-
|
|
136
|
-
// Cleanup
|
|
137
|
-
await tempEmail.cleanup();
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
test('should handle login with existing account', async () => {
|
|
141
|
-
const result = await authService.login('user@example.com', 'password123');
|
|
142
|
-
expect(result.success).toBe(true);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
## Updates
|
|
148
|
-
|
|
149
|
-
To update to the latest version:
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
npm update external-services-automation
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
## CI/CD
|
|
156
|
-
|
|
157
|
-
### Bitbucket Pipelines
|
|
158
|
-
|
|
159
|
-
```yaml
|
|
160
|
-
script:
|
|
161
|
-
- npm install
|
|
162
|
-
- npm test
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
## Dependencies
|
|
166
|
-
|
|
167
|
-
The library requires the following peer dependencies to be installed in your project:
|
|
168
|
-
|
|
169
|
-
```bash
|
|
170
|
-
npm install @playwright/test axios-cookiejar-support dotenv tough-cookie
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
Version requirements:
|
|
174
|
-
- `@playwright/test` ^1.40.0
|
|
175
|
-
- `axios-cookiejar-support` ^6.0.2
|
|
176
|
-
- `dotenv` ^16.4.5
|
|
177
|
-
- `tough-cookie` ^5.1.2
|
|
178
|
-
|
|
179
|
-
## Troubleshooting
|
|
180
|
-
|
|
181
|
-
### Package Not Found
|
|
182
|
-
```bash
|
|
183
|
-
npm install external-services-automation
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### Import Errors
|
|
187
|
-
Make sure you're importing from the correct package name:
|
|
188
|
-
```typescript
|
|
189
|
-
import { KindeAuthService } from 'external-services-automation';
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### Missing Peer Dependencies
|
|
193
|
-
```bash
|
|
194
|
-
npm install @playwright/test axios-cookiejar-support dotenv tough-cookie
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
## Development
|
|
198
|
-
|
|
199
|
-
For contributors working on this library:
|
|
200
|
-
|
|
201
|
-
```bash
|
|
202
|
-
git clone https://bitbucket.org/connectist/external-services-automation.git
|
|
203
|
-
cd external-services-automation
|
|
204
|
-
npm install
|
|
205
|
-
npm run build
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
## Links
|
|
209
|
-
|
|
210
|
-
- **NPM Package**: https://www.npmjs.com/package/external-services-automation
|
|
1
|
+
# External Services Automation Library
|
|
2
|
+
|
|
3
|
+
A TypeScript library for test automation with Playwright, focused on integrations with external services like Kinde (authentication) and Stripe (payments).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the package via npm:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install external-services-automation
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
|
|
15
|
+
### Configure Your Test Framework
|
|
16
|
+
|
|
17
|
+
The library can be used with any test framework. Here's an example for Playwright:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
// playwright.config.ts
|
|
21
|
+
import { defineConfig } from '@playwright/test';
|
|
22
|
+
|
|
23
|
+
export default defineConfig({
|
|
24
|
+
testDir: './tests',
|
|
25
|
+
use: {
|
|
26
|
+
baseURL: process.env.BASE_URL || 'https://your-app.com',
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
### Import Components
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import {
|
|
37
|
+
ExternalServicesWorld,
|
|
38
|
+
LoginPage,
|
|
39
|
+
RegisterPage,
|
|
40
|
+
KindeAuthService,
|
|
41
|
+
StripeService,
|
|
42
|
+
GuerrillaMailClient
|
|
43
|
+
} from 'external-services-automation';
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Use Services and Page Objects
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
// Authentication with Kinde
|
|
50
|
+
const authService = new KindeAuthService();
|
|
51
|
+
await authService.login(email, password);
|
|
52
|
+
|
|
53
|
+
// Payment processing with Stripe
|
|
54
|
+
const stripeService = new StripeService();
|
|
55
|
+
await stripeService.upgradeSubscription(planType);
|
|
56
|
+
|
|
57
|
+
// Page interactions
|
|
58
|
+
const loginPage = new LoginPage(page);
|
|
59
|
+
await loginPage.fillCredentials(email, password);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Available Components
|
|
63
|
+
|
|
64
|
+
### Services
|
|
65
|
+
|
|
66
|
+
#### KindeAuthService
|
|
67
|
+
- `login(email: string, password: string)` - Authenticates user with Kinde
|
|
68
|
+
- `register(email: string, firstName: string, lastName: string)` - Creates new account
|
|
69
|
+
- `verifyEmail(code: string)` - Verifies email with confirmation code
|
|
70
|
+
|
|
71
|
+
#### StripeService
|
|
72
|
+
- `upgradeSubscription(planType: string)` - Upgrades subscription to specified plan
|
|
73
|
+
- `updatePaymentMethod(cardDetails: object)` - Updates payment method
|
|
74
|
+
- `getCurrentSubscription()` - Retrieves current subscription details
|
|
75
|
+
|
|
76
|
+
### Page Objects
|
|
77
|
+
|
|
78
|
+
#### Kinde Pages
|
|
79
|
+
- **LoginPage** - Handles login form interactions
|
|
80
|
+
- **RegisterPage** - Manages account registration
|
|
81
|
+
- **ConfirmCodePage** - Email verification code entry
|
|
82
|
+
- **PasswordSetupPage** - Password creation and setup
|
|
83
|
+
|
|
84
|
+
#### Stripe Pages
|
|
85
|
+
- **CurrentSubscriptionPage** - Displays current subscription details
|
|
86
|
+
- **UpdateSubscriptionPage** - Subscription plan selection
|
|
87
|
+
- **UpdatePaymentMethodPage** - Payment method management
|
|
88
|
+
- **ConfirmUpdatePage** - Confirmation dialogs
|
|
89
|
+
- **LeftPanelPage** - Navigation and sidebar interactions
|
|
90
|
+
|
|
91
|
+
### Utilities
|
|
92
|
+
- **GuerrillaMailClient** - Temporary email handling for account verification
|
|
93
|
+
- `createTempEmail()` - Creates temporary email address
|
|
94
|
+
- `getVerificationCode()` - Retrieves verification emails
|
|
95
|
+
- `cleanup()` - Cleans up temporary email resources
|
|
96
|
+
|
|
97
|
+
### World Extension
|
|
98
|
+
- **ExternalServicesWorld** - Shared state management for test scenarios
|
|
99
|
+
|
|
100
|
+
## Example Implementation
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
// In your test files
|
|
104
|
+
import { test, expect } from '@playwright/test';
|
|
105
|
+
import { KindeAuthService, StripeService, GuerrillaMailClient } from 'external-services-automation';
|
|
106
|
+
|
|
107
|
+
test.describe('External Services Integration', () => {
|
|
108
|
+
let authService: KindeAuthService;
|
|
109
|
+
let stripeService: StripeService;
|
|
110
|
+
let tempEmail: GuerrillaMailClient;
|
|
111
|
+
|
|
112
|
+
test.beforeEach(async () => {
|
|
113
|
+
authService = new KindeAuthService();
|
|
114
|
+
stripeService = new StripeService();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('should create account and upgrade subscription', async () => {
|
|
118
|
+
// Create temporary email for account verification
|
|
119
|
+
tempEmail = new GuerrillaMailClient();
|
|
120
|
+
const email = await tempEmail.createTempEmail();
|
|
121
|
+
|
|
122
|
+
// Register new account
|
|
123
|
+
await authService.register(email, 'John', 'Doe');
|
|
124
|
+
|
|
125
|
+
// Verify email
|
|
126
|
+
const verificationCode = await tempEmail.getVerificationCode();
|
|
127
|
+
await authService.verifyEmail(verificationCode);
|
|
128
|
+
|
|
129
|
+
// Upgrade subscription
|
|
130
|
+
await stripeService.upgradeSubscription('premium');
|
|
131
|
+
|
|
132
|
+
// Verify subscription status
|
|
133
|
+
const subscription = await stripeService.getCurrentSubscription();
|
|
134
|
+
expect(subscription.status).toBe('active');
|
|
135
|
+
|
|
136
|
+
// Cleanup
|
|
137
|
+
await tempEmail.cleanup();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('should handle login with existing account', async () => {
|
|
141
|
+
const result = await authService.login('user@example.com', 'password123');
|
|
142
|
+
expect(result.success).toBe(true);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Updates
|
|
148
|
+
|
|
149
|
+
To update to the latest version:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npm update external-services-automation
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## CI/CD
|
|
156
|
+
|
|
157
|
+
### Bitbucket Pipelines
|
|
158
|
+
|
|
159
|
+
```yaml
|
|
160
|
+
script:
|
|
161
|
+
- npm install
|
|
162
|
+
- npm test
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Dependencies
|
|
166
|
+
|
|
167
|
+
The library requires the following peer dependencies to be installed in your project:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
npm install @playwright/test axios-cookiejar-support dotenv tough-cookie
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Version requirements:
|
|
174
|
+
- `@playwright/test` ^1.40.0
|
|
175
|
+
- `axios-cookiejar-support` ^6.0.2
|
|
176
|
+
- `dotenv` ^16.4.5
|
|
177
|
+
- `tough-cookie` ^5.1.2
|
|
178
|
+
|
|
179
|
+
## Troubleshooting
|
|
180
|
+
|
|
181
|
+
### Package Not Found
|
|
182
|
+
```bash
|
|
183
|
+
npm install external-services-automation
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Import Errors
|
|
187
|
+
Make sure you're importing from the correct package name:
|
|
188
|
+
```typescript
|
|
189
|
+
import { KindeAuthService } from 'external-services-automation';
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Missing Peer Dependencies
|
|
193
|
+
```bash
|
|
194
|
+
npm install @playwright/test axios-cookiejar-support dotenv tough-cookie
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Development
|
|
198
|
+
|
|
199
|
+
For contributors working on this library:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
git clone https://bitbucket.org/connectist/external-services-automation.git
|
|
203
|
+
cd external-services-automation
|
|
204
|
+
npm install
|
|
205
|
+
npm run build
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Links
|
|
209
|
+
|
|
210
|
+
- **NPM Package**: https://www.npmjs.com/package/external-services-automation
|
|
211
211
|
- **Repository**: https://bitbucket.org/connectist/external-services-automation
|
|
@@ -6,7 +6,6 @@ export declare class PasswordSetupPage {
|
|
|
6
6
|
readonly confirmPasswordInput: Locator;
|
|
7
7
|
readonly continueButton: Locator;
|
|
8
8
|
readonly dontUseMFAButton: Locator;
|
|
9
|
-
readonly verifyYourIdentityTitle: Locator;
|
|
10
9
|
constructor(page: Page);
|
|
11
10
|
enterPassword(password: string): Promise<void>;
|
|
12
11
|
enterConfirmPassword(password: string): Promise<void>;
|
|
@@ -10,7 +10,6 @@ class PasswordSetupPage {
|
|
|
10
10
|
this.confirmPasswordInput = page.locator('input[name="p_second_password"]');
|
|
11
11
|
this.continueButton = page.locator('button[type="submit"]:has-text("Continue")');
|
|
12
12
|
this.dontUseMFAButton = page.locator('//button[contains(text(), "multi-factor authentication")]');
|
|
13
|
-
this.verifyYourIdentityTitle = page.locator('//h1[text()="Verify your identity"]');
|
|
14
13
|
}
|
|
15
14
|
async enterPassword(password) {
|
|
16
15
|
await this.passwordInput.fill(password);
|
|
@@ -33,13 +32,10 @@ class PasswordSetupPage {
|
|
|
33
32
|
await (0, test_1.expect)(this.continueButton).toBeVisible();
|
|
34
33
|
}
|
|
35
34
|
async dontUseMFA() {
|
|
36
|
-
|
|
37
|
-
await this.
|
|
38
|
-
if (await this.verifyYourIdentityTitle.isVisible()) {
|
|
35
|
+
await this.page.waitForTimeout(3000);
|
|
36
|
+
if (await this.dontUseMFAButton.isVisible()) {
|
|
39
37
|
await this.dontUseMFAButton.click();
|
|
40
|
-
console.log("clicked dontUseMFA");
|
|
41
38
|
}
|
|
42
|
-
console.log("exited dontUseMFA");
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
41
|
exports.PasswordSetupPage = PasswordSetupPage;
|
|
@@ -24,12 +24,10 @@ class UpdatePaymentMethodPage {
|
|
|
24
24
|
const zipCode = '12345';
|
|
25
25
|
try {
|
|
26
26
|
await this.stripeIframe.waitFor({ state: 'visible' });
|
|
27
|
-
// Get the iframe element and switch to it
|
|
28
27
|
const iframeElement = await this.stripeIframe.elementHandle();
|
|
29
28
|
if (!iframeElement) {
|
|
30
29
|
throw new Error('Stripe iframe not found');
|
|
31
30
|
}
|
|
32
|
-
// Switch to the iframe context
|
|
33
31
|
const iframePage = await iframeElement.contentFrame();
|
|
34
32
|
if (!iframePage) {
|
|
35
33
|
throw new Error('Could not access iframe content');
|
|
@@ -8,6 +8,6 @@ export declare class KindeAuthService {
|
|
|
8
8
|
private confirmCodePage;
|
|
9
9
|
private passwordSetupPage;
|
|
10
10
|
constructor(page: Page);
|
|
11
|
-
createAccountWithEmailVerification(): Promise<
|
|
11
|
+
createAccountWithEmailVerification(): Promise<string>;
|
|
12
12
|
deleteTemporaryEmail(): Promise<void>;
|
|
13
13
|
}
|
|
@@ -39,6 +39,7 @@ class KindeAuthService {
|
|
|
39
39
|
const password = 'TestPassword123!';
|
|
40
40
|
await this.passwordSetupPage.submitPasswordForm(password);
|
|
41
41
|
await this.passwordSetupPage.dontUseMFA();
|
|
42
|
+
return this.tempEmail;
|
|
42
43
|
}
|
|
43
44
|
async deleteTemporaryEmail() {
|
|
44
45
|
if (this.tempEmail) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** Structure returned by Guerrilla Mail for a single message */
|
|
2
1
|
export interface GuerrillaEmail {
|
|
3
2
|
mail_id: string;
|
|
4
3
|
mail_subject: string;
|
|
@@ -15,34 +14,11 @@ declare class GuerrillaMailClient {
|
|
|
15
14
|
private emailAddress;
|
|
16
15
|
private client;
|
|
17
16
|
constructor();
|
|
18
|
-
/**
|
|
19
|
-
* Function 1: Crea un email temporal. Si se pasa un alias se fuerza ese usuario.
|
|
20
|
-
* @param alias Nombre de usuario deseado (sin dominio).
|
|
21
|
-
* @returns Dirección de email completa.
|
|
22
|
-
*/
|
|
23
17
|
createMail(alias?: string): Promise<string>;
|
|
24
|
-
/**
|
|
25
|
-
* Function 2: Lee la bandeja y devuelve el email MÁS RECIENTE cuyo subject matchee con subjectRegex.
|
|
26
|
-
* Hace polling hasta timeout.
|
|
27
|
-
* @param subjectRegex Expresión regular a matchear con el asunto.
|
|
28
|
-
* @param timeoutMs Tiempo máximo a esperar (ms).
|
|
29
|
-
* @param pollMs Intervalo entre consultas (ms).
|
|
30
|
-
*/
|
|
31
18
|
readMailBySubject(subjectRegex: RegExp, timeoutMs?: number, pollMs?: number): Promise<GuerrillaEmail>;
|
|
32
|
-
/**
|
|
33
|
-
* Function 3: Elimina un correo específico del servidor.
|
|
34
|
-
* @param mailId ID retornado por la API (mail_id).
|
|
35
|
-
*/
|
|
36
19
|
deleteMail(mailId: string): Promise<void>;
|
|
37
|
-
/** Helper interno para descargar cuerpo completo */
|
|
38
20
|
private fetchEmail;
|
|
39
|
-
/**
|
|
40
|
-
* Function 4: Crea una nueva instancia de email client para aislamiento entre escenarios
|
|
41
|
-
*/
|
|
42
21
|
static createIsolatedClient(): GuerrillaMailClient;
|
|
43
|
-
/**
|
|
44
|
-
* Function 5: Elimina todos los emails del buzón actual
|
|
45
|
-
*/
|
|
46
22
|
clearInbox(): Promise<void>;
|
|
47
23
|
}
|
|
48
24
|
export declare const email: GuerrillaMailClient;
|
|
@@ -19,16 +19,10 @@ class GuerrillaMailClient {
|
|
|
19
19
|
jar,
|
|
20
20
|
withCredentials: true,
|
|
21
21
|
headers: {
|
|
22
|
-
// Recommended to identify politely
|
|
23
22
|
'User-Agent': 'qa-automation-utils/1.0',
|
|
24
23
|
},
|
|
25
24
|
}));
|
|
26
25
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Function 1: Crea un email temporal. Si se pasa un alias se fuerza ese usuario.
|
|
29
|
-
* @param alias Nombre de usuario deseado (sin dominio).
|
|
30
|
-
* @returns Dirección de email completa.
|
|
31
|
-
*/
|
|
32
26
|
async createMail(alias) {
|
|
33
27
|
if (alias) {
|
|
34
28
|
const { data } = await this.client.get(this.API_URL, {
|
|
@@ -53,13 +47,6 @@ class GuerrillaMailClient {
|
|
|
53
47
|
}
|
|
54
48
|
return this.emailAddress;
|
|
55
49
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Function 2: Lee la bandeja y devuelve el email MÁS RECIENTE cuyo subject matchee con subjectRegex.
|
|
58
|
-
* Hace polling hasta timeout.
|
|
59
|
-
* @param subjectRegex Expresión regular a matchear con el asunto.
|
|
60
|
-
* @param timeoutMs Tiempo máximo a esperar (ms).
|
|
61
|
-
* @param pollMs Intervalo entre consultas (ms).
|
|
62
|
-
*/
|
|
63
50
|
async readMailBySubject(subjectRegex, timeoutMs = 60000, pollMs = 5000) {
|
|
64
51
|
const start = Date.now();
|
|
65
52
|
while (Date.now() - start < timeoutMs) {
|
|
@@ -73,35 +60,27 @@ class GuerrillaMailClient {
|
|
|
73
60
|
});
|
|
74
61
|
this.seq = data.seq ?? this.seq;
|
|
75
62
|
const list = data.list ?? [];
|
|
76
|
-
// Filtrar emails que matchean el subject
|
|
77
63
|
const matches = list.filter(m => subjectRegex.test(m.mail_subject));
|
|
78
64
|
if (matches.length > 0) {
|
|
79
|
-
// Ordenar por timestamp descendente (más reciente primero)
|
|
80
65
|
matches.sort((a, b) => b.mail_timestamp - a.mail_timestamp);
|
|
81
|
-
// Tomar el más reciente
|
|
82
66
|
const mostRecent = matches[0];
|
|
83
67
|
const full = await this.fetchEmail(mostRecent.mail_id);
|
|
84
68
|
return full;
|
|
85
69
|
}
|
|
86
70
|
await new Promise(r => setTimeout(r, pollMs));
|
|
87
71
|
}
|
|
88
|
-
throw new Error(`Timeout (${timeoutMs} ms)
|
|
72
|
+
throw new Error(`Timeout (${timeoutMs} ms) waiting for an email with subject matching ${subjectRegex}`);
|
|
89
73
|
}
|
|
90
|
-
/**
|
|
91
|
-
* Function 3: Elimina un correo específico del servidor.
|
|
92
|
-
* @param mailId ID retornado por la API (mail_id).
|
|
93
|
-
*/
|
|
94
74
|
async deleteMail(mailId) {
|
|
95
75
|
await this.client.get(this.API_URL, {
|
|
96
76
|
params: {
|
|
97
77
|
f: 'del_email',
|
|
98
|
-
email_ids: `[${mailId}]`,
|
|
78
|
+
email_ids: `[${mailId}]`,
|
|
99
79
|
ip: this.ip,
|
|
100
80
|
agent: this.agent,
|
|
101
81
|
},
|
|
102
82
|
});
|
|
103
83
|
}
|
|
104
|
-
/** Helper interno para descargar cuerpo completo */
|
|
105
84
|
async fetchEmail(mailId) {
|
|
106
85
|
const { data } = await this.client.get(this.API_URL, {
|
|
107
86
|
params: {
|
|
@@ -113,15 +92,9 @@ class GuerrillaMailClient {
|
|
|
113
92
|
});
|
|
114
93
|
return data;
|
|
115
94
|
}
|
|
116
|
-
/**
|
|
117
|
-
* Function 4: Crea una nueva instancia de email client para aislamiento entre escenarios
|
|
118
|
-
*/
|
|
119
95
|
static createIsolatedClient() {
|
|
120
96
|
return new GuerrillaMailClient();
|
|
121
97
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Function 5: Elimina todos los emails del buzón actual
|
|
124
|
-
*/
|
|
125
98
|
async clearInbox() {
|
|
126
99
|
const { data } = await this.client.get(this.API_URL, {
|
|
127
100
|
params: {
|
|
@@ -132,7 +105,6 @@ class GuerrillaMailClient {
|
|
|
132
105
|
},
|
|
133
106
|
});
|
|
134
107
|
const list = data.list ?? [];
|
|
135
|
-
// Eliminar todos los emails uno por uno
|
|
136
108
|
for (const email of list) {
|
|
137
109
|
try {
|
|
138
110
|
await this.deleteMail(email.mail_id);
|
package/package.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "external-services-automation",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "External services automation library for Playwright and Cucumber",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist/",
|
|
9
|
-
"README.md",
|
|
10
|
-
"package.json"
|
|
11
|
-
],
|
|
12
|
-
"keywords": [
|
|
13
|
-
"playwright",
|
|
14
|
-
"automation",
|
|
15
|
-
"testing",
|
|
16
|
-
"kinde",
|
|
17
|
-
"stripe",
|
|
18
|
-
"external-services"
|
|
19
|
-
],
|
|
20
|
-
"author": "Email Awesome Team",
|
|
21
|
-
"license": "MIT",
|
|
22
|
-
"repository": {
|
|
23
|
-
"type": "git",
|
|
24
|
-
"url": "https://bitbucket.org/connectist/external-services-automation.git"
|
|
25
|
-
},
|
|
26
|
-
"scripts": {
|
|
27
|
-
"build": "tsc",
|
|
28
|
-
"build:watch": "tsc --watch",
|
|
29
|
-
"clean": "rm -rf dist",
|
|
30
|
-
"prebuild": "npm run clean",
|
|
31
|
-
"test": "echo \"No tests specified\" && exit 0",
|
|
32
|
-
"prepublishOnly": "npm run build"
|
|
33
|
-
},
|
|
34
|
-
"peerDependencies": {
|
|
35
|
-
"@playwright/test": "^1.40.0",
|
|
36
|
-
"axios-cookiejar-support": "^6.0.2",
|
|
37
|
-
"tough-cookie": "^5.1.2"
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@types/node": "^22.5.4",
|
|
41
|
-
"typescript": "^5.5.4"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "external-services-automation",
|
|
3
|
+
"version": "1.0.16",
|
|
4
|
+
"description": "External services automation library for Playwright and Cucumber",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/",
|
|
9
|
+
"README.md",
|
|
10
|
+
"package.json"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
"playwright",
|
|
14
|
+
"automation",
|
|
15
|
+
"testing",
|
|
16
|
+
"kinde",
|
|
17
|
+
"stripe",
|
|
18
|
+
"external-services"
|
|
19
|
+
],
|
|
20
|
+
"author": "Email Awesome Team",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://bitbucket.org/connectist/external-services-automation.git"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"build:watch": "tsc --watch",
|
|
29
|
+
"clean": "rm -rf dist",
|
|
30
|
+
"prebuild": "npm run clean",
|
|
31
|
+
"test": "echo \"No tests specified\" && exit 0",
|
|
32
|
+
"prepublishOnly": "npm run build"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@playwright/test": "^1.40.0",
|
|
36
|
+
"axios-cookiejar-support": "^6.0.2",
|
|
37
|
+
"tough-cookie": "^5.1.2"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^22.5.4",
|
|
41
|
+
"typescript": "^5.5.4"
|
|
42
|
+
}
|
|
43
|
+
}
|