fix: keep stock previews current and clarify member access
This commit is contained in:
@@ -53,7 +53,17 @@ async function mockApplication(page, authSession = session()) {
|
||||
let payload = { ok: true };
|
||||
if (url.pathname === "/api/auth/me") payload = authSession;
|
||||
else if (url.pathname === "/api/dashboard") payload = dashboard;
|
||||
else if (url.pathname === "/api/watchlist" || url.pathname === "/api/notes") payload = { items: [] };
|
||||
else if (url.pathname === "/api/stock/002141/preview") {
|
||||
payload = {
|
||||
meta: { trade_date: "2026-07-23", realtime: false, intraday_notice: "" },
|
||||
stock: { code: "002141", name: "Test Stock", industry: "Test Sector", price: 10.8, change: 2.4 },
|
||||
prices: [
|
||||
{ trade_date: "2026-07-22", open: 10, high: 10.5, low: 9.9, close: 10.2, volume: 1000 },
|
||||
{ trade_date: "2026-07-23", open: 10.3, high: 10.9, low: 10.2, close: 10.8, volume: 1200 },
|
||||
],
|
||||
intraday: [],
|
||||
};
|
||||
} else if (url.pathname === "/api/watchlist" || url.pathname === "/api/notes") payload = { items: [] };
|
||||
else if (url.pathname === "/api/alerts") {
|
||||
payload = {
|
||||
items: [{
|
||||
@@ -180,6 +190,23 @@ test("regular account cannot see admin controls and member features are gated",
|
||||
await page.locator('[data-view="screenerView"]').first().click();
|
||||
await expect(page.locator("#screenerView .member-gate")).toBeVisible();
|
||||
await expect(page.locator("#screenerRunButton")).toBeDisabled();
|
||||
await page.locator("#assistantButton").click();
|
||||
await expect(page.locator("#settingsDialog")).toBeVisible();
|
||||
await expect(page.locator("#membershipAccessNotice")).toHaveText("复盘助手仅对会员开放");
|
||||
await expect(page.locator("#membershipAccessNotice")).toBeVisible();
|
||||
});
|
||||
|
||||
test("stock hover preview ignores the selected historical date", async ({ page }) => {
|
||||
await mockApplication(page, session("user", true));
|
||||
await page.goto("/index.html");
|
||||
await page.locator("#tradeDate").fill("2026-07-01");
|
||||
const requestPromise = page.waitForRequest((request) => request.url().includes("/api/stock/002141/preview"));
|
||||
await page.evaluate(() => showStockPreview("002141", document.querySelector("#globalSearchButton")));
|
||||
const request = await requestPromise;
|
||||
const requestUrl = new URL(request.url());
|
||||
expect(requestUrl.searchParams.has("trade_date")).toBe(false);
|
||||
await expect(page.locator("#stockPreviewDate")).toHaveText("2026-07-23");
|
||||
await expect(page.locator("#stockPreviewName")).toHaveText("Test Stock");
|
||||
});
|
||||
|
||||
test("mobile shell stays within the viewport", async ({ page }) => {
|
||||
|
||||
Reference in New Issue
Block a user