-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreenshots.spec.ts
52 lines (43 loc) · 1.35 KB
/
screenshots.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { expect, test } from "@playwright/test";
import mapsConfig from "./config.maps";
import userConfig from "./config";
import { existsSync } from "node:fs";
const sysConfig = {
testTimeout: 30_000,
mapTimeout: 15_000,
};
for (const [name, posAngle] of Object.entries(mapsConfig)) {
if (["", "todo"].includes(posAngle.toLowerCase())) {
continue;
}
test(`#${name}#`, async ({ page }) => {
const destPath = `./dist/${name}.jpg`;
test.skip(
userConfig.skipExisting && existsSync(destPath),
"Screenshot already exists",
);
test.setTimeout(sysConfig.testTimeout);
await test.step("load FTE", async () => {
await page.setViewportSize({
width: userConfig.width,
height: userConfig.height,
});
await page.goto(`http://localhost:5173?map=${name}&posangle=${posAngle}`);
await expect(page.locator("#fteEngineIsReady")).toBeAttached();
});
const fte = page.locator("#fteCanvas");
await test.step("set pos/angle", async () => {
await expect(page.locator("#fteShotIsReady")).toBeAttached({
timeout: sysConfig.mapTimeout,
});
});
await test.step("save screenshot", async () => {
await fte.screenshot({
animations: "disabled",
path: destPath,
quality: userConfig.jpegQuality,
type: "jpeg",
});
});
});
}