@yuneta/gobj-ui 7.25.19 → 7.25.20

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.
@@ -156,15 +156,20 @@ function build(name)
156
156
  return {remote, host, engine};
157
157
  }
158
158
 
159
- /* What the engine publishes on a Save of one topic's arrangement. */
160
- function save_arrangement(engine, topic)
159
+ /* What the engine publishes on a Save of one topic's arrangement,
160
+ * from its load number `graphs_load`. */
161
+ function save_arrangement(engine, topic, graphs_load)
161
162
  {
162
- gobj_publish_event(engine, "EV_UPDATE_NODE", {
163
+ let kw = {
163
164
  treedb_name: "treedb_test",
164
165
  topic_name: "__graphs__",
165
166
  record: {id: topic, topic: topic, active: true, properties: {nodes: {}}},
166
167
  options: {list_dict: true, autolink: false, create: true}
167
- });
168
+ };
169
+ if(graphs_load !== undefined) {
170
+ kw.graphs_load = graphs_load;
171
+ }
172
+ gobj_publish_event(engine, "EV_UPDATE_NODE", kw);
168
173
  }
169
174
 
170
175
  /* The answer as the real transports build it: the command frame
@@ -188,6 +193,11 @@ function refused()
188
193
  return told.filter((t) => t.event === "EV_GRAPHS_WRITE_REFUSED").map((t) => t.kw.topic);
189
194
  }
190
195
 
196
+ function refused_kw()
197
+ {
198
+ return told.filter((t) => t.event === "EV_GRAPHS_WRITE_REFUSED").map((t) => t.kw);
199
+ }
200
+
191
201
  describe("a __graphs__ write that does not land is said to the engine", () => {
192
202
 
193
203
  test("refused by the backend", () => {
@@ -222,6 +232,30 @@ describe("a __graphs__ write that does not land is said to the engine", () => {
222
232
  expect(refused()).toEqual(["binaries"]);
223
233
  });
224
234
 
235
+ /* Before gobj-ui 7.25.20 the refusal carried only the topic, and
236
+ * the engine applied one answered after a reload to the fresh
237
+ * load. The engine's load number now travels in __md_command__
238
+ * and comes back with the refusal, on every path. */
239
+ test("the engine's load comes back with the refusal, on every path", () => {
240
+ const {remote, host, engine} = build("g6");
241
+ save_arrangement(engine, "yunos", 7);
242
+ expect(commands[0].kw.__md_command__.graphs_load).toBe(7);
243
+ answer(host, remote, commands[0], -1, "not authorized");
244
+
245
+ refuse_on_the_way = true;
246
+ save_arrangement(engine, "binaries", 7);
247
+ refuse_on_the_way = false;
248
+
249
+ gobj_change_state(remote, "ST_DISCONNECTED");
250
+ save_arrangement(engine, "realms", 8);
251
+
252
+ expect(refused_kw()).toEqual([
253
+ {topic: "yunos", graphs_load: 7},
254
+ {topic: "binaries", graphs_load: 7},
255
+ {topic: "realms", graphs_load: 8}
256
+ ]);
257
+ });
258
+
225
259
  test("a refused write of another topic says nothing to the engine", () => {
226
260
  const {remote, host, engine} = build("g5");
227
261
  gobj_send_event(host, "EV_UPDATE_NODE", {