Add data collection mechanism in end to end test suite
parent
6804a26e74
commit
89832eff9e
|
@ -42,6 +42,7 @@ import {SpaceStoreClass} from "../stores/SpaceStore";
|
|||
import TypingStore from "../stores/TypingStore";
|
||||
import { EventIndexPeg } from "../indexing/EventIndexPeg";
|
||||
import {VoiceRecordingStore} from "../stores/VoiceRecordingStore";
|
||||
import PerformanceMonitor, { PerformanceEntryNames } from "../performance";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
|
@ -79,6 +80,8 @@ declare global {
|
|||
mxVoiceRecordingStore: VoiceRecordingStore;
|
||||
mxTypingStore: TypingStore;
|
||||
mxEventIndexPeg: EventIndexPeg;
|
||||
mxPerformanceMonitor: PerformanceMonitor;
|
||||
mxPerformanceEntryNames: PerformanceEntryNames;
|
||||
}
|
||||
|
||||
interface Document {
|
||||
|
|
|
@ -1858,7 +1858,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
|
||||
// returns a promise which resolves to the new MatrixClient
|
||||
onRegistered(credentials: IMatrixClientCreds) {
|
||||
PerformanceMonitor.stop(PerformanceEntryNames.REGISTER);
|
||||
return Lifecycle.setLoggedIn(credentials);
|
||||
}
|
||||
|
||||
|
@ -1949,6 +1948,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
await Lifecycle.setLoggedIn(credentials);
|
||||
await this.postLoginSetup();
|
||||
PerformanceMonitor.stop(PerformanceEntryNames.LOGIN);
|
||||
PerformanceMonitor.stop(PerformanceEntryNames.REGISTER);
|
||||
};
|
||||
|
||||
// complete security / e2e setup has finished
|
||||
|
|
|
@ -28,10 +28,10 @@ interface GetEntriesOptions {
|
|||
type?: string,
|
||||
}
|
||||
|
||||
type PerformanceCallbackFunction = (entry: PerformanceEntry) => void;
|
||||
type PerformanceCallbackFunction = (entry: PerformanceEntry[]) => void;
|
||||
|
||||
interface PerformanceDataListener {
|
||||
entryTypes?: string[],
|
||||
entryNames?: string[],
|
||||
callback: PerformanceCallbackFunction
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,11 @@ export default class PerformanceMonitor {
|
|||
// when adding a data callback
|
||||
entries.push(measurement);
|
||||
|
||||
listeners.forEach(listener => emitPerformanceData(listener, measurement));
|
||||
listeners.forEach(listener => {
|
||||
if (shouldEmit(listener, measurement)) {
|
||||
listener.callback([measurement])
|
||||
}
|
||||
});
|
||||
|
||||
return measurement;
|
||||
}
|
||||
|
@ -116,9 +120,11 @@ export default class PerformanceMonitor {
|
|||
|
||||
static addPerformanceDataCallback(listener: PerformanceDataListener, buffer = false) {
|
||||
listeners.push(listener);
|
||||
|
||||
if (buffer) {
|
||||
entries.forEach(entry => emitPerformanceData(listener, entry));
|
||||
const toEmit = entries.filter(entry => shouldEmit(listener, entry));
|
||||
if (toEmit.length > 0) {
|
||||
listener.callback(toEmit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,10 +140,8 @@ export default class PerformanceMonitor {
|
|||
}
|
||||
}
|
||||
|
||||
function emitPerformanceData(listener, entry): void {
|
||||
if (!listener.entryTypes || listener.entryTypes.includes(entry.entryType)) {
|
||||
listener.callback(entry)
|
||||
}
|
||||
function shouldEmit(listener: PerformanceDataListener, entry: PerformanceEntry): boolean {
|
||||
return !listener.entryNames || listener.entryNames.includes(entry.name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,3 +161,6 @@ function supportsPerformanceApi(): boolean {
|
|||
function buildKey(name: string, id?: string): string {
|
||||
return `${name}${id ? `:${id}` : ''}`;
|
||||
}
|
||||
|
||||
window.mxPerformanceMonitor = PerformanceMonitor;
|
||||
window.mxPerformanceEntryNames = PerformanceEntryNames;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
node_modules
|
||||
*.png
|
||||
element/env
|
||||
performance-entries.json
|
||||
|
|
|
@ -208,7 +208,7 @@ module.exports = class ElementSession {
|
|||
this.log.done();
|
||||
}
|
||||
|
||||
close() {
|
||||
async close() {
|
||||
return this.browser.close();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ const fs = require("fs");
|
|||
const program = require('commander');
|
||||
program
|
||||
.option('--no-logs', "don't output logs, document html on error", false)
|
||||
.option('--app-url [url]', "url to test", "http://localhost:5000")
|
||||
.option('--app-url [url]', "url to test", "http://localhost:8080")
|
||||
.option('--windowed', "dont run tests headless", false)
|
||||
.option('--slow-mo', "type at a human speed", false)
|
||||
.option('--dev-tools', "open chrome devtools in browser window", false)
|
||||
|
@ -79,8 +79,26 @@ async function runTests() {
|
|||
await new Promise((resolve) => setTimeout(resolve, 5 * 60 * 1000));
|
||||
}
|
||||
|
||||
await Promise.all(sessions.map((session) => session.close()));
|
||||
const performanceEntries = {};
|
||||
|
||||
await Promise.all(sessions.map(async (session) => {
|
||||
// Collecting all performance monitoring data before closing the session
|
||||
const measurements = await session.page.evaluate(() => {
|
||||
let measurements = [];
|
||||
window.mxPerformanceMonitor.addPerformanceDataCallback({
|
||||
entryNames: [
|
||||
window.mxPerformanceEntryNames.REGISTER,
|
||||
],
|
||||
callback: (events) => {
|
||||
measurements = JSON.stringify(events);
|
||||
},
|
||||
}, true);
|
||||
return measurements;
|
||||
});
|
||||
performanceEntries[session.username] = JSON.parse(measurements);
|
||||
return session.close();
|
||||
}));
|
||||
fs.writeFileSync(`performance-entries.json`, JSON.stringify(performanceEntries));
|
||||
if (failure) {
|
||||
process.exit(-1);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue