From 73735767bb1a732f77a05f648dcf99f175f05be8 Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Tue, 3 Nov 2026 14:37:38 +0700 Subject: [PATCH] test(smoke): live cases for the Stockbit session (orderbook, actions, calendar) Run only when `idx stockbit status` reports a session. They keep the user's real config directory, which holds the session: an isolated copy would refresh on its own and spend the user's rotating refresh token. Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- scripts/live-smoke.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/scripts/live-smoke.sh b/scripts/live-smoke.sh index 7281509..026911f 100755 --- a/scripts/live-smoke.sh +++ b/scripts/live-smoke.sh @@ -71,10 +71,14 @@ LOG_DIR="$WORKDIR/logs" COMMON_ENV=("IDX_PROVIDER=msn" "IDX_HISTORY_PROVIDER=auto" "IDX_NO_COLOR=1") # Each binary gets its own config, cache, and data so both really fetch. +# Stockbit session cases keep the user's real config directory, which holds +# the session: a copy would refresh on its own and spend the user's rotating +# refresh token, while the real file is shared under its lock. +REAL_CONFIG=0 side_env() { local home="$WORKDIR/$1" - printf '%s\n' "XDG_CONFIG_HOME=$home/config" "XDG_CACHE_HOME=$home/cache" \ - "XDG_DATA_HOME=$home/data" "${COMMON_ENV[@]}" + (( REAL_CONFIG )) || printf '%s\n' "XDG_CONFIG_HOME=$home/config" + printf '%s\n' "XDG_CACHE_HOME=$home/cache" "XDG_DATA_HOME=$home/data" "${COMMON_ENV[@]}" } # Values of these commands should not move between two back-to-back runs. @@ -128,6 +132,10 @@ contract() { echo '(.highlights | type == "array") and (.risks | type == "array")' ;; "stocks news "*) echo 'type == "array" and all(.[]; (.title | type == "string") and (.url | type == "string"))' ;; + "stocks orderbook "*) + echo '(.symbol | type == "string") and (.price | type == "number") and (.market_status | type == "string") and (.bids | type == "array") and (.offers | type == "array")' ;; + "stocks actions "*|"stocks calendar"*) + echo 'type == "array" and length > 0 and all(.[]; (.symbol | type == "string") and (.kind | type == "string") and (.date | type == "string"))' ;; "stocks broker "*) echo '(.symbol | type == "string") and (.buyers | length > 0) and (.sellers | length > 0) and all(.buyers[]; (.code | type == "string") and (.value | type == "number")) and (.total_value | type == "number")' ;; "stocks bandar "*) @@ -253,6 +261,16 @@ if selected stockbit; then run_new_case intraday "stocks intraday $SYMBOL" run_new_case intraday-index "stocks intraday ^JKSE" run_new_case quote-stockbit "--provider stockbit stocks quote $SYMBOL" + # With the user's own session (`idx stockbit login`), if there is one. + if (( DRY_RUN )) || "${BIN_PATH:-idx}" -o json stockbit status 2>/dev/null | jq -e '.logged_in' >/dev/null; then + REAL_CONFIG=1 + run_new_case orderbook "stocks orderbook $SYMBOL --depth 5" + run_new_case actions "stocks actions $SYMBOL --kind dividend,split" + run_new_case calendar "stocks calendar --kind dividend,rights" + REAL_CONFIG=0 + else + echo " no Stockbit session: orderbook, actions and calendar not run" + fi fi if selected ownership; then