@reventlessdev/reventless-gwt 1.0.0-alpha.286 → 1.0.0-alpha.288
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 +16 -0
- package/package.json +6 -6
- package/src/MismatchRender.res +2 -2
- package/src/MismatchRender.res.mjs +1 -1
- package/src/OutboundTranslation_GWT.res +23 -22
- package/src/OutboundTranslation_GWT.res.mjs +9 -16
- package/src/Outcome.res +30 -13
- package/src/Outcome.res.mjs +4 -1
- package/src/ScenarioRecorder.res +7 -7
- package/src/ScenarioRecorder.res.mjs +7 -6
- package/tests/ClosedSetWordsTest.res +42 -0
- package/tests/ClosedSetWordsTest.res.mjs +67 -0
- package/tests/OutboundFromSliceGwtTest.res +5 -5
- package/tests/OutboundFromSliceGwtTest.res.mjs +4 -1
- package/tests/OutboundTranslationGwtTest.res +4 -4
- package/tests/OutboundTranslationGwtTest.res.mjs +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 1.0.0-alpha.288 (2026-11-15)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @reventlessdev/reventless-gwt
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# 1.0.0-alpha.287 (2026-11-12)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @reventlessdev/reventless-gwt
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# 1.0.0-alpha.286 (2026-11-11)
|
|
7
23
|
|
|
8
24
|
### Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reventlessdev/reventless-gwt",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.288",
|
|
4
4
|
"description": "Given-When-Then DSLs and test harness for Reventless slice testing",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"jest": {
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"sury": "11.1.0",
|
|
17
|
-
"@reventlessdev/rescript-effect": "1.0.0-alpha.3",
|
|
18
17
|
"@reventlessdev/rescript-jest": "1.0.0-alpha.13",
|
|
18
|
+
"@reventlessdev/rescript-effect": "1.0.0-alpha.3",
|
|
19
19
|
"@reventlessdev/rescript-node": "2.0.0-alpha.26",
|
|
20
|
-
"@reventlessdev/reventless-
|
|
21
|
-
"@reventlessdev/reventless-
|
|
22
|
-
"@reventlessdev/reventless-spec": "3.0.0-alpha.
|
|
20
|
+
"@reventlessdev/reventless-core": "3.0.0-alpha.339",
|
|
21
|
+
"@reventlessdev/reventless-infra": "3.0.0-alpha.232",
|
|
22
|
+
"@reventlessdev/reventless-spec": "3.0.0-alpha.201"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"rescript": "12.3.1",
|
|
26
26
|
"sury-ppx": "11.1.0",
|
|
27
|
-
"@reventlessdev/reventless-ppx": "1.0.0-alpha.
|
|
27
|
+
"@reventlessdev/reventless-ppx": "1.0.0-alpha.113"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"rescript": "^12.3.1"
|
package/src/MismatchRender.res
CHANGED
|
@@ -23,7 +23,7 @@ type field =
|
|
|
23
23
|
| Stack(string)
|
|
24
24
|
|
|
25
25
|
type normalized = {
|
|
26
|
-
kind:
|
|
26
|
+
kind: Outcome.mismatchKind,
|
|
27
27
|
fields: array<field>,
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -82,5 +82,5 @@ let normalize = (m: Outcome.mismatch): normalized => {
|
|
|
82
82
|
]
|
|
83
83
|
| Throw({error, stack}) => [Error(error), Stack(stack)]
|
|
84
84
|
}
|
|
85
|
-
{kind: Outcome.
|
|
85
|
+
{kind: Outcome.kindOf(m), fields}
|
|
86
86
|
}
|
|
@@ -17,10 +17,15 @@ module type SliceSpec = {
|
|
|
17
17
|
let collect: (consumedEvent, ~sourceId: string) => array<(string, outboundItem)>
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
/** A to-do's status after an attempt, by the word a mismatch prints it with. A
|
|
21
|
+
successful translate (Ok) marks the item `Completed`; a failure (Error) leaves
|
|
22
|
+
it `Failed`, or `Abandoned` once `maxRetries` attempts have failed. `Pending`
|
|
23
|
+
is the older name for `Failed`, kept for one release. */
|
|
24
|
+
type todoStatus =
|
|
25
|
+
| Completed
|
|
26
|
+
| Failed
|
|
27
|
+
| Abandoned
|
|
28
|
+
| Pending
|
|
24
29
|
|
|
25
30
|
module type T = {
|
|
26
31
|
module Spec: SliceSpec
|
|
@@ -198,17 +203,13 @@ module Make = (Spec: SliceSpec): (T with module Spec = Spec) => {
|
|
|
198
203
|
}
|
|
199
204
|
}
|
|
200
205
|
|
|
201
|
-
let statusToString = (s: todoStatus) =>
|
|
202
|
-
switch s {
|
|
203
|
-
| #Completed => "#Completed"
|
|
204
|
-
| #Pending => "#Pending"
|
|
205
|
-
}
|
|
206
|
+
let statusToString = (s: todoStatus): string => (s :> string)
|
|
206
207
|
|
|
207
208
|
let thenTodoStatus = async (pending, expectedId, expectedStatus) => {
|
|
208
209
|
let {id, result, _} = await pending
|
|
209
210
|
let actualStatus: todoStatus = switch result {
|
|
210
|
-
| Ok(_) =>
|
|
211
|
-
| Error(_) =>
|
|
211
|
+
| Ok(_) => Completed
|
|
212
|
+
| Error(_) => Pending
|
|
212
213
|
}
|
|
213
214
|
if id == expectedId && actualStatus == expectedStatus {
|
|
214
215
|
Outcome.pass
|
|
@@ -230,9 +231,8 @@ module Make = (Spec: SliceSpec): (T with module Spec = Spec) => {
|
|
|
230
231
|
}
|
|
231
232
|
}
|
|
232
233
|
|
|
233
|
-
/** A to-do's status as the runtime leaves it after an attempt.
|
|
234
|
-
|
|
235
|
-
type status = [#Completed | #Failed | #Abandoned | #Pending]
|
|
234
|
+
/** A to-do's status as the runtime leaves it after an attempt. */
|
|
235
|
+
type status = todoStatus
|
|
236
236
|
|
|
237
237
|
// The slice as written: its `Spec` and its `_Translation` body, run against
|
|
238
238
|
// recording capability fakes.
|
|
@@ -324,8 +324,8 @@ module FromSlice = (
|
|
|
324
324
|
result: result.contents,
|
|
325
325
|
retries: failures.contents,
|
|
326
326
|
status: switch result.contents {
|
|
327
|
-
| Ok(_) =>
|
|
328
|
-
| Error(_) => failures.contents >= maxRetries ?
|
|
327
|
+
| Ok(_) => Completed
|
|
328
|
+
| Error(_) => failures.contents >= maxRetries ? Abandoned : Failed
|
|
329
329
|
},
|
|
330
330
|
sent: todo.fakes.calls(),
|
|
331
331
|
}
|
|
@@ -350,7 +350,7 @@ module FromSlice = (
|
|
|
350
350
|
item: todo.item,
|
|
351
351
|
result: Ok(Translation.onExhausted(todo.id, todo.item, ~lastError)),
|
|
352
352
|
retries: Spec.maxRetries,
|
|
353
|
-
status:
|
|
353
|
+
status: Abandoned,
|
|
354
354
|
sent: [],
|
|
355
355
|
}
|
|
356
356
|
|
|
@@ -407,16 +407,17 @@ module FromSlice = (
|
|
|
407
407
|
)
|
|
408
408
|
}
|
|
409
409
|
|
|
410
|
-
|
|
410
|
+
/** `Pending` is read, and printed, as `Failed`. */
|
|
411
|
+
let current = (s: status): status =>
|
|
411
412
|
switch s {
|
|
412
|
-
|
|
|
413
|
-
|
|
|
414
|
-
| #Abandoned => "#Abandoned"
|
|
413
|
+
| Pending => Failed
|
|
414
|
+
| _ => s
|
|
415
415
|
}
|
|
416
|
+
let statusName = (s: status): string => (current(s) :> string)
|
|
416
417
|
|
|
417
418
|
let thenTodoStatus = async (pending, expectedId, expectedStatus: status) => {
|
|
418
419
|
let {id, status, _} = await pending
|
|
419
|
-
if id == expectedId &&
|
|
420
|
+
if id == expectedId && current(status) == current(expectedStatus) {
|
|
420
421
|
Outcome.pass
|
|
421
422
|
} else {
|
|
422
423
|
let encOne = (rid, s) =>
|
|
@@ -141,13 +141,6 @@ function Make(Spec) {
|
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
|
-
let statusToString = s => {
|
|
145
|
-
if (s === "Pending") {
|
|
146
|
-
return "#Pending";
|
|
147
|
-
} else {
|
|
148
|
-
return "#Completed";
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
144
|
let thenTodoStatus = async (pending, expectedId, expectedStatus) => {
|
|
152
145
|
let match = await pending;
|
|
153
146
|
let id = match.id;
|
|
@@ -159,7 +152,7 @@ function Make(Spec) {
|
|
|
159
152
|
let encOne = (rid, rstatus) => {
|
|
160
153
|
let d = {};
|
|
161
154
|
d["id"] = rid;
|
|
162
|
-
d["status"] =
|
|
155
|
+
d["status"] = rstatus;
|
|
163
156
|
return d;
|
|
164
157
|
};
|
|
165
158
|
return Outcome$ReventlessGwt.fail({
|
|
@@ -376,20 +369,19 @@ function FromSlice(Spec) {
|
|
|
376
369
|
});
|
|
377
370
|
}
|
|
378
371
|
};
|
|
379
|
-
let
|
|
380
|
-
if (s === "
|
|
381
|
-
return "
|
|
382
|
-
} else if (s === "Abandoned") {
|
|
383
|
-
return "#Abandoned";
|
|
372
|
+
let current = s => {
|
|
373
|
+
if (s === "Pending") {
|
|
374
|
+
return "Failed";
|
|
384
375
|
} else {
|
|
385
|
-
return
|
|
376
|
+
return s;
|
|
386
377
|
}
|
|
387
378
|
};
|
|
379
|
+
let statusName = current;
|
|
388
380
|
let thenTodoStatus = async (pending, expectedId, expectedStatus) => {
|
|
389
381
|
let match = await pending;
|
|
390
382
|
let status = match.status;
|
|
391
383
|
let id = match.id;
|
|
392
|
-
if (id === expectedId &&
|
|
384
|
+
if (id === expectedId && current(status) === current(expectedStatus)) {
|
|
393
385
|
return Outcome$ReventlessGwt.pass;
|
|
394
386
|
}
|
|
395
387
|
let encOne = (rid, s) => Object.fromEntries([
|
|
@@ -399,7 +391,7 @@ function FromSlice(Spec) {
|
|
|
399
391
|
],
|
|
400
392
|
[
|
|
401
393
|
"status",
|
|
402
|
-
|
|
394
|
+
current(s)
|
|
403
395
|
]
|
|
404
396
|
]);
|
|
405
397
|
return Outcome$ReventlessGwt.fail({
|
|
@@ -433,6 +425,7 @@ function FromSlice(Spec) {
|
|
|
433
425
|
thenSent: thenSent,
|
|
434
426
|
thenNothingSent: thenNothingSent,
|
|
435
427
|
thenRetryRecorded: thenRetryRecorded,
|
|
428
|
+
current: current,
|
|
436
429
|
statusName: statusName,
|
|
437
430
|
thenTodoStatus: thenTodoStatus
|
|
438
431
|
};
|
package/src/Outcome.res
CHANGED
|
@@ -44,22 +44,39 @@ type outcome = result<unit, mismatch>
|
|
|
44
44
|
let pass: outcome = Ok()
|
|
45
45
|
let fail = (m): outcome => Error(m)
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
/** A mismatch's kind without its values. Its text is the mismatch's constructor name. */
|
|
48
|
+
type mismatchKind =
|
|
49
|
+
| @as("EventsMismatch") EventsMismatchKind
|
|
50
|
+
| @as("ErrorMismatch") ErrorMismatchKind
|
|
51
|
+
| @as("StateMismatch") StateMismatchKind
|
|
52
|
+
| @as("NoEventExpected") NoEventExpectedKind
|
|
53
|
+
| @as("TodoMismatch") TodoMismatchKind
|
|
54
|
+
| @as("AppendConditionMismatch") AppendConditionMismatchKind
|
|
55
|
+
| @as("TranslateError") TranslateErrorKind
|
|
56
|
+
| @as("QueryRowsMismatch") QueryRowsMismatchKind
|
|
57
|
+
| @as("PublishedActionsMismatch") PublishedActionsMismatchKind
|
|
58
|
+
| @as("ScopeDegraded") ScopeDegradedKind
|
|
59
|
+
| @as("PartitionUnresolved") PartitionUnresolvedKind
|
|
60
|
+
| @as("Throw") ThrowKind
|
|
61
|
+
|
|
62
|
+
let kindOf = (m: mismatch): mismatchKind =>
|
|
48
63
|
switch m {
|
|
49
|
-
| EventsMismatch(_) =>
|
|
50
|
-
| ErrorMismatch(_) =>
|
|
51
|
-
| StateMismatch(_) =>
|
|
52
|
-
| NoEventExpected(_) =>
|
|
53
|
-
| TodoMismatch(_) =>
|
|
54
|
-
| AppendConditionMismatch(_) =>
|
|
55
|
-
| TranslateError(_) =>
|
|
56
|
-
| QueryRowsMismatch(_) =>
|
|
57
|
-
| PublishedActionsMismatch(_) =>
|
|
58
|
-
| ScopeDegraded(_) =>
|
|
59
|
-
| PartitionUnresolved(_) =>
|
|
60
|
-
| Throw(_) =>
|
|
64
|
+
| EventsMismatch(_) => EventsMismatchKind
|
|
65
|
+
| ErrorMismatch(_) => ErrorMismatchKind
|
|
66
|
+
| StateMismatch(_) => StateMismatchKind
|
|
67
|
+
| NoEventExpected(_) => NoEventExpectedKind
|
|
68
|
+
| TodoMismatch(_) => TodoMismatchKind
|
|
69
|
+
| AppendConditionMismatch(_) => AppendConditionMismatchKind
|
|
70
|
+
| TranslateError(_) => TranslateErrorKind
|
|
71
|
+
| QueryRowsMismatch(_) => QueryRowsMismatchKind
|
|
72
|
+
| PublishedActionsMismatch(_) => PublishedActionsMismatchKind
|
|
73
|
+
| ScopeDegraded(_) => ScopeDegradedKind
|
|
74
|
+
| PartitionUnresolved(_) => PartitionUnresolvedKind
|
|
75
|
+
| Throw(_) => ThrowKind
|
|
61
76
|
}
|
|
62
77
|
|
|
78
|
+
let kindName = (m: mismatch): string => (kindOf(m) :> string)
|
|
79
|
+
|
|
63
80
|
let stringifyJson = (j: JSON.t) => JSON.stringify(j, ~space=2)
|
|
64
81
|
let stringifyOptJson = (j: option<JSON.t>) =>
|
|
65
82
|
switch j {
|
package/src/Outcome.res.mjs
CHANGED
|
@@ -9,7 +9,7 @@ function fail(m) {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
function
|
|
12
|
+
function kindOf(m) {
|
|
13
13
|
switch (m.TAG) {
|
|
14
14
|
case "EventsMismatch" :
|
|
15
15
|
return "EventsMismatch";
|
|
@@ -38,6 +38,8 @@ function kindName(m) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
let kindName = kindOf;
|
|
42
|
+
|
|
41
43
|
function stringifyJson(j) {
|
|
42
44
|
return JSON.stringify(j, undefined, 2);
|
|
43
45
|
}
|
|
@@ -92,6 +94,7 @@ let pass = {
|
|
|
92
94
|
export {
|
|
93
95
|
pass,
|
|
94
96
|
fail,
|
|
97
|
+
kindOf,
|
|
95
98
|
kindName,
|
|
96
99
|
stringifyJson,
|
|
97
100
|
stringifyOptJson,
|
package/src/ScenarioRecorder.res
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// time; otherwise every call is a no-op. A test file whose sidecar the PPX wrote is left alone:
|
|
12
12
|
// read from source, it carries values and ids a run cannot.
|
|
13
13
|
|
|
14
|
-
type entry = {kind:
|
|
14
|
+
type entry = {kind: Reventless.SidecarStepKind.t, element: string}
|
|
15
15
|
|
|
16
16
|
type scenario = {
|
|
17
17
|
title: string,
|
|
@@ -90,7 +90,7 @@ let writtenByPpx = (path: string) =>
|
|
|
90
90
|
|
|
91
91
|
let entryJson = (e: entry) => JSON.Object(
|
|
92
92
|
Dict.fromArray([
|
|
93
|
-
("kind", JSON.String(e.kind)),
|
|
93
|
+
("kind", JSON.String(Reventless.SidecarStepKind.toString(e.kind))),
|
|
94
94
|
("element", JSON.String(e.element)),
|
|
95
95
|
("values", JSON.Array([])),
|
|
96
96
|
]),
|
|
@@ -175,17 +175,17 @@ let push = (pick: scenario => array<entry>, entries: array<entry>) =>
|
|
|
175
175
|
|
|
176
176
|
/** The history a command is decided on, by event name. */
|
|
177
177
|
let given = (names: array<string>) =>
|
|
178
|
-
push(s => s.given, names->Array.map(element => {kind:
|
|
178
|
+
push(s => s.given, names->Array.map(element => {kind: Event, element}))
|
|
179
179
|
|
|
180
180
|
/** The command a test sends. */
|
|
181
|
-
let whenCommand = (name: string) => push(s => s.when_, [{kind:
|
|
181
|
+
let whenCommand = (name: string) => push(s => s.when_, [{kind: Command, element: name}])
|
|
182
182
|
|
|
183
183
|
/** What a test expects: these events. */
|
|
184
184
|
let thenEvents = (names: array<string>) =>
|
|
185
|
-
push(s => s.then_, names->Array.map(element => {kind:
|
|
185
|
+
push(s => s.then_, names->Array.map(element => {kind: Event, element}))
|
|
186
186
|
|
|
187
187
|
/** What a test expects: this error. */
|
|
188
|
-
let thenError = (name: string) => push(s => s.then_, [{kind:
|
|
188
|
+
let thenError = (name: string) => push(s => s.then_, [{kind: Error, element: name}])
|
|
189
189
|
|
|
190
190
|
/** What a test expects: no event. */
|
|
191
|
-
let thenNoEvent = () => push(s => s.then_, [{kind:
|
|
191
|
+
let thenNoEvent = () => push(s => s.then_, [{kind: NoEvent, element: ""}])
|
|
@@ -4,6 +4,7 @@ import * as Nodefs from "node:fs";
|
|
|
4
4
|
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
5
5
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
6
6
|
import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
|
|
7
|
+
import * as SidecarStepKind$Reventless from "@reventlessdev/reventless-spec/src/lifecycle/SidecarStepKind.res.mjs";
|
|
7
8
|
|
|
8
9
|
function enabled() {
|
|
9
10
|
let match = process.env["REVENTLESS_EMIT_SIDECAR"];
|
|
@@ -104,7 +105,7 @@ function entryJson(e) {
|
|
|
104
105
|
return Object.fromEntries([
|
|
105
106
|
[
|
|
106
107
|
"kind",
|
|
107
|
-
e.kind
|
|
108
|
+
SidecarStepKind$Reventless.toString(e.kind)
|
|
108
109
|
],
|
|
109
110
|
[
|
|
110
111
|
"element",
|
|
@@ -243,35 +244,35 @@ function push(pick, entries) {
|
|
|
243
244
|
|
|
244
245
|
function given(names) {
|
|
245
246
|
push(s => s.given, names.map(element => ({
|
|
246
|
-
kind: "
|
|
247
|
+
kind: "Event",
|
|
247
248
|
element: element
|
|
248
249
|
})));
|
|
249
250
|
}
|
|
250
251
|
|
|
251
252
|
function whenCommand(name) {
|
|
252
253
|
push(s => s.when_, [{
|
|
253
|
-
kind: "
|
|
254
|
+
kind: "Command",
|
|
254
255
|
element: name
|
|
255
256
|
}]);
|
|
256
257
|
}
|
|
257
258
|
|
|
258
259
|
function thenEvents(names) {
|
|
259
260
|
push(s => s.then_, names.map(element => ({
|
|
260
|
-
kind: "
|
|
261
|
+
kind: "Event",
|
|
261
262
|
element: element
|
|
262
263
|
})));
|
|
263
264
|
}
|
|
264
265
|
|
|
265
266
|
function thenError(name) {
|
|
266
267
|
push(s => s.then_, [{
|
|
267
|
-
kind: "
|
|
268
|
+
kind: "Error",
|
|
268
269
|
element: name
|
|
269
270
|
}]);
|
|
270
271
|
}
|
|
271
272
|
|
|
272
273
|
function thenNoEvent() {
|
|
273
274
|
push(s => s.then_, [{
|
|
274
|
-
kind: "
|
|
275
|
+
kind: "NoEvent",
|
|
275
276
|
element: ""
|
|
276
277
|
}]);
|
|
277
278
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
open JestGlobals
|
|
2
|
+
|
|
3
|
+
// The words a mismatch and a to-do status print with, held as variants: each
|
|
4
|
+
// prints as the word a report already carries.
|
|
5
|
+
|
|
6
|
+
describe("Outcome.mismatchKind", () => {
|
|
7
|
+
testSync("a mismatch's kind prints as its constructor's name", () =>
|
|
8
|
+
expect(
|
|
9
|
+
[
|
|
10
|
+
Outcome.EventsMismatch({expected: [], actual: []}),
|
|
11
|
+
NoEventExpected({actual: []}),
|
|
12
|
+
TranslateError({expected: "", actual: None}),
|
|
13
|
+
PartitionUnresolved({boundary: "", reasons: []}),
|
|
14
|
+
Throw({error: "", stack: ""}),
|
|
15
|
+
]->Array.map(Outcome.kindName),
|
|
16
|
+
)->toEqual([
|
|
17
|
+
"EventsMismatch",
|
|
18
|
+
"NoEventExpected",
|
|
19
|
+
"TranslateError",
|
|
20
|
+
"PartitionUnresolved",
|
|
21
|
+
"Throw",
|
|
22
|
+
])
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
testSync("the rendered mismatch carries the same kind", () =>
|
|
26
|
+
expect(
|
|
27
|
+
(MismatchRender.normalize(
|
|
28
|
+
Outcome.StateMismatch({key: "k", expected: None, actual: None}),
|
|
29
|
+
).kind :> string),
|
|
30
|
+
)->toBe("StateMismatch")
|
|
31
|
+
)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
describe("OutboundTranslation_GWT.todoStatus", () => {
|
|
35
|
+
testSync("prints each status as a mismatch shows it", () =>
|
|
36
|
+
expect(
|
|
37
|
+
[OutboundTranslation_GWT.Completed, Failed, Abandoned, Pending]->Array.map(
|
|
38
|
+
s => (s :> string),
|
|
39
|
+
),
|
|
40
|
+
)->toEqual(["Completed", "Failed", "Abandoned", "Pending"])
|
|
41
|
+
)
|
|
42
|
+
})
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Outcome$ReventlessGwt from "../src/Outcome.res.mjs";
|
|
4
|
+
import * as MismatchRender$ReventlessGwt from "../src/MismatchRender.res.mjs";
|
|
5
|
+
|
|
6
|
+
globalThis.describe("Outcome.mismatchKind", () => {
|
|
7
|
+
globalThis.test("a mismatch's kind prints as its constructor's name", () => {
|
|
8
|
+
globalThis.expect([
|
|
9
|
+
{
|
|
10
|
+
TAG: "EventsMismatch",
|
|
11
|
+
expected: [],
|
|
12
|
+
actual: []
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
TAG: "NoEventExpected",
|
|
16
|
+
actual: []
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
TAG: "TranslateError",
|
|
20
|
+
expected: "",
|
|
21
|
+
actual: undefined
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
TAG: "PartitionUnresolved",
|
|
25
|
+
boundary: "",
|
|
26
|
+
reasons: []
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
TAG: "Throw",
|
|
30
|
+
error: "",
|
|
31
|
+
stack: ""
|
|
32
|
+
}
|
|
33
|
+
].map(Outcome$ReventlessGwt.kindName)).toEqual([
|
|
34
|
+
"EventsMismatch",
|
|
35
|
+
"NoEventExpected",
|
|
36
|
+
"TranslateError",
|
|
37
|
+
"PartitionUnresolved",
|
|
38
|
+
"Throw"
|
|
39
|
+
]);
|
|
40
|
+
});
|
|
41
|
+
globalThis.test("the rendered mismatch carries the same kind", () => {
|
|
42
|
+
globalThis.expect(MismatchRender$ReventlessGwt.normalize({
|
|
43
|
+
TAG: "StateMismatch",
|
|
44
|
+
key: "k",
|
|
45
|
+
expected: undefined,
|
|
46
|
+
actual: undefined
|
|
47
|
+
}).kind).toBe("StateMismatch");
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
globalThis.describe("OutboundTranslation_GWT.todoStatus", () => {
|
|
52
|
+
globalThis.test("prints each status as a mismatch shows it", () => {
|
|
53
|
+
globalThis.expect([
|
|
54
|
+
"Completed",
|
|
55
|
+
"Failed",
|
|
56
|
+
"Abandoned",
|
|
57
|
+
"Pending"
|
|
58
|
+
].map(s => s)).toEqual([
|
|
59
|
+
"Completed",
|
|
60
|
+
"Failed",
|
|
61
|
+
"Abandoned",
|
|
62
|
+
"Pending"
|
|
63
|
+
]);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
/* Not a pure module */
|
|
@@ -83,20 +83,20 @@ describe("OutboundTranslation_GWT.FromSlice", () => {
|
|
|
83
83
|
givenTodo("c1", {email: "a@b.c"})
|
|
84
84
|
->givenCapabilities(down)
|
|
85
85
|
->whenTranslated
|
|
86
|
-
->thenTodoStatus("c1",
|
|
86
|
+
->thenTodoStatus("c1", Failed)
|
|
87
87
|
)
|
|
88
88
|
|
|
89
|
-
test("
|
|
89
|
+
test("Pending still reads as Failed", () =>
|
|
90
90
|
givenTodo("c1", {email: "a@b.c"})
|
|
91
91
|
->givenCapabilities(down)
|
|
92
92
|
->whenTranslated
|
|
93
|
-
->thenTodoStatus("c1",
|
|
93
|
+
->thenTodoStatus("c1", Pending)
|
|
94
94
|
)
|
|
95
95
|
|
|
96
96
|
test("maxRetries failed attempts abandon the row", () =>
|
|
97
97
|
givenTodo("c1", {email: "a@b.c"})
|
|
98
98
|
->whenTranslateRetrying(async (_, _) => Error("down"))
|
|
99
|
-
->thenTodoStatus("c1",
|
|
99
|
+
->thenTodoStatus("c1", Abandoned)
|
|
100
100
|
)
|
|
101
101
|
|
|
102
102
|
test("maxRetries attempts in all, as the runtime makes them", () =>
|
|
@@ -108,7 +108,7 @@ describe("OutboundTranslation_GWT.FromSlice", () => {
|
|
|
108
108
|
test("a throw is a failed attempt", () =>
|
|
109
109
|
givenTodo("c1", {email: "a@b.c"})
|
|
110
110
|
->whenTranslateMocked(async (_, _) => JsError.throwWithMessage("boom"))
|
|
111
|
-
->thenTodoStatus("c1",
|
|
111
|
+
->thenTodoStatus("c1", Failed)
|
|
112
112
|
)
|
|
113
113
|
|
|
114
114
|
test("exhausted: onExhausted is what the domain hears", () =>
|
|
@@ -188,7 +188,7 @@ describe("OutboundTranslation_GWT.FromSlice", () => {
|
|
|
188
188
|
test("a failed attempt leaves the row Failed", undefined, () => thenTodoStatus(whenTranslated(givenCapabilities(givenTodo("c1", {
|
|
189
189
|
email: "a@b.c"
|
|
190
190
|
}), down)), "c1", "Failed"));
|
|
191
|
-
test("
|
|
191
|
+
test("Pending still reads as Failed", undefined, () => thenTodoStatus(whenTranslated(givenCapabilities(givenTodo("c1", {
|
|
192
192
|
email: "a@b.c"
|
|
193
193
|
}), down)), "c1", "Pending"));
|
|
194
194
|
test("maxRetries failed attempts abandon the row", undefined, () => thenTodoStatus(whenTranslateRetrying(givenTodo("c1", {
|
|
@@ -231,6 +231,8 @@ let attempts = include.attempts;
|
|
|
231
231
|
|
|
232
232
|
let thenNoCommand = include.thenNoCommand;
|
|
233
233
|
|
|
234
|
+
let current = include.current;
|
|
235
|
+
|
|
234
236
|
let statusName = include.statusName;
|
|
235
237
|
|
|
236
238
|
export {
|
|
@@ -259,6 +261,7 @@ export {
|
|
|
259
261
|
thenSent,
|
|
260
262
|
thenNothingSent,
|
|
261
263
|
thenRetryRecorded,
|
|
264
|
+
current,
|
|
262
265
|
statusName,
|
|
263
266
|
thenTodoStatus,
|
|
264
267
|
down,
|
|
@@ -29,16 +29,16 @@ describe("SendTrackingEmail OutboundTranslationSlice", () => {
|
|
|
29
29
|
->thenTodos([("o1", {orderId: "o1", email: "x@y"})])
|
|
30
30
|
)
|
|
31
31
|
|
|
32
|
-
test("translate success is fire-and-forget →
|
|
32
|
+
test("translate success is fire-and-forget → Completed", () =>
|
|
33
33
|
givenTodo("o1", {orderId: "o1", email: "x@y"})
|
|
34
34
|
->whenTranslateMocked((_id, _item) => Promise.resolve(Ok(None)))
|
|
35
|
-
->thenTodoStatus("o1",
|
|
35
|
+
->thenTodoStatus("o1", Completed)
|
|
36
36
|
)
|
|
37
37
|
|
|
38
|
-
test("translate failure records a retry →
|
|
38
|
+
test("translate failure records a retry → Pending", () =>
|
|
39
39
|
givenTodo("o1", {orderId: "o1", email: "x@y"})
|
|
40
40
|
->whenTranslateMocked((_id, _item) => Promise.resolve(Error("smtp down")))
|
|
41
|
-
->thenTodoStatus("o1",
|
|
41
|
+
->thenTodoStatus("o1", Pending)
|
|
42
42
|
)
|
|
43
43
|
|
|
44
44
|
test("retrying translate succeeds on the third attempt → 2 retries recorded", () => {
|
|
@@ -70,14 +70,14 @@ describe("SendTrackingEmail OutboundTranslationSlice", () => {
|
|
|
70
70
|
email: "x@y"
|
|
71
71
|
}
|
|
72
72
|
]]));
|
|
73
|
-
test("translate success is fire-and-forget →
|
|
73
|
+
test("translate success is fire-and-forget → Completed", undefined, () => thenTodoStatus(whenTranslateMocked(givenTodo("o1", {
|
|
74
74
|
orderId: "o1",
|
|
75
75
|
email: "x@y"
|
|
76
76
|
}), (_id, _item) => Promise.resolve({
|
|
77
77
|
TAG: "Ok",
|
|
78
78
|
_0: undefined
|
|
79
79
|
})), "o1", "Completed"));
|
|
80
|
-
test("translate failure records a retry →
|
|
80
|
+
test("translate failure records a retry → Pending", undefined, () => thenTodoStatus(whenTranslateMocked(givenTodo("o1", {
|
|
81
81
|
orderId: "o1",
|
|
82
82
|
email: "x@y"
|
|
83
83
|
}), (_id, _item) => Promise.resolve({
|