From 75b2a14ba6214da774bea7e698e6f28862edda03 Mon Sep 17 00:00:00 2001 From: Alec Gibson <12036746+alecgibson@users.noreply.github.com> Date: Wed, 29 May 2024 11:45:53 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Fix=20create=20resubmit=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One of our tests currently checks resubmitting a create op after reconnecting during submission. However, since reconnection happens so quickly, this test case can cause two commit attempts in parallel. We currently only wait for the first request to resolve, which means that the second request can continue into the next test, causing unexpected test failures. This change waits for both acks to be sent before finishing the test. --- test/client/submit.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/client/submit.js b/test/client/submit.js index c74058499..8f71e00ec 100644 --- a/test/client/submit.js +++ b/test/client/submit.js @@ -289,11 +289,15 @@ module.exports = function() { next(); }); - var doc = connection.get('dogs', 'fido'); - doc.create({age: 3}, function(error) { - expect(doc.version).to.equal(1); - done(error); + var count = 0; + backend.use('reply', function(message, next) { + next(); + if (message.reply.a === 'op') count++; + if (count === 2) done(); }); + + var doc = connection.get('dogs', 'fido'); + doc.create({age: 10}, errorHandler(done)); }); it('does not fail when resubmitting a create op on a doc that was deleted', function(done) {