feat: persist heaven readings in unified dialog
This commit is contained in:
@@ -144,6 +144,19 @@ async function mockApplication(page, authSession = session()) {
|
||||
}],
|
||||
summary: { total: 1, observed: 1, t1_win_rate: 100, t5_win_rate: null, average_t5: null },
|
||||
};
|
||||
} else if (url.pathname === "/api/heaven/readings") {
|
||||
payload = {
|
||||
mode: url.searchParams.get("mode") || "fortune",
|
||||
items: [{
|
||||
id: 31,
|
||||
mode: "fortune",
|
||||
context_date: "20260723",
|
||||
subject: "2026-07-23 观气",
|
||||
subject_detail: "丙午年 · 乙未月 · 己丑日 · 土气偏显",
|
||||
answer: "三层气机已经合参,今日宜先定节奏,再看行动。",
|
||||
created_at: "2026-07-23T09:12:00+08:00",
|
||||
}],
|
||||
};
|
||||
} else if (url.pathname === "/api/mentors/setup") payload = { trade_date: "20260722", mentors: [] };
|
||||
else if (url.pathname === "/api/heaven/setup") {
|
||||
await route.fulfill({ status: 503, contentType: "application/json", body: JSON.stringify({ error: "测试环境不加载问天数据" }) });
|
||||
@@ -214,6 +227,37 @@ test("stock hover preview ignores the selected historical date", async ({ page }
|
||||
await expect(page.locator("#stockPreviewName")).toHaveText("Test Stock");
|
||||
});
|
||||
|
||||
test("saved daily fortune opens in the reading dialog without regenerating", async ({ page }) => {
|
||||
await mockApplication(page, session("user", true));
|
||||
await page.goto("/index.html");
|
||||
await page.locator('[data-view="heavenView"]').first().click();
|
||||
await page.locator('[data-heaven-panel="fortune"]').click();
|
||||
await page.evaluate(() => {
|
||||
state.heavenSetup = { field: {}, chart: { available: true } };
|
||||
state.heavenInterpretations.fortune = {
|
||||
id: 31,
|
||||
mode: "fortune",
|
||||
context_date: "20260723",
|
||||
subject: "2026-07-23 观气",
|
||||
subject_detail: "丙午年 · 乙未月 · 己丑日 · 土气偏显",
|
||||
answer: "三层气机已经合参,今日宜先定节奏,再看行动。",
|
||||
created_at: "2026-07-23T09:12:00+08:00",
|
||||
};
|
||||
updateHeavenInterpretationControls();
|
||||
});
|
||||
await expect(page.locator("#interpretFortuneButton")).toHaveText("已解运");
|
||||
const interpretRequests = [];
|
||||
page.on("request", (request) => {
|
||||
if (request.url().includes("/api/heaven/interpret")) interpretRequests.push(request.url());
|
||||
});
|
||||
await page.locator("#interpretFortuneButton").click();
|
||||
await expect(page.locator("#heavenReadingDialog")).toBeVisible();
|
||||
await expect(page.locator("#heavenReadingAnswer")).toContainText("今日宜先定节奏");
|
||||
expect(interpretRequests).toHaveLength(0);
|
||||
await page.locator('[data-heaven-reading-tab="history"]').click();
|
||||
await expect(page.locator("#heavenReadingHistoryList .heaven-reading-history-item")).toHaveCount(1);
|
||||
});
|
||||
|
||||
test("mobile shell stays within the viewport", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 375, height: 812 });
|
||||
await mockApplication(page, session("user", true));
|
||||
@@ -280,6 +324,21 @@ for (const viewport of [
|
||||
const dialogWidth = await page.locator("#tradeLogDialog").evaluate((dialog) => dialog.getBoundingClientRect().width);
|
||||
expect(dialogWidth).toBeLessThanOrEqual(viewport.width);
|
||||
await page.locator("#closeTradeLogDialog").click();
|
||||
await page.evaluate(() => {
|
||||
state.heavenInterpretations.fortune = {
|
||||
id: 31,
|
||||
subject: "2026-07-23 观气",
|
||||
subject_detail: "丙午年 · 乙未月 · 己丑日",
|
||||
answer: "当日解运结果",
|
||||
context_date: "20260723",
|
||||
created_at: "2026-07-23T09:12:00+08:00",
|
||||
};
|
||||
openHeavenReading("fortune", { loading: false });
|
||||
});
|
||||
await expect(page.locator("#heavenReadingDialog")).toBeVisible();
|
||||
const readingWidth = await page.locator("#heavenReadingDialog").evaluate((dialog) => dialog.getBoundingClientRect().width);
|
||||
expect(readingWidth).toBeLessThanOrEqual(viewport.width);
|
||||
await page.locator("#closeHeavenReadingDialog").click();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user