From 238afde00a5f2ecf891741485f2d6c857129b3b9 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 20 Jul 2017 11:01:27 +0100 Subject: [PATCH] Increase the timeout for clearing indexeddbs Chrome seems to take ages (like, 1500ms regularly) to clear out the indexeddbs, and that's causing test timeouts. Bump the timeout to hack around it. Also: clear both dbs in parallel (can't hurt, right?) and improve diagnostics on the process. --- test/app-tests/loading.js | 9 +++++++-- test/test-utils.js | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/test/app-tests/loading.js b/test/app-tests/loading.js index c7151aca..21619876 100644 --- a/test/app-tests/loading.js +++ b/test/app-tests/loading.js @@ -82,9 +82,14 @@ describe('loading:', function () { // unmounting should have cleared the MatrixClientPeg expect(MatrixClientPeg.get()).toBe(null); + // chrome seems to take *ages* to delete the indexeddbs. + this.timeout(10000); + // clear the indexeddbs so we can start from a clean slate next time. - await test_utils.deleteIndexedDB('matrix-js-sdk:crypto'); - await test_utils.deleteIndexedDB('matrix-js-sdk:riot-web-sync'); + await Promise.all([ + test_utils.deleteIndexedDB('matrix-js-sdk:crypto'), + test_utils.deleteIndexedDB('matrix-js-sdk:riot-web-sync'), + ]); console.log(`${Date.now()}: loading: afterEach complete`); }); diff --git a/test/test-utils.js b/test/test-utils.js index 007883df..a5b22feb 100644 --- a/test/test-utils.js +++ b/test/test-utils.js @@ -34,7 +34,8 @@ export function deleteIndexedDB(dbName) { return; } - console.log(`${Date.now()}: Removing indexeddb instance: ${dbName}`); + const startTime = Date.now(); + console.log(`${startTime}: Removing indexeddb instance: ${dbName}`); const req = window.indexedDB.deleteDatabase(dbName); req.onblocked = () => { @@ -48,7 +49,8 @@ export function deleteIndexedDB(dbName) { }; req.onsuccess = () => { - console.log(`${Date.now()}: Removed indexeddb instance: ${dbName}`); + const now = Date.now(); + console.log(`${now}: Removed indexeddb instance: ${dbName} in ${now-startTime} ms`); resolve(); }; }).catch((e) => {