penpotqa/tests/performance/thumbnail.spec.js

29 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

2024-01-09 19:50:16 +00:00
import { expect } from '@playwright/test';
import { performanceTest } from '../../fixtures.js';
import { PerformancePage } from '../../pages/performance-page';
2023-09-12 11:46:41 +00:00
2024-01-09 19:50:16 +00:00
performanceTest('PERF Thumbnail renderer', async ({ page }) => {
2023-09-12 11:46:41 +00:00
const performancePage = new PerformancePage(page);
await performancePage.setup();
// TODO: Medir el tiempo que tarda en renderizar el thumbnail.
2024-01-09 19:50:16 +00:00
const content = page.locator('.frame-container > .frame-content');
await content.waitFor();
performance.mark('imposter:start');
2023-09-12 11:46:41 +00:00
2024-01-09 19:50:16 +00:00
const imposter = page.locator('.frame-container > .frame-imposter');
await imposter.waitFor();
performance.mark('imposter:end');
2023-09-12 11:46:41 +00:00
2024-01-09 19:50:16 +00:00
const measure = performance.measure('imposter', 'imposter:start', 'imposter:end');
console.log(measure.duration, measure.entryType, measure.name);
2023-09-12 11:46:41 +00:00
const [averageFrameRate, averageLongTaskDuration] =
await performancePage.measure();
expect(averageFrameRate).toBeGreaterThan(55);
expect(averageFrameRate).toBeLessThan(65);
expect(averageLongTaskDuration).toBeLessThan(0.5);
2024-01-09 19:50:16 +00:00
});