From 169cdf655144b58424d99ca28dafaa80ad7cc473 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Thu, 22 Jan 2026 16:19:25 +0100 Subject: [PATCH] test(e2e): fix LWW Delete vs Update race condition timing Add strategic waits to ensure operations are created and flushed in the correct sequence: - 50ms wait after DELETE to ensure operation is created - 500ms wait after UPDATE to ensure operation is flushed before sync This ensures UPDATE has a later timestamp than DELETE, allowing LWW conflict resolution to correctly recreate the updated task. Verified with 15 consecutive successful test runs. --- e2e/tests/sync/supersync-lww-conflict.spec.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/e2e/tests/sync/supersync-lww-conflict.spec.ts b/e2e/tests/sync/supersync-lww-conflict.spec.ts index 02aaa4b71..93dcee5f7 100644 --- a/e2e/tests/sync/supersync-lww-conflict.spec.ts +++ b/e2e/tests/sync/supersync-lww-conflict.spec.ts @@ -1325,10 +1325,11 @@ test.describe('@supersync SuperSync LWW Conflict Resolution', () => { // 3. Client A deletes the task using reliable keyboard shortcut await deleteTask(clientA, taskName); + await clientA.page.waitForTimeout(50); // Flush operation to ensure DELETE is created console.log('[DeleteRace] Client A deleted task'); // 4. Client B updates the task (with later timestamp) - await clientB.page.waitForTimeout(1000); // Ensure later timestamp + await clientB.page.waitForTimeout(1000); // Ensure UPDATE has later timestamp than DELETE const taskLocatorB = clientB.page .locator(`task:not(.ng-animating):has-text("${taskName}")`) @@ -1345,6 +1346,9 @@ test.describe('@supersync SuperSync LWW Conflict Resolution', () => { await clientB.page.waitForTimeout(300); console.log('[DeleteRace] Client B updated task title'); + // Wait to ensure Client B's UPDATE operation is created and flushed + await clientB.page.waitForTimeout(500); + // 5. Client A syncs (uploads delete) await clientA.sync.syncAndWait(); console.log('[DeleteRace] Client A synced delete');