From 626468f83f835e04ac1a2dcf25b70c4b4ce5b754 Mon Sep 17 00:00:00 2001 From: AzazelN28 Date: Tue, 12 Sep 2023 13:46:41 +0200 Subject: [PATCH] add imposter performance measures --- pages/login-page.js | 2 +- tests/performance/thumbnail.spec.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tests/performance/thumbnail.spec.js diff --git a/pages/login-page.js b/pages/login-page.js index 98419e7f..93786874 100644 --- a/pages/login-page.js +++ b/pages/login-page.js @@ -9,7 +9,7 @@ exports.LoginPage = class LoginPage extends BasePage { this.pageTitle = page.locator('h1[data-test="login-title"]'); this.emailInput = page.locator("#email"); this.pwdInput = page.locator("#password"); - this.loginButton = page.locator('input[name="submit"]'); + this.loginButton = page.locator('[data-test="login-submit"]'); this.emailInputError = page.locator( 'div[class=" invalid with-icon custom-input"] #email' ); diff --git a/tests/performance/thumbnail.spec.js b/tests/performance/thumbnail.spec.js new file mode 100644 index 00000000..7a492504 --- /dev/null +++ b/tests/performance/thumbnail.spec.js @@ -0,0 +1,28 @@ +import { expect } from "@playwright/test"; +import { performanceTest } from "../../fixtures.js"; +import { PerformancePage } from "../../pages/performance-page"; + +performanceTest("PERF Thumbnail renderer", async ({ page }) => { + const performancePage = new PerformancePage(page); + await performancePage.setup(); + + // TODO: Medir el tiempo que tarda en renderizar el thumbnail. + + const content = page.locator(".frame-container > .frame-content"); + await content.waitFor() + performance.mark('imposter:start') + + const imposter = page.locator(".frame-container > .frame-imposter"); + await imposter.waitFor() + performance.mark('imposter:end') + + const measure = performance.measure('imposter', 'imposter:start', 'imposter:end') + console.log(measure.duration, measure.entryType, measure.name) + + const [averageFrameRate, averageLongTaskDuration] = + await performancePage.measure(); + + expect(averageFrameRate).toBeGreaterThan(55); + expect(averageFrameRate).toBeLessThan(65); + expect(averageLongTaskDuration).toBeLessThan(0.5); +})