-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
log how long it takes to run the subway scenario
- Loading branch information
1 parent
a26a20f
commit 631bee8
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,48 @@ | ||
const { expect } = require("@playwright/test"); | ||
const Logger = require("node-json-logger"); | ||
const { performance } = require("node:perf_hooks"); | ||
|
||
const logger = new Logger(); | ||
|
||
exports.scenario = async ({ page, baseURL }) => { | ||
const start1 = performance.now(); | ||
await page.goto(`${baseURL}/`); | ||
const end1 = performance.now(); | ||
const duration1 = Math.floor(end1 - start1); | ||
|
||
// We should be able to use down arrow and enter to select the first result. | ||
// But, the enter key does not load the page. So, we have to click the first result. | ||
const start2 = performance.now(); | ||
await page | ||
.locator("div.search-wrapper input#input") | ||
.pressSequentially("Green Line"); | ||
const end2 = performance.now(); | ||
const duration2 = Math.floor(end2 - start2); | ||
|
||
const start3 = performance.now(); | ||
await page.waitForSelector("ul#algolia-list"); | ||
await page.locator("ul#algolia-list li:first-child a").click(); | ||
const end3 = performance.now(); | ||
const duration3 = Math.floor(end3 - start3); | ||
|
||
const start4 = performance.now(); | ||
await expect(page.locator("h1.schedule__route-name")).toHaveText( | ||
"Green Line", | ||
); | ||
await page.waitForSelector("li.m-schedule-diagram__stop"); | ||
await expect | ||
.poll(async () => page.locator("li.m-schedule-diagram__stop").count()) | ||
.toBeGreaterThan(1); | ||
const end4 = performance.now(); | ||
const duration4 = Math.floor(end4 - start4); | ||
|
||
const start5 = performance.now(); | ||
await page.locator("a.alerts-tab").click(); | ||
await expect( | ||
page.getByRole("heading", { name: "Alerts", exact: true }), | ||
).toBeVisible(); | ||
const end5 = performance.now(); | ||
const duration5 = Math.floor(end5 - start5); | ||
|
||
logger.info([duration1, duration2, duration3, duration4, duration5]); | ||
}; |