@rotorsoft/act-tck 1.37.12 → 1.38.0

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
@@ -4890,6 +4890,70 @@ var runStoreTck = (options) => {
4890
4890
  expect8(seen[0].pii).toEqual({ email: "u@example.com", name: "Ursula" });
4891
4891
  expect8(seen[0].data).toEqual({ amount: 1 });
4892
4892
  });
4893
+ describe8("with_pii (#1675)", () => {
4894
+ const seed_pii = async (s) => await store.commit(
4895
+ s,
4896
+ [
4897
+ {
4898
+ name: "Incremented",
4899
+ data: { amount: 1 },
4900
+ pii: { email: "w@example.com" }
4901
+ }
4902
+ ],
4903
+ make_meta({ stream: s })
4904
+ );
4905
+ it7("returns the payload by default and omits it when declined", async () => {
4906
+ const s = `pii-flag-${uid()}`;
4907
+ await seed_pii(s);
4908
+ const read = async (with_pii) => {
4909
+ const seen = [];
4910
+ await store.query(
4911
+ (e) => {
4912
+ seen.push(e);
4913
+ },
4914
+ { stream: s, stream_exact: true, with_pii }
4915
+ );
4916
+ return seen;
4917
+ };
4918
+ expect8((await read())[0].pii).toEqual({ email: "w@example.com" });
4919
+ expect8((await read(true))[0].pii).toEqual({
4920
+ email: "w@example.com"
4921
+ });
4922
+ const declined = await read(false);
4923
+ expect8(declined).toHaveLength(1);
4924
+ expect8(declined[0].pii ?? null).toBeNull();
4925
+ expect8(declined[0].data).toEqual({ amount: 1 });
4926
+ expect8(declined[0].name).toBe("Incremented");
4927
+ expect8(declined[0].stream).toBe(s);
4928
+ });
4929
+ it7("never hands back the stored payload in place of the real one", async () => {
4930
+ const s = `pii-flag-raw-${uid()}`;
4931
+ await seed_pii(s);
4932
+ const seen = [];
4933
+ await store.query(
4934
+ (e) => {
4935
+ seen.push(e);
4936
+ },
4937
+ { stream: s, stream_exact: true, with_pii: false }
4938
+ );
4939
+ const pii = seen[0].pii;
4940
+ expect8(pii ?? null).toBeNull();
4941
+ expect8(typeof pii).not.toBe("string");
4942
+ });
4943
+ it7("applies to every matching row, not just the first", async () => {
4944
+ const s = `pii-flag-many-${uid()}`;
4945
+ for (let i = 0; i < 3; i++) await seed_pii(s);
4946
+ const seen = [];
4947
+ await store.query(
4948
+ (e) => {
4949
+ seen.push(e);
4950
+ },
4951
+ { stream: s, stream_exact: true, with_pii: false }
4952
+ );
4953
+ expect8(seen).toHaveLength(3);
4954
+ for (const e of seen) expect8(e.pii ?? null).toBeNull();
4955
+ });
4956
+ });
4893
4957
  it7("round-trips a Date losslessly in pii, like data/meta (#1365/#1370/#1556)", async () => {
4894
4958
  const s = `pii-date-${uid()}`;
4895
4959
  const when = /* @__PURE__ */ new Date("2024-03-01T10:20:30.000Z");