From 581d68b14229059bfcbe2674a3a3293379231861 Mon Sep 17 00:00:00 2001 From: schulace Date: Wed, 3 Mar 2021 14:24:36 -0700 Subject: [PATCH] chore: minimal reproduction of large diff on reconnect --- packages/client/package.json | 2 +- packages/client/src/client.spec.ts | 37 +++++++++++++----------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/packages/client/package.json b/packages/client/package.json index 5df9c8e..2bbea51 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -22,7 +22,7 @@ "build:types": "tsc --emitDeclarationOnly", "build:js": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline", "watch": "yarn build:js -w", - "test": "jest" + "test": "DEBUG=app* jest" }, "dependencies": { "@babel/plugin-proposal-optional-chaining": "^7.9.0", diff --git a/packages/client/src/client.spec.ts b/packages/client/src/client.spec.ts index f84f5c6..cae3ae1 100644 --- a/packages/client/src/client.spec.ts +++ b/packages/client/src/client.spec.ts @@ -41,7 +41,12 @@ const server = createServer(function(req, res) { res.end() }) -const defaultSlateJson = [{ type: 'paragraph', children: [{ text: '' }] }] +const defaultSlateJson = [ + { + type: 'paragraph', + children: [{ text: 'hello world' }, { text: 'goodbye world' }] + } +] const collabBackend = new AutomergeCollaboration({ entry: server, defaultValue: defaultSlateJson, @@ -280,37 +285,27 @@ describe('automerge editor client tests', () => { it.only('should work with concurrent insert text operations', async () => { const editor1 = await createCollabEditor() - const editor2 = await createCollabEditor() + console.log('----\neditor1 disconnect\n-----') + await waitForCondition(() => { + return getActiveConnections(collabBackend.backend, docId) === 1 + }) editor1.disconnect() - await waitForCondition(() => { - return getActiveConnections(collabBackend.backend, docId) === 1 - }) - - // editor2.insertNode({ type: 'paragraph', children: [{ text: 'hi' }] }) - // await waitForCondition(() => { - // return collabBackend.backend.getDocument(docId)?.children.length === 1 - // }) + await waitForCondition( + () => getActiveConnections(collabBackend.backend, docId) === 0 + ) + console.log('----\neditor1 reconnect\n-----') editor1.connect() await waitForCondition( - () => getActiveConnections(collabBackend.backend, docId) === 2 + () => getActiveConnections(collabBackend.backend, docId) === 1 ) - // await waitForCondition(() => { - // return editor1.children.length === 1 - // }) - - editor2.destroy() - - await waitForCondition(() => { - return getActiveConnections(collabBackend.backend, docId) === 1 - }) + await new Promise(res => setTimeout(res, 3000)) console.log('destroying last editor') - editor1.destroy() await waitForCondition(() => {