proxymail-qa 0.11.2 → 0.13.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 +91 -11
- package/dist/cli-main.d.ts +19 -0
- package/dist/cli-main.js +373 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +27 -0
- package/dist/cypress-methods.d.ts +9 -0
- package/dist/cypress-methods.js +71 -0
- package/dist/cypress-plugin.d.ts +4 -0
- package/dist/cypress-plugin.js +28 -0
- package/dist/cypress.d.ts +32 -0
- package/dist/cypress.js +42 -0
- package/dist/index.d.ts +667 -9
- package/dist/index.js +409 -12
- package/dist/playwright-reporter.d.ts +1 -1
- package/dist/playwright-reporter.js +4 -3
- package/package.json +19 -4
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Cypress's Node side (FM-15): registers the task cy.proxymail calls, so the
|
|
2
|
+
// API key stays in Node and never reaches the browser.
|
|
3
|
+
//
|
|
4
|
+
// // cypress.config.ts
|
|
5
|
+
// import { setupProxyMailQA } from 'proxymail-qa/cypress/plugin';
|
|
6
|
+
// export default defineConfig({ e2e: { setupNodeEvents(on) { setupProxyMailQA(on); } } });
|
|
7
|
+
//
|
|
8
|
+
// With PROXYMAIL_QA_RUN set (the GitHub Action sets it), each call says which
|
|
9
|
+
// test it came from, so the run's report shows it.
|
|
10
|
+
import { CYPRESS_METHODS, CYPRESS_TASK } from './cypress-methods.js';
|
|
11
|
+
import { ProxyMailQA } from './index.js';
|
|
12
|
+
const ALLOWED = new Set(CYPRESS_METHODS);
|
|
13
|
+
export function setupProxyMailQA(on, options = {}) {
|
|
14
|
+
// Made at the first call, so a missing key fails the test that needs it
|
|
15
|
+
// with the client's own message, not Cypress's start.
|
|
16
|
+
let base;
|
|
17
|
+
on('task', {
|
|
18
|
+
[CYPRESS_TASK]: async ({ method, args, test }) => {
|
|
19
|
+
if (!ALLOWED.has(method))
|
|
20
|
+
throw new Error(`cy.proxymail has no ${method}.`);
|
|
21
|
+
base ??= new ProxyMailQA(options);
|
|
22
|
+
const qa = test ? base.forTest(test) : base;
|
|
23
|
+
const result = await qa[method].apply(qa, args);
|
|
24
|
+
// A Cypress task can't return undefined.
|
|
25
|
+
return result === undefined ? null : result;
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type CypressMethod, type CypressTaskCall } from './cypress-methods.js';
|
|
2
|
+
import type { ProxyMailQA } from './index.js';
|
|
3
|
+
export type ProxyMailCommands = {
|
|
4
|
+
[K in CypressMethod]: (...args: Parameters<ProxyMailQA[K]>) => Cypress.Chainable<Awaited<ReturnType<ProxyMailQA[K]>>>;
|
|
5
|
+
};
|
|
6
|
+
declare global {
|
|
7
|
+
namespace Cypress {
|
|
8
|
+
interface Chainable<Subject = any> {
|
|
9
|
+
proxymail: ProxyMailCommands;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
interface CypressGlobal {
|
|
14
|
+
currentTest?: {
|
|
15
|
+
title?: string;
|
|
16
|
+
titlePath?: string[];
|
|
17
|
+
} | null;
|
|
18
|
+
log: (options: {
|
|
19
|
+
name: string;
|
|
20
|
+
displayName?: string;
|
|
21
|
+
message: string;
|
|
22
|
+
}) => unknown;
|
|
23
|
+
}
|
|
24
|
+
interface CyGlobal {
|
|
25
|
+
task: (name: string, arg: CypressTaskCall, options: {
|
|
26
|
+
log: boolean;
|
|
27
|
+
timeout?: number;
|
|
28
|
+
}) => unknown;
|
|
29
|
+
}
|
|
30
|
+
export declare function taskTimeout(method: string, args: unknown[]): number | undefined;
|
|
31
|
+
export declare function proxymailCommands(Cypress: CypressGlobal, cy: CyGlobal): ProxyMailCommands;
|
|
32
|
+
export {};
|
package/dist/cypress.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Cypress commands (FM-15), matching the Playwright helper: cy.proxymail has
|
|
2
|
+
// the client's methods, for the test it's in. Import it in the support file
|
|
3
|
+
// and register the task with setupProxyMailQA from proxymail-qa/cypress/plugin.
|
|
4
|
+
//
|
|
5
|
+
// // cypress/support/e2e.ts
|
|
6
|
+
// import 'proxymail-qa/cypress';
|
|
7
|
+
//
|
|
8
|
+
// it('signs up', () => {
|
|
9
|
+
// cy.proxymail.createAddress({ persona: true }).then(({ address }) => {
|
|
10
|
+
// …
|
|
11
|
+
// cy.proxymail.waitForCode(address).then(({ value }) => cy.get('[name=code]').type(value));
|
|
12
|
+
// });
|
|
13
|
+
// });
|
|
14
|
+
//
|
|
15
|
+
// Each command runs in Node through cy.task, so the API key never reaches the
|
|
16
|
+
// browser. In a run, each call says which test it came from.
|
|
17
|
+
import { CYPRESS_METHODS, CYPRESS_TASK } from './cypress-methods.js';
|
|
18
|
+
import { testName } from './test-name.js';
|
|
19
|
+
const WAITS = new Set(['waitForCode', 'waitForLink', 'expectNoEmail']);
|
|
20
|
+
const DEFAULT_WAIT = 30;
|
|
21
|
+
// Cypress gives up on a task after 60 seconds; a wait can hold for its
|
|
22
|
+
// timeout, so give it that and a margin.
|
|
23
|
+
export function taskTimeout(method, args) {
|
|
24
|
+
if (!WAITS.has(method))
|
|
25
|
+
return undefined;
|
|
26
|
+
const options = args[1];
|
|
27
|
+
return ((options?.timeout ?? DEFAULT_WAIT) + 30) * 1000;
|
|
28
|
+
}
|
|
29
|
+
// Builds cy.proxymail from Cypress's globals; exported for the tests.
|
|
30
|
+
export function proxymailCommands(Cypress, cy) {
|
|
31
|
+
const call = (method, args) => {
|
|
32
|
+
const test = Cypress.currentTest;
|
|
33
|
+
const name = test ? testName('', test.titlePath ?? (test.title ? [test.title] : [])) : '';
|
|
34
|
+
Cypress.log({ name: 'proxymail', displayName: 'proxymail', message: [method, typeof args[0] === 'string' ? args[0] : ''].filter(Boolean).join(' ') });
|
|
35
|
+
return cy.task(CYPRESS_TASK, { method, args, test: name || null }, { log: false, timeout: taskTimeout(method, args) });
|
|
36
|
+
};
|
|
37
|
+
return Object.fromEntries(CYPRESS_METHODS.map((method) => [method, (...args) => call(method, args)]));
|
|
38
|
+
}
|
|
39
|
+
const globals = globalThis;
|
|
40
|
+
if (globals.Cypress && globals.cy) {
|
|
41
|
+
Object.defineProperty(globals.cy, 'proxymail', { value: proxymailCommands(globals.Cypress, globals.cy), configurable: true });
|
|
42
|
+
}
|