mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 09:52:04 +00:00
fix a couple flaky tests (#5061)
* fix: forgot to increase maxDiffPixels for one snapshot test, making it more chance to flake. let's see if this work * hopefully fix PerformanceIndicator test flakes * hopefully actually fix PerfIndicator test this time * ok, *finally* fix PerfIndicator test... hopefully... * simplify PerfIndicator test to check only for positive fps value
This commit is contained in:
parent
54d1b8991c
commit
a5580912e3
@ -47,7 +47,7 @@ test.use({
|
|||||||
});
|
});
|
||||||
|
|
||||||
test.describe('ExportAsJSON', () => {
|
test.describe('ExportAsJSON', () => {
|
||||||
test.only('autoscale off causes no error from undefined user range', async ({ page }) => {
|
test('autoscale off causes no error from undefined user range', async ({ page }) => {
|
||||||
await page.goto('/', { waitUntil: 'networkidle' });
|
await page.goto('/', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
await setTimeRange(page);
|
await setTimeRange(page);
|
||||||
@ -102,7 +102,7 @@ test.describe('ExportAsJSON', () => {
|
|||||||
testYTicks(page, ['0.00', '0.50', '1.00', '1.50', '2.00']),
|
testYTicks(page, ['0.00', '0.50', '1.00', '1.50', '2.00']),
|
||||||
new Promise(r => setTimeout(r, 100))
|
new Promise(r => setTimeout(r, 100))
|
||||||
.then(() => canvas.screenshot())
|
.then(() => canvas.screenshot())
|
||||||
.then(shot => expect(shot).toMatchSnapshot('autoscale-canvas-panned.png', { maxDiffPixels: 20 }))
|
.then(shot => expect(shot).toMatchSnapshot('autoscale-canvas-panned.png', { maxDiffPixels: 40 }))
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 24 KiB |
Binary file not shown.
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 30 KiB |
@ -20,10 +20,7 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
import PerformancePlugin from './plugin.js';
|
import PerformancePlugin from './plugin.js';
|
||||||
import {
|
import { createOpenMct, resetApplicationState } from 'utils/testing';
|
||||||
createOpenMct,
|
|
||||||
resetApplicationState
|
|
||||||
} from 'utils/testing';
|
|
||||||
|
|
||||||
describe('the plugin', () => {
|
describe('the plugin', () => {
|
||||||
let openmct;
|
let openmct;
|
||||||
@ -31,9 +28,8 @@ describe('the plugin', () => {
|
|||||||
let child;
|
let child;
|
||||||
|
|
||||||
let performanceIndicator;
|
let performanceIndicator;
|
||||||
let countFramesPromise;
|
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach(done => {
|
||||||
openmct = createOpenMct();
|
openmct = createOpenMct();
|
||||||
|
|
||||||
element = document.createElement('div');
|
element = document.createElement('div');
|
||||||
@ -42,11 +38,9 @@ describe('the plugin', () => {
|
|||||||
|
|
||||||
openmct.install(new PerformancePlugin());
|
openmct.install(new PerformancePlugin());
|
||||||
|
|
||||||
countFramesPromise = countFrames();
|
|
||||||
|
|
||||||
openmct.on('start', done);
|
openmct.on('start', done);
|
||||||
|
|
||||||
performanceIndicator = openmct.indicators.indicatorObjects.find((indicator) => {
|
performanceIndicator = openmct.indicators.indicatorObjects.find(indicator => {
|
||||||
return indicator.text && indicator.text() === '~ fps';
|
return indicator.text && indicator.text() === '~ fps';
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -61,25 +55,21 @@ describe('the plugin', () => {
|
|||||||
expect(performanceIndicator).toBeDefined();
|
expect(performanceIndicator).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('correctly calculates fps', () => {
|
it('calculates an fps value', async () => {
|
||||||
return countFramesPromise.then((frames) => {
|
await loopForABit();
|
||||||
expect(performanceIndicator.text()).toEqual(`${frames} fps`);
|
// eslint-disable-next-line
|
||||||
});
|
expect(parseInt(performanceIndicator.text().split(' fps')[0])).toBeGreaterThan(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
function countFrames() {
|
function loopForABit() {
|
||||||
let startTime = performance.now();
|
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise(resolve => {
|
||||||
requestAnimationFrame(function incrementCount() {
|
requestAnimationFrame(function loop() {
|
||||||
let now = performance.now();
|
if (++frames === 240) {
|
||||||
|
resolve();
|
||||||
if ((now - startTime) < 1000) {
|
|
||||||
frames++;
|
|
||||||
requestAnimationFrame(incrementCount);
|
|
||||||
} else {
|
} else {
|
||||||
resolve(frames);
|
requestAnimationFrame(loop);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user