Skip to content

Commit

Permalink
Feat(playwright performance): Pw perf tests (#959)
Browse files Browse the repository at this point in the history
* feat: initial perf tests for routes

fix: refactor

* Fix: updated per review comments

---------

Co-authored-by: asharonbaltazar <[email protected]>
  • Loading branch information
zerogravit1 and asharonbaltazar authored Jan 9, 2025
1 parent f0b89cc commit b92334d
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 53 deletions.
60 changes: 7 additions & 53 deletions test/e2e/tests/a11y/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,11 @@
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
import * as routes from "../fixtures/routes";

const staticRoutes = [
"/",
"/dashboard",
"/faq",
"/profile",
"/new-submission",
"/new-submission/spa",
"/new-submission/spa/medicaid",
"/new-submission/spa/chip",
"/new-submission/waiver",
"/new-submission/waiver/b",
"/new-submission/waiver/b/b4",
"/new-submission/waiver/b/capitated",
"/new-submission/spa/medicaid/landing/medicaid-eligibility",
"/new-submission/waiver/b/capitated/amendment/create",
"/new-submission/waiver/b/capitated/renewal/create",
"/new-submission/waiver/b/capitated/initial/create",
"/new-submission/waiver/b/b4/initial/create",
"/new-submission/waiver/b/b4/amendment/create",
"/new-submission/waiver/b/b4/renewal/create",
"/new-submission/spa/medicaid/create",
"/new-submission/spa/chip/create",
"/new-submission/waiver/app-k",
"/new-submission/waiver/temporary-extensions",
];
const STATIC_ROUTES = routes.STATIC;

test.describe("test a11y on static routes", {tag: ["@CI"]}, () => {
for (const route of staticRoutes) {
test.describe("test a11y on static routes", {tag: ["@CI", "@a11y"] }, () => {
for (const route of STATIC_ROUTES) {
test(`${route} should not have any automatically detectable accessibility issues`, async ({
page,
}) => {
Expand All @@ -44,34 +21,11 @@ test.describe("test a11y on static routes", {tag: ["@CI"]}, () => {
}
});

const webformRoutes = [
"/guides/abp",
"/webform/g3/202401",
"/webform/g2b/202401",
"/webform/g2a/202401",
"/webform/g1/202401",
"/webform/cs8/202401",
"/webform/cs3/202401",
"/webform/cs7/202401",
"/webform/abp11/202401",
"/webform/abp10/202401",
"/webform/abp9/202401",
"/webform/abp7/202401",
"/webform/abp6/202401",
"/webform/abp5/202401",
"/webform/abp4/202401",
"/webform/abp3_1/202401",
"/webform/abp3/202401",
"/webform/abp2c/202401",
"/webform/abp2b/202401",
"/webform/abp2a/202401",
"/webform/abp1/202401",
"/webform/abp1/202402",
];
const WEBFORM_ROUTES = routes.WEBFORM;

// Add to CI when prior to going to Prod
test.describe("test a11y on webform routes", {tag: ["@CI"]}, () => {
for (const route of webformRoutes) {
test.describe("test a11y on webform routes", {tag: ["@CI", "@a11y"] }, () => {
for (const route of WEBFORM_ROUTES) {
test(`${route} should not have any automatically detectable accessibility issues`, async ({
page,
}) => {
Expand Down
50 changes: 50 additions & 0 deletions test/e2e/tests/fixtures/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
export const STATIC = [
"/",
"/dashboard",
"/faq",
"/profile",
"/new-submission",
"/new-submission/spa",
"/new-submission/spa/medicaid",
"/new-submission/spa/chip",
"/new-submission/waiver",
"/new-submission/waiver/b",
"/new-submission/waiver/b/b4",
"/new-submission/waiver/b/capitated",
"/new-submission/spa/medicaid/landing/medicaid-eligibility",
"/new-submission/waiver/b/capitated/amendment/create",
"/new-submission/waiver/b/capitated/renewal/create",
"/new-submission/waiver/b/capitated/initial/create",
"/new-submission/waiver/b/b4/initial/create",
"/new-submission/waiver/b/b4/amendment/create",
"/new-submission/waiver/b/b4/renewal/create",
"/new-submission/spa/medicaid/create",
"/new-submission/spa/chip/create",
"/new-submission/waiver/app-k",
"/new-submission/waiver/temporary-extensions",
];

export const WEBFORM = [
"/guides/abp",
"/webform/g3/202401",
"/webform/g2b/202401",
"/webform/g2a/202401",
"/webform/g1/202401",
"/webform/cs8/202401",
"/webform/cs3/202401",
"/webform/cs7/202401",
"/webform/abp11/202401",
"/webform/abp10/202401",
"/webform/abp9/202401",
"/webform/abp7/202401",
"/webform/abp6/202401",
"/webform/abp5/202401",
"/webform/abp4/202401",
"/webform/abp3_1/202401",
"/webform/abp3/202401",
"/webform/abp2c/202401",
"/webform/abp2b/202401",
"/webform/abp2a/202401",
"/webform/abp1/202401",
"/webform/abp1/202402",
];
42 changes: 42 additions & 0 deletions test/e2e/tests/perf/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { test } from "@playwright/test";
import * as routes from "../fixtures/routes";

const STATIC_ROUTES = routes.STATIC;

test.describe("test performance on static routes", { tag: ["@perf"] }, () => {
for (const route of STATIC_ROUTES) {
test(`Time to First Byte for ${route}`, { tag: ["@ttfb"] }, async({ page }) => {
await page.goto(route);
const ttfb = await page.evaluate(() => performance.timing.responseStart - performance.timing.requestStart)
console.log(`TTFB for ${route}: ${ttfb} ms`);
});

test(`Largest Contentful Paint for ${route}`, { tag: ["@lcp"] }, async ({ page }) => {
await page.goto(route);
const lcp = await page.evaluate(async () => {
return new Promise((resolve) => {
new PerformanceObserver((entryList) => {
const entries = entryList.getEntries();
resolve(entries[entries.length - 1]);
}).observe({ type: 'largest-contentful-paint', buffered: true });
});
});

console.log(`Largest Contentful Paint for ${route} is: ${lcp.startTime} ms`);
});

test(`First Contentful Paint for ${route}`, { tag: ["@fcp"] }, async ({ page }) => {
await page.goto(route);
const fcp = await page.evaluate(async () => {
return new Promise((resolve) => {
new PerformanceObserver((entryList) => {
const entries = entryList.getEntries();
resolve(entries[0]);
}).observe({ type: 'paint', buffered: true });
});
});

console.log(`First Contentful Paint for ${route} is: ${fcp.startTime} ms`);
});
}
});

0 comments on commit b92334d

Please sign in to comment.