@graffiti-garden/api 0.2.7 → 0.2.9
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/tests/channel-stats.d.ts +1 -1
- package/dist/tests/channel-stats.d.ts.map +1 -1
- package/dist/tests/crud.d.ts +1 -1
- package/dist/tests/crud.d.ts.map +1 -1
- package/dist/tests/discover.d.ts +1 -1
- package/dist/tests/discover.d.ts.map +1 -1
- package/dist/tests/orphans.d.ts +1 -1
- package/dist/tests/orphans.d.ts.map +1 -1
- package/dist/tests/synchronize.d.ts +1 -1
- package/dist/tests/synchronize.d.ts.map +1 -1
- package/dist/tests.mjs +1426 -1
- package/dist/tests.mjs.map +3 -3
- package/package.json +1 -1
- package/tests/channel-stats.ts +16 -11
- package/tests/crud.ts +21 -51
- package/tests/discover.ts +15 -49
- package/tests/location.ts +1 -1
- package/tests/orphans.ts +19 -10
- package/tests/synchronize.ts +27 -26
package/tests/crud.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { it, expect, describe } from "vitest";
|
|
1
|
+
import { it, expect, describe, beforeEach } from "vitest";
|
|
2
2
|
import type {
|
|
3
3
|
Graffiti,
|
|
4
4
|
GraffitiSession,
|
|
@@ -16,18 +16,27 @@ import { randomPutObject, randomString } from "./utils";
|
|
|
16
16
|
|
|
17
17
|
export const graffitiCRUDTests = (
|
|
18
18
|
useGraffiti: () => Pick<Graffiti, "put" | "get" | "delete" | "patch">,
|
|
19
|
-
useSession1: () => GraffitiSession
|
|
20
|
-
useSession2: () => GraffitiSession
|
|
19
|
+
useSession1: () => GraffitiSession | Promise<GraffitiSession>,
|
|
20
|
+
useSession2: () => GraffitiSession | Promise<GraffitiSession>,
|
|
21
21
|
) => {
|
|
22
|
-
describe(
|
|
22
|
+
describe.concurrent(
|
|
23
23
|
"CRUD",
|
|
24
24
|
{
|
|
25
25
|
timeout: 20000,
|
|
26
26
|
},
|
|
27
27
|
() => {
|
|
28
|
+
let graffiti: ReturnType<typeof useGraffiti>;
|
|
29
|
+
let session: GraffitiSession;
|
|
30
|
+
let session1: GraffitiSession;
|
|
31
|
+
let session2: GraffitiSession;
|
|
32
|
+
beforeEach(async () => {
|
|
33
|
+
graffiti = useGraffiti();
|
|
34
|
+
session1 = await useSession1();
|
|
35
|
+
session = session1;
|
|
36
|
+
session2 = await useSession2();
|
|
37
|
+
});
|
|
38
|
+
|
|
28
39
|
it("put, get, delete", async () => {
|
|
29
|
-
const graffiti = useGraffiti();
|
|
30
|
-
const session = useSession1();
|
|
31
40
|
const value = {
|
|
32
41
|
something: "hello, world~ c:",
|
|
33
42
|
};
|
|
@@ -63,7 +72,7 @@ export const graffitiCRUDTests = (
|
|
|
63
72
|
expect(beforeReplaced.name).toEqual(previous.name);
|
|
64
73
|
expect(beforeReplaced.actor).toEqual(previous.actor);
|
|
65
74
|
expect(beforeReplaced.source).toEqual(previous.source);
|
|
66
|
-
expect(beforeReplaced.lastModified).
|
|
75
|
+
expect(beforeReplaced.lastModified).toBeGreaterThanOrEqual(
|
|
67
76
|
gotten.lastModified,
|
|
68
77
|
);
|
|
69
78
|
|
|
@@ -77,7 +86,7 @@ export const graffitiCRUDTests = (
|
|
|
77
86
|
const beforeDeleted = await graffiti.delete(afterReplaced, session);
|
|
78
87
|
expect(beforeDeleted.tombstone).toEqual(true);
|
|
79
88
|
expect(beforeDeleted.value).toEqual(newValue);
|
|
80
|
-
expect(beforeDeleted.lastModified).
|
|
89
|
+
expect(beforeDeleted.lastModified).toBeGreaterThanOrEqual(
|
|
81
90
|
beforeReplaced.lastModified,
|
|
82
91
|
);
|
|
83
92
|
|
|
@@ -87,9 +96,6 @@ export const graffitiCRUDTests = (
|
|
|
87
96
|
});
|
|
88
97
|
|
|
89
98
|
it("get non-existant", async () => {
|
|
90
|
-
const graffiti = useGraffiti();
|
|
91
|
-
const session = useSession1();
|
|
92
|
-
|
|
93
99
|
const putted = await graffiti.put(randomPutObject(), session);
|
|
94
100
|
await expect(
|
|
95
101
|
graffiti.get(
|
|
@@ -103,10 +109,6 @@ export const graffitiCRUDTests = (
|
|
|
103
109
|
});
|
|
104
110
|
|
|
105
111
|
it("put, get, delete with wrong actor", async () => {
|
|
106
|
-
const graffiti = useGraffiti();
|
|
107
|
-
const session1 = useSession1();
|
|
108
|
-
const session2 = useSession2();
|
|
109
|
-
|
|
110
112
|
await expect(
|
|
111
113
|
graffiti.put(
|
|
112
114
|
{ value: {}, channels: [], actor: session2.actor },
|
|
@@ -129,9 +131,6 @@ export const graffitiCRUDTests = (
|
|
|
129
131
|
});
|
|
130
132
|
|
|
131
133
|
it("put and get with schema", async () => {
|
|
132
|
-
const graffiti = useGraffiti();
|
|
133
|
-
const session = useSession1();
|
|
134
|
-
|
|
135
134
|
const schema = {
|
|
136
135
|
properties: {
|
|
137
136
|
value: {
|
|
@@ -166,9 +165,6 @@ export const graffitiCRUDTests = (
|
|
|
166
165
|
});
|
|
167
166
|
|
|
168
167
|
it("put and get with invalid schema", async () => {
|
|
169
|
-
const graffiti = useGraffiti();
|
|
170
|
-
const session = useSession1();
|
|
171
|
-
|
|
172
168
|
const putted = await graffiti.put({ value: {}, channels: [] }, session);
|
|
173
169
|
await expect(
|
|
174
170
|
graffiti.get(putted, {
|
|
@@ -183,9 +179,6 @@ export const graffitiCRUDTests = (
|
|
|
183
179
|
});
|
|
184
180
|
|
|
185
181
|
it("put and get with wrong schema", async () => {
|
|
186
|
-
const graffiti = useGraffiti();
|
|
187
|
-
const session = useSession1();
|
|
188
|
-
|
|
189
182
|
const putted = await graffiti.put(
|
|
190
183
|
{
|
|
191
184
|
value: {
|
|
@@ -212,10 +205,6 @@ export const graffitiCRUDTests = (
|
|
|
212
205
|
});
|
|
213
206
|
|
|
214
207
|
it("put and get with empty access control", async () => {
|
|
215
|
-
const graffiti = useGraffiti();
|
|
216
|
-
const session1 = useSession1();
|
|
217
|
-
const session2 = useSession2();
|
|
218
|
-
|
|
219
208
|
const value = {
|
|
220
209
|
um: "hi",
|
|
221
210
|
};
|
|
@@ -244,10 +233,6 @@ export const graffitiCRUDTests = (
|
|
|
244
233
|
});
|
|
245
234
|
|
|
246
235
|
it("put and get with specific access control", async () => {
|
|
247
|
-
const graffiti = useGraffiti();
|
|
248
|
-
const session1 = useSession1();
|
|
249
|
-
const session2 = useSession2();
|
|
250
|
-
|
|
251
236
|
const value = {
|
|
252
237
|
um: "hi",
|
|
253
238
|
};
|
|
@@ -282,14 +267,14 @@ export const graffitiCRUDTests = (
|
|
|
282
267
|
});
|
|
283
268
|
|
|
284
269
|
it("patch value", async () => {
|
|
285
|
-
const graffiti = useGraffiti();
|
|
286
|
-
const session = useSession1();
|
|
287
|
-
|
|
288
270
|
const value = {
|
|
289
271
|
something: "hello, world~ c:",
|
|
290
272
|
};
|
|
291
273
|
const putted = await graffiti.put({ value, channels: [] }, session);
|
|
292
274
|
|
|
275
|
+
// Wait just a bit to make sure the lastModified is different
|
|
276
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
277
|
+
|
|
293
278
|
const patch: GraffitiPatch = {
|
|
294
279
|
value: [
|
|
295
280
|
{ op: "replace", path: "/something", value: "goodbye, world~ :c" },
|
|
@@ -298,6 +283,7 @@ export const graffitiCRUDTests = (
|
|
|
298
283
|
const beforePatched = await graffiti.patch(patch, putted, session);
|
|
299
284
|
expect(beforePatched.value).toEqual(value);
|
|
300
285
|
expect(beforePatched.tombstone).toBe(true);
|
|
286
|
+
expect(beforePatched.lastModified).toBeGreaterThan(putted.lastModified);
|
|
301
287
|
|
|
302
288
|
const gotten = await graffiti.get(putted, {});
|
|
303
289
|
expect(gotten.value).toEqual({
|
|
@@ -309,9 +295,6 @@ export const graffitiCRUDTests = (
|
|
|
309
295
|
});
|
|
310
296
|
|
|
311
297
|
it("patch deleted object", async () => {
|
|
312
|
-
const graffiti = useGraffiti();
|
|
313
|
-
const session = useSession1();
|
|
314
|
-
|
|
315
298
|
const putted = await graffiti.put(randomPutObject(), session);
|
|
316
299
|
const deleted = await graffiti.delete(putted, session);
|
|
317
300
|
await expect(
|
|
@@ -320,9 +303,6 @@ export const graffitiCRUDTests = (
|
|
|
320
303
|
});
|
|
321
304
|
|
|
322
305
|
it("deep patch", async () => {
|
|
323
|
-
const graffiti = useGraffiti();
|
|
324
|
-
const session = useSession1();
|
|
325
|
-
|
|
326
306
|
const value = {
|
|
327
307
|
something: {
|
|
328
308
|
another: {
|
|
@@ -361,9 +341,6 @@ export const graffitiCRUDTests = (
|
|
|
361
341
|
});
|
|
362
342
|
|
|
363
343
|
it("patch channels", async () => {
|
|
364
|
-
const graffiti = useGraffiti();
|
|
365
|
-
const session = useSession1();
|
|
366
|
-
|
|
367
344
|
const channelsBefore = [randomString()];
|
|
368
345
|
const channelsAfter = [randomString()];
|
|
369
346
|
|
|
@@ -383,9 +360,6 @@ export const graffitiCRUDTests = (
|
|
|
383
360
|
});
|
|
384
361
|
|
|
385
362
|
it("patch 'increment' with test", async () => {
|
|
386
|
-
const graffiti = useGraffiti();
|
|
387
|
-
const session = useSession1();
|
|
388
|
-
|
|
389
363
|
const putted = await graffiti.put(
|
|
390
364
|
{
|
|
391
365
|
value: {
|
|
@@ -435,8 +409,6 @@ export const graffitiCRUDTests = (
|
|
|
435
409
|
});
|
|
436
410
|
|
|
437
411
|
it("invalid patch", async () => {
|
|
438
|
-
const graffiti = useGraffiti();
|
|
439
|
-
const session = useSession1();
|
|
440
412
|
const object = randomPutObject();
|
|
441
413
|
const putted = await graffiti.put(object, session);
|
|
442
414
|
|
|
@@ -455,8 +427,6 @@ export const graffitiCRUDTests = (
|
|
|
455
427
|
});
|
|
456
428
|
|
|
457
429
|
it("patch channels to be wrong", async () => {
|
|
458
|
-
const graffiti = useGraffiti();
|
|
459
|
-
const session = useSession1();
|
|
460
430
|
const object = randomPutObject();
|
|
461
431
|
object.allowed = [randomString()];
|
|
462
432
|
const putted = await graffiti.put(object, session);
|
package/tests/discover.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { it, expect, describe, assert } from "vitest";
|
|
1
|
+
import { it, expect, describe, assert, beforeEach } from "vitest";
|
|
2
2
|
import type {
|
|
3
3
|
Graffiti,
|
|
4
4
|
GraffitiSession,
|
|
@@ -8,19 +8,27 @@ import { randomString, nextStreamValue, randomPutObject } from "./utils";
|
|
|
8
8
|
|
|
9
9
|
export const graffitiDiscoverTests = (
|
|
10
10
|
useGraffiti: () => Pick<Graffiti, "discover" | "put" | "delete" | "patch">,
|
|
11
|
-
useSession1: () => GraffitiSession
|
|
12
|
-
useSession2: () => GraffitiSession
|
|
11
|
+
useSession1: () => GraffitiSession | Promise<GraffitiSession>,
|
|
12
|
+
useSession2: () => GraffitiSession | Promise<GraffitiSession>,
|
|
13
13
|
) => {
|
|
14
|
-
describe("discover", { timeout: 20000 }, () => {
|
|
14
|
+
describe.concurrent("discover", { timeout: 20000 }, () => {
|
|
15
|
+
let graffiti: ReturnType<typeof useGraffiti>;
|
|
16
|
+
let session: GraffitiSession;
|
|
17
|
+
let session1: GraffitiSession;
|
|
18
|
+
let session2: GraffitiSession;
|
|
19
|
+
beforeEach(async () => {
|
|
20
|
+
graffiti = useGraffiti();
|
|
21
|
+
session1 = await useSession1();
|
|
22
|
+
session = session1;
|
|
23
|
+
session2 = await useSession2();
|
|
24
|
+
});
|
|
25
|
+
|
|
15
26
|
it("discover nothing", async () => {
|
|
16
|
-
const graffiti = useGraffiti();
|
|
17
27
|
const iterator = graffiti.discover([], {});
|
|
18
28
|
expect(await iterator.next()).toHaveProperty("done", true);
|
|
19
29
|
});
|
|
20
30
|
|
|
21
31
|
it("discover single", async () => {
|
|
22
|
-
const graffiti = useGraffiti();
|
|
23
|
-
const session = useSession1();
|
|
24
32
|
const object = randomPutObject();
|
|
25
33
|
|
|
26
34
|
const putted = await graffiti.put(object, session);
|
|
@@ -39,8 +47,6 @@ export const graffitiDiscoverTests = (
|
|
|
39
47
|
});
|
|
40
48
|
|
|
41
49
|
it("discover wrong channel", async () => {
|
|
42
|
-
const graffiti = useGraffiti();
|
|
43
|
-
const session = useSession1();
|
|
44
50
|
const object = randomPutObject();
|
|
45
51
|
await graffiti.put(object, session);
|
|
46
52
|
const iterator = graffiti.discover([randomString()], {});
|
|
@@ -48,10 +54,6 @@ export const graffitiDiscoverTests = (
|
|
|
48
54
|
});
|
|
49
55
|
|
|
50
56
|
it("discover not allowed", async () => {
|
|
51
|
-
const graffiti = useGraffiti();
|
|
52
|
-
const session1 = useSession1();
|
|
53
|
-
const session2 = useSession2();
|
|
54
|
-
|
|
55
57
|
const object = randomPutObject();
|
|
56
58
|
object.allowed = [randomString(), randomString()];
|
|
57
59
|
const putted = await graffiti.put(object, session1);
|
|
@@ -73,10 +75,6 @@ export const graffitiDiscoverTests = (
|
|
|
73
75
|
});
|
|
74
76
|
|
|
75
77
|
it("discover allowed", async () => {
|
|
76
|
-
const graffiti = useGraffiti();
|
|
77
|
-
const session1 = useSession1();
|
|
78
|
-
const session2 = useSession2();
|
|
79
|
-
|
|
80
78
|
const object = randomPutObject();
|
|
81
79
|
object.allowed = [randomString(), session2.actor, randomString()];
|
|
82
80
|
const putted = await graffiti.put(object, session1);
|
|
@@ -93,10 +91,6 @@ export const graffitiDiscoverTests = (
|
|
|
93
91
|
|
|
94
92
|
for (const prop of ["name", "actor", "lastModified"] as const) {
|
|
95
93
|
it(`discover for ${prop}`, async () => {
|
|
96
|
-
const graffiti = useGraffiti();
|
|
97
|
-
const session1 = useSession1();
|
|
98
|
-
const session2 = useSession2();
|
|
99
|
-
|
|
100
94
|
const object1 = randomPutObject();
|
|
101
95
|
const putted1 = await graffiti.put(object1, session1);
|
|
102
96
|
|
|
@@ -123,9 +117,6 @@ export const graffitiDiscoverTests = (
|
|
|
123
117
|
}
|
|
124
118
|
|
|
125
119
|
it("discover with lastModified range", async () => {
|
|
126
|
-
const graffiti = useGraffiti();
|
|
127
|
-
const session = useSession1();
|
|
128
|
-
|
|
129
120
|
const object = randomPutObject();
|
|
130
121
|
const putted1 = await graffiti.put(object, session);
|
|
131
122
|
// Make sure the lastModified is different
|
|
@@ -219,10 +210,6 @@ export const graffitiDiscoverTests = (
|
|
|
219
210
|
});
|
|
220
211
|
|
|
221
212
|
it("discover schema allowed, as and not as owner", async () => {
|
|
222
|
-
const graffiti = useGraffiti();
|
|
223
|
-
const session1 = useSession1();
|
|
224
|
-
const session2 = useSession2();
|
|
225
|
-
|
|
226
213
|
const object = randomPutObject();
|
|
227
214
|
object.allowed = [randomString(), session2.actor, randomString()];
|
|
228
215
|
await graffiti.put(object, session1);
|
|
@@ -315,10 +302,6 @@ export const graffitiDiscoverTests = (
|
|
|
315
302
|
});
|
|
316
303
|
|
|
317
304
|
it("discover schema channels, as and not as owner", async () => {
|
|
318
|
-
const graffiti = useGraffiti();
|
|
319
|
-
const session1 = useSession1();
|
|
320
|
-
const session2 = useSession2();
|
|
321
|
-
|
|
322
305
|
const object = randomPutObject();
|
|
323
306
|
object.channels = [randomString(), randomString(), randomString()];
|
|
324
307
|
await graffiti.put(object, session1);
|
|
@@ -411,9 +394,6 @@ export const graffitiDiscoverTests = (
|
|
|
411
394
|
});
|
|
412
395
|
|
|
413
396
|
it("discover query for empty allowed", async () => {
|
|
414
|
-
const graffiti = useGraffiti();
|
|
415
|
-
const session1 = useSession1();
|
|
416
|
-
|
|
417
397
|
const publicO = randomPutObject();
|
|
418
398
|
|
|
419
399
|
const publicSchema = {
|
|
@@ -445,9 +425,6 @@ export const graffitiDiscoverTests = (
|
|
|
445
425
|
});
|
|
446
426
|
|
|
447
427
|
it("discover query for values", async () => {
|
|
448
|
-
const graffiti = useGraffiti();
|
|
449
|
-
const session = useSession1();
|
|
450
|
-
|
|
451
428
|
const object1 = randomPutObject();
|
|
452
429
|
object1.value = { test: randomString() };
|
|
453
430
|
await graffiti.put(object1, session);
|
|
@@ -486,9 +463,6 @@ export const graffitiDiscoverTests = (
|
|
|
486
463
|
});
|
|
487
464
|
|
|
488
465
|
it("discover for deleted content", async () => {
|
|
489
|
-
const graffiti = useGraffiti();
|
|
490
|
-
const session = useSession1();
|
|
491
|
-
|
|
492
466
|
const object = randomPutObject();
|
|
493
467
|
const putted = await graffiti.put(object, session);
|
|
494
468
|
const deleted = await graffiti.delete(putted, session);
|
|
@@ -506,9 +480,6 @@ export const graffitiDiscoverTests = (
|
|
|
506
480
|
it("discover for replaced channels", async () => {
|
|
507
481
|
// Do this a bunch to check for concurrency issues
|
|
508
482
|
for (let i = 0; i < 10; i++) {
|
|
509
|
-
const graffiti = useGraffiti();
|
|
510
|
-
const session = useSession1();
|
|
511
|
-
|
|
512
483
|
const object1 = randomPutObject();
|
|
513
484
|
const putted = await graffiti.put(object1, session);
|
|
514
485
|
const object2 = randomPutObject();
|
|
@@ -548,8 +519,6 @@ export const graffitiDiscoverTests = (
|
|
|
548
519
|
});
|
|
549
520
|
|
|
550
521
|
it("discover for patched allowed", async () => {
|
|
551
|
-
const graffiti = useGraffiti();
|
|
552
|
-
const session = useSession1();
|
|
553
522
|
const object = randomPutObject();
|
|
554
523
|
const putted = await graffiti.put(object, session);
|
|
555
524
|
await graffiti.patch(
|
|
@@ -569,9 +538,6 @@ export const graffitiDiscoverTests = (
|
|
|
569
538
|
});
|
|
570
539
|
|
|
571
540
|
it("put concurrently and discover one", async () => {
|
|
572
|
-
const graffiti = useGraffiti();
|
|
573
|
-
const session = useSession1();
|
|
574
|
-
|
|
575
541
|
const object = randomPutObject();
|
|
576
542
|
object.name = randomString();
|
|
577
543
|
|
package/tests/location.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { randomString } from "./utils";
|
|
|
6
6
|
export const graffitiLocationTests = (
|
|
7
7
|
useGraffiti: () => Pick<Graffiti, "locationToUri" | "uriToLocation">,
|
|
8
8
|
) => {
|
|
9
|
-
describe("URI and location conversion", () => {
|
|
9
|
+
describe.concurrent("URI and location conversion", () => {
|
|
10
10
|
it("location to uri and back", async () => {
|
|
11
11
|
const graffiti = useGraffiti();
|
|
12
12
|
const location = {
|
package/tests/orphans.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { it, expect, describe, assert } from "vitest";
|
|
1
|
+
import { it, expect, describe, assert, beforeEach } from "vitest";
|
|
2
2
|
import type { Graffiti, GraffitiSession } from "@graffiti-garden/api";
|
|
3
3
|
import { randomPutObject, randomString } from "./utils";
|
|
4
4
|
|
|
@@ -7,14 +7,22 @@ export const graffitiOrphanTests = (
|
|
|
7
7
|
Graffiti,
|
|
8
8
|
"recoverOrphans" | "put" | "delete" | "patch"
|
|
9
9
|
>,
|
|
10
|
-
useSession1: () => GraffitiSession
|
|
11
|
-
useSession2: () => GraffitiSession
|
|
10
|
+
useSession1: () => GraffitiSession | Promise<GraffitiSession>,
|
|
11
|
+
useSession2: () => GraffitiSession | Promise<GraffitiSession>,
|
|
12
12
|
) => {
|
|
13
|
-
describe("recoverOrphans", () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
describe("recoverOrphans", { timeout: 20000 }, () => {
|
|
14
|
+
let graffiti: ReturnType<typeof useGraffiti>;
|
|
15
|
+
let session: GraffitiSession;
|
|
16
|
+
let session1: GraffitiSession;
|
|
17
|
+
let session2: GraffitiSession;
|
|
18
|
+
beforeEach(async () => {
|
|
19
|
+
graffiti = useGraffiti();
|
|
20
|
+
session1 = await useSession1();
|
|
21
|
+
session = session1;
|
|
22
|
+
session2 = await useSession2();
|
|
23
|
+
});
|
|
17
24
|
|
|
25
|
+
it("list orphans", async () => {
|
|
18
26
|
const existingOrphans: string[] = [];
|
|
19
27
|
const orphanIterator1 = graffiti.recoverOrphans({}, session);
|
|
20
28
|
for await (const orphan of orphanIterator1) {
|
|
@@ -39,13 +47,13 @@ export const graffitiOrphanTests = (
|
|
|
39
47
|
});
|
|
40
48
|
|
|
41
49
|
it("replaced orphan, no longer", async () => {
|
|
42
|
-
const graffiti = useGraffiti();
|
|
43
|
-
const session = useSession1();
|
|
44
|
-
|
|
45
50
|
const object = randomPutObject();
|
|
46
51
|
object.channels = [];
|
|
47
52
|
const putOrphan = await graffiti.put(object, session);
|
|
48
53
|
|
|
54
|
+
// Wait for the put to be processed
|
|
55
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
56
|
+
|
|
49
57
|
const putNotOrphan = await graffiti.put(
|
|
50
58
|
{
|
|
51
59
|
...putOrphan,
|
|
@@ -55,6 +63,7 @@ export const graffitiOrphanTests = (
|
|
|
55
63
|
session,
|
|
56
64
|
);
|
|
57
65
|
expect(putNotOrphan.name).toBe(putOrphan.name);
|
|
66
|
+
expect(putNotOrphan.lastModified).toBeGreaterThan(putOrphan.lastModified);
|
|
58
67
|
|
|
59
68
|
const orphanIterator = graffiti.recoverOrphans({}, session);
|
|
60
69
|
let numResults = 0;
|
package/tests/synchronize.ts
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
import { it, expect, describe, assert } from "vitest";
|
|
1
|
+
import { it, expect, describe, assert, beforeEach } from "vitest";
|
|
2
2
|
import type { GraffitiFactory, GraffitiSession } from "@graffiti-garden/api";
|
|
3
3
|
import { randomPutObject, randomString } from "./utils";
|
|
4
4
|
|
|
5
5
|
export const graffitiSynchronizeTests = (
|
|
6
6
|
useGraffiti: GraffitiFactory,
|
|
7
|
-
useSession1: () => GraffitiSession
|
|
8
|
-
useSession2: () => GraffitiSession
|
|
7
|
+
useSession1: () => GraffitiSession | Promise<GraffitiSession>,
|
|
8
|
+
useSession2: () => GraffitiSession | Promise<GraffitiSession>,
|
|
9
9
|
) => {
|
|
10
|
-
describe("synchronizeDiscover", () => {
|
|
10
|
+
describe.concurrent("synchronizeDiscover", () => {
|
|
11
|
+
let graffiti: ReturnType<typeof useGraffiti>;
|
|
12
|
+
let session: GraffitiSession;
|
|
13
|
+
let session1: GraffitiSession;
|
|
14
|
+
let session2: GraffitiSession;
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
graffiti = useGraffiti();
|
|
17
|
+
session1 = await useSession1();
|
|
18
|
+
session = session1;
|
|
19
|
+
session2 = await useSession2();
|
|
20
|
+
});
|
|
21
|
+
|
|
11
22
|
it("get", async () => {
|
|
12
23
|
const graffiti1 = useGraffiti();
|
|
13
|
-
const session = useSession1();
|
|
14
24
|
|
|
15
25
|
const object = randomPutObject();
|
|
16
26
|
const channels = object.channels.slice(1);
|
|
@@ -31,9 +41,6 @@ export const graffitiSynchronizeTests = (
|
|
|
31
41
|
});
|
|
32
42
|
|
|
33
43
|
it("put", async () => {
|
|
34
|
-
const graffiti = useGraffiti();
|
|
35
|
-
const session = useSession1();
|
|
36
|
-
|
|
37
44
|
const beforeChannel = randomString();
|
|
38
45
|
const afterChannel = randomString();
|
|
39
46
|
const sharedChannel = randomString();
|
|
@@ -97,9 +104,6 @@ export const graffitiSynchronizeTests = (
|
|
|
97
104
|
});
|
|
98
105
|
|
|
99
106
|
it("patch", async () => {
|
|
100
|
-
const graffiti = useGraffiti();
|
|
101
|
-
const session = useSession1();
|
|
102
|
-
|
|
103
107
|
const beforeChannel = randomString();
|
|
104
108
|
const afterChannel = randomString();
|
|
105
109
|
const sharedChannel = randomString();
|
|
@@ -178,9 +182,6 @@ export const graffitiSynchronizeTests = (
|
|
|
178
182
|
});
|
|
179
183
|
|
|
180
184
|
it("delete", async () => {
|
|
181
|
-
const graffiti = useGraffiti();
|
|
182
|
-
const session = useSession1();
|
|
183
|
-
|
|
184
185
|
const channels = [randomString(), randomString(), randomString()];
|
|
185
186
|
|
|
186
187
|
const oldValue = { hello: "world" };
|
|
@@ -209,10 +210,6 @@ export const graffitiSynchronizeTests = (
|
|
|
209
210
|
});
|
|
210
211
|
|
|
211
212
|
it("not allowed", async () => {
|
|
212
|
-
const graffiti = useGraffiti();
|
|
213
|
-
const session1 = useSession1();
|
|
214
|
-
const session2 = useSession2();
|
|
215
|
-
|
|
216
213
|
const allChannels = [randomString(), randomString(), randomString()];
|
|
217
214
|
const channels = allChannels.slice(1);
|
|
218
215
|
|
|
@@ -261,11 +258,19 @@ export const graffitiSynchronizeTests = (
|
|
|
261
258
|
});
|
|
262
259
|
});
|
|
263
260
|
|
|
264
|
-
describe("synchronizeGet", () => {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
261
|
+
describe.concurrent("synchronizeGet", () => {
|
|
262
|
+
let graffiti: ReturnType<typeof useGraffiti>;
|
|
263
|
+
let session: GraffitiSession;
|
|
264
|
+
let session1: GraffitiSession;
|
|
265
|
+
let session2: GraffitiSession;
|
|
266
|
+
beforeEach(async () => {
|
|
267
|
+
graffiti = useGraffiti();
|
|
268
|
+
session1 = await useSession1();
|
|
269
|
+
session = session1;
|
|
270
|
+
session2 = await useSession2();
|
|
271
|
+
});
|
|
268
272
|
|
|
273
|
+
it("replace, delete", async () => {
|
|
269
274
|
const object = randomPutObject();
|
|
270
275
|
const putted = await graffiti.put(object, session);
|
|
271
276
|
|
|
@@ -310,10 +315,6 @@ export const graffitiSynchronizeTests = (
|
|
|
310
315
|
});
|
|
311
316
|
|
|
312
317
|
it("not allowed", async () => {
|
|
313
|
-
const graffiti = useGraffiti();
|
|
314
|
-
const session1 = useSession1();
|
|
315
|
-
const session2 = useSession2();
|
|
316
|
-
|
|
317
318
|
const object = randomPutObject();
|
|
318
319
|
const putted = await graffiti.put(object, session1);
|
|
319
320
|
|