@rotorsoft/act-tck 1.38.0 → 1.38.2

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/dist/index.js CHANGED
@@ -1112,6 +1112,7 @@ import {
1112
1112
  ConcurrencyError,
1113
1113
  InMemoryCache,
1114
1114
  SNAP_EVENT as SNAP_EVENT2,
1115
+ sleep,
1115
1116
  TOMBSTONE_EVENT,
1116
1117
  ValidationError
1117
1118
  } from "@rotorsoft/act";
@@ -3489,6 +3490,62 @@ var runStoreTck = (options) => {
3489
3490
  );
3490
3491
  expect8(remaining[0].data).toEqual({ count: 7 });
3491
3492
  });
3493
+ it7("leaves exactly one seed when a stream is listed twice (#1677)", async () => {
3494
+ const s = `trunc-dup-${uid()}`;
3495
+ await store.commit(
3496
+ s,
3497
+ [inc(1), inc(2)],
3498
+ make_meta({ stream: s })
3499
+ );
3500
+ const result = await store.truncate([
3501
+ { stream: s, snapshot: { count: 1 } },
3502
+ { stream: s, snapshot: { count: 2 } }
3503
+ ]);
3504
+ const remaining = [];
3505
+ await store.query(
3506
+ (e) => {
3507
+ remaining.push(e);
3508
+ },
3509
+ { stream: s, stream_exact: true, with_snaps: true }
3510
+ );
3511
+ expect8(remaining).toHaveLength(1);
3512
+ expect8(remaining[0].data).toEqual({ count: 2 });
3513
+ expect8(result.get(s)?.deleted).toBe(1);
3514
+ });
3515
+ it7("applies windowed targets before full ones (#1677)", async () => {
3516
+ const s = `trunc-mix-${uid()}`;
3517
+ await store.commit(
3518
+ s,
3519
+ [inc(1)],
3520
+ make_meta({ stream: s })
3521
+ );
3522
+ await store.commit(
3523
+ s,
3524
+ [inc(2)],
3525
+ make_meta({ stream: s })
3526
+ );
3527
+ await sleep(5);
3528
+ const cutoff = /* @__PURE__ */ new Date();
3529
+ const result = await store.truncate([
3530
+ { stream: s, before: cutoff },
3531
+ { stream: s, snapshot: { count: 9 } }
3532
+ ]);
3533
+ const entry2 = result.get(s);
3534
+ expect8(entry2).toBeDefined();
3535
+ expect8(entry2.before).toBeUndefined();
3536
+ expect8(entry2.committed.name).toBe(
3537
+ "__snapshot__"
3538
+ );
3539
+ const remaining = [];
3540
+ await store.query(
3541
+ (e) => {
3542
+ remaining.push(e);
3543
+ },
3544
+ { stream: s, stream_exact: true, with_snaps: true }
3545
+ );
3546
+ expect8(remaining).toHaveLength(1);
3547
+ expect8(remaining[0].data).toEqual({ count: 9 });
3548
+ });
3492
3549
  it7("returns an empty map for empty input", async () => {
3493
3550
  const result = await store.truncate([]);
3494
3551
  expect8(result.size).toBe(0);