feat: add contextual heaven loading rituals
This commit is contained in:
@@ -340,6 +340,48 @@ test("saved daily fortune opens in the reading dialog without regenerating", asy
|
||||
await expect(page.locator("#heavenReadingHistoryList .heaven-reading-history-item")).toHaveCount(1);
|
||||
});
|
||||
|
||||
test("heaven reading loading uses the matching canvas scene and stops cleanly", async ({ page }) => {
|
||||
await mockApplication(page, session("user", true));
|
||||
await page.goto("/index.html");
|
||||
const cases = [
|
||||
["trend", "hexagram"],
|
||||
["fortune", "fortune"],
|
||||
["heart", "hexagram"],
|
||||
];
|
||||
for (const [mode, scene] of cases) {
|
||||
await page.evaluate(([readingMode]) => openHeavenReading(readingMode, { loading: true }), [mode]);
|
||||
const canvas = page.locator("#heavenReadingCanvas");
|
||||
await expect(canvas).toBeVisible();
|
||||
await expect(canvas).toHaveAttribute("data-scene", scene);
|
||||
await expect(canvas).toHaveAttribute("data-running", "true");
|
||||
await page.waitForTimeout(180);
|
||||
const pixels = await canvas.evaluate((element) => {
|
||||
const context = element.getContext("2d");
|
||||
const data = context.getImageData(0, 0, element.width, element.height).data;
|
||||
const colors = new Set();
|
||||
const step = Math.max(4, Math.floor(data.length / 1200 / 4) * 4);
|
||||
for (let index = 0; index < data.length; index += step) {
|
||||
colors.add(`${data[index]},${data[index + 1]},${data[index + 2]},${data[index + 3]}`);
|
||||
}
|
||||
return { width: element.width, height: element.height, colors: colors.size };
|
||||
});
|
||||
expect(pixels.width).toBeGreaterThan(300);
|
||||
expect(pixels.height).toBeGreaterThan(300);
|
||||
expect(pixels.colors).toBeGreaterThan(3);
|
||||
if (mode === "trend") {
|
||||
const completionMs = await page.evaluate(async () => {
|
||||
const started = performance.now();
|
||||
await heavenReadingAnimation.complete();
|
||||
return performance.now() - started;
|
||||
});
|
||||
expect(completionMs).toBeLessThan(1000);
|
||||
await expect(canvas).toHaveAttribute("data-running", "false");
|
||||
}
|
||||
await page.locator("#closeHeavenReadingDialog").click();
|
||||
await expect(canvas).toHaveAttribute("data-running", "false");
|
||||
}
|
||||
});
|
||||
|
||||
test("heart breathing prepares once then contracts on each exhale", async ({ page }) => {
|
||||
await mockApplication(page, session("user", true));
|
||||
await page.goto("/index.html");
|
||||
|
||||
Reference in New Issue
Block a user