mirror of https://github.com/vector-im/riot-web
Merge branch 'develop' into rav/deflakify_joining_test
commit
43f56483aa
|
@ -30,7 +30,7 @@ import sdk from 'matrix-react-sdk';
|
||||||
import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg';
|
import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg';
|
||||||
import * as languageHandler from 'matrix-react-sdk/lib/languageHandler';
|
import * as languageHandler from 'matrix-react-sdk/lib/languageHandler';
|
||||||
|
|
||||||
import test_utils from '../test-utils';
|
import * as test_utils from '../test-utils';
|
||||||
import MockHttpBackend from '../mock-request';
|
import MockHttpBackend from '../mock-request';
|
||||||
import {parseQs, parseQsFromFragment} from '../../src/vector/url_utils';
|
import {parseQs, parseQsFromFragment} from '../../src/vector/url_utils';
|
||||||
|
|
||||||
|
@ -68,12 +68,19 @@ describe('loading:', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(async function() {
|
||||||
if (parentDiv) {
|
if (parentDiv) {
|
||||||
ReactDOM.unmountComponentAtNode(parentDiv);
|
ReactDOM.unmountComponentAtNode(parentDiv);
|
||||||
parentDiv.remove();
|
parentDiv.remove();
|
||||||
parentDiv = null;
|
parentDiv = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unmounting should have cleared the MatrixClientPeg
|
||||||
|
expect(MatrixClientPeg.get()).toBe(null);
|
||||||
|
|
||||||
|
// 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');
|
||||||
});
|
});
|
||||||
|
|
||||||
/* simulate the load process done by index.js
|
/* simulate the load process done by index.js
|
||||||
|
|
|
@ -7,7 +7,7 @@ var q = require('q');
|
||||||
* name to stdout.
|
* name to stdout.
|
||||||
* @param {Mocha.Context} context The test context
|
* @param {Mocha.Context} context The test context
|
||||||
*/
|
*/
|
||||||
module.exports.beforeEach = function(context) {
|
export function beforeEach(context) {
|
||||||
var desc = context.currentTest.fullTitle();
|
var desc = context.currentTest.fullTitle();
|
||||||
console.log();
|
console.log();
|
||||||
console.log(desc);
|
console.log(desc);
|
||||||
|
@ -16,13 +16,40 @@ module.exports.beforeEach = function(context) {
|
||||||
// some tests store things in localstorage. Improve independence of tests
|
// some tests store things in localstorage. Improve independence of tests
|
||||||
// by making sure that they don't inherit any old state.
|
// by making sure that they don't inherit any old state.
|
||||||
window.localStorage.clear();
|
window.localStorage.clear();
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true if the current environment supports webrtc
|
* returns true if the current environment supports webrtc
|
||||||
*/
|
*/
|
||||||
module.exports.browserSupportsWebRTC = function() {
|
export function browserSupportsWebRTC() {
|
||||||
var n = global.window.navigator;
|
var n = global.window.navigator;
|
||||||
return n.getUserMedia || n.webkitGetUserMedia ||
|
return n.getUserMedia || n.webkitGetUserMedia ||
|
||||||
n.mozGetUserMedia;
|
n.mozGetUserMedia;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export function deleteIndexedDB(dbName) {
|
||||||
|
return new q.Promise((resolve, reject) => {
|
||||||
|
if (!window.indexedDB) {
|
||||||
|
resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Removing indexeddb instance: ${dbName}`);
|
||||||
|
const req = window.indexedDB.deleteDatabase(dbName);
|
||||||
|
|
||||||
|
req.onblocked = () => {
|
||||||
|
console.log(`can't yet delete indexeddb because it is open elsewhere`);
|
||||||
|
};
|
||||||
|
|
||||||
|
req.onerror = (ev) => {
|
||||||
|
reject(new Error(
|
||||||
|
"unable to delete indexeddb: " + ev.target.error,
|
||||||
|
));
|
||||||
|
};
|
||||||
|
|
||||||
|
req.onsuccess = () => {
|
||||||
|
console.log(`Removed indexeddb instance: ${dbName}`);
|
||||||
|
resolve();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue