@pplethai/cli 0.16.0 → 0.16.1
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/package.json +2 -1
- package/templates/golden-path/test/email-offline.test.ts +10 -7
- package/templates/golden-path/test/fixtures/overlay/platform/email/entry.md +12 -0
- package/templates/golden-path/test/fixtures/overlay/platform/email/mocks/responses.json +11 -0
- package/templates/golden-path/test/fixtures/overlay/platform/payments/entry.md +12 -0
- package/templates/golden-path/test/fixtures/overlay/platform/payments/mocks/responses.json +62 -0
- package/templates/golden-path/test/payments-offline.ts +10 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pplethai/cli",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "npm run build:template && node scripts/bundle.mjs",
|
|
20
20
|
"build:template": "node scripts/bundle-template.mjs",
|
|
21
|
+
"verify:template": "node scripts/verify-template.mjs",
|
|
21
22
|
"typecheck": "tsc --noEmit",
|
|
22
23
|
"test": "vitest run",
|
|
23
24
|
"test:watch": "vitest"
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
// Offline email (#435). The
|
|
2
|
-
//
|
|
3
|
-
// drives
|
|
1
|
+
// Offline email (#435). The mocks for `platform/email` (a copy of
|
|
2
|
+
// registry/email/mocks/responses.json) are the answers `npm run dev` gives. This
|
|
3
|
+
// drives those files through the same matcher a Builder's `callService` uses
|
|
4
4
|
// offline, so a fresh app can send an email against them with nothing deployed.
|
|
5
5
|
|
|
6
6
|
import { describe, expect, it } from "vitest";
|
|
7
7
|
import { answerFromOverlay } from "../src/dev-call-service";
|
|
8
8
|
import { callService } from "../src/call-service";
|
|
9
9
|
|
|
10
|
-
// The
|
|
10
|
+
// The mocks as a fresh app has them (test/fixtures/overlay/platform/email),
|
|
11
|
+
// laid out as `pple registry` writes them into `.pple/registry/`. They are a
|
|
12
|
+
// copy of the registry's own, which a Builder's app does not carry; the repo
|
|
13
|
+
// keeps the copy equal to the original (recipes/registry-fixtures.test.ts).
|
|
11
14
|
const files: Record<string, unknown> = Object.fromEntries(
|
|
12
|
-
Object.entries(
|
|
13
|
-
(
|
|
14
|
-
),
|
|
15
|
+
Object.entries(
|
|
16
|
+
import.meta.glob("./fixtures/overlay/platform/email/**/*", { eager: true, query: "?raw", import: "default" }),
|
|
17
|
+
).map(([file, text]) => [file.replace("./fixtures/", ""), text]),
|
|
15
18
|
);
|
|
16
19
|
|
|
17
20
|
const offline: typeof fetch = async (input, init) => {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
kind: service
|
|
3
|
+
visibility: private
|
|
4
|
+
userToken: none
|
|
5
|
+
description: ส่งอีเมลข้อความธรรมดาถึงที่อยู่ที่แอประบุ จากผู้ส่งที่พรรคยืนยันแล้ว
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Email
|
|
9
|
+
|
|
10
|
+
The registry's `platform/email`, as a fresh app has it offline. Its mocks are a
|
|
11
|
+
copy of `registry/email/mocks/responses.json`; the repo keeps them equal
|
|
12
|
+
(`recipes/registry-fixtures.test.ts`).
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
kind: service
|
|
3
|
+
visibility: private
|
|
4
|
+
userToken: none
|
|
5
|
+
description: รับเงินบริจาคและค่าสมาชิกผ่านหน้าชำระเงินของแพลตฟอร์ม
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Payments
|
|
9
|
+
|
|
10
|
+
The registry's `platform/payments`, as a fresh app has it offline. Its mocks are a
|
|
11
|
+
copy of `registry/payments/mocks/responses.json`; the repo keeps them equal
|
|
12
|
+
(`recipes/registry-fixtures.test.ts`).
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"method": "POST",
|
|
4
|
+
"path": "/",
|
|
5
|
+
"status": 201,
|
|
6
|
+
"body": {
|
|
7
|
+
"id": "pay_offline-mock",
|
|
8
|
+
"checkoutUrl": "https://pay.example.invalid/pay_offline-mock",
|
|
9
|
+
"state": "created"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"method": "GET",
|
|
14
|
+
"path": "/pay_offline-mock",
|
|
15
|
+
"status": 200,
|
|
16
|
+
"body": {
|
|
17
|
+
"id": "pay_offline-mock",
|
|
18
|
+
"kind": "donation",
|
|
19
|
+
"amountSatang": 50000,
|
|
20
|
+
"description": "รายการทดสอบ",
|
|
21
|
+
"reference": "offline-mock",
|
|
22
|
+
"state": "paid",
|
|
23
|
+
"mode": "test",
|
|
24
|
+
"payer": { "name": "บุคคลทดสอบ หนึ่ง", "maskedCitizenId": "x-xxxx-xxxxx-xx-0" },
|
|
25
|
+
"voucher": { "number": "TEST-PV-000001", "nameTh": "หลักฐานการรับชำระเงิน (ไม่ใช่ใบเสร็จรับเงิน)", "isReceipt": false },
|
|
26
|
+
"receipt": null,
|
|
27
|
+
"paidAt": "2026-01-01T00:00:00.000Z",
|
|
28
|
+
"refusal": null,
|
|
29
|
+
"undecided": false,
|
|
30
|
+
"refund": null
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"method": "POST",
|
|
35
|
+
"path": "/pay_offline-mock/receipt",
|
|
36
|
+
"status": 201,
|
|
37
|
+
"body": {
|
|
38
|
+
"receipt": { "id": "rcp_offline-mock", "number": "TEST-2569-000001", "isTest": true, "issuedAt": "2026-01-01T00:00:00.000Z", "replaces": null }
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"method": "POST",
|
|
43
|
+
"path": "/pay_offline-mock/reject",
|
|
44
|
+
"status": 200,
|
|
45
|
+
"body": {
|
|
46
|
+
"id": "pay_offline-mock",
|
|
47
|
+
"kind": "donation",
|
|
48
|
+
"amountSatang": 50000,
|
|
49
|
+
"description": "รายการทดสอบ",
|
|
50
|
+
"reference": "offline-mock",
|
|
51
|
+
"state": "refunded",
|
|
52
|
+
"mode": "test",
|
|
53
|
+
"payer": { "name": "บุคคลทดสอบ หนึ่ง", "maskedCitizenId": "x-xxxx-xxxxx-xx-0" },
|
|
54
|
+
"voucher": { "number": "TEST-PV-000001", "nameTh": "หลักฐานการรับชำระเงิน (ไม่ใช่ใบเสร็จรับเงิน)", "isReceipt": false },
|
|
55
|
+
"receipt": null,
|
|
56
|
+
"paidAt": "2026-01-01T00:00:00.000Z",
|
|
57
|
+
"refusal": null,
|
|
58
|
+
"undecided": false,
|
|
59
|
+
"refund": { "status": "refunded" }
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
]
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
// The
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// The `platform/payments` mocks, served the way `npm run dev` serves them
|
|
2
|
+
// (ADR-0026): through the offline matcher, as a Persona. Tests use it as the
|
|
3
|
+
// fake Platform Service, so a test runs the answers a Builder sees offline, not
|
|
4
|
+
// a hand-written copy of them.
|
|
5
5
|
|
|
6
6
|
import { answerFromOverlay } from "../src/dev-call-service";
|
|
7
7
|
|
|
8
|
-
// The
|
|
9
|
-
//
|
|
8
|
+
// The mocks as a fresh app has them (test/fixtures/overlay/platform/payments),
|
|
9
|
+
// laid out as `pple registry` writes them into `.pple/registry/`. They are a
|
|
10
|
+
// copy of the registry's own, which a Builder's app does not carry; the repo
|
|
11
|
+
// keeps the copy equal to the original (recipes/registry-fixtures.test.ts).
|
|
10
12
|
const files: Record<string, unknown> = Object.fromEntries(
|
|
11
13
|
Object.entries(
|
|
12
|
-
import.meta.glob("
|
|
13
|
-
).map(([file, text]) => [file.replace("
|
|
14
|
+
import.meta.glob("./fixtures/overlay/platform/payments/**/*", { eager: true, query: "?raw", import: "default" }),
|
|
15
|
+
).map(([file, text]) => [file.replace("./fixtures/", ""), text]),
|
|
14
16
|
);
|
|
15
17
|
|
|
16
18
|
/** Handles `{PPLE_SERVICES_URL}/platform/payments/…` as the mocks would for `persona`. */
|