From b5a80f69cb2e2793e5134e23a0eb3e72cdbdbe0b Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Tue, 22 Sep 2026 03:48:12 +0800 Subject: Add multi-source bond quote probe fields and daily fallback (3d-20) --- qa/driver/browser-test.js | 23 +++++++++++++++++++++-- qa/stub/fund-lab-python | 13 ++++++++----- 2 files changed, 29 insertions(+), 7 deletions(-) (limited to 'qa') diff --git a/qa/driver/browser-test.js b/qa/driver/browser-test.js index 401cb78..22385f8 100644 --- a/qa/driver/browser-test.js +++ b/qa/driver/browser-test.js @@ -669,7 +669,7 @@ async function bondsScenario(page) { `quote=${JSON.stringify(quote).slice(0, 160)} result=${resultText.slice(0, 160)}` ); - await page.fill(".bond-code-input", "019547"); + await page.fill(".bond-code-input", "999997"); await page.click(".bond-quote-action"); await page.waitForFunction( () => { @@ -685,7 +685,7 @@ async function bondsScenario(page) { const token = process.env.QA_TOKEN || "qa-token"; const failure = await page.evaluate(async (token) => { - const response = await fetch("/api/market/bond-quote?code=019547", { + const response = await fetch("/api/market/bond-quote?code=999997", { headers: { Authorization: `Bearer ${token}` }, }); let body = null; @@ -705,6 +705,25 @@ async function bondsScenario(page) { `message=${unavailableText.slice(0, 200)} status=${failure.status}` ); + await page.fill(".bond-code-input", "019547"); + await page.click(".bond-quote-action"); + await page.waitForSelector(".bond-quote-result", { timeout: 10000 }); + + const dailyText = ((await page.textContent(".bond-quote-result")) || "").trim(); + const dailyQuote = lastBondQuoteResponse || {}; + + check( + "B3 国债日线路径返回行情日期与净价字符串", + dailyQuote.code === "019547" && + typeof dailyQuote.price === "string" && + dailyQuote.price.length > 0 && + typeof dailyQuote.date === "string" && + dailyQuote.date.length > 0 && + dailyText.includes(dailyQuote.price) && + dailyText.includes(dailyQuote.date), + `quote=${JSON.stringify(dailyQuote).slice(0, 200)}` + ); + await page.screenshot({ path: SHOTS + "/21-bonds.png" }); } diff --git a/qa/stub/fund-lab-python b/qa/stub/fund-lab-python index c9ce981..88372b8 100755 --- a/qa/stub/fund-lab-python +++ b/qa/stub/fund-lab-python @@ -32,13 +32,16 @@ case "$OP" in printf '{"schema_version":"fund-lab.akshare.v1","operation":"nav","source":"stub-synthetic","source_revision":"stub-1","_synthetic":true,"collected_at":"%s","instrument":{"code":"%s"},"observations":[{"nav_date":"2026-09-15","published_at":null,"nav":"1.1000","accumulated_nav":null,"daily_return":null},{"nav_date":"2026-09-16","published_at":null,"nav":"1.1205","accumulated_nav":null,"daily_return":"1.86"},{"nav_date":"2026-09-17","published_at":null,"nav":"1.1180","accumulated_nav":null,"daily_return":"-0.22"},{"nav_date":"2026-09-18","published_at":null,"nav":"1.1500","accumulated_nav":null,"daily_return":"2.86"},{"nav_date":"2026-09-21","published_at":null,"nav":"1.1902","accumulated_nav":null,"daily_return":"3.49"}]}\n' "$TS" "$CODE" ;; bond-quote) - # Synthetic rows mirror the live AKShare convertible-bond spot contract: - # a known live code answers with a name/price, unknown codes fail like the - # "no valid quote" collector error (-> API 503). + # Synthetic rows mirror the live AKShare bond contract: a convertible code + # answers from the spot path (name + price), a treasury-style code answers + # from the daily path (date + clean price, no name), and unknown codes fail + # like the "no valid bond quote" collector error (-> API 503). if [ "$CODE" = "110075" ]; then - printf '{"schema_version":"fund-lab.akshare.v1","operation":"bond-quote","source":"stub-synthetic","source_revision":"stub-1","_synthetic":true,"collected_at":"%s","instrument":{"code":"%s"},"quote":{"name":"南航转债","price":"106.368","maturity_date":"2026-10-15"}}\n' "$TS" "$CODE" + printf '{"schema_version":"fund-lab.akshare.v1","operation":"bond-quote","source":"stub-synthetic","source_revision":"stub-1/hs-cov-spot","_synthetic":true,"collected_at":"%s","instrument":{"code":"%s"},"quote":{"name":"南航转债","price":"106.368","clean_price":"106.368","accrued_interest":null,"date":null,"maturity_date":"2026-10-15"}}\n' "$TS" "$CODE" + elif [ "$CODE" = "019547" ]; then + printf '{"schema_version":"fund-lab.akshare.v1","operation":"bond-quote","source":"stub-synthetic","source_revision":"stub-1/hs-bond-daily","_synthetic":true,"collected_at":"%s","instrument":{"code":"%s"},"quote":{"name":null,"price":"119.858","clean_price":"119.858","accrued_interest":null,"date":"2026-09-21","maturity_date":null}}\n' "$TS" "$CODE" else - echo "AKShare collector failed: no valid quote for $CODE" >&2 + echo "AKShare collector failed: no valid bond quote for $CODE" >&2 exit 2 fi ;; -- cgit v1.2.3