mirror of
				https://github.com/cudr/slate-collaborative.git
				synced 2025-06-13 12:54:04 +00:00 
			
		
		
		
	chore: minimal reproduction of large diff on reconnect
This commit is contained in:
		
							parent
							
								
									513770336a
								
							
						
					
					
						commit
						581d68b142
					
				| @ -22,7 +22,7 @@ | |||||||
|     "build:types": "tsc --emitDeclarationOnly", |     "build:types": "tsc --emitDeclarationOnly", | ||||||
|     "build:js": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline", |     "build:js": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline", | ||||||
|     "watch": "yarn build:js -w", |     "watch": "yarn build:js -w", | ||||||
|     "test": "jest" |     "test": "DEBUG=app* jest" | ||||||
|   }, |   }, | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@babel/plugin-proposal-optional-chaining": "^7.9.0", |     "@babel/plugin-proposal-optional-chaining": "^7.9.0", | ||||||
|  | |||||||
| @ -41,7 +41,12 @@ const server = createServer(function(req, res) { | |||||||
|   res.end() |   res.end() | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| const defaultSlateJson = [{ type: 'paragraph', children: [{ text: '' }] }] | const defaultSlateJson = [ | ||||||
|  |   { | ||||||
|  |     type: 'paragraph', | ||||||
|  |     children: [{ text: 'hello world' }, { text: 'goodbye world' }] | ||||||
|  |   } | ||||||
|  | ] | ||||||
| const collabBackend = new AutomergeCollaboration({ | const collabBackend = new AutomergeCollaboration({ | ||||||
|   entry: server, |   entry: server, | ||||||
|   defaultValue: defaultSlateJson, |   defaultValue: defaultSlateJson, | ||||||
| @ -280,37 +285,27 @@ describe('automerge editor client tests', () => { | |||||||
| 
 | 
 | ||||||
|   it.only('should work with concurrent insert text operations', async () => { |   it.only('should work with concurrent insert text operations', async () => { | ||||||
|     const editor1 = await createCollabEditor() |     const editor1 = await createCollabEditor() | ||||||
|     const editor2 = await createCollabEditor() |     console.log('----\neditor1 disconnect\n-----') | ||||||
|  |     await waitForCondition(() => { | ||||||
|  |       return getActiveConnections(collabBackend.backend, docId) === 1 | ||||||
|  |     }) | ||||||
| 
 | 
 | ||||||
|     editor1.disconnect() |     editor1.disconnect() | ||||||
| 
 | 
 | ||||||
|     await waitForCondition(() => { |     await waitForCondition( | ||||||
|       return getActiveConnections(collabBackend.backend, docId) === 1 |       () => getActiveConnections(collabBackend.backend, docId) === 0 | ||||||
|     }) |     ) | ||||||
| 
 |  | ||||||
|     // editor2.insertNode({ type: 'paragraph', children: [{ text: 'hi' }] })
 |  | ||||||
|     // await waitForCondition(() => {
 |  | ||||||
|     //   return collabBackend.backend.getDocument(docId)?.children.length === 1
 |  | ||||||
|     // })
 |  | ||||||
| 
 | 
 | ||||||
|  |     console.log('----\neditor1 reconnect\n-----') | ||||||
|     editor1.connect() |     editor1.connect() | ||||||
| 
 | 
 | ||||||
|     await waitForCondition( |     await waitForCondition( | ||||||
|       () => getActiveConnections(collabBackend.backend, docId) === 2 |       () => getActiveConnections(collabBackend.backend, docId) === 1 | ||||||
|     ) |     ) | ||||||
| 
 | 
 | ||||||
|     // await waitForCondition(() => {
 |     await new Promise(res => setTimeout(res, 3000)) | ||||||
|     //   return editor1.children.length === 1
 |  | ||||||
|     // })
 |  | ||||||
| 
 |  | ||||||
|     editor2.destroy() |  | ||||||
| 
 |  | ||||||
|     await waitForCondition(() => { |  | ||||||
|       return getActiveConnections(collabBackend.backend, docId) === 1 |  | ||||||
|     }) |  | ||||||
| 
 | 
 | ||||||
|     console.log('destroying last editor') |     console.log('destroying last editor') | ||||||
| 
 |  | ||||||
|     editor1.destroy() |     editor1.destroy() | ||||||
| 
 | 
 | ||||||
|     await waitForCondition(() => { |     await waitForCondition(() => { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user