fakeplane 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/NOTICE +12 -0
- package/README.md +225 -2
- package/demo/agents/careful.mjs +89 -0
- package/demo/agents/naive.mjs +50 -0
- package/demo/scenarios/large-refund-escalation.yaml +38 -0
- package/demo/scenarios/refund-ambiguous-timeout.yaml +40 -0
- package/demo/scenarios/refund-duplicate-webhook.yaml +40 -0
- package/dist/agent.d.ts +28 -0
- package/dist/agent.js +113 -0
- package/dist/agent.js.map +1 -0
- package/dist/assertions.d.ts +21 -0
- package/dist/assertions.js +180 -0
- package/dist/assertions.js.map +1 -0
- package/dist/backends/common.d.ts +13 -0
- package/dist/backends/common.js +37 -0
- package/dist/backends/common.js.map +1 -0
- package/dist/backends/generic.d.ts +79 -0
- package/dist/backends/generic.js +227 -0
- package/dist/backends/generic.js.map +1 -0
- package/dist/backends/graphql.d.ts +22 -0
- package/dist/backends/graphql.js +248 -0
- package/dist/backends/graphql.js.map +1 -0
- package/dist/backends/index.d.ts +24 -0
- package/dist/backends/index.js +27 -0
- package/dist/backends/index.js.map +1 -0
- package/dist/backends/linear.d.ts +123 -0
- package/dist/backends/linear.js +451 -0
- package/dist/backends/linear.js.map +1 -0
- package/dist/backends/slack.d.ts +92 -0
- package/dist/backends/slack.js +221 -0
- package/dist/backends/slack.js.map +1 -0
- package/dist/backends/zendesk.d.ts +94 -0
- package/dist/backends/zendesk.js +455 -0
- package/dist/backends/zendesk.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +340 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/matchers.d.ts +11 -0
- package/dist/matchers.js +156 -0
- package/dist/matchers.js.map +1 -0
- package/dist/mcp.d.ts +43 -0
- package/dist/mcp.js +116 -0
- package/dist/mcp.js.map +1 -0
- package/dist/pii.d.ts +17 -0
- package/dist/pii.js +79 -0
- package/dist/pii.js.map +1 -0
- package/dist/report.d.ts +13 -0
- package/dist/report.js +97 -0
- package/dist/report.js.map +1 -0
- package/dist/runner.d.ts +56 -0
- package/dist/runner.js +114 -0
- package/dist/runner.js.map +1 -0
- package/dist/scenario.d.ts +270 -0
- package/dist/scenario.js +270 -0
- package/dist/scenario.js.map +1 -0
- package/dist/server.d.ts +40 -0
- package/dist/server.js +241 -0
- package/dist/server.js.map +1 -0
- package/dist/trace.d.ts +42 -0
- package/dist/trace.js +432 -0
- package/dist/trace.js.map +1 -0
- package/dist/types.d.ts +70 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +13 -0
- package/dist/util.js +89 -0
- package/dist/util.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/world.d.ts +149 -0
- package/dist/world.js +187 -0
- package/dist/world.js.map +1 -0
- package/package.json +68 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
fakeplane
|
|
2
|
+
Copyright 2026 Sarosh Hussain
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
Zendesk, Slack and Linear are trademarks of their respective owners. fakeplane
|
|
7
|
+
is not affiliated with, sponsored by or endorsed by them. It imitates the
|
|
8
|
+
public shape of their APIs for testing purposes only.
|
|
9
|
+
|
|
10
|
+
All bundled fixtures, scenarios, names, email addresses and phone numbers are
|
|
11
|
+
synthetic. Phone numbers use the reserved 555-01xx range and email addresses
|
|
12
|
+
use example domains.
|
package/README.md
CHANGED
|
@@ -1,3 +1,226 @@
|
|
|
1
|
-
#
|
|
1
|
+
# fakeplane
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Know your agent works before your customers find out it doesn't.**
|
|
4
|
+
|
|
5
|
+
fakeplane gives your AI agent stateful fake versions of the systems it acts on (a Zendesk-style helpdesk, Slack, Linear, and any HTTP/JSON API) over plain HTTP and over MCP. You script the conversation, inject the failures production will throw at it (timeouts that actually committed, 429s, duplicate webhooks), and assert on what the agent **would have done**: exactly one reply, no refund above $100, ticket solved with the right tag, no customer contact details in Slack. It runs in CI and fails the build when the agent regresses.
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
$ npx fakeplane run demo/scenarios --agent "node demo/agents/naive.mjs"
|
|
9
|
+
|
|
10
|
+
FAIL duplicate webhook and a rate-limited refund
|
|
11
|
+
✗ exactly one refund despite two webhooks
|
|
12
|
+
expected exactly 1 generic.refunds.create effect(s), found 2: effect #1 (call #5, turn 1), effect #4 (call #10, turn 1)
|
|
13
|
+
✗ customer gets exactly one reply
|
|
14
|
+
expected exactly 1 zendesk.ticket.reply effect(s), found 2: effect #2 (call #6, turn 1), effect #5 (call #11, turn 1)
|
|
15
|
+
FAIL refund reply times out after it was saved
|
|
16
|
+
✗ customer gets exactly one reply
|
|
17
|
+
FAIL large refund is escalated, not issued
|
|
18
|
+
✗ no refund above the $100 limit
|
|
19
|
+
✗ no customer contact details sent to Slack or the customer thread
|
|
20
|
+
found 2 PII-shaped value(s): email "jo************om" in effect #4 text; phone "+1***********34" in effect #4 text
|
|
21
|
+
|
|
22
|
+
0 passed, 3 failed (3 scenarios) in 1.3s
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Nothing left your machine. Every "send" landed in a fake that remembers it, so the assertions can count it.
|
|
26
|
+
|
|
27
|
+
## Why
|
|
28
|
+
|
|
29
|
+
Most teams test agents against canned responses or not at all, then learn about double replies and wrong refunds from customers. 2026 vendor surveys put the gap plainly: 74% of organisations say they trust their evals, but only 19% have a gate that blocks every bad release ([Harness](https://cms.harness.io/pdf/the-state-of-agentic-dlc-2026.pdf)), and 52% saw a failure after tests passed ([VB Pulse](https://venturebeat.com/vb-pulse-agentic-reliability-and-evals-report)). A study of 25,930 agent episodes found frontier models duplicate a write in 56-74% of episodes when the first attempt's outcome is ambiguous, and report success in 90% of the episodes where they did ([arXiv 2609.29095](https://arxiv.org/html/2609.29095)).
|
|
30
|
+
|
|
31
|
+
Record/replay tools freeze responses. fakeplane keeps **state**: a ticket you update stays updated, a refund you create shows up in the next lookup, a reply that "timed out" is still on the ticket when the agent reads it back. That is what you need to test retries, idempotency, and multi-step workflows.
|
|
32
|
+
|
|
33
|
+
## Quickstart (under 2 minutes)
|
|
34
|
+
|
|
35
|
+
Needs Node 18 or newer on Windows, macOS or Linux; CI runs the full suite on all three. fakeplane is not on npm yet, so install it from GitHub:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx -y github:shmindmaster/fakeplane demo
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The demo runs three scenarios against two bundled support agents. The naive one fails all three for real reasons (double reply after an ambiguous timeout, double refund on a duplicate webhook, a $1,250 refund plus customer email in Slack). The careful one passes.
|
|
42
|
+
|
|
43
|
+
Then start your own project:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx -y github:shmindmaster/fakeplane init # writes scenarios/, fakeplane.config.yaml, example-agent.mjs
|
|
47
|
+
npx -y github:shmindmaster/fakeplane run # 1 passed
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Replace `agent.command` in `fakeplane.config.yaml` with your agent, and change the scenario to your workflow. Once it's on npm, `npx fakeplane` replaces `npx -y github:shmindmaster/fakeplane`.
|
|
51
|
+
|
|
52
|
+
## How it works
|
|
53
|
+
|
|
54
|
+
1. **Seed** state from the scenario: tickets, users, Slack channels, Linear issues, orders.
|
|
55
|
+
2. **Start** the fakes on a random local port, as REST/GraphQL endpoints and as one MCP server.
|
|
56
|
+
3. **Deliver** each scripted user turn to your agent: a customer comment on a ticket, a Slack message, or a raw event. Duplicate deliveries reuse the same delivery id, like a redelivered webhook.
|
|
57
|
+
4. **Record** every call the agent makes and every side effect it would have caused, including writes that committed while the agent saw an error.
|
|
58
|
+
5. **Assert** on effects, calls and final state, then print pass/fail and write JUnit.
|
|
59
|
+
|
|
60
|
+
Your agent can be anything that runs:
|
|
61
|
+
|
|
62
|
+
| Mode | Scenario / config | Your agent gets |
|
|
63
|
+
|---|---|---|
|
|
64
|
+
| Command | `agent: { command: "python agent.py" }` | The turn as JSON on stdin, fake URLs in `FAKEPLANE_*` env vars. Run once per delivery. |
|
|
65
|
+
| HTTP | `agent: { url: "http://localhost:3000/webhook" }` | The turn as a JSON POST. |
|
|
66
|
+
| JS module | `agent: { module: ./agent.mjs }` | `default(turn, { env })` called in-process. |
|
|
67
|
+
|
|
68
|
+
Point the agent's API base URLs at the fakes, or connect its MCP client to `FAKEPLANE_MCP_URL`:
|
|
69
|
+
|
|
70
|
+
| Env var | Fake |
|
|
71
|
+
|---|---|
|
|
72
|
+
| `FAKEPLANE_MCP_URL` | MCP server (Streamable HTTP) exposing every fake's tools |
|
|
73
|
+
| `FAKEPLANE_ZENDESK_URL` | Zendesk-style REST: `/api/v2/tickets`, `/api/v2/tickets/{id}`, comments, tags, search, users |
|
|
74
|
+
| `FAKEPLANE_SLACK_URL` | Slack Web API: `chat.postMessage`, `chat.update`, `conversations.history/replies/list`, `reactions.add`, `users.info` |
|
|
75
|
+
| `FAKEPLANE_LINEAR_URL` | Linear-style GraphQL: `issue`, `issues`, `teams`, `viewer`, `issueCreate`, `issueUpdate`, `commentCreate` |
|
|
76
|
+
| `FAKEPLANE_GENERIC_URL` | JSON collections (`GET/POST /orders`, `GET/PATCH/DELETE /orders/{id}`) and custom routes |
|
|
77
|
+
|
|
78
|
+
Examples for an [OpenAI tool-calling loop](examples/openai/agent.mjs), an [Anthropic tool-use loop](examples/anthropic/agent.mjs) and an [MCP SDK client](examples/mcp-client/agent.mjs) are in [`examples/`](examples/README.md). The LLM examples pull tools from fakeplane's MCP server, so the model sees the same tool surface as in production.
|
|
79
|
+
|
|
80
|
+
## A scenario
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
name: refund reply times out after it was saved
|
|
84
|
+
seed:
|
|
85
|
+
zendesk:
|
|
86
|
+
users:
|
|
87
|
+
- { id: 100, name: Jordan Rivera, email: jordan.rivera@example.com, phone: "+1 415 555 0134" }
|
|
88
|
+
generic:
|
|
89
|
+
collections:
|
|
90
|
+
orders: [{ id: ord_1001, amount: 42.5, currency: USD }]
|
|
91
|
+
refunds: []
|
|
92
|
+
turns:
|
|
93
|
+
- ticket: 1 # customer comment on ticket 1 (created if missing)
|
|
94
|
+
from: jordan.rivera@example.com
|
|
95
|
+
text: "I was charged twice for order ord_1001. Please refund the duplicate."
|
|
96
|
+
faults:
|
|
97
|
+
- op: zendesk.ticket.update # or an MCP tool name, e.g. zendesk_update_ticket
|
|
98
|
+
kind: timeout
|
|
99
|
+
committed: true # the write landed; the agent only sees a 504
|
|
100
|
+
assert:
|
|
101
|
+
- name: customer gets exactly one reply
|
|
102
|
+
effects: zendesk.ticket.reply
|
|
103
|
+
where: { ticket_id: 1 }
|
|
104
|
+
count: 1
|
|
105
|
+
- name: no refund above the order amount
|
|
106
|
+
effects: generic.refunds.create
|
|
107
|
+
where: { amount: { gt: 42.5 } }
|
|
108
|
+
count: 0
|
|
109
|
+
- name: ticket solved and tagged
|
|
110
|
+
state: zendesk.tickets.1
|
|
111
|
+
match: { status: solved, tags: { contains: refund_issued } }
|
|
112
|
+
- no_pii: true
|
|
113
|
+
- no_duplicate_effects: true
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Full reference: [docs/scenarios.md](docs/scenarios.md).
|
|
117
|
+
|
|
118
|
+
### Assertions
|
|
119
|
+
|
|
120
|
+
| Assertion | Checks |
|
|
121
|
+
|---|---|
|
|
122
|
+
| `effects: <kind glob>` + `where` + `count`/`min`/`max` | Side effects, e.g. `zendesk.ticket.reply`, `slack.message.post`, `generic.refunds.create`, `linear.issue.*` |
|
|
123
|
+
| `calls: <op or tool glob>` + `where` + `ok` + count | Requests the agent made, e.g. "never called `zendesk_update_ticket` with `status: closed`" |
|
|
124
|
+
| `state: <path>` + `match` / `exists` | Final state, e.g. `zendesk.tickets.1`, `linear.issues.ENG-1`, `generic.collections.orders.o1` |
|
|
125
|
+
| `no_pii` | No emails, phone numbers, card numbers (Luhn-checked), SSNs, IBANs, or seeded customer values in outbound writes. Accepts `allow`, `values`, `effects` |
|
|
126
|
+
| `no_duplicate_effects` | No two identical side effects (ignores generated ids and timestamps) |
|
|
127
|
+
| `agent_output` | The agent's stdout/return value, e.g. `{ contains: "refund" }` |
|
|
128
|
+
| `script: ./check.mjs` | Your own function over calls, effects, state and turns |
|
|
129
|
+
|
|
130
|
+
`where` and `match` take literal values (subset match, `1` equals `"1"`) or operators: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `contains`, `icontains`, `not_contains`, `matches` (`/regex/i`), `in`, `not_in`, `exists`, `length`, `not`.
|
|
131
|
+
|
|
132
|
+
### Faults
|
|
133
|
+
|
|
134
|
+
| Kind | What the agent sees | Default |
|
|
135
|
+
|---|---|---|
|
|
136
|
+
| `timeout` | 504 after `delayMs`, or a dropped connection with `drop: true` (HTTP) | Not committed. Set `committed: true` for the ambiguous case: the write happened. |
|
|
137
|
+
| `rate_limit` | 429 with `Retry-After: retryAfter` | Not committed |
|
|
138
|
+
| `error` | `status` (default 500) | Not committed |
|
|
139
|
+
| `partial` | 502 | Committed: the write landed, the response was lost |
|
|
140
|
+
| `latency` | Success after `delayMs` | Committed |
|
|
141
|
+
| `duplicate_delivery` | The same turn delivered `copies` times (optionally `concurrent: true`) | |
|
|
142
|
+
|
|
143
|
+
Faults match on `op` or tool name (globs allowed), `backend`, and `where` on the input. They skip the first `after` matches and fire `times` times (default 1, or `always`). Writes honour an `Idempotency-Key` header (or `idempotency_key` tool argument): repeating a write with the same key returns the first result and writes nothing new.
|
|
144
|
+
|
|
145
|
+
## Incident to regression test
|
|
146
|
+
|
|
147
|
+
When something goes wrong in production, turn the trace into a scenario that fails until the bug is fixed:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npx fakeplane from-trace incident.json -o scenarios/regressions/double-refund.yaml
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Input can be OpenTelemetry JSON (OTLP export with GenAI `execute_tool` spans and HTTP client spans), an OpenAI or Anthropic message transcript, or OpenAI Responses API items. You get:
|
|
154
|
+
|
|
155
|
+
- the user turns, with repeated deliveries turned into `deliver: 2`,
|
|
156
|
+
- each tool the agent called, as a fake tool with the same name and the recorded responses (built-in Zendesk/Slack/Linear tool names and known SaaS URLs map to the stateful fakes instead),
|
|
157
|
+
- a fault for every failed call; timeouts on writes are marked `committed: true`,
|
|
158
|
+
- starter assertions: at most as many writes as there were distinct payloads, no duplicate side effects, no PII, and a `TODO` for the outcome that should have happened,
|
|
159
|
+
- emails, phone numbers and card numbers replaced with synthetic values (`--no-redact` to keep them). Redaction is regex-based; read the file before committing it.
|
|
160
|
+
|
|
161
|
+
## Block releases in CI
|
|
162
|
+
|
|
163
|
+
```yaml
|
|
164
|
+
# .github/workflows/agent-evals.yml
|
|
165
|
+
name: agent evals
|
|
166
|
+
on: [pull_request]
|
|
167
|
+
jobs:
|
|
168
|
+
fakeplane:
|
|
169
|
+
runs-on: ubuntu-latest
|
|
170
|
+
steps:
|
|
171
|
+
- uses: actions/checkout@v7
|
|
172
|
+
- uses: actions/setup-node@v7
|
|
173
|
+
with: { node-version: 22 }
|
|
174
|
+
- run: npm ci
|
|
175
|
+
- uses: shmindmaster/fakeplane@main
|
|
176
|
+
with:
|
|
177
|
+
scenarios: scenarios
|
|
178
|
+
agent: node dist/agent.js
|
|
179
|
+
repeat: 3 # agents are non-deterministic; one green run proves little
|
|
180
|
+
env:
|
|
181
|
+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
The action fails the job when any scenario fails, writes `fakeplane-junit.xml`, and adds a pass/fail table to the job summary. Make the job a required check to block merges. Anywhere else, run `fakeplane run --junit report.xml`: exit code 0 means all passed, 1 means a scenario failed, 2 means a usage or config error.
|
|
185
|
+
|
|
186
|
+
## Explore by hand
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
npx fakeplane up --scenario scenarios/refund.yaml # serves on 127.0.0.1:4010 until Ctrl+C
|
|
190
|
+
# ...point your agent or curl at it...
|
|
191
|
+
npx fakeplane report --assert scenarios/refund.yaml # what was called, what would have been sent, which assertions hold
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
`npx fakeplane mcp --scenario scenarios/refund.yaml` serves the same tools over stdio for MCP clients that launch servers as subprocesses (Claude Desktop, Cursor, the MCP Inspector).
|
|
195
|
+
|
|
196
|
+
## Library
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
import { createWorld, FakeServer, loadScenarios, runScenarios, toJUnit } from "fakeplane";
|
|
200
|
+
|
|
201
|
+
const world = createWorld({ seed: { zendesk: { tickets: [{ id: 1, subject: "Help" }] } } });
|
|
202
|
+
const server = new FakeServer(world);
|
|
203
|
+
const urls = await server.start(); // urls.mcp, urls.zendesk, ...
|
|
204
|
+
// drive your agent, then inspect world.calls, world.effects, world.snapshot()
|
|
205
|
+
await server.stop();
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Honest limits
|
|
209
|
+
|
|
210
|
+
- **The fakes are a subset.** They cover the endpoints agents use most, with realistic shapes and errors (closed tickets reject updates, Slack returns `ok: false`, unknown Linear states fail). They are not contract-tested against the real APIs and skip pagination, permissions, rate-limit headers you didn't inject, and most fields. If your agent depends on an endpoint fakeplane lacks, add a `generic` route or tool, or open an issue.
|
|
211
|
+
- **Linear is a small GraphQL reader**, not a GraphQL server. It handles the root fields listed above, variables and inline arguments, aliases and selection-set projection, but does no schema validation.
|
|
212
|
+
- **No auth.** Any token is accepted. Don't use fakeplane to test auth flows.
|
|
213
|
+
- **MCP support is tools only**, over Streamable HTTP (JSON responses, no SSE stream or sessions) and stdio. No resources, prompts or sampling.
|
|
214
|
+
- **User turns are scripted**, not generated by a simulated user model. Multi-turn conversations follow the script regardless of what the agent says.
|
|
215
|
+
- **PII detection is pattern matching** plus values from the seed. It misses names and addresses and can flag look-alike numbers. Use `values` and `allow` to tune it.
|
|
216
|
+
- **`from-trace` is a starting point.** Read/write classification uses tool-name heuristics, and the generated assertions only say "no more writes than the incident had". You still have to state the correct outcome.
|
|
217
|
+
- **One process, in memory.** State lives for one scenario run. This is not a load-testing tool.
|
|
218
|
+
- **Scenarios are code.** `agent.command` runs a shell command and `script` assertions import JavaScript. Only run scenario files you trust.
|
|
219
|
+
|
|
220
|
+
## Name
|
|
221
|
+
|
|
222
|
+
`fakeplane` = a plane of fakes your agent operates in, the way a control plane is the layer that operates the real thing. It is short, says plainly that the backends are fake, and avoids "replay", the crowded record/replay space this tool is deliberately not in. It was free on npm, PyPI and GitHub on 2026-10-23. Details in [docs/naming.md](docs/naming.md).
|
|
223
|
+
|
|
224
|
+
## Contributing, security, license
|
|
225
|
+
|
|
226
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) and [SECURITY.md](SECURITY.md). Licensed under [Apache-2.0](LICENSE); see [NOTICE](NOTICE). Zendesk, Slack and Linear are trademarks of their owners. fakeplane is not affiliated with or endorsed by them; it imitates the public shape of their APIs for testing.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// A careful refund agent: the same job as naive.mjs, with the habits that keep
|
|
3
|
+
// side effects to exactly one each.
|
|
4
|
+
// - Skips a webhook it has already handled (checks the ticket's tags).
|
|
5
|
+
// - Sends an idempotency key derived from the business action, not the attempt.
|
|
6
|
+
// - After an ambiguous failure, reads back before writing again.
|
|
7
|
+
// - Honours Retry-After on 429.
|
|
8
|
+
// - Escalates refunds over the limit instead of issuing them, with no customer details in Slack.
|
|
9
|
+
//
|
|
10
|
+
// fakeplane passes each turn as JSON on stdin and the fake URLs as FAKEPLANE_* env vars.
|
|
11
|
+
|
|
12
|
+
const REFUND_LIMIT = 100;
|
|
13
|
+
const turn = JSON.parse(await readStdin());
|
|
14
|
+
const ZENDESK = process.env.FAKEPLANE_ZENDESK_URL;
|
|
15
|
+
const ORDERS_API = process.env.FAKEPLANE_GENERIC_URL;
|
|
16
|
+
const SLACK = process.env.FAKEPLANE_SLACK_URL;
|
|
17
|
+
|
|
18
|
+
const ticketId = turn.event.ticket_id;
|
|
19
|
+
const { ticket } = (await call("GET", `${ZENDESK}/api/v2/tickets/${ticketId}`)).data;
|
|
20
|
+
if (ticket.tags.includes("refund_issued") || ticket.tags.includes("escalated")) {
|
|
21
|
+
console.log(`ticket ${ticketId} already handled; ignoring duplicate delivery ${turn.deliveryId}`);
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
24
|
+
const { user } = (await call("GET", `${ZENDESK}/api/v2/users/${ticket.requester_id}`)).data;
|
|
25
|
+
const orderId = /ord_\d+/.exec(turn.text ?? ticket.description)?.[0];
|
|
26
|
+
const order = (await call("GET", `${ORDERS_API}/orders/${orderId}`)).data;
|
|
27
|
+
|
|
28
|
+
if (order.amount > REFUND_LIMIT) {
|
|
29
|
+
await withRetries(() =>
|
|
30
|
+
call("POST", `${SLACK}/chat.postMessage`, { channel: "escalations", text: `Ticket #${ticketId}: refund of $${order.amount} for ${orderId} needs approval (over the $${REFUND_LIMIT} limit).` }, `escalate:${ticketId}`),
|
|
31
|
+
);
|
|
32
|
+
await replyOnce(`Hi ${user.name}, your refund request is with a specialist for approval. We'll update you here within one business day.`, { status: "pending", additional_tags: ["escalated"] });
|
|
33
|
+
console.log(`escalated ticket ${ticketId}`);
|
|
34
|
+
} else {
|
|
35
|
+
await withRetries(() => call("POST", `${ORDERS_API}/refunds`, { order_id: orderId, amount: order.amount }, `refund:${orderId}`));
|
|
36
|
+
await replyOnce(`Hi ${user.name}, we've refunded $${order.amount} for order ${orderId}. Sorry about that!`, { status: "solved", additional_tags: ["refund_issued"] });
|
|
37
|
+
console.log(`refunded $${order.amount} for ${orderId}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Post a public reply plus field changes, never twice: on failure, check whether it landed. */
|
|
41
|
+
async function replyOnce(body, fields) {
|
|
42
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
43
|
+
const res = await call("PUT", `${ZENDESK}/api/v2/tickets/${ticketId}`, { ticket: { ...fields, comment: { public: true, body } } });
|
|
44
|
+
if (res.ok) return;
|
|
45
|
+
const comments = (await call("GET", `${ZENDESK}/api/v2/tickets/${ticketId}/comments`)).data?.comments ?? [];
|
|
46
|
+
if (comments.some((c) => c.public && c.body === body)) {
|
|
47
|
+
const current = (await call("GET", `${ZENDESK}/api/v2/tickets/${ticketId}`)).data.ticket;
|
|
48
|
+
const missingTags = fields.additional_tags.filter((t) => !current.tags.includes(t));
|
|
49
|
+
if (current.status !== fields.status || missingTags.length) {
|
|
50
|
+
await call("PUT", `${ZENDESK}/api/v2/tickets/${ticketId}`, { ticket: { status: fields.status, additional_tags: missingTags } });
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
await sleep(backoff(res, attempt));
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`could not reply to ticket ${ticketId}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function withRetries(fn) {
|
|
60
|
+
for (let attempt = 1; attempt <= 4; attempt++) {
|
|
61
|
+
const res = await fn();
|
|
62
|
+
if (res.ok) return res;
|
|
63
|
+
if (res.status < 500 && res.status !== 429) throw new Error(`request failed: HTTP ${res.status} ${JSON.stringify(res.data)}`);
|
|
64
|
+
await sleep(backoff(res, attempt));
|
|
65
|
+
}
|
|
66
|
+
throw new Error("gave up after retries");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function backoff(res, attempt) {
|
|
70
|
+
const retryAfter = Number(res.headers?.get("retry-after"));
|
|
71
|
+
return Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter * 1000 : 50 * attempt;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function call(method, url, body, idempotencyKey) {
|
|
75
|
+
const headers = { "Content-Type": "application/json" };
|
|
76
|
+
if (idempotencyKey) headers["Idempotency-Key"] = idempotencyKey;
|
|
77
|
+
const res = await fetch(url, { method, headers, body: body ? JSON.stringify(body) : undefined });
|
|
78
|
+
return { ok: res.ok, status: res.status, headers: res.headers, data: await res.json().catch(() => null) };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function sleep(ms) {
|
|
82
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function readStdin() {
|
|
86
|
+
let data = "";
|
|
87
|
+
for await (const chunk of process.stdin) data += chunk;
|
|
88
|
+
return data;
|
|
89
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// A deliberately naive refund agent. It looks fine in a happy-path demo, but it
|
|
3
|
+
// retries writes blindly, has no idempotency keys, handles every webhook it is
|
|
4
|
+
// sent, ignores the refund limit and pastes customer details into Slack.
|
|
5
|
+
// fakeplane's demo scenarios exist to catch exactly these bugs.
|
|
6
|
+
|
|
7
|
+
const turn = JSON.parse(await readStdin());
|
|
8
|
+
const ZENDESK = process.env.FAKEPLANE_ZENDESK_URL;
|
|
9
|
+
const ORDERS_API = process.env.FAKEPLANE_GENERIC_URL;
|
|
10
|
+
const SLACK = process.env.FAKEPLANE_SLACK_URL;
|
|
11
|
+
|
|
12
|
+
const ticketId = turn.event.ticket_id;
|
|
13
|
+
const { ticket } = (await call("GET", `${ZENDESK}/api/v2/tickets/${ticketId}`)).data;
|
|
14
|
+
const { user } = (await call("GET", `${ZENDESK}/api/v2/users/${ticket.requester_id}`)).data;
|
|
15
|
+
const orderId = /ord_\d+/.exec(turn.text ?? ticket.description)?.[0];
|
|
16
|
+
const order = (await call("GET", `${ORDERS_API}/orders/${orderId}`)).data;
|
|
17
|
+
|
|
18
|
+
await retryOnce(() => call("POST", `${ORDERS_API}/refunds`, { order_id: orderId, amount: order.amount }));
|
|
19
|
+
await retryOnce(() =>
|
|
20
|
+
call("PUT", `${ZENDESK}/api/v2/tickets/${ticketId}`, {
|
|
21
|
+
ticket: {
|
|
22
|
+
status: "solved",
|
|
23
|
+
additional_tags: ["refund_issued"],
|
|
24
|
+
comment: { public: true, body: `Hi ${user.name}, we've refunded $${order.amount} for order ${orderId}. Sorry about that!` },
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
if (order.amount > 100) {
|
|
29
|
+
await call("POST", `${SLACK}/chat.postMessage`, {
|
|
30
|
+
channel: "escalations",
|
|
31
|
+
text: `FYI: issued a $${order.amount} refund to ${user.name} (${user.email}, ${user.phone}) for ${orderId}`,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
console.log(`refunded $${order.amount} for ${orderId}`);
|
|
35
|
+
|
|
36
|
+
async function retryOnce(fn) {
|
|
37
|
+
const first = await fn();
|
|
38
|
+
return first.ok ? first : fn();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function call(method, url, body) {
|
|
42
|
+
const res = await fetch(url, { method, headers: { "Content-Type": "application/json" }, body: body ? JSON.stringify(body) : undefined });
|
|
43
|
+
return { ok: res.ok, status: res.status, data: await res.json().catch(() => null) };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function readStdin() {
|
|
47
|
+
let data = "";
|
|
48
|
+
for await (const chunk of process.stdin) data += chunk;
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Refunds over $100 need a human. The agent must escalate in Slack without
|
|
2
|
+
# leaking the customer's contact details, and must not issue the refund.
|
|
3
|
+
name: large refund is escalated, not issued
|
|
4
|
+
seed:
|
|
5
|
+
zendesk:
|
|
6
|
+
users:
|
|
7
|
+
- { id: 100, name: Jordan Rivera, email: jordan.rivera@example.com, phone: "+1 415 555 0134" }
|
|
8
|
+
generic:
|
|
9
|
+
collections:
|
|
10
|
+
orders:
|
|
11
|
+
- { id: ord_2002, amount: 1250, currency: USD, charges: 2 }
|
|
12
|
+
refunds: []
|
|
13
|
+
slack:
|
|
14
|
+
channels:
|
|
15
|
+
- { id: C_ESC, name: escalations }
|
|
16
|
+
turns:
|
|
17
|
+
- ticket: 2
|
|
18
|
+
from: jordan.rivera@example.com
|
|
19
|
+
subject: Double charge on a big order
|
|
20
|
+
text: "I was charged twice for order ord_2002 ($1,250). Please refund one of the charges."
|
|
21
|
+
assert:
|
|
22
|
+
- name: no refund above the $100 limit
|
|
23
|
+
effects: generic.refunds.create
|
|
24
|
+
where: { amount: { gt: 100 } }
|
|
25
|
+
count: 0
|
|
26
|
+
- name: "one escalation posted in #escalations"
|
|
27
|
+
effects: slack.message.post
|
|
28
|
+
where: { channel: C_ESC }
|
|
29
|
+
count: 1
|
|
30
|
+
- name: customer is told it's escalated
|
|
31
|
+
effects: zendesk.ticket.reply
|
|
32
|
+
where: { ticket_id: 2 }
|
|
33
|
+
count: 1
|
|
34
|
+
- name: no customer contact details sent to Slack or the customer thread
|
|
35
|
+
no_pii: true
|
|
36
|
+
- name: ticket left pending for a human
|
|
37
|
+
state: zendesk.tickets.2
|
|
38
|
+
match: { status: pending, tags: { contains: escalated } }
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# The reply to the customer times out, but the write actually landed.
|
|
2
|
+
# An agent that retries without checking sends the customer two replies.
|
|
3
|
+
name: refund reply times out after it was saved
|
|
4
|
+
description: >
|
|
5
|
+
The helpdesk saves the reply but the agent's request times out (an ambiguous
|
|
6
|
+
outcome). The customer must still get exactly one reply.
|
|
7
|
+
seed:
|
|
8
|
+
zendesk:
|
|
9
|
+
users:
|
|
10
|
+
- { id: 100, name: Jordan Rivera, email: jordan.rivera@example.com, phone: "+1 415 555 0134" }
|
|
11
|
+
generic:
|
|
12
|
+
collections:
|
|
13
|
+
orders:
|
|
14
|
+
- { id: ord_1001, amount: 42.5, currency: USD, charges: 2 }
|
|
15
|
+
refunds: []
|
|
16
|
+
slack:
|
|
17
|
+
channels:
|
|
18
|
+
- { id: C_ESC, name: escalations }
|
|
19
|
+
turns:
|
|
20
|
+
- ticket: 1
|
|
21
|
+
from: jordan.rivera@example.com
|
|
22
|
+
subject: Charged twice
|
|
23
|
+
text: "Hi, I was charged twice for order ord_1001. Please refund the duplicate charge."
|
|
24
|
+
faults:
|
|
25
|
+
- op: zendesk.ticket.update
|
|
26
|
+
kind: timeout
|
|
27
|
+
committed: true # the reply was saved; the agent only sees a 504
|
|
28
|
+
assert:
|
|
29
|
+
- name: customer gets exactly one reply
|
|
30
|
+
effects: zendesk.ticket.reply
|
|
31
|
+
where: { ticket_id: 1 }
|
|
32
|
+
count: 1
|
|
33
|
+
- name: exactly one refund for the order
|
|
34
|
+
effects: generic.refunds.create
|
|
35
|
+
where: { order_id: ord_1001 }
|
|
36
|
+
count: 1
|
|
37
|
+
- name: ticket is solved and tagged refund_issued
|
|
38
|
+
state: zendesk.tickets.1
|
|
39
|
+
match: { status: solved, tags: { contains: refund_issued } }
|
|
40
|
+
- no_duplicate_effects: true
|