@roc-db/test-utils 0.2.0-pre.100 → 0.2.0-pre.102
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 +31 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -235,6 +235,9 @@ var entities = [
|
|
|
235
235
|
PostVersion,
|
|
236
236
|
UserEntity
|
|
237
237
|
];
|
|
238
|
+
// src/operations/index.ts
|
|
239
|
+
import { pageEntities, pageMutations, redo, undo } from "roc-db";
|
|
240
|
+
|
|
238
241
|
// src/operations/applyDraft.ts
|
|
239
242
|
import { Query, QueryChain, writeOperation } from "roc-db";
|
|
240
243
|
var applyDraft = writeOperation("applyDraft", DraftRefSchema, (txn) => {
|
|
@@ -724,6 +727,10 @@ var crudBySlug = writeOperation26("crudBySlug", z50.object({ slug: z50.string(),
|
|
|
724
727
|
|
|
725
728
|
// src/operations/index.ts
|
|
726
729
|
var operations = [
|
|
730
|
+
pageMutations,
|
|
731
|
+
pageEntities,
|
|
732
|
+
undo,
|
|
733
|
+
redo,
|
|
727
734
|
applyDraft,
|
|
728
735
|
createBlockImage,
|
|
729
736
|
createBlockTitle,
|
|
@@ -1327,7 +1334,30 @@ var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
|
|
|
1327
1334
|
expect2(() => changeSetAdapter2.createBlockImage({
|
|
1328
1335
|
parentRef: post2.ref,
|
|
1329
1336
|
url: "https://example.com/image.png"
|
|
1330
|
-
})).toThrowError(
|
|
1337
|
+
})).toThrowError(new RegExp(`changeSetRef .*${draftRef2}.* has already been applied`));
|
|
1338
|
+
});
|
|
1339
|
+
test("debounce does not collapse across changeSets (applied draft)", async () => {
|
|
1340
|
+
const [post2] = await adapter1.createPost({
|
|
1341
|
+
title: "Debounce repro",
|
|
1342
|
+
slug: faker.lorem.slug(5),
|
|
1343
|
+
tags: []
|
|
1344
|
+
});
|
|
1345
|
+
const [draft1] = await adapter1.createDraft({ postRef: post2.ref });
|
|
1346
|
+
const draft1adapter = adapter1.changeSet(draft1.ref);
|
|
1347
|
+
const [, mutation1] = await draft1adapter.updatePostDescription({
|
|
1348
|
+
ref: post2.ref,
|
|
1349
|
+
description: "From draft 1"
|
|
1350
|
+
});
|
|
1351
|
+
expect2(mutation1.changeSetRef).toBe(draft1.ref);
|
|
1352
|
+
await adapter1.applyDraft(draft1.ref);
|
|
1353
|
+
const [draft2] = await adapter1.createDraft({ postRef: post2.ref });
|
|
1354
|
+
const draft2adapter = adapter1.changeSet(draft2.ref);
|
|
1355
|
+
const [, mutation2] = await draft2adapter.updatePostDescription({
|
|
1356
|
+
ref: post2.ref,
|
|
1357
|
+
description: "From draft 2"
|
|
1358
|
+
});
|
|
1359
|
+
expect2(mutation2.ref).not.toBe(mutation1.ref);
|
|
1360
|
+
expect2(mutation2.changeSetRef).toBe(draft2.ref);
|
|
1331
1361
|
});
|
|
1332
1362
|
test("deleteDraft", async () => {
|
|
1333
1363
|
const { draftRef: draftRef2 } = await prepareChangeSetTest(adapter1);
|