@camphoric/camphoric-event-import-tools 2.1.0 → 2.2.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/CHANGELOG.md +12 -0
- package/README.md +53 -4
- package/dist/e2e.d.ts +17 -3
- package/dist/e2e.d.ts.map +1 -1
- package/dist/e2e.js +60 -7
- package/dist/e2e.js.map +1 -1
- package/dist/e2eAdmin.d.ts +59 -0
- package/dist/e2eAdmin.d.ts.map +1 -0
- package/dist/e2eAdmin.js +103 -0
- package/dist/e2eAdmin.js.map +1 -0
- package/dist/e2eImport.d.ts +1 -0
- package/dist/e2eImport.d.ts.map +1 -1
- package/dist/e2eImport.js +8 -4
- package/dist/e2eImport.js.map +1 -1
- package/dist/e2ePayPal.d.ts +34 -0
- package/dist/e2ePayPal.d.ts.map +1 -0
- package/dist/e2ePayPal.js +104 -0
- package/dist/e2ePayPal.js.map +1 -0
- package/dist/e2eRegistrationForm.d.ts +42 -0
- package/dist/e2eRegistrationForm.d.ts.map +1 -1
- package/dist/e2eRegistrationForm.js +99 -0
- package/dist/e2eRegistrationForm.js.map +1 -1
- package/dist/e2eServer.d.ts +2 -0
- package/dist/e2eServer.d.ts.map +1 -1
- package/dist/e2eServer.js +14 -1
- package/dist/e2eServer.js.map +1 -1
- package/e2e-compose.yml +38 -3
- package/e2e.ts +67 -9
- package/e2eAdmin.ts +174 -0
- package/e2eFakePayPal.py +112 -0
- package/e2eImport.ts +13 -2
- package/e2ePayPal.ts +129 -0
- package/e2eRegistrationForm.ts +108 -0
- package/e2eServer.ts +19 -1
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.2.0](https://github.com/camphoric/camphoric/compare/camphoric-event-import-tools-v2.1.0...camphoric-event-import-tools-v2.2.0) (2026-11-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **data:** add and remove list items and campers in the e2e page object (list, removeCamper) ([57da044](https://github.com/camphoric/camphoric/commit/57da044c1eee79d92a6811572b9b8f012c2b79ef))
|
|
9
|
+
* **data:** create invitations in the e2e harness (admin.invite) ([57da044](https://github.com/camphoric/camphoric/commit/57da044c1eee79d92a6811572b9b8f012c2b79ef))
|
|
10
|
+
* **data:** raise the e2e server's registration throttles ([57da044](https://github.com/camphoric/camphoric/commit/57da044c1eee79d92a6811572b9b8f012c2b79ef))
|
|
11
|
+
* **data:** read the email the e2e server sent (admin.emails) ([57da044](https://github.com/camphoric/camphoric/commit/57da044c1eee79d92a6811572b9b8f012c2b79ef))
|
|
12
|
+
* **data:** read the payment step's totals in the e2e page object (paymentTotal) ([57da044](https://github.com/camphoric/camphoric/commit/57da044c1eee79d92a6811572b9b8f012c2b79ef))
|
|
13
|
+
* **data:** take online payments in e2e tests through a fake PayPal (onlinePayment, startOnlinePayment, payPal.order) ([57da044](https://github.com/camphoric/camphoric/commit/57da044c1eee79d92a6811572b9b8f012c2b79ef))
|
|
14
|
+
|
|
3
15
|
## [2.1.0](https://github.com/camphoric/camphoric/compare/camphoric-event-import-tools-v2.0.0...camphoric-event-import-tools-v2.1.0) (2026-11-06)
|
|
4
16
|
|
|
5
17
|
|
package/README.md
CHANGED
|
@@ -47,7 +47,11 @@ importer:
|
|
|
47
47
|
- **The server:** `setUpEvent()` starts a throwaway Camphoric from the release image, pulled
|
|
48
48
|
fresh each run (`CAMPHORIC_IMAGE_TAG` picks the tag, default `latest`;
|
|
49
49
|
`CAMPHORIC_E2E_IMAGE` names a locally built image instead), imports the event, and removes the
|
|
50
|
-
server when the tests end.
|
|
50
|
+
server when the tests end. Its registration throttles (registering, saving drafts, opening an
|
|
51
|
+
invitation, checking a promo code) allow `1000/minute` from one address, so a suite isn't told
|
|
52
|
+
to wait (`CAMPHORIC_E2E_REGISTER_RATE`, `_REGISTRATION_DRAFT_RATE`, `_INVITATION_LOOKUP_RATE`
|
|
53
|
+
and `_PROMO_CODE_CHECK_RATE` change them; a real server's are 10 to 30 a minute). It sends email as it's queued, to its console, keeping what it sent in its outbox
|
|
54
|
+
(see `admin.emails()` below).
|
|
51
55
|
- **An existing server:** `CAMPHORIC_E2E_SERVER_URL`, with `CAMPHORIC_E2E_SERVER_USERNAME` /
|
|
52
56
|
`_PASSWORD` for its admin, makes it import into that server instead. Not `CAMPHORIC_URL`, so
|
|
53
57
|
tests never import into a development server by accident. One that isn't local also needs
|
|
@@ -56,9 +60,54 @@ importer:
|
|
|
56
60
|
can be tested whatever its dates say (`openRegistration: false` keeps them).
|
|
57
61
|
- **One shared event:** every test, on desktop and mobile Chrome, shares the one imported event.
|
|
58
62
|
A registration one test completes stays, taking lodging capacity the others see.
|
|
59
|
-
- **What tests use:** a `test` with
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
- **What tests use:** a `test` with these fixtures, and `expect`:
|
|
64
|
+
- `registration`: a `RegistrationForm` page object (fields by label, campers, lodging, lists,
|
|
65
|
+
the price ticker, submitting and paying);
|
|
66
|
+
- `admin`: a `CamphoricAdmin`, what an organizer does, through the admin API as the admin the
|
|
67
|
+
event was imported as (invitations, and the email sent);
|
|
68
|
+
- `payPal`: a `FakePayPal`, the orders the server asked the throwaway server's fake PayPal for;
|
|
69
|
+
- `eventId`: the imported event's id.
|
|
70
|
+
- **Campers and lists:** `addCamper()` adds one and `removeCamper(n)` removes the nth (from 1;
|
|
71
|
+
the ones after it move up). A list question (an array of objects in the schema, such as a
|
|
72
|
+
camper's parking passes) is `list(title)`, on the form or a camper (a camper's list through
|
|
73
|
+
`camper(n)`: on the form, every camper's list has that title): `items()` (to count),
|
|
74
|
+
`item(n)` (its questions), `add()` (returns the new item's questions) and `remove(n)`:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
const passes = registration.camper(1).list('Parking Passes');
|
|
78
|
+
const pass = await passes.add();
|
|
79
|
+
await pass.select('Vehicle Type', 'Regular car');
|
|
80
|
+
await passes.remove(1);
|
|
81
|
+
await expect(passes.items()).toHaveCount(0);
|
|
82
|
+
```
|
|
83
|
+
- **The payment step:** `choosePaymentOption(title)` picks a payment option, and
|
|
84
|
+
`paymentTotal()` is what it costs as the step shows it, by check, or with `'online'`, with
|
|
85
|
+
the event's e-payment handling. `payByCheck()` completes the registration.
|
|
86
|
+
- **Paying online:** `setUpEvent({ ..., onlinePayment: true })` imports the event with PayPal
|
|
87
|
+
enabled (a client id only the fakes accept), so the payment step offers PayPal's buttons and
|
|
88
|
+
adds the handling. The throwaway server's PayPal API is then a fake (`e2eFakePayPal.py`, run
|
|
89
|
+
on the app image and mounted from this package, so Docker must see its files), and the browser
|
|
90
|
+
gets a fake of PayPal's script. Neither is there without `onlinePayment`, or with an existing
|
|
91
|
+
server, whose own PayPal would refuse the client id: `onlinePayment` needs the throwaway
|
|
92
|
+
server. `startOnlinePayment()` (or `('Card')`) presses a
|
|
93
|
+
PayPal button: the registration is completed and the server creates its PayPal order, but the
|
|
94
|
+
payer never approves, so nothing is paid. `payPal.order(id)` is what the server asked for,
|
|
95
|
+
its amount as sent:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const online = await registration.paymentTotal('online');
|
|
99
|
+
const order = await payPal.order(await registration.startOnlinePayment());
|
|
100
|
+
expect(order.amount).toBe(online.toFixed(2)); // to the cent, as PayPal takes it
|
|
101
|
+
```
|
|
102
|
+
- **Invitations:** `admin.invite(type)` creates an invitation to register as the registration
|
|
103
|
+
type with that `name`, for a new `@example.com` address (or `{ email, name }`), as the
|
|
104
|
+
admin's "Invite" does, and returns its `code`, `email` and `registerUrl` (the form with the
|
|
105
|
+
invitation, to `page.goto()`). `{ send: true }` emails it too.
|
|
106
|
+
- **Sent email:** `admin.emails({ to, kind })` is the email the server sent about the event
|
|
107
|
+
(from its outbox, newest first): each one's `kind` (`confirmation`, `invitation`, …),
|
|
108
|
+
`status`, `subject`, `text` and `html`. Email is recorded before the request that sends it
|
|
109
|
+
answers, so after a registration's last step it's there; `to` matches the address in any
|
|
110
|
+
case. It works with an existing server too.
|
|
62
111
|
- **Lodging:** a camper's `chooseLodging(...names)` picks a name at each level and returns the
|
|
63
112
|
choices each level offered; `lodgingLevels()` is the lodging dropdowns shown now, one per
|
|
64
113
|
level. A lodging offers nothing below it when no dropdown appears under it: after
|
package/dist/e2e.d.ts
CHANGED
|
@@ -20,9 +20,15 @@
|
|
|
20
20
|
* with its registration open, and removes the throwaway server when the tests
|
|
21
21
|
* end. Every test, on every device, shares that one event: a registration
|
|
22
22
|
* one test completes stays, taking up lodging capacity the others see.
|
|
23
|
+
*
|
|
24
|
+
* A throwaway server's PayPal is a fake (e2ePayPal.ts): with `onlinePayment`
|
|
25
|
+
* the payment step shows PayPal's buttons, and a test can read what the
|
|
26
|
+
* server asked PayPal for, without anything being paid.
|
|
23
27
|
*/
|
|
24
28
|
import { type PlaywrightTestConfig } from '@playwright/test';
|
|
29
|
+
import { CamphoricAdmin } from './e2eAdmin.ts';
|
|
25
30
|
import { type ImportForE2EOptions } from './e2eImport.ts';
|
|
31
|
+
import { FakePayPal } from './e2ePayPal.ts';
|
|
26
32
|
import { RegistrationForm } from './e2eRegistrationForm.ts';
|
|
27
33
|
import { type CamphoricServerOptions } from './e2eServer.ts';
|
|
28
34
|
export { expect } from '@playwright/test';
|
|
@@ -30,8 +36,12 @@ export { camphoricServer } from './e2eServer.ts';
|
|
|
30
36
|
export type { CamphoricServer, CamphoricServerOptions } from './e2eServer.ts';
|
|
31
37
|
export { importForE2E } from './e2eImport.ts';
|
|
32
38
|
export type { ImportForE2EOptions } from './e2eImport.ts';
|
|
33
|
-
export { CamperSection, FormSection, RegistrationForm } from './e2eRegistrationForm.ts';
|
|
34
|
-
export
|
|
39
|
+
export { CamperSection, FormSection, ListQuestion, RegistrationForm } from './e2eRegistrationForm.ts';
|
|
40
|
+
export { CamphoricAdmin } from './e2eAdmin.ts';
|
|
41
|
+
export type { E2EInvitation, EmailsOptions, InviteOptions, SentEmail } from './e2eAdmin.ts';
|
|
42
|
+
export { FakePayPal } from './e2ePayPal.ts';
|
|
43
|
+
export type { PayPalOrder } from './e2ePayPal.ts';
|
|
44
|
+
export type SetUpEventOptions = Pick<ImportForE2EOptions, 'event' | 'validate' | 'withSampleRegistrations' | 'openRegistration' | 'onlinePayment'> & Omit<CamphoricServerOptions, 'fakePayPal'>;
|
|
35
45
|
/**
|
|
36
46
|
* A Playwright global setup: starts the server, imports the event, and
|
|
37
47
|
* returns the teardown that removes a throwaway server.
|
|
@@ -46,10 +56,14 @@ export declare function defineEventE2EConfig({ globalSetup, ...overrides }: {
|
|
|
46
56
|
} & PlaywrightTestConfig): PlaywrightTestConfig;
|
|
47
57
|
/**
|
|
48
58
|
* Playwright's test, with the server as its baseURL and these fixtures:
|
|
49
|
-
* `eventId`, the imported event's id
|
|
59
|
+
* `eventId`, the imported event's id; `registration`, its form; `admin`,
|
|
60
|
+
* what an organizer does (invitations, the email sent); and `payPal`, the
|
|
61
|
+
* throwaway server's fake PayPal (the orders the server created).
|
|
50
62
|
*/
|
|
51
63
|
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & {
|
|
52
64
|
eventId: number;
|
|
53
65
|
registration: RegistrationForm;
|
|
66
|
+
admin: CamphoricAdmin;
|
|
67
|
+
payPal: FakePayPal;
|
|
54
68
|
}, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
55
69
|
//# sourceMappingURL=e2e.d.ts.map
|
package/dist/e2e.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"e2e.d.ts","sourceRoot":"","sources":["../e2e.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"e2e.d.ts","sourceRoot":"","sources":["../e2e.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAuC,KAAK,oBAAoB,EAA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gB,oBAAoB,CAClC,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,oBAAoB,GAC5E,oBAAoB,CAkBtB;AASD;;;;;GAKG;AAGH,eAAO,MAAM,IAAI;aACN,MAAM;kBACD,gBAAgB;WACvB,cAAc;YACb,UAAU;wGAqClB,CAAC"}
|
package/dist/e2e.js
CHANGED
|
@@ -20,29 +20,51 @@
|
|
|
20
20
|
* with its registration open, and removes the throwaway server when the tests
|
|
21
21
|
* end. Every test, on every device, shares that one event: a registration
|
|
22
22
|
* one test completes stays, taking up lodging capacity the others see.
|
|
23
|
+
*
|
|
24
|
+
* A throwaway server's PayPal is a fake (e2ePayPal.ts): with `onlinePayment`
|
|
25
|
+
* the payment step shows PayPal's buttons, and a test can read what the
|
|
26
|
+
* server asked PayPal for, without anything being paid.
|
|
23
27
|
*/
|
|
24
28
|
import { defineConfig, devices, test as base } from '@playwright/test';
|
|
29
|
+
import { getAuthToken } from "./getAuthInfo.js";
|
|
30
|
+
import { CamphoricAdmin } from "./e2eAdmin.js";
|
|
25
31
|
import { importForE2E } from "./e2eImport.js";
|
|
32
|
+
import { FAKE_PAYPAL_SDK, FakePayPal, PAYPAL_SDK_URL } from "./e2ePayPal.js";
|
|
26
33
|
import { RegistrationForm } from "./e2eRegistrationForm.js";
|
|
27
34
|
import { camphoricServer } from "./e2eServer.js";
|
|
28
35
|
export { expect } from '@playwright/test';
|
|
29
36
|
export { camphoricServer } from "./e2eServer.js";
|
|
30
37
|
export { importForE2E } from "./e2eImport.js";
|
|
31
|
-
export { CamperSection, FormSection, RegistrationForm } from "./e2eRegistrationForm.js";
|
|
38
|
+
export { CamperSection, FormSection, ListQuestion, RegistrationForm } from "./e2eRegistrationForm.js";
|
|
39
|
+
export { CamphoricAdmin } from "./e2eAdmin.js";
|
|
40
|
+
export { FakePayPal } from "./e2ePayPal.js";
|
|
32
41
|
// What the global setup hands the tests (workers inherit its environment)
|
|
33
42
|
const URL_VARIABLE = 'CAMPHORIC_E2E_RUN_URL';
|
|
34
43
|
const EVENT_VARIABLE = 'CAMPHORIC_E2E_RUN_EVENT_ID';
|
|
44
|
+
// The admin's API token (signing in once: Camphoric throttles sign-in)
|
|
45
|
+
const TOKEN_VARIABLE = 'CAMPHORIC_E2E_RUN_TOKEN';
|
|
46
|
+
// A throwaway server's fake PayPal API
|
|
47
|
+
const PAYPAL_VARIABLE = 'CAMPHORIC_E2E_RUN_PAYPAL_URL';
|
|
35
48
|
/**
|
|
36
49
|
* A Playwright global setup: starts the server, imports the event, and
|
|
37
50
|
* returns the teardown that removes a throwaway server.
|
|
38
51
|
*/
|
|
39
52
|
export function setUpEvent(options) {
|
|
40
53
|
return async () => {
|
|
41
|
-
const server = await camphoricServer(options);
|
|
54
|
+
const server = await camphoricServer({ ...options, fakePayPal: options.onlinePayment });
|
|
42
55
|
try {
|
|
56
|
+
if (options.onlinePayment && !server.payPalUrl) {
|
|
57
|
+
throw new Error('onlinePayment needs the throwaway server, whose PayPal is a fake: '
|
|
58
|
+
+ 'CAMPHORIC_E2E_SERVER_URL\'s PayPal would refuse its client id');
|
|
59
|
+
}
|
|
43
60
|
const eventId = await importForE2E({ ...options, ...server });
|
|
44
61
|
process.env[URL_VARIABLE] = server.url;
|
|
45
62
|
process.env[EVENT_VARIABLE] = String(eventId);
|
|
63
|
+
process.env[TOKEN_VARIABLE] = await getAuthToken(server.url);
|
|
64
|
+
if (server.payPalUrl)
|
|
65
|
+
process.env[PAYPAL_VARIABLE] = server.payPalUrl;
|
|
66
|
+
else
|
|
67
|
+
delete process.env[PAYPAL_VARIABLE];
|
|
46
68
|
}
|
|
47
69
|
catch (e) {
|
|
48
70
|
await server.stop();
|
|
@@ -74,19 +96,35 @@ export function defineEventE2EConfig({ globalSetup, ...overrides }) {
|
|
|
74
96
|
...overrides,
|
|
75
97
|
});
|
|
76
98
|
}
|
|
99
|
+
// The server's URL, from the global setup
|
|
100
|
+
function serverUrl() {
|
|
101
|
+
const url = process.env[URL_VARIABLE];
|
|
102
|
+
if (!url)
|
|
103
|
+
throw new Error('no Camphoric server: run these tests with a config from defineEventE2EConfig');
|
|
104
|
+
return url;
|
|
105
|
+
}
|
|
77
106
|
/**
|
|
78
107
|
* Playwright's test, with the server as its baseURL and these fixtures:
|
|
79
|
-
* `eventId`, the imported event's id
|
|
108
|
+
* `eventId`, the imported event's id; `registration`, its form; `admin`,
|
|
109
|
+
* what an organizer does (invitations, the email sent); and `payPal`, the
|
|
110
|
+
* throwaway server's fake PayPal (the orders the server created).
|
|
80
111
|
*/
|
|
81
112
|
// (Playwright reads a fixture's dependencies from its destructured first
|
|
82
113
|
// argument, so one with none takes an empty pattern.)
|
|
83
114
|
export const test = base.extend({
|
|
84
115
|
// eslint-disable-next-line no-empty-pattern
|
|
85
116
|
baseURL: async ({}, use) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
117
|
+
await use(serverUrl());
|
|
118
|
+
},
|
|
119
|
+
// With the fake PayPal API, the browser gets the fake PayPal script, whose
|
|
120
|
+
// buttons work with it
|
|
121
|
+
context: async ({ context }, use) => {
|
|
122
|
+
if (process.env[PAYPAL_VARIABLE]) {
|
|
123
|
+
await context.route(PAYPAL_SDK_URL, route => route.fulfill({
|
|
124
|
+
contentType: 'text/javascript', body: FAKE_PAYPAL_SDK,
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
await use(context);
|
|
90
128
|
},
|
|
91
129
|
// eslint-disable-next-line no-empty-pattern
|
|
92
130
|
eventId: async ({}, use) => {
|
|
@@ -95,5 +133,20 @@ export const test = base.extend({
|
|
|
95
133
|
registration: async ({ page, eventId }, use) => {
|
|
96
134
|
await use(new RegistrationForm(page, eventId));
|
|
97
135
|
},
|
|
136
|
+
admin: async ({ eventId }, use) => {
|
|
137
|
+
const token = process.env[TOKEN_VARIABLE];
|
|
138
|
+
if (!token)
|
|
139
|
+
throw new Error('no admin token: run these tests with a config from defineEventE2EConfig');
|
|
140
|
+
await use(new CamphoricAdmin(serverUrl(), token, eventId));
|
|
141
|
+
},
|
|
142
|
+
// eslint-disable-next-line no-empty-pattern
|
|
143
|
+
payPal: async ({}, use) => {
|
|
144
|
+
const url = process.env[PAYPAL_VARIABLE];
|
|
145
|
+
if (!url) {
|
|
146
|
+
throw new Error('no fake PayPal: it comes with the throwaway server (not CAMPHORIC_E2E_SERVER_URL) '
|
|
147
|
+
+ 'when setUpEvent is given onlinePayment: true');
|
|
148
|
+
}
|
|
149
|
+
await use(new FakePayPal(url));
|
|
150
|
+
},
|
|
98
151
|
});
|
|
99
152
|
//# sourceMappingURL=e2e.js.map
|
package/dist/e2e.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"e2e.js","sourceRoot":"","sources":["../e2e.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"e2e.js","sourceRoot":"","sources":["../e2e.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,IAAI,IAAI,EAA6B,MAAM,kBAAkB,CAAC;AAElG,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAA4B,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAA+B,MAAM,gBAAgB,CAAC;AAE9E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,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AAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC;QACvG,MAAM,GAAG,CAAC,IAAI,cAAc,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7D,CAAC;IACD,4CAA4C;IAC5C,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE;QACxB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,oFAAoF;kBAChG,8CAA8C,CAAC,CAAC;QACtD,CAAC;QACD,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an organizer does in the admin, for an event's e2e tests: invitations
|
|
3
|
+
* to register as a registration type, and the emails the server sent. It
|
|
4
|
+
* uses the admin API (as the admin client does), signed in as the admin the
|
|
5
|
+
* event was imported as, so tests don't drive the admin's own pages.
|
|
6
|
+
*/
|
|
7
|
+
/** An invitation to register as one of the event's registration types. */
|
|
8
|
+
export interface E2EInvitation {
|
|
9
|
+
id: number;
|
|
10
|
+
code: string;
|
|
11
|
+
email: string;
|
|
12
|
+
registerUrl: string;
|
|
13
|
+
}
|
|
14
|
+
export interface InviteOptions {
|
|
15
|
+
email?: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
send?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** An email the server sent (or queued), from its outbox. */
|
|
20
|
+
export interface SentEmail {
|
|
21
|
+
id: number;
|
|
22
|
+
kind: string;
|
|
23
|
+
status: string;
|
|
24
|
+
to: string;
|
|
25
|
+
from: string;
|
|
26
|
+
replyTo: string;
|
|
27
|
+
subject: string;
|
|
28
|
+
text: string;
|
|
29
|
+
html: string;
|
|
30
|
+
lastError: string;
|
|
31
|
+
registration: number | null;
|
|
32
|
+
invitation: number | null;
|
|
33
|
+
}
|
|
34
|
+
export interface EmailsOptions {
|
|
35
|
+
to?: string;
|
|
36
|
+
kind?: string;
|
|
37
|
+
}
|
|
38
|
+
export declare class CamphoricAdmin {
|
|
39
|
+
readonly url: string;
|
|
40
|
+
readonly eventId: number;
|
|
41
|
+
private readonly token;
|
|
42
|
+
constructor(url: string, token: string, eventId: number);
|
|
43
|
+
/**
|
|
44
|
+
* Creates an invitation to register as the registration type with this
|
|
45
|
+
* `name` (its name in the event's data, not its label), as the admin's
|
|
46
|
+
* "Invite a special registration" does. Open its form with
|
|
47
|
+
* `page.goto(invitation.registerUrl)`.
|
|
48
|
+
*/
|
|
49
|
+
invite(registrationType: string, options?: InviteOptions): Promise<E2EInvitation>;
|
|
50
|
+
/**
|
|
51
|
+
* The emails the server sent about the event (its outbox), newest first,
|
|
52
|
+
* with what each said. Email is recorded as the request that sends it ends,
|
|
53
|
+
* so after a registration it's there when the page has moved on; to wait
|
|
54
|
+
* for one: `await expect.poll(async () => (await admin.emails({ to })).length).toBe(1)`.
|
|
55
|
+
*/
|
|
56
|
+
emails(options?: EmailsOptions): Promise<SentEmail[]>;
|
|
57
|
+
private request;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=e2eAdmin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e2eAdmin.d.ts","sourceRoot":"","sources":["../e2eAdmin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,0EAA0E;AAC1E,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IAGX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IAGd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAE5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,6DAA6D;AAC7D,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IAEX,IAAI,EAAE,MAAM,CAAC;IAGb,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAE5B,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAyBD,qBAAa,cAAc;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAEnB,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAMvD;;;;;OAKG;IACG,MAAM,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,aAAa,CAAC;IAyB3F;;;;;OAKG;IACG,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;YAgCjD,OAAO;CActB"}
|
package/dist/e2eAdmin.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an organizer does in the admin, for an event's e2e tests: invitations
|
|
3
|
+
* to register as a registration type, and the emails the server sent. It
|
|
4
|
+
* uses the admin API (as the admin client does), signed in as the admin the
|
|
5
|
+
* event was imported as, so tests don't drive the admin's own pages.
|
|
6
|
+
*/
|
|
7
|
+
import { randomBytes } from 'node:crypto';
|
|
8
|
+
// The address in "Name <address>", or the whole of a bare one
|
|
9
|
+
const address = (recipient) => (/<([^>]*)>\s*$/.exec(recipient)?.[1] ?? recipient).trim().toLowerCase();
|
|
10
|
+
export class CamphoricAdmin {
|
|
11
|
+
url;
|
|
12
|
+
eventId;
|
|
13
|
+
token;
|
|
14
|
+
constructor(url, token, eventId) {
|
|
15
|
+
this.url = url.replace(/\/$/, '');
|
|
16
|
+
this.token = token;
|
|
17
|
+
this.eventId = eventId;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates an invitation to register as the registration type with this
|
|
21
|
+
* `name` (its name in the event's data, not its label), as the admin's
|
|
22
|
+
* "Invite a special registration" does. Open its form with
|
|
23
|
+
* `page.goto(invitation.registerUrl)`.
|
|
24
|
+
*/
|
|
25
|
+
async invite(registrationType, options = {}) {
|
|
26
|
+
const types = await this.request('GET', `/api/registrationtypes/?event=${this.eventId}`);
|
|
27
|
+
const type = types.find(t => t.name === registrationType);
|
|
28
|
+
if (!type) {
|
|
29
|
+
const names = types.map(t => t.name).join(', ') || 'none';
|
|
30
|
+
throw new Error(`the event has no registration type named '${registrationType}' (it has: ${names})`);
|
|
31
|
+
}
|
|
32
|
+
const email = options.email ?? `e2e.invitee.${randomBytes(4).toString('hex')}@example.com`;
|
|
33
|
+
const invitation = await this.request('POST', '/api/invitations/', {
|
|
34
|
+
registration_type: type.id,
|
|
35
|
+
recipient_name: options.name ?? '',
|
|
36
|
+
recipient_email: email,
|
|
37
|
+
});
|
|
38
|
+
if (options.send)
|
|
39
|
+
await this.request('POST', `/api/invitations/${invitation.id}/send`);
|
|
40
|
+
const link = new URL(invitation.register_link, this.url);
|
|
41
|
+
return {
|
|
42
|
+
id: invitation.id,
|
|
43
|
+
code: invitation.invitation_code,
|
|
44
|
+
email,
|
|
45
|
+
registerUrl: `${link.pathname}${link.search}`,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The emails the server sent about the event (its outbox), newest first,
|
|
50
|
+
* with what each said. Email is recorded as the request that sends it ends,
|
|
51
|
+
* so after a registration it's there when the page has moved on; to wait
|
|
52
|
+
* for one: `await expect.poll(async () => (await admin.emails({ to })).length).toBe(1)`.
|
|
53
|
+
*/
|
|
54
|
+
async emails(options = {}) {
|
|
55
|
+
const query = new URLSearchParams({ event: String(this.eventId) });
|
|
56
|
+
if (options.to)
|
|
57
|
+
query.set('q', address(options.to));
|
|
58
|
+
if (options.kind)
|
|
59
|
+
query.set('kind', options.kind);
|
|
60
|
+
const listed = [];
|
|
61
|
+
let next = `/api/emailmessages/?${query}`;
|
|
62
|
+
while (next) {
|
|
63
|
+
const page = await this.request('GET', next);
|
|
64
|
+
listed.push(...page.results);
|
|
65
|
+
// (Its path only: behind a proxy the server may name itself by another
|
|
66
|
+
// scheme or host, where the token wouldn't be sent)
|
|
67
|
+
next = page.next ? `${new URL(page.next).pathname}${new URL(page.next).search}` : null;
|
|
68
|
+
}
|
|
69
|
+
// (q matches part of the recipient or subject)
|
|
70
|
+
const wanted = options.to ? listed.filter(m => address(m.to) === address(options.to ?? '')) : listed;
|
|
71
|
+
const messages = await Promise.all(wanted.map(m => this.request('GET', `/api/emailmessages/${m.id}/`)));
|
|
72
|
+
return messages.map(m => ({
|
|
73
|
+
id: m.id,
|
|
74
|
+
kind: m.kind,
|
|
75
|
+
status: m.status,
|
|
76
|
+
to: m.to,
|
|
77
|
+
from: m.from_email,
|
|
78
|
+
replyTo: m.reply_to,
|
|
79
|
+
subject: m.subject,
|
|
80
|
+
text: m.text,
|
|
81
|
+
html: m.html,
|
|
82
|
+
lastError: m.last_error,
|
|
83
|
+
registration: m.registration,
|
|
84
|
+
invitation: m.invitation,
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
async request(method, path, body) {
|
|
88
|
+
const url = new URL(path, this.url);
|
|
89
|
+
const response = await fetch(url, {
|
|
90
|
+
method,
|
|
91
|
+
headers: {
|
|
92
|
+
'Authorization': `Token ${this.token}`,
|
|
93
|
+
...(body === undefined ? {} : { 'Content-Type': 'application/json' }),
|
|
94
|
+
},
|
|
95
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
96
|
+
});
|
|
97
|
+
const text = await response.text();
|
|
98
|
+
if (!response.ok)
|
|
99
|
+
throw new Error(`${method} ${url.pathname} answered ${response.status}: ${text}`);
|
|
100
|
+
return (text ? JSON.parse(text) : undefined);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=e2eAdmin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e2eAdmin.js","sourceRoot":"","sources":["../e2eAdmin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAqE1C,8DAA8D;AAC9D,MAAM,OAAO,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAEhH,MAAM,OAAO,cAAc;IAChB,GAAG,CAAS;IACZ,OAAO,CAAS;IACR,KAAK,CAAS;IAE/B,YAAY,GAAW,EAAE,KAAa,EAAE,OAAe;QACrD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CAAC,gBAAwB,EAAE,UAAyB,EAAE;QAChE,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAC9B,KAAK,EAAE,iCAAiC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC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GAAG,MAAM,IAAI,GAAG,CAAC,QAAQ,aAAa,QAAQ,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC,CAAC;QACpG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAM,CAAC;IACpD,CAAC;CACF"}
|
package/dist/e2eImport.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface ImportForE2EOptions {
|
|
|
10
10
|
password: string;
|
|
11
11
|
withSampleRegistrations?: boolean;
|
|
12
12
|
openRegistration?: boolean;
|
|
13
|
+
onlinePayment?: boolean;
|
|
13
14
|
}
|
|
14
15
|
/** Imports the event (and creates its organization), returning its id. */
|
|
15
16
|
export declare function importForE2E(options: ImportForE2EOptions): Promise<number>;
|
package/dist/e2eImport.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"e2eImport.d.ts","sourceRoot":"","sources":["../e2eImport.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"e2eImport.d.ts","sourceRoot":"","sources":["../e2eImport.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,WAAW,mBAAmB;IAElC,KAAK,EAAE,eAAe,CAAC;IAEvB,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,EAAE,CAAC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IAEjB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAKlC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAM3B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,0EAA0E;AAC1E,wBAAsB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqChF"}
|
package/dist/e2eImport.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { getAuthToken } from "./getAuthInfo.js";
|
|
5
5
|
import CamphoricEventCreator from "./CamphoricEventCreator.js";
|
|
6
|
+
import { E2E_PAYPAL_CLIENT_ID } from "./e2ePayPal.js";
|
|
6
7
|
import { Organizations, organizationLoader } from "./organizations.js";
|
|
7
8
|
/** Imports the event (and creates its organization), returning its id. */
|
|
8
9
|
export async function importForE2E(options) {
|
|
9
|
-
const { event, validate, url, username, password, withSampleRegistrations = false, openRegistration = true, } = options;
|
|
10
|
+
const { event, validate, url, username, password, withSampleRegistrations = false, openRegistration = true, onlinePayment = false, } = options;
|
|
10
11
|
// The fetcher logs in with these
|
|
11
12
|
process.env.DJANGO_SUPERUSER_USERNAME = username;
|
|
12
13
|
process.env.DJANGO_SUPERUSER_PASSWORD = password;
|
|
@@ -18,7 +19,10 @@ export async function importForE2E(options) {
|
|
|
18
19
|
registration_start: new Date(Date.now() - day).toISOString(),
|
|
19
20
|
registration_end: new Date(Date.now() + 365 * day).toISOString(),
|
|
20
21
|
};
|
|
21
|
-
const
|
|
22
|
+
const payPal = { paypal_enabled: true, paypal_client_id: E2E_PAYPAL_CLIENT_ID };
|
|
23
|
+
// Set again afterwards too, like the window
|
|
24
|
+
const changes = { ...(openRegistration ? window : {}), ...(onlinePayment ? payPal : {}) };
|
|
25
|
+
const data = { ...event.data, event: { ...event.data.event, ...changes } };
|
|
22
26
|
const token = await getAuthToken(url);
|
|
23
27
|
const organization = await organizationLoader(token, url)(event.organization);
|
|
24
28
|
const creator = new CamphoricEventCreator({
|
|
@@ -31,8 +35,8 @@ export async function importForE2E(options) {
|
|
|
31
35
|
});
|
|
32
36
|
await creator.create();
|
|
33
37
|
const { id } = creator.savedEvent();
|
|
34
|
-
if (
|
|
35
|
-
await creator.fetch('PATCH', `/api/events/${id}/`,
|
|
38
|
+
if (Object.keys(changes).length)
|
|
39
|
+
await creator.fetch('PATCH', `/api/events/${id}/`, changes);
|
|
36
40
|
return id;
|
|
37
41
|
}
|
|
38
42
|
//# sourceMappingURL=e2eImport.js.map
|
package/dist/e2eImport.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"e2eImport.js","sourceRoot":"","sources":["../e2eImport.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"e2eImport.js","sourceRoot":"","sources":["../e2eImport.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AA0BvE,0EAA0E;AAC1E,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAA4B;IAC7D,MAAM,EACJ,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,uBAAuB,GAAG,KAAK,EAAE,gBAAgB,GAAG,IAAI,EAClG,aAAa,GAAG,KAAK,GACtB,GAAG,OAAO,CAAC;IACZ,iCAAiC;IACjC,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,QAAQ,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,QAAQ,CAAC;IAEjD,wEAAwE;IACxE,oEAAoE;IACpE,sBAAsB;IACtB,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAChC,MAAM,MAAM,GAAG;QACb,kBAAkB,EAAE,IAAI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,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM;QAAE,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAE7F,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PayPal, faked for an event's e2e tests. The throwaway server's PayPal API is
|
|
3
|
+
* e2eFakePayPal.py, and the browser's PayPal script is FAKE_PAYPAL_SDK (the
|
|
4
|
+
* `test` fixture serves it in place of PayPal's), so the payment step's
|
|
5
|
+
* PayPal buttons work without a PayPal account and nothing is paid.
|
|
6
|
+
*/
|
|
7
|
+
/** What the server asked PayPal for, as e2eFakePayPal.py recorded it. */
|
|
8
|
+
export interface PayPalOrder {
|
|
9
|
+
id: string;
|
|
10
|
+
amount: string;
|
|
11
|
+
currency: string;
|
|
12
|
+
body: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export declare const E2E_PAYPAL_CLIENT_ID = "camphoric-e2e-fake-paypal";
|
|
15
|
+
export declare const PAYPAL_SDK_URL: RegExp;
|
|
16
|
+
/** The fake PayPal API's record of the orders the server created. */
|
|
17
|
+
export declare class FakePayPal {
|
|
18
|
+
readonly url: string;
|
|
19
|
+
constructor(url: string);
|
|
20
|
+
/** Every order the server created, oldest first. */
|
|
21
|
+
orders(): Promise<PayPalOrder[]>;
|
|
22
|
+
/** The order with this id, as the server asked for it. */
|
|
23
|
+
order(id: string): Promise<PayPalOrder>;
|
|
24
|
+
private get;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* PayPal's browser script, faked: `paypal.Buttons()` draws a "PayPal" and a
|
|
28
|
+
* "Debit or Credit Card" button, as the client's PayPal library expects. A
|
|
29
|
+
* click does what PayPal's does up to its popup: onClick, then createOrder
|
|
30
|
+
* (which asks the server for the order). The popup then stays "open": the
|
|
31
|
+
* payer never approves or cancels, so nothing is captured.
|
|
32
|
+
*/
|
|
33
|
+
export declare const FAKE_PAYPAL_SDK = "(() => {\n const buttons = [['paypal', 'PayPal'], ['card', 'Debit or Credit Card']];\n window.paypal = {\n version: 'camphoric-e2e-fake',\n FUNDING: { PAYPAL: 'paypal', CARD: 'card' },\n Buttons(props) {\n let container = null;\n const elements = [];\n // Disabled (as the client does while it's busy) by the buttons' own\n // attribute, so a test's click waits until they're enabled\n const setDisabled = (disabled) => {\n for (const button of elements) button.disabled = disabled;\n return Promise.resolve();\n };\n const actions = { enable: () => setDisabled(false), disable: () => setDisabled(true) };\n const pay = async (fundingSource) => {\n const data = { fundingSource };\n const clickActions = { resolve: () => Promise.resolve(), reject: () => Promise.resolve() };\n if (props.onClick && (await props.onClick(data, clickActions)) === false) return;\n try {\n await props.createOrder(data, {});\n } catch (error) {\n if (props.onError) props.onError(error);\n }\n };\n return {\n isEligible: () => true,\n render(target) {\n container = typeof target === 'string' ? document.querySelector(target) : target;\n const box = document.createElement('div');\n box.setAttribute('data-camphoric-e2e-paypal', '');\n for (const [fundingSource, label] of buttons) {\n const button = document.createElement('button');\n button.type = 'button';\n button.textContent = label;\n button.addEventListener('click', () => { pay(fundingSource); });\n elements.push(button);\n box.appendChild(button);\n }\n container.appendChild(box);\n if (props.onInit) props.onInit({}, actions);\n return Promise.resolve();\n },\n updateProps: () => Promise.resolve(),\n close() {\n if (container) container.replaceChildren();\n return Promise.resolve();\n },\n };\n },\n };\n})();\n";
|
|
34
|
+
//# sourceMappingURL=e2ePayPal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e2ePayPal.d.ts","sourceRoot":"","sources":["../e2ePayPal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yEAAyE;AACzE,MAAM,WAAW,WAAW;IAE1B,EAAE,EAAE,MAAM,CAAC;IAGX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AASD,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAGhE,eAAO,MAAM,cAAc,QAA2D,CAAC;AAEvF,qEAAqE;AACrE,qBAAa,UAAU;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;gBAET,GAAG,EAAE,MAAM;IAIvB,oDAAoD;IAC9C,MAAM,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAKtC,0DAA0D;IACpD,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;YAI/B,GAAG;CAOlB;AAYD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,yjEAoD3B,CAAC"}
|