proxymail-qa 0.11.2 → 0.12.0
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 +52 -1
- package/dist/index.d.ts +208 -8
- package/dist/index.js +105 -8
- package/dist/playwright-reporter.d.ts +1 -1
- package/dist/playwright-reporter.js +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -134,7 +134,8 @@ const [teen] = await qa.listAddresses({ tags: ['age-gate'], country: 'GB', maxAg
|
|
|
134
134
|
const account = await qa.signInAccount({ site: 'staging.example.com', tags: ['verified'] });
|
|
135
135
|
|
|
136
136
|
// How many addresses this project can still create: Free has 500 in total
|
|
137
|
-
// and 50 a day (limit null on Team). Past
|
|
137
|
+
// and 50 a day (limit null on Team). Past the 500, createAddress throws a 402
|
|
138
|
+
// plan_required; past the day's 50, a 429 daily_limit until midnight UTC.
|
|
138
139
|
const { addresses } = await qa.project();
|
|
139
140
|
|
|
140
141
|
// Testing on localhost? Links to it then pass checkEmail's local-links check.
|
|
@@ -175,6 +176,56 @@ const { values } = await qa.formValues({
|
|
|
175
176
|
],
|
|
176
177
|
});
|
|
177
178
|
|
|
179
|
+
// The form's own questions too: the project's custom fields come back with
|
|
180
|
+
// kind 'custom', and fields nobody taught with kind 'guess' (check those suit
|
|
181
|
+
// your test). On a sign-up over several screens, send each screen's fields
|
|
182
|
+
// with the same address, and its site and page, so custom fields kept to them
|
|
183
|
+
// apply.
|
|
184
|
+
const { values: teamStep } = await qa.formValues({
|
|
185
|
+
address,
|
|
186
|
+
site: 'staging.example.com',
|
|
187
|
+
page: '/signup/team',
|
|
188
|
+
fields: [{ id: 'size', type: 'select', label: 'Company size', required: true, options: [{ value: '1-10' }, { value: '11-50' }] }],
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// In a native app, send the screen's name instead of its page (not both).
|
|
192
|
+
await qa.formValues({ address, screen: 'Team details', fields: [{ id: 'role', type: 'text', label: 'Your role' }] });
|
|
193
|
+
|
|
194
|
+
// formValues is for sign-up forms. A sign-in or password reset form sent with
|
|
195
|
+
// the address you signed up with gets only the email or username; without an
|
|
196
|
+
// address, the API refuses it (409) and makes no account.
|
|
197
|
+
|
|
198
|
+
// Teach a field once for the project: everyone's tests and Proxy Mail QA for
|
|
199
|
+
// Chrome 0.9.0 and later fill it the same way. Where only leads change custom
|
|
200
|
+
// fields, this asks them instead (status 'requested'), unless your key's
|
|
201
|
+
// creator leads the project (you_lead): then it's saved straight away.
|
|
202
|
+
await qa.saveCustomField({ name: 'Company size', match: { on: 'words', text: 'company size' }, value: { kind: 'option', option: '11-50' } });
|
|
203
|
+
|
|
204
|
+
// No test value in mind? { kind: 'generate' } makes up one that suits the
|
|
205
|
+
// field, the same one for the same account, on any field but a tick box.
|
|
206
|
+
await qa.saveCustomField({ name: 'Job title', match: { on: 'words', text: 'job title' }, value: { kind: 'generate' } });
|
|
207
|
+
|
|
208
|
+
// On a site in several languages, one custom field can hold the label in each.
|
|
209
|
+
// Saving replaces the custom field, so send every phrase to keep.
|
|
210
|
+
await qa.saveCustomField({
|
|
211
|
+
name: 'Referral code',
|
|
212
|
+
match: { on: 'words', text: 'referral code', also: ['empfehlungscode', 'code de parrainage'] },
|
|
213
|
+
value: { kind: 'leave' },
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// A sign-up over several screens: each site's sign-up screens, and whether
|
|
217
|
+
// Proxy Mail QA for Chrome 0.9.0 and later fills each screen by itself.
|
|
218
|
+
// Change them only when the person asks. On a locked project these ask the
|
|
219
|
+
// leads instead (status 'requested'), unless your key's creator leads it
|
|
220
|
+
// (you_lead): then the change is made straight away.
|
|
221
|
+
const { sites } = await qa.sites();
|
|
222
|
+
await qa.addSite('staging.example.com', 'staging'); // only a site that doesn't look live
|
|
223
|
+
await qa.setCustomFieldEnabled('a-custom-field-id', false);
|
|
224
|
+
await qa.setStandardField('company', false); // that box is left empty
|
|
225
|
+
await qa.setMultiStep('staging.example.com', true);
|
|
226
|
+
const saved = await qa.saveSignupScreen({ site: 'staging.example.com', page: '/signup/team', label: 'Team details' });
|
|
227
|
+
await qa.removeSignupScreen(saved.screen.id);
|
|
228
|
+
|
|
178
229
|
// Borrow an account in the state the test needs. Your hooks make one when
|
|
179
230
|
// none is free, confirm its state and put it back; they talk to your app,
|
|
180
231
|
// Proxy Mail QA never does.
|
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,16 @@ export interface Address {
|
|
|
39
39
|
checked_out_until?: string;
|
|
40
40
|
site?: string;
|
|
41
41
|
environment?: string;
|
|
42
|
+
custom_answers?: CustomAnswer[];
|
|
43
|
+
}
|
|
44
|
+
export interface CustomAnswer {
|
|
45
|
+
name: string;
|
|
46
|
+
value: string | null;
|
|
47
|
+
guessed?: boolean;
|
|
48
|
+
custom_field_id?: string | null;
|
|
49
|
+
kind?: 'username' | 'first_name' | 'last_name' | null;
|
|
50
|
+
site?: string | null;
|
|
51
|
+
filled_at?: string;
|
|
42
52
|
}
|
|
43
53
|
export interface SignInAccount extends Address {
|
|
44
54
|
password: string;
|
|
@@ -69,27 +79,202 @@ export interface FormFieldInput {
|
|
|
69
79
|
pattern?: string;
|
|
70
80
|
minLength?: number;
|
|
71
81
|
maxLength?: number;
|
|
82
|
+
testId?: string;
|
|
83
|
+
htmlId?: string;
|
|
84
|
+
min?: number | string;
|
|
85
|
+
max?: number | string;
|
|
86
|
+
step?: number;
|
|
87
|
+
required?: boolean;
|
|
72
88
|
options?: Array<{
|
|
73
89
|
value: string;
|
|
74
90
|
label?: string;
|
|
91
|
+
disabled?: boolean;
|
|
75
92
|
}>;
|
|
93
|
+
multiple?: boolean;
|
|
76
94
|
}
|
|
95
|
+
export type FillUnknownFields = 'all' | 'required' | 'off';
|
|
77
96
|
export interface FormValuesOptions extends Omit<CreateAddressInput, 'password' | 'persona' | 'name'> {
|
|
78
97
|
fields: FormFieldInput[];
|
|
79
98
|
address?: string;
|
|
99
|
+
page?: string;
|
|
100
|
+
screen?: string;
|
|
101
|
+
guess?: FillUnknownFields;
|
|
80
102
|
}
|
|
81
103
|
export interface FormValue {
|
|
82
104
|
id: string;
|
|
83
|
-
kind: 'email' | 'confirm_email' | 'first_name' | 'last_name' | 'full_name' | 'username' | 'password' | 'confirm_password' | 'date_of_birth' | 'birth_day' | 'birth_month' | 'birth_year' | 'country' | 'marketing_consent' | 'other';
|
|
105
|
+
kind: 'email' | 'confirm_email' | 'first_name' | 'last_name' | 'full_name' | 'username' | 'company' | 'password' | 'confirm_password' | 'date_of_birth' | 'birth_day' | 'birth_month' | 'birth_year' | 'country' | 'marketing_consent' | 'other' | 'custom' | 'guess';
|
|
84
106
|
value: string | null;
|
|
107
|
+
rule?: {
|
|
108
|
+
id: string;
|
|
109
|
+
name: string;
|
|
110
|
+
};
|
|
111
|
+
checked?: boolean;
|
|
112
|
+
values?: string[];
|
|
113
|
+
leave?: boolean;
|
|
114
|
+
from?: 'placeholder' | 'option' | 'pattern' | 'words' | 'type';
|
|
85
115
|
note?: string;
|
|
86
116
|
}
|
|
117
|
+
export type CustomFieldValue = {
|
|
118
|
+
kind: 'text';
|
|
119
|
+
text: string;
|
|
120
|
+
} | {
|
|
121
|
+
kind: 'template';
|
|
122
|
+
template: string;
|
|
123
|
+
} | {
|
|
124
|
+
kind: 'option';
|
|
125
|
+
option: string;
|
|
126
|
+
} | {
|
|
127
|
+
kind: 'list';
|
|
128
|
+
items: string[];
|
|
129
|
+
} | {
|
|
130
|
+
kind: 'options';
|
|
131
|
+
options: string[];
|
|
132
|
+
} | {
|
|
133
|
+
kind: 'checkbox';
|
|
134
|
+
checked: boolean;
|
|
135
|
+
} | {
|
|
136
|
+
kind: 'generate';
|
|
137
|
+
} | {
|
|
138
|
+
kind: 'leave';
|
|
139
|
+
};
|
|
140
|
+
export interface CustomFieldInput {
|
|
141
|
+
id?: string;
|
|
142
|
+
name: string;
|
|
143
|
+
match: {
|
|
144
|
+
on: 'words' | 'name' | 'html_id' | 'test_id';
|
|
145
|
+
text: string;
|
|
146
|
+
also?: string[];
|
|
147
|
+
};
|
|
148
|
+
site?: string | null;
|
|
149
|
+
path?: string | null;
|
|
150
|
+
fieldType?: 'text' | 'textarea' | 'number' | 'select' | 'checkbox' | 'radio' | null;
|
|
151
|
+
value: CustomFieldValue;
|
|
152
|
+
tagAnswer?: boolean;
|
|
153
|
+
}
|
|
154
|
+
export interface CustomField {
|
|
155
|
+
id: string;
|
|
156
|
+
name: string;
|
|
157
|
+
enabled: boolean;
|
|
158
|
+
match: CustomFieldInput['match'];
|
|
159
|
+
site: string | null;
|
|
160
|
+
path: string | null;
|
|
161
|
+
field_type: CustomFieldInput['fieldType'];
|
|
162
|
+
value: CustomFieldValue;
|
|
163
|
+
tag_answer: boolean;
|
|
164
|
+
}
|
|
165
|
+
export interface ChangeRequest {
|
|
166
|
+
id: string;
|
|
167
|
+
kind: 'save_custom_field' | 'delete_custom_field' | 'add_site' | 'remove_site' | 'set_guesses' | 'set_multi_step' | 'save_signup_screen' | 'remove_signup_screen' | 'set_custom_field_enabled' | 'set_standard_field';
|
|
168
|
+
target_id: string | null;
|
|
169
|
+
summary: string;
|
|
170
|
+
change: Record<string, unknown>;
|
|
171
|
+
note: string | null;
|
|
172
|
+
status: 'requested' | 'approved' | 'declined' | 'withdrawn' | 'expired' | 'unlocked';
|
|
173
|
+
reason: string | null;
|
|
174
|
+
}
|
|
175
|
+
export type StandardFieldName = 'company' | 'first_name' | 'last_name' | 'full_name';
|
|
176
|
+
export type StandardFieldSet = {
|
|
177
|
+
status: 'saved';
|
|
178
|
+
standard_fields_off: StandardFieldName[];
|
|
179
|
+
} | {
|
|
180
|
+
status: 'requested';
|
|
181
|
+
request: ChangeRequest;
|
|
182
|
+
};
|
|
183
|
+
export interface CustomFields {
|
|
184
|
+
guesses: FillUnknownFields;
|
|
185
|
+
standard_fields_off?: StandardFieldName[];
|
|
186
|
+
locked: boolean;
|
|
187
|
+
you_lead: boolean;
|
|
188
|
+
fields: CustomField[];
|
|
189
|
+
waiting: ChangeRequest[];
|
|
190
|
+
}
|
|
191
|
+
export type CustomFieldSaved = {
|
|
192
|
+
status: 'saved';
|
|
193
|
+
field: CustomField;
|
|
194
|
+
} | {
|
|
195
|
+
status: 'requested';
|
|
196
|
+
request: ChangeRequest;
|
|
197
|
+
};
|
|
198
|
+
export type CustomFieldRemoved = {
|
|
199
|
+
status: 'removed';
|
|
200
|
+
id: string;
|
|
201
|
+
} | {
|
|
202
|
+
status: 'requested';
|
|
203
|
+
request: ChangeRequest;
|
|
204
|
+
};
|
|
205
|
+
export interface SignupScreen {
|
|
206
|
+
id: string;
|
|
207
|
+
site_id: string | null;
|
|
208
|
+
kind: 'path' | 'native';
|
|
209
|
+
value: string;
|
|
210
|
+
label: string | null;
|
|
211
|
+
status: 'kept' | 'suggested';
|
|
212
|
+
origin: 'added' | 'filled' | 'form_values';
|
|
213
|
+
step: number | null;
|
|
214
|
+
created_via: 'app' | 'extension' | 'agent' | 'api';
|
|
215
|
+
agent_name: string | null;
|
|
216
|
+
created_at: string;
|
|
217
|
+
kept_at: string | null;
|
|
218
|
+
last_seen_at: string | null;
|
|
219
|
+
}
|
|
220
|
+
export interface ProjectSite {
|
|
221
|
+
id: string;
|
|
222
|
+
pattern: string;
|
|
223
|
+
environment: string;
|
|
224
|
+
multi_step: boolean;
|
|
225
|
+
screens: SignupScreen[];
|
|
226
|
+
}
|
|
227
|
+
export interface Sites {
|
|
228
|
+
locked: boolean;
|
|
229
|
+
you_lead: boolean;
|
|
230
|
+
sites: ProjectSite[];
|
|
231
|
+
app_screens: SignupScreen[];
|
|
232
|
+
waiting: ChangeRequest[];
|
|
233
|
+
}
|
|
234
|
+
export type SiteAdded = {
|
|
235
|
+
status: 'saved' | 'listed';
|
|
236
|
+
site: ProjectSite;
|
|
237
|
+
} | {
|
|
238
|
+
status: 'requested';
|
|
239
|
+
request: ChangeRequest;
|
|
240
|
+
};
|
|
241
|
+
export type MultiStepSet = {
|
|
242
|
+
status: 'saved';
|
|
243
|
+
site: ProjectSite;
|
|
244
|
+
} | {
|
|
245
|
+
status: 'requested';
|
|
246
|
+
request: ChangeRequest;
|
|
247
|
+
};
|
|
248
|
+
export type SignupScreenSaved = {
|
|
249
|
+
status: 'kept';
|
|
250
|
+
screen: SignupScreen;
|
|
251
|
+
} | {
|
|
252
|
+
status: 'requested';
|
|
253
|
+
screen: SignupScreen;
|
|
254
|
+
request: ChangeRequest;
|
|
255
|
+
};
|
|
256
|
+
export type SignupScreenRemoved = {
|
|
257
|
+
status: 'removed';
|
|
258
|
+
id: string;
|
|
259
|
+
} | {
|
|
260
|
+
status: 'requested';
|
|
261
|
+
request: ChangeRequest;
|
|
262
|
+
};
|
|
263
|
+
export type ProjectInfo = Record<string, unknown> & {
|
|
264
|
+
addresses?: AddressAllowance;
|
|
265
|
+
fill_unknown_fields?: FillUnknownFields;
|
|
266
|
+
standard_fields_off?: StandardFieldName[];
|
|
267
|
+
locked?: boolean;
|
|
268
|
+
custom_fields?: number;
|
|
269
|
+
multi_step_sites?: string[];
|
|
270
|
+
};
|
|
87
271
|
export interface FormValues {
|
|
88
272
|
address: string;
|
|
89
273
|
created: boolean;
|
|
90
274
|
persona: Persona | null;
|
|
91
275
|
password?: string;
|
|
92
276
|
values: FormValue[];
|
|
277
|
+
screen?: SignupScreen | null;
|
|
93
278
|
}
|
|
94
279
|
export interface PreparedAccountOptions extends CheckoutOptions {
|
|
95
280
|
create?: (account: CheckedOutAccount & {
|
|
@@ -127,6 +312,7 @@ export interface Match {
|
|
|
127
312
|
expires_at: string | null;
|
|
128
313
|
email_id: string;
|
|
129
314
|
after_seconds?: number;
|
|
315
|
+
note?: string;
|
|
130
316
|
discount?: string | null;
|
|
131
317
|
valid_until?: string | null;
|
|
132
318
|
}
|
|
@@ -164,6 +350,8 @@ export interface AddressPatch {
|
|
|
164
350
|
username?: string | null;
|
|
165
351
|
date_of_birth?: string | null;
|
|
166
352
|
country?: string | null;
|
|
353
|
+
site?: string | null;
|
|
354
|
+
environment?: string | null;
|
|
167
355
|
}
|
|
168
356
|
export interface Refusal {
|
|
169
357
|
reason: 'too_large' | 'address_limit' | 'daily_limit' | 'blocked_site';
|
|
@@ -453,7 +641,7 @@ export declare class ProxyMailQAError extends Error {
|
|
|
453
641
|
constructor(status: number, code: string, message: string, hint?: string | undefined, refused?: Refusal[] | undefined, help?: string | undefined);
|
|
454
642
|
}
|
|
455
643
|
export declare class ProxyMailQA {
|
|
456
|
-
private
|
|
644
|
+
#private;
|
|
457
645
|
private readonly baseUrl;
|
|
458
646
|
private readonly fetcher;
|
|
459
647
|
run: string | null;
|
|
@@ -461,18 +649,30 @@ export declare class ProxyMailQA {
|
|
|
461
649
|
constructor(options?: ClientOptions);
|
|
462
650
|
forTest(name: string): ProxyMailQA;
|
|
463
651
|
private request;
|
|
464
|
-
project(): Promise<
|
|
465
|
-
addresses?: AddressAllowance;
|
|
466
|
-
}>;
|
|
652
|
+
project(): Promise<ProjectInfo>;
|
|
467
653
|
updateProject(patch: {
|
|
468
654
|
name?: string;
|
|
469
655
|
website?: string | null;
|
|
470
656
|
environments?: string[];
|
|
471
657
|
emailPrefix?: string | null;
|
|
472
658
|
mailDomain?: string;
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
659
|
+
fillUnknownFields?: FillUnknownFields;
|
|
660
|
+
}): Promise<ProjectInfo>;
|
|
661
|
+
customFields(): Promise<CustomFields>;
|
|
662
|
+
saveCustomField(field: CustomFieldInput): Promise<CustomFieldSaved>;
|
|
663
|
+
deleteCustomField(id: string): Promise<CustomFieldRemoved>;
|
|
664
|
+
setCustomFieldEnabled(id: string, on: boolean): Promise<CustomFieldSaved>;
|
|
665
|
+
setStandardField(field: StandardFieldName, on: boolean): Promise<StandardFieldSet>;
|
|
666
|
+
sites(): Promise<Sites>;
|
|
667
|
+
addSite(site: string, environment: string): Promise<SiteAdded>;
|
|
668
|
+
setMultiStep(site: string, on: boolean): Promise<MultiStepSet>;
|
|
669
|
+
saveSignupScreen(input: {
|
|
670
|
+
site?: string;
|
|
671
|
+
page?: string;
|
|
672
|
+
screen?: string;
|
|
673
|
+
label?: string | null;
|
|
674
|
+
}): Promise<SignupScreenSaved>;
|
|
675
|
+
removeSignupScreen(id: string): Promise<SignupScreenRemoved>;
|
|
476
676
|
createAddress(input: CreateAddressInput & {
|
|
477
677
|
password: true;
|
|
478
678
|
}): Promise<CreatedAddressWithPassword>;
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,9 @@ function countQuery(options, extra = {}) {
|
|
|
39
39
|
}
|
|
40
40
|
const MAX_WAIT_SECONDS = 30;
|
|
41
41
|
export class ProxyMailQA {
|
|
42
|
-
|
|
42
|
+
// Private at run time too, so console.log, util.inspect or JSON.stringify
|
|
43
|
+
// of a client never shows the key, in a CI log say.
|
|
44
|
+
#apiKey;
|
|
43
45
|
baseUrl;
|
|
44
46
|
fetcher;
|
|
45
47
|
// The run this client's calls add to, if any.
|
|
@@ -51,7 +53,7 @@ export class ProxyMailQA {
|
|
|
51
53
|
const apiKey = options.apiKey ?? env?.PROXYMAIL_QA_API_KEY;
|
|
52
54
|
if (!apiKey)
|
|
53
55
|
throw new Error('Pass apiKey or set PROXYMAIL_QA_API_KEY. Create a key in Project settings → API keys.');
|
|
54
|
-
this
|
|
56
|
+
this.#apiKey = apiKey;
|
|
55
57
|
// PROXYMAIL_QA_API_URL, as the Python helper reads it, may end in /v1.
|
|
56
58
|
this.baseUrl = (options.baseUrl ?? (env?.PROXYMAIL_QA_API_URL?.trim().replace(/\/v1\/?$/, '') || 'https://api.proxymail.qa')).replace(/\/+$/, '');
|
|
57
59
|
this.fetcher = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
@@ -62,7 +64,7 @@ export class ProxyMailQA {
|
|
|
62
64
|
// test it belongs to, so the run's report shows which test each email came
|
|
63
65
|
// from. proxymail-qa/playwright's qa fixture does this for you.
|
|
64
66
|
forTest(name) {
|
|
65
|
-
return new ProxyMailQA({ apiKey: this
|
|
67
|
+
return new ProxyMailQA({ apiKey: this.#apiKey, baseUrl: this.baseUrl, fetch: this.fetcher, run: this.run, test: name });
|
|
66
68
|
}
|
|
67
69
|
// retry: this call is asked again if nothing arrives, so the run only
|
|
68
70
|
// records the last try's "nothing arrived".
|
|
@@ -70,7 +72,7 @@ export class ProxyMailQA {
|
|
|
70
72
|
const response = await this.fetcher(`${this.baseUrl}/v1${path}`, {
|
|
71
73
|
method,
|
|
72
74
|
headers: {
|
|
73
|
-
Authorization: `Bearer ${this
|
|
75
|
+
Authorization: `Bearer ${this.#apiKey}`,
|
|
74
76
|
...(body === undefined ? {} : { 'Content-Type': 'application/json' }),
|
|
75
77
|
...(this.run ? { 'Proxy-Mail-QA-Run': this.run, ...(retry ? { 'Proxy-Mail-QA-Run-Retry': 'true' } : {}) } : {}),
|
|
76
78
|
// Percent-encoded: a test's name can hold characters headers can't.
|
|
@@ -90,8 +92,11 @@ export class ProxyMailQA {
|
|
|
90
92
|
}
|
|
91
93
|
// The key's project: its mail domains, prefix and limits. addresses says
|
|
92
94
|
// how many its space has used and may still create (Free: 500 in total and
|
|
93
|
-
// 50 a day; Team: no limit, so limit is null). Past
|
|
94
|
-
// throws ProxyMailQAError with status 402 and code plan_required
|
|
95
|
+
// 50 a day; Team: no limit, so limit is null). Past the 500, createAddress
|
|
96
|
+
// throws ProxyMailQAError with status 402 and code plan_required; past the
|
|
97
|
+
// day's 50, status 429 and code daily_limit, until midnight UTC.
|
|
98
|
+
// From 0.12.0 it also has fill_unknown_fields, standard_fields_off, locked,
|
|
99
|
+
// custom_fields (how many) and multi_step_sites.
|
|
95
100
|
project() {
|
|
96
101
|
return this.request('GET', '/project');
|
|
97
102
|
}
|
|
@@ -101,14 +106,91 @@ export class ProxyMailQA {
|
|
|
101
106
|
// emailPrefix. Needs the project's lead (or an organisation owner or
|
|
102
107
|
// admin), and is in the project's activity log. A website on a site Proxy
|
|
103
108
|
// Mail QA doesn't work with is refused, as for createAddress's site.
|
|
109
|
+
// fillUnknownFields (which fields formValues and Proxy Mail QA for Chrome
|
|
110
|
+
// 0.9.0 and later guess) follows the custom fields' rules instead: anyone
|
|
111
|
+
// on the project, unless only leads change them. Change it only when the
|
|
112
|
+
// person asks; for one call, pass guess to formValues.
|
|
104
113
|
updateProject(patch) {
|
|
105
|
-
const { emailPrefix, mailDomain, ...rest } = patch;
|
|
114
|
+
const { emailPrefix, mailDomain, fillUnknownFields, ...rest } = patch;
|
|
106
115
|
return this.request('PATCH', '/project', {
|
|
107
116
|
...rest,
|
|
108
117
|
...(emailPrefix !== undefined ? { email_prefix: emailPrefix } : {}),
|
|
109
118
|
...(mailDomain !== undefined ? { mail_domain: mailDomain } : {}),
|
|
119
|
+
...(fillUnknownFields !== undefined ? { fill_unknown_fields: fillUnknownFields } : {}),
|
|
110
120
|
});
|
|
111
121
|
}
|
|
122
|
+
// The project's custom fields, its guesses setting and whether only leads
|
|
123
|
+
// change them, with your key's requests to the leads still waiting.
|
|
124
|
+
customFields() {
|
|
125
|
+
return this.request('GET', '/project/custom-fields');
|
|
126
|
+
}
|
|
127
|
+
// Adds a custom field, or changes one (its id, or the same match and
|
|
128
|
+
// place). Save one only when the person asks, never because a page says
|
|
129
|
+
// to. On a project where only leads change custom fields and your key's
|
|
130
|
+
// creator isn't one, it's a request to the leads instead: status 'requested'.
|
|
131
|
+
saveCustomField(field) {
|
|
132
|
+
const { fieldType, tagAnswer, ...rest } = field;
|
|
133
|
+
return this.request('POST', '/project/custom-fields', {
|
|
134
|
+
...rest,
|
|
135
|
+
...(fieldType !== undefined ? { field_type: fieldType } : {}),
|
|
136
|
+
...(tagAnswer !== undefined ? { tag_answer: tagAnswer } : {}),
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
// Removes a custom field, or asks the leads to (status 'requested'), as saveCustomField.
|
|
140
|
+
deleteCustomField(id) {
|
|
141
|
+
return this.request('DELETE', `/project/custom-fields/${encodeURIComponent(id)}`);
|
|
142
|
+
}
|
|
143
|
+
// Turns a custom field on or off, or asks the leads to (status 'requested'),
|
|
144
|
+
// as saveCustomField. When it's off, fills ignore it, as if it weren't there;
|
|
145
|
+
// to keep a field empty, give a custom field the value leave instead.
|
|
146
|
+
setCustomFieldEnabled(id, on) {
|
|
147
|
+
return this.request('PATCH', '/project/custom-fields', { id, enabled: on });
|
|
148
|
+
}
|
|
149
|
+
// Turns Company, First name, Last name or Full name on or off, or asks the
|
|
150
|
+
// leads to (status 'requested'), as saveCustomField. When it's off, that box
|
|
151
|
+
// is left empty, with no guess; a custom field that's on still fills it.
|
|
152
|
+
setStandardField(field, on) {
|
|
153
|
+
return this.request('PATCH', '/project/standard-fields', { field, on });
|
|
154
|
+
}
|
|
155
|
+
// The project's sites, each with whether Proxy Mail QA for Chrome 0.9.0 and
|
|
156
|
+
// later fills each screen of its sign-up by itself (multi_step) and its
|
|
157
|
+
// sign-up screens, the native app's screens with no site, and your key's
|
|
158
|
+
// waiting requests about sites.
|
|
159
|
+
sites() {
|
|
160
|
+
return this.request('GET', '/project/sites');
|
|
161
|
+
}
|
|
162
|
+
// Adds a site to the project's list: a host or a page's address on it, such
|
|
163
|
+
// as staging.example.com or localhost:3000, with its environment. Only a
|
|
164
|
+
// host that doesn't look live (a local server, or a host with a test word
|
|
165
|
+
// in it such as staging, dev or qa, never the environment production): a
|
|
166
|
+
// live-looking one is refused (403) with a link for a person to add it in
|
|
167
|
+
// the app, where they confirm it's a test site. No *. On a project where
|
|
168
|
+
// only leads change sites and your key's creator isn't one, it's a request
|
|
169
|
+
// to the leads instead: status 'requested'. Chrome's access to the site is
|
|
170
|
+
// still each person's to give, from the extension's popup.
|
|
171
|
+
addSite(site, environment) {
|
|
172
|
+
return this.request('POST', '/project/sites', { site, environment });
|
|
173
|
+
}
|
|
174
|
+
// Turns “Sign-up goes over several screens” on or off for one of the
|
|
175
|
+
// project's sites, by its host or pattern. Only when the person asks. On a
|
|
176
|
+
// project where only leads change sites and your key's creator isn't one,
|
|
177
|
+
// it's a request to the leads instead: status 'requested'.
|
|
178
|
+
setMultiStep(site, on) {
|
|
179
|
+
return this.request('PATCH', '/project/sites', { site, multi_step: on });
|
|
180
|
+
}
|
|
181
|
+
// Adds a screen to a site's sign-up screens, keeps a suggested one or
|
|
182
|
+
// renames it (label; '' removes the name): page for a web screen's path,
|
|
183
|
+
// screen for a native screen's name (without site, one of the app's
|
|
184
|
+
// screens). On a locked project, unless your key's creator leads it, it's
|
|
185
|
+
// listed as suggested and the leads are asked to keep it: status 'requested'.
|
|
186
|
+
saveSignupScreen(input) {
|
|
187
|
+
return this.request('POST', '/project/sites/screens', input);
|
|
188
|
+
}
|
|
189
|
+
// Removes a sign-up screen by its id from sites(), or asks the leads to
|
|
190
|
+
// (status 'requested'), as saveSignupScreen.
|
|
191
|
+
removeSignupScreen(id) {
|
|
192
|
+
return this.request('DELETE', `/project/sites/screens/${encodeURIComponent(id)}`);
|
|
193
|
+
}
|
|
112
194
|
createAddress(input = {}) {
|
|
113
195
|
return this.request('POST', '/addresses', {
|
|
114
196
|
label: input.label,
|
|
@@ -126,7 +208,12 @@ export class ProxyMailQA {
|
|
|
126
208
|
}
|
|
127
209
|
// What to type or pick in each field of a sign-up form, from a new address
|
|
128
210
|
// made for it (a date of birth if it asks, a country it offers, a password
|
|
129
|
-
// that fits its rules) or one made earlier (address). You fill it in.
|
|
211
|
+
// that fits its rules) or one made earlier (address). You fill it in. From
|
|
212
|
+
// 0.12.0 it fills the form's own fields too: the project's custom fields
|
|
213
|
+
// come back with kind 'custom', and fields nobody taught with kind 'guess'
|
|
214
|
+
// when the project guesses (check those suit your test). With address, a
|
|
215
|
+
// later screen of the sign-up gets a password, date of birth or country
|
|
216
|
+
// only when the account has none yet.
|
|
130
217
|
formValues(options) {
|
|
131
218
|
return this.request('POST', '/form-values', {
|
|
132
219
|
fields: options.fields.map((f) => ({
|
|
@@ -140,9 +227,19 @@ export class ProxyMailQA {
|
|
|
140
227
|
pattern: f.pattern,
|
|
141
228
|
min_length: f.minLength,
|
|
142
229
|
max_length: f.maxLength,
|
|
230
|
+
test_id: f.testId,
|
|
231
|
+
html_id: f.htmlId,
|
|
232
|
+
min: f.min,
|
|
233
|
+
max: f.max,
|
|
234
|
+
step: f.step,
|
|
235
|
+
required: f.required,
|
|
143
236
|
options: f.options,
|
|
237
|
+
multiple: f.multiple,
|
|
144
238
|
})),
|
|
145
239
|
address: options.address,
|
|
240
|
+
page: options.page,
|
|
241
|
+
screen: options.screen,
|
|
242
|
+
guess: options.guess,
|
|
146
243
|
label: options.label,
|
|
147
244
|
lifetime_days: options.lifetimeDays,
|
|
148
245
|
domain: options.domain,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FullResult, Reporter, Suite } from '@playwright/test/reporter';
|
|
2
2
|
import { type ClientOptions } from './index.js';
|
|
3
3
|
export default class ProxyMailQAReporter implements Reporter {
|
|
4
|
-
private
|
|
4
|
+
#private;
|
|
5
5
|
private suite;
|
|
6
6
|
constructor(options?: Pick<ClientOptions, 'apiKey' | 'baseUrl'>);
|
|
7
7
|
onBegin(_config: unknown, suite: Suite): void;
|
|
@@ -3,10 +3,11 @@ import { testName } from './test-name.js';
|
|
|
3
3
|
// Enough for a report; the rest are in Playwright's own.
|
|
4
4
|
const MAX_RESULTS = 200;
|
|
5
5
|
export default class ProxyMailQAReporter {
|
|
6
|
-
options;
|
|
7
6
|
suite = null;
|
|
7
|
+
// Private at run time, as the client's key is, so logging the reporter never shows an apiKey given here.
|
|
8
|
+
#options;
|
|
8
9
|
constructor(options = {}) {
|
|
9
|
-
this
|
|
10
|
+
this.#options = options;
|
|
10
11
|
}
|
|
11
12
|
onBegin(_config, suite) {
|
|
12
13
|
this.suite = suite;
|
|
@@ -48,7 +49,7 @@ export default class ProxyMailQAReporter {
|
|
|
48
49
|
}
|
|
49
50
|
client() {
|
|
50
51
|
try {
|
|
51
|
-
const qa = new ProxyMailQA(this
|
|
52
|
+
const qa = new ProxyMailQA(this.#options);
|
|
52
53
|
return qa.run ? qa : null;
|
|
53
54
|
}
|
|
54
55
|
catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "proxymail-qa",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Test every email your app sends from Playwright, Cypress, Jest, Vitest or any Node script: disposable inboxes, sign-up codes, links and coupons, email checks, unsubscribe tests and run reports.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Proxy Mail QA <hello@proxymail.qa> (https://proxymail.qa)",
|