diff options
Diffstat (limited to 'qa/driver/browser-test.js')
| -rw-r--r-- | qa/driver/browser-test.js | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/qa/driver/browser-test.js b/qa/driver/browser-test.js index 4a4b799..6403dc5 100644 --- a/qa/driver/browser-test.js +++ b/qa/driver/browser-test.js @@ -25,6 +25,7 @@ let createdFundResponse = null; let lastOrdersResponse = null; let lastConfirmResponse = null; let lastRedemptionConfirmResponse = null; +let lastReturnsResponse = null; function check(name, ok, detail) { results.push({ name, ok, detail: detail || "" }); @@ -103,7 +104,7 @@ async function summaryLabelExists(page, label, name) { if (!createdFundResponse) createdFundResponse = await r.json(); } catch {} } - if (r.url().includes("/api/funds/") && !r.url().includes("/orders") && r.request().method() === "GET" && r.status() < 400) fundGets++; + if (/\/api\/funds\/[0-9a-f-]{36}$/i.test(new URL(r.url()).pathname) && r.request().method() === "GET" && r.status() < 400) fundGets++; if (r.url().includes("/api/funds/") && r.url().includes("/orders") && r.request().method() === "GET" && r.status() < 400) { orderGets++; try { @@ -129,6 +130,11 @@ async function summaryLabelExists(page, label, name) { lastPositionsResponse = await r.json(); } catch {} } + if (r.url().includes("/returns") && r.request().method() === "GET" && r.status() < 400) { + try { + lastReturnsResponse = await r.json(); + } catch {} + } if (r.status() >= 400 && !/\/api\/instruments\//.test(r.url()) && !/\/orders/.test(r.url()) && !/\/redemptions/.test(r.url()) && !/\/capital/.test(r.url())) { consoleErrors.push("resource " + r.status() + ": " + r.url()); } @@ -175,6 +181,7 @@ async function summaryLabelExists(page, label, name) { await redeemScenario(page); await capitalScenario(page); await dividendScenario(page); + await returnsScenario(page); } finally { check("G1 无浏览器控制台/页面错误", consoleErrors.length === 0, consoleErrors.slice(0, 3).join(" | ")); await browser.close(); @@ -411,6 +418,51 @@ async function dividendScenario(page) { await page.screenshot({ path: SHOTS + "/15-dividend-history.png" }); } +async function returnsScenario(page) { + // R 系列: 收益与资产曲线(接 L 场景:现金 5442.99,持仓 50.00000000 @1.1902 = 59.51) + await page.waitForSelector(".returns-panel", { timeout: 10000 }); + const eyebrow = ((await page.textContent(".returns-panel .eyebrow")) || "").trim(); + check("R1 收益面板 eyebrow 为 10 / RETURNS", eyebrow === "10 / RETURNS", eyebrow); + + lastReturnsResponse = null; + await page.click(".returns-refresh-action"); + for (let i = 0; i < 200 && lastReturnsResponse === null; i++) { + await page.waitForTimeout(100); + } + const returns = lastReturnsResponse || {}; + const points = Array.isArray(returns.points) ? returns.points : []; + const last = points.length > 0 ? points[points.length - 1] : {}; + check( + "R2 收益接口返回现金流调整后的总资产与累计收益", + returns.pending === false && + last.date === "2026-09-21" && + last.totalAssets === "5502.50" && + last.cumulativeReturn === "2.50" && + last.cash === "5442.99" && + last.holdingsValue === "59.51" && + typeof last.unitNav === "string" && + last.unitNav.length > 0, + JSON.stringify(returns).slice(0, 280) + ); + + await page.waitForSelector(".returns-panel .metric-strip", { timeout: 15000 }); + const metricText = ((await page.textContent(".returns-panel .metric-strip")) || ""); + const noteText = ((await page.textContent(".returns-panel .returns-note")) || ""); + const markers = await page.locator(".returns-chart circle").count(); + check( + "R3 收益卡片与 API 一致、图表有点且不补零", + metricText.includes("总资产") && + metricText.includes("5502.50") && + metricText.includes("累计收益") && + metricText.includes("2.50") && + metricText.includes("数据更新时间") && + markers >= 1 && + noteText.includes("不补零"), + `metrics=${metricText.slice(0, 160)} markers=${markers}` + ); + await page.screenshot({ path: SHOTS + "/16-returns-curve.png" }); +} + const failed = results.filter((r) => !r.ok); console.log(`\n==== ${results.length - failed.length}/${results.length} passed ====`); process.exit(failed.length > 0 ? 1 : 0); |
