@reventlessdev/online-shop-aggregates-ordering 3.0.0-alpha.249 → 3.0.0-alpha.251
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/lib/bs/.compiler.log +2 -2
- package/lib/bs/OrderingPlugin.cmi +0 -0
- package/lib/bs/OrderingPlugin.cmt +0 -0
- package/lib/bs/OrderingPlugin.mlmap +1 -0
- package/lib/bs/compiler-info.json +1 -1
- package/lib/bs/src/CatalogProduct/Aggregate/CatalogProduct_Behavior-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/CatalogProduct/Aggregate/CatalogProduct_Behavior-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Customer/Aggregate/Customer_Behavior-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Customer/Aggregate/Customer_Behavior-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Customer/ReadModel/Customers_Projections-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Customer/ReadModel/Customers_Projections-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Extension/Products_Extension-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Extension/Products_Extension-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/ExtensionPoint/Orders_ExtensionPointMapping-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/ExtensionPoint/Orders_ExtensionPointMapping-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Order/Aggregate/Order-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Order/Aggregate/Order-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Order/Aggregate/Order_Behavior-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Order/Aggregate/Order_Behavior-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Order/Aggregate/Order_Mappings-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Order/Aggregate/Order_Mappings-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Order/ReadModel/Orders_Projections-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Order/ReadModel/Orders_Projections-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Order/SideEffect/Order_EmailNotification-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Order/SideEffect/Order_EmailNotification-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Plugin-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Plugin-OrderingPlugin.cmt +0 -0
- package/lib/bs/src/Task/OrderNotifications-OrderingPlugin.cmi +0 -0
- package/lib/bs/src/Task/OrderNotifications-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/CatalogProduct/Aggregate/CatalogProduct_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/CatalogProduct/Aggregate/CatalogProduct_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/CatalogProduct/Aggregate/CatalogProduct_GWT.ast +0 -0
- package/lib/bs/tests/CatalogProduct/Aggregate/CatalogProduct_GWT.res +11 -5
- package/lib/bs/tests/CatalogProduct/Aggregate/CatalogProduct_GWT.res.mjs +6 -5
- package/lib/bs/tests/CatalogProduct/ReadModel/AvailableProducts_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/CatalogProduct/ReadModel/AvailableProducts_GWT.ast +0 -0
- package/lib/bs/tests/CatalogProduct/ReadModel/AvailableProducts_GWT.res +2 -0
- package/lib/bs/tests/Customer/Aggregate/Customer_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Customer/Aggregate/Customer_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Customer/Aggregate/Customer_GWT.ast +0 -0
- package/lib/bs/tests/Customer/Aggregate/Customer_GWT.res +32 -17
- package/lib/bs/tests/Customer/Aggregate/Customer_GWT.res.mjs +31 -30
- package/lib/bs/tests/Customer/ReadModel/Customers_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Customer/ReadModel/Customers_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Customer/ReadModel/Customers_GWT.ast +0 -0
- package/lib/bs/tests/Customer/ReadModel/Customers_GWT.res +4 -0
- package/lib/bs/tests/Extension/Products_Extension_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Extension/Products_Extension_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Extension/Products_Extension_GWT.ast +0 -0
- package/lib/bs/tests/Extension/Products_Extension_GWT.res +3 -2
- package/lib/bs/tests/Extension/Products_Extension_GWT.res.mjs +3 -5
- package/lib/bs/tests/ExtensionPoint/Orders_ExtensionPointMapping_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/ExtensionPoint/Orders_ExtensionPointMapping_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/ExtensionPoint/Orders_ExtensionPointMapping_GWT.ast +0 -0
- package/lib/bs/tests/ExtensionPoint/Orders_ExtensionPointMapping_GWT.res +5 -3
- package/lib/bs/tests/ExtensionPoint/Orders_ExtensionPointMapping_GWT.res.mjs +6 -16
- package/lib/bs/tests/Order/Aggregate/OrderMappings_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Order/Aggregate/OrderMappings_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Order/Aggregate/OrderMappings_GWT.ast +0 -0
- package/lib/bs/tests/Order/Aggregate/OrderMappings_GWT.res +4 -0
- package/lib/bs/tests/Order/Aggregate/Order_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Order/Aggregate/Order_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Order/Aggregate/Order_GWT.ast +0 -0
- package/lib/bs/tests/Order/Aggregate/Order_GWT.res +24 -5
- package/lib/bs/tests/Order/Aggregate/Order_GWT.res.mjs +6 -5
- package/lib/bs/tests/Order/ReadModel/Orders_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Order/ReadModel/Orders_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Order/ReadModel/Orders_GWT.ast +0 -0
- package/lib/bs/tests/Order/ReadModel/Orders_GWT.res +4 -0
- package/lib/bs/tests/Order/SideEffect/Order_EmailNotification_GWT-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Order/SideEffect/Order_EmailNotification_GWT-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Ordering_Examples-OrderingPlugin.cmi +0 -0
- package/lib/bs/tests/Ordering_Examples-OrderingPlugin.cmj +0 -0
- package/lib/bs/tests/Ordering_Examples-OrderingPlugin.cmt +0 -0
- package/lib/bs/tests/Ordering_Examples.ast +0 -0
- package/lib/bs/tests/Ordering_Examples.res +13 -0
- package/lib/bs/tests/Ordering_Examples.res.mjs +35 -0
- package/lib/ocaml/.compiler.log +2 -2
- package/lib/ocaml/AvailableProducts_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/AvailableProducts_GWT.ast +0 -0
- package/lib/ocaml/AvailableProducts_GWT.res +2 -0
- package/lib/ocaml/CatalogProduct_Behavior-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/CatalogProduct_Behavior-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/CatalogProduct_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/CatalogProduct_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/CatalogProduct_GWT.ast +0 -0
- package/lib/ocaml/CatalogProduct_GWT.res +11 -5
- package/lib/ocaml/Customer_Behavior-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Customer_Behavior-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Customer_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Customer_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Customer_GWT.ast +0 -0
- package/lib/ocaml/Customer_GWT.res +32 -17
- package/lib/ocaml/Customers_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Customers_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Customers_GWT.ast +0 -0
- package/lib/ocaml/Customers_GWT.res +4 -0
- package/lib/ocaml/Customers_Projections-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Customers_Projections-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Order-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Order-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/OrderMappings_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/OrderMappings_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/OrderMappings_GWT.ast +0 -0
- package/lib/ocaml/OrderMappings_GWT.res +4 -0
- package/lib/ocaml/OrderNotifications-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/OrderNotifications-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Order_Behavior-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Order_Behavior-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Order_EmailNotification-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Order_EmailNotification-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Order_EmailNotification_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Order_EmailNotification_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Order_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Order_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Order_GWT.ast +0 -0
- package/lib/ocaml/Order_GWT.res +24 -5
- package/lib/ocaml/Order_Mappings-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Order_Mappings-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/OrderingPlugin.cmi +0 -0
- package/lib/ocaml/OrderingPlugin.cmt +0 -0
- package/lib/ocaml/OrderingPlugin.mlmap +1 -0
- package/lib/ocaml/Ordering_Examples-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Ordering_Examples-OrderingPlugin.cmj +0 -0
- package/lib/ocaml/Ordering_Examples-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Ordering_Examples.ast +0 -0
- package/lib/ocaml/Ordering_Examples.res +13 -0
- package/lib/ocaml/Orders_ExtensionPointMapping-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Orders_ExtensionPointMapping-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Orders_ExtensionPointMapping_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Orders_ExtensionPointMapping_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Orders_ExtensionPointMapping_GWT.ast +0 -0
- package/lib/ocaml/Orders_ExtensionPointMapping_GWT.res +5 -3
- package/lib/ocaml/Orders_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Orders_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Orders_GWT.ast +0 -0
- package/lib/ocaml/Orders_GWT.res +4 -0
- package/lib/ocaml/Orders_Projections-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Orders_Projections-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Plugin-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Plugin-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Products_Extension-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Products_Extension-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Products_Extension_GWT-OrderingPlugin.cmi +0 -0
- package/lib/ocaml/Products_Extension_GWT-OrderingPlugin.cmt +0 -0
- package/lib/ocaml/Products_Extension_GWT.ast +0 -0
- package/lib/ocaml/Products_Extension_GWT.res +3 -2
- package/package.json +8 -8
- package/tests/CatalogProduct/Aggregate/CatalogProduct_GWT.res +11 -5
- package/tests/CatalogProduct/Aggregate/CatalogProduct_GWT.res.mjs +6 -5
- package/tests/CatalogProduct/ReadModel/AvailableProducts_GWT.res +2 -0
- package/tests/Customer/Aggregate/Customer_GWT.res +32 -17
- package/tests/Customer/Aggregate/Customer_GWT.res.mjs +31 -30
- package/tests/Customer/ReadModel/Customers_GWT.res +4 -0
- package/tests/Extension/Products_Extension_GWT.res +3 -2
- package/tests/Extension/Products_Extension_GWT.res.mjs +3 -5
- package/tests/ExtensionPoint/Orders_ExtensionPointMapping_GWT.res +5 -3
- package/tests/ExtensionPoint/Orders_ExtensionPointMapping_GWT.res.mjs +6 -16
- package/tests/Order/Aggregate/OrderMappings_GWT.res +4 -0
- package/tests/Order/Aggregate/Order_GWT.res +24 -5
- package/tests/Order/Aggregate/Order_GWT.res.mjs +6 -5
- package/tests/Order/ReadModel/Orders_GWT.res +4 -0
- package/tests/Ordering_Examples.res +13 -0
- package/tests/Ordering_Examples.res.mjs +35 -0
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import * as Customer$OrderingPlugin from "../../../src/Customer/Aggregate/Customer.res.mjs";
|
|
4
4
|
import * as Behavior_GWT$ReventlessGwt from "@reventlessdev/reventless-gwt/src/Behavior_GWT.res.mjs";
|
|
5
5
|
import * as Customer_Behavior$OrderingPlugin from "../../../src/Customer/Aggregate/Customer_Behavior.res.mjs";
|
|
6
|
+
import * as Ordering_Examples$OrderingPlugin from "../../Ordering_Examples.res.mjs";
|
|
6
7
|
|
|
7
8
|
let include = Behavior_GWT$ReventlessGwt.MakeFromAggregate({
|
|
8
9
|
name: Customer$OrderingPlugin.name,
|
|
@@ -40,42 +41,42 @@ let thenError = include.thenError;
|
|
|
40
41
|
describe("Customer Behavior", () => {
|
|
41
42
|
test("Register on new aggregate produces Registered", () => thenEvent(whenCmd(givenEvents([]), {
|
|
42
43
|
TAG: "Register",
|
|
43
|
-
email:
|
|
44
|
-
address:
|
|
44
|
+
email: Ordering_Examples$OrderingPlugin.aliceEmail,
|
|
45
|
+
address: Ordering_Examples$OrderingPlugin.mainStreet
|
|
45
46
|
}), {
|
|
46
47
|
TAG: "Registered",
|
|
47
|
-
email:
|
|
48
|
-
address:
|
|
48
|
+
email: Ordering_Examples$OrderingPlugin.aliceEmail,
|
|
49
|
+
address: Ordering_Examples$OrderingPlugin.mainStreet
|
|
49
50
|
}));
|
|
50
51
|
test("Register on existing aggregate returns CustomerAlreadyRegistered", () => thenError(whenCmd(givenEvents([{
|
|
51
52
|
TAG: "Registered",
|
|
52
|
-
email:
|
|
53
|
-
address:
|
|
53
|
+
email: Ordering_Examples$OrderingPlugin.aliceEmail,
|
|
54
|
+
address: Ordering_Examples$OrderingPlugin.mainStreet
|
|
54
55
|
}]), {
|
|
55
56
|
TAG: "Register",
|
|
56
|
-
email:
|
|
57
|
-
address:
|
|
57
|
+
email: Ordering_Examples$OrderingPlugin.bobEmail,
|
|
58
|
+
address: Ordering_Examples$OrderingPlugin.oakAvenue
|
|
58
59
|
}), "CustomerAlreadyRegistered"));
|
|
59
60
|
test("Register on deactivated aggregate returns CustomerAlreadyDeactivated", () => thenError(whenCmd(givenEvents([
|
|
60
61
|
{
|
|
61
62
|
TAG: "Registered",
|
|
62
|
-
email:
|
|
63
|
-
address:
|
|
63
|
+
email: Ordering_Examples$OrderingPlugin.aliceEmail,
|
|
64
|
+
address: Ordering_Examples$OrderingPlugin.mainStreet
|
|
64
65
|
},
|
|
65
66
|
"Deactivated"
|
|
66
67
|
]), {
|
|
67
68
|
TAG: "Register",
|
|
68
|
-
email:
|
|
69
|
-
address:
|
|
69
|
+
email: Ordering_Examples$OrderingPlugin.bobEmail,
|
|
70
|
+
address: Ordering_Examples$OrderingPlugin.oakAvenue
|
|
70
71
|
}), "CustomerAlreadyDeactivated"));
|
|
71
72
|
test("UpdateEmail on non-existent aggregate returns CustomerNotFound", () => thenError(whenCmd(givenEvents([]), {
|
|
72
73
|
TAG: "UpdateEmail",
|
|
73
|
-
email:
|
|
74
|
+
email: Ordering_Examples$OrderingPlugin.bobEmail
|
|
74
75
|
}), "CustomerNotFound"));
|
|
75
76
|
test("UpdateEmail on active customer produces EmailUpdated", () => thenEvent(whenCmd(givenEvents([{
|
|
76
77
|
TAG: "Registered",
|
|
77
|
-
email:
|
|
78
|
-
address:
|
|
78
|
+
email: Ordering_Examples$OrderingPlugin.aliceEmail,
|
|
79
|
+
address: Ordering_Examples$OrderingPlugin.mainStreet
|
|
79
80
|
}]), {
|
|
80
81
|
TAG: "UpdateEmail",
|
|
81
82
|
email: "alice2@example.com"
|
|
@@ -85,22 +86,22 @@ describe("Customer Behavior", () => {
|
|
|
85
86
|
}));
|
|
86
87
|
test("UpdateEmail to same email produces no events (idempotent)", () => thenNoEvent(whenCmd(givenEvents([{
|
|
87
88
|
TAG: "Registered",
|
|
88
|
-
email:
|
|
89
|
-
address:
|
|
89
|
+
email: Ordering_Examples$OrderingPlugin.aliceEmail,
|
|
90
|
+
address: Ordering_Examples$OrderingPlugin.mainStreet
|
|
90
91
|
}]), {
|
|
91
92
|
TAG: "UpdateEmail",
|
|
92
|
-
email:
|
|
93
|
+
email: Ordering_Examples$OrderingPlugin.aliceEmail
|
|
93
94
|
})));
|
|
94
95
|
test("UpdateEmail on deactivated customer returns CustomerAlreadyDeactivated", () => thenError(whenCmd(givenEvents([
|
|
95
96
|
{
|
|
96
97
|
TAG: "Registered",
|
|
97
|
-
email:
|
|
98
|
-
address:
|
|
98
|
+
email: Ordering_Examples$OrderingPlugin.aliceEmail,
|
|
99
|
+
address: Ordering_Examples$OrderingPlugin.mainStreet
|
|
99
100
|
},
|
|
100
101
|
"Deactivated"
|
|
101
102
|
]), {
|
|
102
103
|
TAG: "UpdateEmail",
|
|
103
|
-
email:
|
|
104
|
+
email: Ordering_Examples$OrderingPlugin.bobEmail
|
|
104
105
|
}), "CustomerAlreadyDeactivated"));
|
|
105
106
|
test("UpdateAddress on non-existent aggregate returns CustomerNotFound", () => thenError(whenCmd(givenEvents([]), {
|
|
106
107
|
TAG: "UpdateAddress",
|
|
@@ -108,8 +109,8 @@ describe("Customer Behavior", () => {
|
|
|
108
109
|
}), "CustomerNotFound"));
|
|
109
110
|
test("UpdateAddress on active customer produces AddressUpdated", () => thenEvent(whenCmd(givenEvents([{
|
|
110
111
|
TAG: "Registered",
|
|
111
|
-
email:
|
|
112
|
-
address:
|
|
112
|
+
email: Ordering_Examples$OrderingPlugin.aliceEmail,
|
|
113
|
+
address: Ordering_Examples$OrderingPlugin.mainStreet
|
|
113
114
|
}]), {
|
|
114
115
|
TAG: "UpdateAddress",
|
|
115
116
|
address: "789 Pine Rd"
|
|
@@ -119,23 +120,23 @@ describe("Customer Behavior", () => {
|
|
|
119
120
|
}));
|
|
120
121
|
test("UpdateAddress to same address produces no events (idempotent)", () => thenNoEvent(whenCmd(givenEvents([{
|
|
121
122
|
TAG: "Registered",
|
|
122
|
-
email:
|
|
123
|
-
address:
|
|
123
|
+
email: Ordering_Examples$OrderingPlugin.aliceEmail,
|
|
124
|
+
address: Ordering_Examples$OrderingPlugin.mainStreet
|
|
124
125
|
}]), {
|
|
125
126
|
TAG: "UpdateAddress",
|
|
126
|
-
address:
|
|
127
|
+
address: Ordering_Examples$OrderingPlugin.mainStreet
|
|
127
128
|
})));
|
|
128
129
|
test("Deactivate on non-existent aggregate returns CustomerNotFound", () => thenError(whenCmd(givenEvents([]), "Deactivate"), "CustomerNotFound"));
|
|
129
130
|
test("Deactivate on active customer produces Deactivated", () => thenEvent(whenCmd(givenEvents([{
|
|
130
131
|
TAG: "Registered",
|
|
131
|
-
email:
|
|
132
|
-
address:
|
|
132
|
+
email: Ordering_Examples$OrderingPlugin.aliceEmail,
|
|
133
|
+
address: Ordering_Examples$OrderingPlugin.mainStreet
|
|
133
134
|
}]), "Deactivate"), "Deactivated"));
|
|
134
135
|
test("Deactivate on deactivated customer produces no events (idempotent)", () => thenNoEvent(whenCmd(givenEvents([
|
|
135
136
|
{
|
|
136
137
|
TAG: "Registered",
|
|
137
|
-
email:
|
|
138
|
-
address:
|
|
138
|
+
email: Ordering_Examples$OrderingPlugin.aliceEmail,
|
|
139
|
+
address: Ordering_Examples$OrderingPlugin.mainStreet
|
|
139
140
|
},
|
|
140
141
|
"Deactivated"
|
|
141
142
|
]), "Deactivate")));
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
@@reventless.gwt(Customers_Projections.CustomerMapping)
|
|
2
2
|
|
|
3
3
|
describe("Customers ReadModel ← Customer", () => {
|
|
4
|
+
// scenario-id: d64df451-1238-400b-b146-4bd84dfb232b
|
|
4
5
|
test("Registered sets initial read model state", () =>
|
|
5
6
|
givenEvents([])
|
|
6
7
|
->whenEvent(Customer.Registered({email: "alice@example.com", address: "123 Main St"}))
|
|
7
8
|
->thenState({Customers.email: "alice@example.com", address: "123 Main St", deactivated: false})
|
|
8
9
|
)
|
|
9
10
|
|
|
11
|
+
// scenario-id: 80d62196-a14f-4da6-9993-384996b0be93
|
|
10
12
|
test("EmailUpdated updates the email", () =>
|
|
11
13
|
givenEvents([Customer.Registered({email: "alice@example.com", address: "123 Main St"})])
|
|
12
14
|
->whenEvent(Customer.EmailUpdated({email: "alice2@example.com"}))
|
|
13
15
|
->thenState({Customers.email: "alice2@example.com", address: "123 Main St", deactivated: false})
|
|
14
16
|
)
|
|
15
17
|
|
|
18
|
+
// scenario-id: 55ce1763-d498-440d-8c19-2dc8adfa69e2
|
|
16
19
|
test("AddressUpdated updates the address", () =>
|
|
17
20
|
givenEvents([Customer.Registered({email: "alice@example.com", address: "123 Main St"})])
|
|
18
21
|
->whenEvent(Customer.AddressUpdated({address: "789 Pine Rd"}))
|
|
19
22
|
->thenState({Customers.email: "alice@example.com", address: "789 Pine Rd", deactivated: false})
|
|
20
23
|
)
|
|
21
24
|
|
|
25
|
+
// scenario-id: 9885a011-7448-431f-ae96-629aae5f9823
|
|
22
26
|
test("Deactivated sets deactivated flag", () =>
|
|
23
27
|
givenEvents([Customer.Registered({email: "alice@example.com", address: "123 Main St"})])
|
|
24
28
|
->whenEvent(Customer.Deactivated)
|
|
@@ -5,16 +5,17 @@
|
|
|
5
5
|
// `Mapping` is brought into scope by the PPX `open Products_Extension`; opening
|
|
6
6
|
// it surfaces the extension point's events and the delegate's commands.
|
|
7
7
|
open Mapping
|
|
8
|
-
|
|
9
|
-
let p1 = CatalogSpec.ProductId.make("p1")
|
|
8
|
+
open Ordering_Examples
|
|
10
9
|
|
|
11
10
|
describe("Products Extension delegate", () => {
|
|
11
|
+
// scenario-id: 4c14eb06-02b8-41ae-b0b8-cf33ef430e93
|
|
12
12
|
test("ProductBecameAvailable issues Sync", () =>
|
|
13
13
|
whenIncomingEvent(
|
|
14
14
|
ExtensionPoint.ProductBecameAvailable({productId: p1, name: "Book", price: 9.99}),
|
|
15
15
|
)->thenPublishesAggregateCommand("p1", Delegate.Sync({name: "Book", price: 9.99}))
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
+
// scenario-id: d3760e9e-c4f6-4a2f-bb5a-8e57a965ba68
|
|
18
19
|
test("ProductPriceChanged issues UpdatePrice", () =>
|
|
19
20
|
whenIncomingEvent(
|
|
20
21
|
ExtensionPoint.ProductPriceChanged({productId: p1, price: 7.5}),
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import * as ProductId$CatalogSpec from "@reventlessdev/online-shop-aggregates-catalog-spec/src/ProductId.res.mjs";
|
|
4
4
|
import * as Delegate_GWT$ReventlessGwt from "@reventlessdev/reventless-gwt/src/Delegate_GWT.res.mjs";
|
|
5
5
|
import * as CatalogProduct$OrderingPlugin from "../../src/CatalogProduct/Aggregate/CatalogProduct.res.mjs";
|
|
6
|
+
import * as Ordering_Examples$OrderingPlugin from "../Ordering_Examples.res.mjs";
|
|
6
7
|
import * as Products_Extension$OrderingPlugin from "../../src/Extension/Products_Extension.res.mjs";
|
|
7
8
|
import * as Products_ExtensionPoint$CatalogSpec from "@reventlessdev/online-shop-aggregates-catalog-spec/src/Products_ExtensionPoint.res.mjs";
|
|
8
9
|
|
|
@@ -41,12 +42,10 @@ let whenIncomingEvent = include.whenIncomingEvent;
|
|
|
41
42
|
|
|
42
43
|
let thenPublishesAggregateCommand = include.thenPublishesAggregateCommand;
|
|
43
44
|
|
|
44
|
-
let p1 = ProductId$CatalogSpec.make("p1");
|
|
45
|
-
|
|
46
45
|
describe("Products Extension delegate", () => {
|
|
47
46
|
test("ProductBecameAvailable issues Sync", undefined, () => thenPublishesAggregateCommand(whenIncomingEvent({
|
|
48
47
|
TAG: "ProductBecameAvailable",
|
|
49
|
-
productId: p1,
|
|
48
|
+
productId: Ordering_Examples$OrderingPlugin.p1,
|
|
50
49
|
name: "Book",
|
|
51
50
|
price: 9.99
|
|
52
51
|
}), "p1", {
|
|
@@ -56,7 +55,7 @@ describe("Products Extension delegate", () => {
|
|
|
56
55
|
}));
|
|
57
56
|
test("ProductPriceChanged issues UpdatePrice", undefined, () => thenPublishesAggregateCommand(whenIncomingEvent({
|
|
58
57
|
TAG: "ProductPriceChanged",
|
|
59
|
-
productId: p1,
|
|
58
|
+
productId: Ordering_Examples$OrderingPlugin.p1,
|
|
60
59
|
price: 7.5
|
|
61
60
|
}), "p1", {
|
|
62
61
|
TAG: "UpdatePrice",
|
|
@@ -108,6 +107,5 @@ export {
|
|
|
108
107
|
thenHandlesDirective,
|
|
109
108
|
thenHandlesDirectives,
|
|
110
109
|
thenHandlesNoDirective,
|
|
111
|
-
p1,
|
|
112
110
|
}
|
|
113
111
|
/* include Not a pure module */
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
// into one public per-product event each (one-to-many fan-out).
|
|
3
3
|
@@reventless.gwt
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
let p1 = CatalogSpec.ProductId.make("p1")
|
|
7
|
-
let p2 = CatalogSpec.ProductId.make("p2")
|
|
5
|
+
open Ordering_Examples
|
|
8
6
|
|
|
9
7
|
describe("Orders ExtensionPoint mapping — per-product fan-out", () => {
|
|
8
|
+
// scenario-id: b3fe53fe-84bd-4bb7-aca3-a0f9db5a186f
|
|
10
9
|
test("Placed fans out to one ItemOrdered per product", () =>
|
|
11
10
|
whenDelegateEvent(
|
|
12
11
|
Delegate.Placed({customerId: c1, productIds: [p1, p2]}),
|
|
@@ -16,6 +15,7 @@ describe("Orders ExtensionPoint mapping — per-product fan-out", () => {
|
|
|
16
15
|
])
|
|
17
16
|
)
|
|
18
17
|
|
|
18
|
+
// scenario-id: c916b814-2006-4d62-9fff-60bb99ddcfd3
|
|
19
19
|
test("Cancelled fans out to one ItemOrderCancelled per product", () =>
|
|
20
20
|
whenDelegateEvent(Delegate.Cancelled({productIds: [p1, p2]}))->thenPublishesEvents([
|
|
21
21
|
("p1", ExtensionPoint.ItemOrderCancelled({productId: "p1", orderId: "gwt-id"})),
|
|
@@ -23,8 +23,10 @@ describe("Orders ExtensionPoint mapping — per-product fan-out", () => {
|
|
|
23
23
|
])
|
|
24
24
|
)
|
|
25
25
|
|
|
26
|
+
// scenario-id: 3647a0be-51ed-4d6d-83b3-9fa53a596e49
|
|
26
27
|
test("Shipped publishes nothing", () => whenDelegateEvent(Delegate.Shipped)->thenPublishesNothing)
|
|
27
28
|
|
|
29
|
+
// scenario-id: 0ac71311-60e6-4373-b078-96cfaf91724d
|
|
28
30
|
test("Refunded publishes nothing", () =>
|
|
29
31
|
whenDelegateEvent(Delegate.Refunded({reason: "customer-changed-mind"}))->thenPublishesNothing
|
|
30
32
|
)
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
3
|
import * as Order$OrderingPlugin from "../../src/Order/Aggregate/Order.res.mjs";
|
|
4
|
-
import * as ProductId$CatalogSpec from "@reventlessdev/online-shop-aggregates-catalog-spec/src/ProductId.res.mjs";
|
|
5
4
|
import * as OrderId$OrderingPlugin from "../../src/Order/OrderId.res.mjs";
|
|
6
|
-
import * as CustomerId$OrderingPlugin from "../../src/Customer/CustomerId.res.mjs";
|
|
7
5
|
import * as Delegate_GWT$ReventlessGwt from "@reventlessdev/reventless-gwt/src/Delegate_GWT.res.mjs";
|
|
6
|
+
import * as Ordering_Examples$OrderingPlugin from "../Ordering_Examples.res.mjs";
|
|
8
7
|
import * as Orders_ExtensionPoint$OrderingSpec from "@reventlessdev/online-shop-aggregates-ordering-spec/src/Orders_ExtensionPoint.res.mjs";
|
|
9
8
|
import * as Orders_ExtensionPointMapping$OrderingPlugin from "../../src/ExtensionPoint/Orders_ExtensionPointMapping.res.mjs";
|
|
10
9
|
|
|
@@ -44,19 +43,13 @@ let whenDelegateEvent = include.whenDelegateEvent;
|
|
|
44
43
|
|
|
45
44
|
let thenPublishesEvents = include.thenPublishesEvents;
|
|
46
45
|
|
|
47
|
-
let c1 = CustomerId$OrderingPlugin.make("c1");
|
|
48
|
-
|
|
49
|
-
let p1 = ProductId$CatalogSpec.make("p1");
|
|
50
|
-
|
|
51
|
-
let p2 = ProductId$CatalogSpec.make("p2");
|
|
52
|
-
|
|
53
46
|
describe("Orders ExtensionPoint mapping — per-product fan-out", () => {
|
|
54
47
|
test("Placed fans out to one ItemOrdered per product", undefined, () => thenPublishesEvents(whenDelegateEvent({
|
|
55
48
|
TAG: "Placed",
|
|
56
|
-
customerId: c1,
|
|
49
|
+
customerId: Ordering_Examples$OrderingPlugin.c1,
|
|
57
50
|
productIds: [
|
|
58
|
-
p1,
|
|
59
|
-
p2
|
|
51
|
+
Ordering_Examples$OrderingPlugin.p1,
|
|
52
|
+
Ordering_Examples$OrderingPlugin.p2
|
|
60
53
|
]
|
|
61
54
|
}), [
|
|
62
55
|
[
|
|
@@ -81,8 +74,8 @@ describe("Orders ExtensionPoint mapping — per-product fan-out", () => {
|
|
|
81
74
|
test("Cancelled fans out to one ItemOrderCancelled per product", undefined, () => thenPublishesEvents(whenDelegateEvent({
|
|
82
75
|
TAG: "Cancelled",
|
|
83
76
|
productIds: [
|
|
84
|
-
p1,
|
|
85
|
-
p2
|
|
77
|
+
Ordering_Examples$OrderingPlugin.p1,
|
|
78
|
+
Ordering_Examples$OrderingPlugin.p2
|
|
86
79
|
]
|
|
87
80
|
}), [
|
|
88
81
|
[
|
|
@@ -151,8 +144,5 @@ export {
|
|
|
151
144
|
thenHandlesDirective,
|
|
152
145
|
thenHandlesDirectives,
|
|
153
146
|
thenHandlesNoDirective,
|
|
154
|
-
c1,
|
|
155
|
-
p1,
|
|
156
|
-
p2,
|
|
157
147
|
}
|
|
158
148
|
/* include Not a pure module */
|
|
@@ -22,6 +22,7 @@ let prod1 = CatalogSpec.ProductId.make("prod-1")
|
|
|
22
22
|
let placedEvent = Order.Placed({customerId: cust1, productIds: [prod1]})
|
|
23
23
|
|
|
24
24
|
describe("Order auto-ship mapping (Placed → Ship)", () => {
|
|
25
|
+
// scenario-id: 2fd227c7-248e-47be-939a-467bceeb8796
|
|
25
26
|
test("Place → AutoShipMapping issues Ship → target emits Shipped", () =>
|
|
26
27
|
givenSourceEvents([])
|
|
27
28
|
->andTargetEvents([("order-1", [placedEvent])])
|
|
@@ -29,6 +30,7 @@ describe("Order auto-ship mapping (Placed → Ship)", () => {
|
|
|
29
30
|
->thenTargetEvent("order-1", Order.Shipped)
|
|
30
31
|
)
|
|
31
32
|
|
|
33
|
+
// scenario-id: 366966a9-f65a-44cf-9bd2-4df7ef7bced4
|
|
32
34
|
test("Ship command does not fire the mapping (only Placed events do)", () =>
|
|
33
35
|
givenSourceEvents([placedEvent])
|
|
34
36
|
->andTargetEvents([("order-1", [placedEvent])])
|
|
@@ -36,6 +38,7 @@ describe("Order auto-ship mapping (Placed → Ship)", () => {
|
|
|
36
38
|
->thenNoTargetEvent
|
|
37
39
|
)
|
|
38
40
|
|
|
41
|
+
// scenario-id: c6203367-d2ff-4903-b1a2-8cc259ec62ee
|
|
39
42
|
test("Cancel command does not fire the mapping", () =>
|
|
40
43
|
givenSourceEvents([placedEvent])
|
|
41
44
|
->andTargetEvents([("order-1", [placedEvent])])
|
|
@@ -43,6 +46,7 @@ describe("Order auto-ship mapping (Placed → Ship)", () => {
|
|
|
43
46
|
->thenNoTargetEvent
|
|
44
47
|
)
|
|
45
48
|
|
|
49
|
+
// scenario-id: d20d610d-7ec8-4767-8d88-4556c1bf7059
|
|
46
50
|
test("Refund command does not fire the mapping (only Placed events do)", () =>
|
|
47
51
|
givenSourceEvents([placedEvent, Order.Cancelled({productIds: [prod1]})])
|
|
48
52
|
->andTargetEvents([("order-1", [placedEvent, Order.Cancelled({productIds: [prod1]})])])
|
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
@@reventless.gwt
|
|
2
2
|
|
|
3
|
+
open Ordering_Examples
|
|
4
|
+
|
|
3
5
|
// Ids are typed; the literals are made once, here.
|
|
4
6
|
let cust1 = CustomerId.make("cust-1")
|
|
5
7
|
let prod1 = CatalogSpec.ProductId.make("prod-1")
|
|
6
8
|
let prod2 = CatalogSpec.ProductId.make("prod-2")
|
|
7
9
|
|
|
8
10
|
describe("Order Behavior", () => {
|
|
11
|
+
// scenario-id: 4f723805-10e2-4b72-b40a-6cf71e91c375
|
|
9
12
|
test("Place on new aggregate produces Placed", () =>
|
|
10
13
|
givenEvents([])
|
|
11
14
|
->whenCmd(Place({customerId: cust1, productIds: [prod1, prod2]}))
|
|
12
15
|
->thenEvent(Placed({customerId: cust1, productIds: [prod1, prod2]}))
|
|
13
16
|
)
|
|
14
17
|
|
|
18
|
+
// scenario-id: 061fb189-7195-474f-8010-0a0339d7cf11
|
|
15
19
|
test("Place on existing order returns OrderAlreadyPlaced", () =>
|
|
16
20
|
givenEvents([Placed({customerId: cust1, productIds: [prod1]})])
|
|
17
21
|
->whenCmd(Place({customerId: cust1, productIds: [prod1]}))
|
|
18
22
|
->thenError(OrderAlreadyPlaced)
|
|
19
23
|
)
|
|
20
24
|
|
|
25
|
+
// scenario-id: 3cb519a2-53ba-4f66-938f-2d5e4a3b736b
|
|
21
26
|
test("Place on shipped order returns OrderAlreadyShipped", () =>
|
|
22
27
|
givenEvents([Placed({customerId: cust1, productIds: [prod1]}), Shipped])
|
|
23
28
|
->whenCmd(Place({customerId: cust1, productIds: [prod1]}))
|
|
24
29
|
->thenError(OrderAlreadyShipped)
|
|
25
30
|
)
|
|
26
31
|
|
|
32
|
+
// scenario-id: e74bad7c-abe6-4313-9290-b20f75897285
|
|
27
33
|
test("Place on cancelled order returns OrderAlreadyCancelled", () =>
|
|
28
34
|
givenEvents([
|
|
29
35
|
Placed({customerId: cust1, productIds: [prod1]}),
|
|
@@ -33,24 +39,28 @@ describe("Order Behavior", () => {
|
|
|
33
39
|
->thenError(OrderAlreadyCancelled)
|
|
34
40
|
)
|
|
35
41
|
|
|
42
|
+
// scenario-id: 1e97733f-32dd-473a-86e9-6c2cfec8f813
|
|
36
43
|
test("Ship on non-existent order returns OrderNotFound", () =>
|
|
37
44
|
givenEvents([])
|
|
38
45
|
->whenCmd(Ship)
|
|
39
46
|
->thenError(OrderNotFound)
|
|
40
47
|
)
|
|
41
48
|
|
|
49
|
+
// scenario-id: 54073db7-f835-4d89-a648-71b6dc4869c2
|
|
42
50
|
test("Ship on placed order produces Shipped", () =>
|
|
43
51
|
givenEvents([Placed({customerId: cust1, productIds: [prod1]})])
|
|
44
52
|
->whenCmd(Ship)
|
|
45
53
|
->thenEvent(Shipped)
|
|
46
54
|
)
|
|
47
55
|
|
|
56
|
+
// scenario-id: 2d4c200e-ece6-40c4-a67d-460f5beca59e
|
|
48
57
|
test("Ship on shipped order produces no events (idempotent)", () =>
|
|
49
58
|
givenEvents([Placed({customerId: cust1, productIds: [prod1]}), Shipped])
|
|
50
59
|
->whenCmd(Ship)
|
|
51
60
|
->thenNoEvent
|
|
52
61
|
)
|
|
53
62
|
|
|
63
|
+
// scenario-id: 08783980-65d7-4114-b4ef-f0f95b0b3fc5
|
|
54
64
|
test("Ship on cancelled order returns OrderAlreadyCancelled", () =>
|
|
55
65
|
givenEvents([
|
|
56
66
|
Placed({customerId: cust1, productIds: [prod1]}),
|
|
@@ -60,24 +70,28 @@ describe("Order Behavior", () => {
|
|
|
60
70
|
->thenError(OrderAlreadyCancelled)
|
|
61
71
|
)
|
|
62
72
|
|
|
73
|
+
// scenario-id: 2104ec68-2de0-464b-b8f8-379f47b03db9
|
|
63
74
|
test("Cancel on non-existent order returns OrderNotFound", () =>
|
|
64
75
|
givenEvents([])
|
|
65
76
|
->whenCmd(Cancel)
|
|
66
77
|
->thenError(OrderNotFound)
|
|
67
78
|
)
|
|
68
79
|
|
|
80
|
+
// scenario-id: 3d974a23-5eb6-4463-9824-e61b0fa5a278
|
|
69
81
|
test("Cancel on placed order produces Cancelled", () =>
|
|
70
82
|
givenEvents([Placed({customerId: cust1, productIds: [prod1]})])
|
|
71
83
|
->whenCmd(Cancel)
|
|
72
84
|
->thenEvent(Cancelled({productIds: [prod1]}))
|
|
73
85
|
)
|
|
74
86
|
|
|
87
|
+
// scenario-id: 6144fcb7-d768-4237-9e67-e530c736210d
|
|
75
88
|
test("Cancel on shipped order returns OrderAlreadyShipped", () =>
|
|
76
89
|
givenEvents([Placed({customerId: cust1, productIds: [prod1]}), Shipped])
|
|
77
90
|
->whenCmd(Cancel)
|
|
78
91
|
->thenError(OrderAlreadyShipped)
|
|
79
92
|
)
|
|
80
93
|
|
|
94
|
+
// scenario-id: 07679806-2e68-4cdb-b8c0-8cc67bd65fa7
|
|
81
95
|
test("Cancel on cancelled order produces no events (idempotent)", () =>
|
|
82
96
|
givenEvents([
|
|
83
97
|
Placed({customerId: cust1, productIds: [prod1]}),
|
|
@@ -87,40 +101,45 @@ describe("Order Behavior", () => {
|
|
|
87
101
|
->thenNoEvent
|
|
88
102
|
)
|
|
89
103
|
|
|
104
|
+
// scenario-id: aa624dbf-659b-4685-8695-4203e23a855f
|
|
90
105
|
test("Refund on non-existent order returns OrderNotFound", () =>
|
|
91
106
|
givenEvents([])
|
|
92
107
|
->whenCmd(Refund({reason: "lost-in-transit"}))
|
|
93
108
|
->thenError(OrderNotFound)
|
|
94
109
|
)
|
|
95
110
|
|
|
111
|
+
// scenario-id: cf56897b-1cf0-4768-8ada-eae11c069d95
|
|
96
112
|
test("Refund on placed order returns OrderNotCancelled", () =>
|
|
97
113
|
givenEvents([Placed({customerId: cust1, productIds: [prod1]})])
|
|
98
|
-
->whenCmd(Refund({reason:
|
|
114
|
+
->whenCmd(Refund({reason: changedMind}))
|
|
99
115
|
->thenError(OrderNotCancelled)
|
|
100
116
|
)
|
|
101
117
|
|
|
118
|
+
// scenario-id: 802fb4a7-3768-4c6d-8a54-444f44891515
|
|
102
119
|
test("Refund on shipped order returns OrderNotCancelled", () =>
|
|
103
120
|
givenEvents([Placed({customerId: cust1, productIds: [prod1]}), Shipped])
|
|
104
121
|
->whenCmd(Refund({reason: "delivered-damaged"}))
|
|
105
122
|
->thenError(OrderNotCancelled)
|
|
106
123
|
)
|
|
107
124
|
|
|
125
|
+
// scenario-id: d9f7692d-4d64-41d9-b845-f5958fe95bc0
|
|
108
126
|
test("Refund on cancelled order produces Refunded", () =>
|
|
109
127
|
givenEvents([
|
|
110
128
|
Placed({customerId: cust1, productIds: [prod1]}),
|
|
111
129
|
Cancelled({productIds: [prod1]}),
|
|
112
130
|
])
|
|
113
|
-
->whenCmd(Refund({reason:
|
|
114
|
-
->thenEvent(Refunded({reason:
|
|
131
|
+
->whenCmd(Refund({reason: changedMind}))
|
|
132
|
+
->thenEvent(Refunded({reason: changedMind}))
|
|
115
133
|
)
|
|
116
134
|
|
|
135
|
+
// scenario-id: 4ced8701-2214-4f05-89ed-057b130979ad
|
|
117
136
|
test("Refund on already-refunded order produces no events (idempotent)", () =>
|
|
118
137
|
givenEvents([
|
|
119
138
|
Placed({customerId: cust1, productIds: [prod1]}),
|
|
120
139
|
Cancelled({productIds: [prod1]}),
|
|
121
|
-
Refunded({reason:
|
|
140
|
+
Refunded({reason: changedMind}),
|
|
122
141
|
])
|
|
123
|
-
->whenCmd(Refund({reason:
|
|
142
|
+
->whenCmd(Refund({reason: changedMind}))
|
|
124
143
|
->thenNoEvent
|
|
125
144
|
)
|
|
126
145
|
})
|
|
@@ -5,6 +5,7 @@ import * as ProductId$CatalogSpec from "@reventlessdev/online-shop-aggregates-ca
|
|
|
5
5
|
import * as CustomerId$OrderingPlugin from "../../../src/Customer/CustomerId.res.mjs";
|
|
6
6
|
import * as Behavior_GWT$ReventlessGwt from "@reventlessdev/reventless-gwt/src/Behavior_GWT.res.mjs";
|
|
7
7
|
import * as Order_Behavior$OrderingPlugin from "../../../src/Order/Aggregate/Order_Behavior.res.mjs";
|
|
8
|
+
import * as Ordering_Examples$OrderingPlugin from "../../Ordering_Examples.res.mjs";
|
|
8
9
|
|
|
9
10
|
let include = Behavior_GWT$ReventlessGwt.MakeFromAggregate({
|
|
10
11
|
name: Order$OrderingPlugin.name,
|
|
@@ -160,7 +161,7 @@ describe("Order Behavior", () => {
|
|
|
160
161
|
productIds: [prod1]
|
|
161
162
|
}]), {
|
|
162
163
|
TAG: "Refund",
|
|
163
|
-
reason:
|
|
164
|
+
reason: Ordering_Examples$OrderingPlugin.changedMind
|
|
164
165
|
}), "OrderNotCancelled"));
|
|
165
166
|
test("Refund on shipped order returns OrderNotCancelled", () => thenError(whenCmd(givenEvents([
|
|
166
167
|
{
|
|
@@ -185,10 +186,10 @@ describe("Order Behavior", () => {
|
|
|
185
186
|
}
|
|
186
187
|
]), {
|
|
187
188
|
TAG: "Refund",
|
|
188
|
-
reason:
|
|
189
|
+
reason: Ordering_Examples$OrderingPlugin.changedMind
|
|
189
190
|
}), {
|
|
190
191
|
TAG: "Refunded",
|
|
191
|
-
reason:
|
|
192
|
+
reason: Ordering_Examples$OrderingPlugin.changedMind
|
|
192
193
|
}));
|
|
193
194
|
test("Refund on already-refunded order produces no events (idempotent)", () => thenNoEvent(whenCmd(givenEvents([
|
|
194
195
|
{
|
|
@@ -202,11 +203,11 @@ describe("Order Behavior", () => {
|
|
|
202
203
|
},
|
|
203
204
|
{
|
|
204
205
|
TAG: "Refunded",
|
|
205
|
-
reason:
|
|
206
|
+
reason: Ordering_Examples$OrderingPlugin.changedMind
|
|
206
207
|
}
|
|
207
208
|
]), {
|
|
208
209
|
TAG: "Refund",
|
|
209
|
-
reason:
|
|
210
|
+
reason: Ordering_Examples$OrderingPlugin.changedMind
|
|
210
211
|
})));
|
|
211
212
|
});
|
|
212
213
|
|
|
@@ -6,6 +6,7 @@ let prod1 = CatalogSpec.ProductId.make("prod-1")
|
|
|
6
6
|
let prod2 = CatalogSpec.ProductId.make("prod-2")
|
|
7
7
|
|
|
8
8
|
describe("Orders ReadModel ← Order", () => {
|
|
9
|
+
// scenario-id: 94f5938c-adf9-42c2-8986-1204e0aa0710
|
|
9
10
|
test("Placed sets initial read model state", () =>
|
|
10
11
|
givenEvents([])
|
|
11
12
|
->whenEvent(Order.Placed({customerId: cust1, productIds: [prod1, prod2]}))
|
|
@@ -16,6 +17,7 @@ describe("Orders ReadModel ← Order", () => {
|
|
|
16
17
|
})
|
|
17
18
|
)
|
|
18
19
|
|
|
20
|
+
// scenario-id: 4b7e916e-e7db-4c00-9337-9e2fe4104c93
|
|
19
21
|
test("Shipped updates status", () =>
|
|
20
22
|
givenEvents([Order.Placed({customerId: cust1, productIds: [prod1]})])
|
|
21
23
|
->whenEvent(Order.Shipped)
|
|
@@ -26,6 +28,7 @@ describe("Orders ReadModel ← Order", () => {
|
|
|
26
28
|
})
|
|
27
29
|
)
|
|
28
30
|
|
|
31
|
+
// scenario-id: a56314fa-907f-425a-80e6-a7ea1a27d6c9
|
|
29
32
|
test("Cancelled updates status", () =>
|
|
30
33
|
givenEvents([Order.Placed({customerId: cust1, productIds: [prod1]})])
|
|
31
34
|
->whenEvent(Order.Cancelled({productIds: [prod1]}))
|
|
@@ -36,6 +39,7 @@ describe("Orders ReadModel ← Order", () => {
|
|
|
36
39
|
})
|
|
37
40
|
)
|
|
38
41
|
|
|
42
|
+
// scenario-id: 96902cd1-2eae-4a35-b5c6-6d28dc9acda7
|
|
39
43
|
test("Refunded updates status", () =>
|
|
40
44
|
givenEvents([
|
|
41
45
|
Order.Placed({customerId: cust1, productIds: [prod1]}),
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
@@reventless.examples
|
|
2
|
+
|
|
3
|
+
let p1: CatalogSpec.ProductId.t = CatalogSpec.ProductId.makeFromString("p1")
|
|
4
|
+
let p2: CatalogSpec.ProductId.t = CatalogSpec.ProductId.makeFromString("p2")
|
|
5
|
+
|
|
6
|
+
let c1: CustomerId.t = CustomerId.makeFromString("c1")
|
|
7
|
+
|
|
8
|
+
let aliceEmail: string = "alice@example.com"
|
|
9
|
+
let bobEmail: string = "bob@example.com"
|
|
10
|
+
let changedMind: string = "customer-changed-mind"
|
|
11
|
+
let laptop: string = "Laptop"
|
|
12
|
+
let mainStreet: string = "123 Main St"
|
|
13
|
+
let oakAvenue: string = "456 Oak Ave"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as ProductId$CatalogSpec from "@reventlessdev/online-shop-aggregates-catalog-spec/src/ProductId.res.mjs";
|
|
4
|
+
import * as CustomerId$OrderingPlugin from "../src/Customer/CustomerId.res.mjs";
|
|
5
|
+
|
|
6
|
+
let p1 = ProductId$CatalogSpec.makeFromString("p1");
|
|
7
|
+
|
|
8
|
+
let p2 = ProductId$CatalogSpec.makeFromString("p2");
|
|
9
|
+
|
|
10
|
+
let c1 = CustomerId$OrderingPlugin.makeFromString("c1");
|
|
11
|
+
|
|
12
|
+
let aliceEmail = "alice@example.com";
|
|
13
|
+
|
|
14
|
+
let bobEmail = "bob@example.com";
|
|
15
|
+
|
|
16
|
+
let changedMind = "customer-changed-mind";
|
|
17
|
+
|
|
18
|
+
let laptop = "Laptop";
|
|
19
|
+
|
|
20
|
+
let mainStreet = "123 Main St";
|
|
21
|
+
|
|
22
|
+
let oakAvenue = "456 Oak Ave";
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
p1,
|
|
26
|
+
p2,
|
|
27
|
+
c1,
|
|
28
|
+
aliceEmail,
|
|
29
|
+
bobEmail,
|
|
30
|
+
changedMind,
|
|
31
|
+
laptop,
|
|
32
|
+
mainStreet,
|
|
33
|
+
oakAvenue,
|
|
34
|
+
}
|
|
35
|
+
/* p1 Not a pure module */
|