@reventlessdev/reventless-gwt 1.0.0-alpha.241 → 1.0.0-alpha.242

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 CHANGED
@@ -3,6 +3,13 @@
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.242 (2026-10-14)
7
+
8
+ ### Bug Fixes
9
+
10
+ * **gwt:** thenStateWithId checks the rows under its id, not that they are the only ones ([279d298](https://github.com/ReventlessDev/reventless-core/commit/279d298866fec60d976f0f8c8a247f684e600ba2))
11
+
12
+
6
13
  # 1.0.0-alpha.241 (2026-10-12)
7
14
 
8
15
  **Note:** Version bump only for package @reventlessdev/reventless-gwt
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reventlessdev/reventless-gwt",
3
- "version": "1.0.0-alpha.241",
3
+ "version": "1.0.0-alpha.242",
4
4
  "description": "Given-When-Then DSLs and test harness for Reventless slice testing",
5
5
  "license": "Apache-2.0",
6
6
  "jest": {
@@ -15,11 +15,11 @@
15
15
  "dependencies": {
16
16
  "sury": "11.0.0",
17
17
  "@reventlessdev/rescript-effect": "0.1.0-alpha.35",
18
- "@reventlessdev/rescript-jest": "1.0.0-alpha.12",
19
- "@reventlessdev/reventless-infra": "3.0.0-alpha.191",
20
18
  "@reventlessdev/rescript-node": "2.0.0-alpha.22",
21
- "@reventlessdev/reventless-spec": "3.0.0-alpha.163",
22
- "@reventlessdev/reventless-core": "3.0.0-alpha.294"
19
+ "@reventlessdev/reventless-core": "3.0.0-alpha.294",
20
+ "@reventlessdev/reventless-infra": "3.0.0-alpha.191",
21
+ "@reventlessdev/rescript-jest": "1.0.0-alpha.12",
22
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.163"
23
23
  },
24
24
  "devDependencies": {
25
25
  "rescript": "12.3.1",
@@ -250,10 +250,10 @@ module Make = (Projection: Reventless.Projection.Mapping): (
250
250
 
251
251
  let thenStatesWithId = async (thunk, id, expectedStates) => {
252
252
  let store = await thunk()
253
- let keys = store->Dict.keysToArray
254
- let actualId = keys->Array.get(0)
255
- let actualStates = store->Dict.valuesToArray->Array.get(0)->Option.getOr([])
256
- if keys->Array.length == 1 && actualId == Some(id) && statesEq(actualStates, expectedStates) {
253
+
254
+ // The rows under that id: rows the given events filed under other ids are another
255
+ // expectation's (`thenAllStates` checks them all).
256
+ if store->Dict.get(id)->Option.mapOr(false, actual => statesEq(actual, expectedStates)) {
257
257
  Outcome.pass
258
258
  } else {
259
259
  Outcome.fail(
@@ -255,10 +255,7 @@ function Make(Projection) {
255
255
  };
256
256
  let thenStatesWithId = async (thunk, id, expectedStates) => {
257
257
  let store = await thunk();
258
- let keys = Object.keys(store);
259
- let actualId = keys[0];
260
- let actualStates = Stdlib_Option.getOr(Object.values(store)[0], []);
261
- if (keys.length === 1 && Primitive_object.equal(actualId, id) && statesEq(actualStates, expectedStates)) {
258
+ if (Stdlib_Option.mapOr(store[id], false, actual => statesEq(actual, expectedStates))) {
262
259
  return Outcome$ReventlessGwt.pass;
263
260
  } else {
264
261
  return Outcome$ReventlessGwt.fail({
@@ -254,10 +254,10 @@ module Make = (Spec: Spec, Projection: Projection with module Spec := Spec): (
254
254
 
255
255
  let thenStatesWithId = async (thunk, id, expectedStates) => {
256
256
  let store = await thunk()
257
- let keys = store->Dict.keysToArray
258
- let actualId = keys->Array.get(0)
259
- let actualStates = store->Dict.valuesToArray->Array.get(0)->Option.getOr([])
260
- if keys->Array.length == 1 && actualId == Some(id) && statesEq(actualStates, expectedStates) {
257
+
258
+ // The rows under that id: rows the given events filed under other ids are another
259
+ // expectation's (`thenAllStates` checks them all).
260
+ if store->Dict.get(id)->Option.mapOr(false, actual => statesEq(actual, expectedStates)) {
261
261
  Outcome.pass
262
262
  } else {
263
263
  Outcome.fail(
@@ -238,10 +238,7 @@ function Make(Spec) {
238
238
  };
239
239
  let thenStatesWithId = async (thunk, id, expectedStates) => {
240
240
  let store = await thunk();
241
- let keys = Object.keys(store);
242
- let actualId = keys[0];
243
- let actualStates = Stdlib_Option.getOr(Object.values(store)[0], []);
244
- if (keys.length === 1 && Primitive_object.equal(actualId, id) && statesEq(actualStates, expectedStates)) {
241
+ if (Stdlib_Option.mapOr(store[id], false, actual => statesEq(actual, expectedStates))) {
245
242
  return Outcome$ReventlessGwt.pass;
246
243
  } else {
247
244
  return Outcome$ReventlessGwt.fail({
@@ -50,4 +50,11 @@ describe("CategoriesView StateViewSlice", () => {
50
50
  ->whenEvent(CategoryRenamed({categoryId: "c1", name: "Consumer Electronics"}))
51
51
  ->thenStateWithId("c1", {categoryId: "c1", name: "Consumer Electronics", archived: false})
52
52
  )
53
+
54
+ // The rows under that id: another category's row, from a given event, is not this one's.
55
+ test("a second category gets its own row, the first one's left as it is", () =>
56
+ givenEvents([CategoryAdded({categoryId: "c1", name: "Electronics"})])
57
+ ->whenEvent(CategoryAdded({categoryId: "c2", name: "Garden"}))
58
+ ->thenStateWithId("c2", {categoryId: "c2", name: "Garden", archived: false})
59
+ )
53
60
  })
@@ -131,6 +131,19 @@ describe("CategoriesView StateViewSlice", () => {
131
131
  name: "Consumer Electronics",
132
132
  archived: false
133
133
  }));
134
+ test("a second category gets its own row, the first one's left as it is", undefined, () => thenStateWithId(whenEvent(givenEvents([{
135
+ TAG: "CategoryAdded",
136
+ categoryId: "c1",
137
+ name: "Electronics"
138
+ }]), {
139
+ TAG: "CategoryAdded",
140
+ categoryId: "c2",
141
+ name: "Garden"
142
+ }), "c2", {
143
+ categoryId: "c2",
144
+ name: "Garden",
145
+ archived: false
146
+ }));
134
147
  });
135
148
 
136
149
  let Spec = include.Spec;