文件
hyb-oa/scripts/qa/run-p2-fin-live-window.sh
T
wangsli 37b4ef2d10
ci-e2e / e2e (push) Canceled after 0s
ci-minimal / check-minimal (push) Canceled after 0s
恢复付款入口与常开基线(08-01-reimbursement-notification-progress-clarity)
2026-08-01 23:12:23 +08:00

114 行
4.5 KiB
Bash
可执行文件

#!/usr/bin/env bash
set -u -o pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
CLIENT_DIR="$ROOT_DIR/client"
PUBLIC_BASE_URL="${LIVE_SMOKE_BASE_URL:-https://oa.hyinda.com}"
REPORT_DIR="${P2_FIN_LIVE_REPORT_DIR:-$ROOT_DIR/artifacts/qa-flow/p2-fin-live-$(date +%Y%m%d-%H%M%S)}"
SUMMARY_TXT="$REPORT_DIR/summary.txt"
FLAG_SNAPSHOT_FILE="$REPORT_DIR/payment-batch-flag-before.json"
STATUS=0
ALREADY_ON_MODE=0
mkdir -p "$REPORT_DIR"
: >"$SUMMARY_TXT"
load_default_env() {
local env_file="${P2_FIN_LIVE_ENV_FILE:-$HOME/.hyb-oa/live-smoke.env}"
if [[ "${P2_FIN_LIVE_SKIP_ENV_FILE:-0}" == "1" || ! -f "$env_file" ]]; then
return 0
fi
set -a
# shellcheck disable=SC1090
source "$env_file"
set +a
PUBLIC_BASE_URL="${LIVE_SMOKE_BASE_URL:-$PUBLIC_BASE_URL}"
echo "[p2-fin-live] loaded masked env file" | tee -a "$SUMMARY_TXT"
}
run_step() {
local name="$1"
shift
local log_file="$REPORT_DIR/${name}.log"
echo ">>> [p2-fin-live] $name" | tee -a "$SUMMARY_TXT"
if "$@" > >(tee "$log_file") 2>&1; then
echo "[p2-fin-live][PASS] $name" | tee -a "$SUMMARY_TXT"
else
local code="$?"
echo "[p2-fin-live][FAIL] $name exit=$code" | tee -a "$SUMMARY_TXT"
STATUS=1
fi
}
run_shell_step() {
local name="$1"
local command="$2"
run_step "$name" bash -lc "$command"
}
restore_payment_batch_flag_snapshot() {
P2_FIN_LIVE_APPROVED=1 LIVE_SMOKE_BASE_URL="$PUBLIC_BASE_URL" \
node "$ROOT_DIR/scripts/qa/payment-batch-flag-snapshot.mjs" restore \
--snapshot-file "$FLAG_SNAPSHOT_FILE"
}
write_summary_json() {
local qa_status="PASS"
if [[ "$STATUS" -ne 0 ]]; then
qa_status="FAIL"
fi
QA_REPORT_DIR="$REPORT_DIR" \
QA_ISSUE_ID="${QA_ISSUE_ID:-P2FLIVE}" \
QA_BASE_URL="$PUBLIC_BASE_URL" \
QA_MODE="p2-fin-live-window" \
QA_STATUS="$qa_status" \
QA_SUMMARY_NOTES="${QA_ISSUE_ID:-P2FLIVE} 公网短窗口:临时启用 payment_batch_v1,结束后恢复调用前完整快照;不部署、不接真实支付、不开放图片 OCR。" \
node "$ROOT_DIR/scripts/qa/write-qa-summary.mjs" >/dev/null 2>&1 || true
}
finish() {
if [[ "${P2_FIN_LIVE_APPROVED:-0}" == "1" && -f "$FLAG_SNAPSHOT_FILE" ]]; then
echo ">>> [p2-fin-live] restore-caller-flag-snapshot" | tee -a "$SUMMARY_TXT"
if restore_payment_batch_flag_snapshot > >(tee "$REPORT_DIR/restore-caller-flag-snapshot.log") 2>&1; then
echo "[p2-fin-live][PASS] restore-caller-flag-snapshot" | tee -a "$SUMMARY_TXT"
else
local code="$?"
echo "[p2-fin-live][FAIL] restore-caller-flag-snapshot exit=$code" | tee -a "$SUMMARY_TXT"
STATUS=1
fi
fi
write_summary_json
echo "[p2-fin-live] report=$REPORT_DIR" | tee -a "$SUMMARY_TXT"
exit "$STATUS"
}
trap finish EXIT
load_default_env
if [[ "${P2_FIN_LIVE_APPROVED:-0}" != "1" ]]; then
echo "[p2-fin-live][ERROR] P2_FIN_LIVE_APPROVED=1 is required for public write test" | tee -a "$SUMMARY_TXT"
STATUS=2
exit "$STATUS"
fi
run_shell_step "live-env-strict" "LIVE_SMOKE_BASE_URL='$PUBLIC_BASE_URL' node '$ROOT_DIR/scripts/qa/check-live-smoke-env.mjs' --strict"
[[ "$STATUS" -eq 0 ]] || exit "$STATUS"
run_shell_step "capture-caller-flag-snapshot" "P2_FIN_LIVE_APPROVED=1 LIVE_SMOKE_BASE_URL='$PUBLIC_BASE_URL' node '$ROOT_DIR/scripts/qa/payment-batch-flag-snapshot.mjs' capture --snapshot-file '$FLAG_SNAPSHOT_FILE'"
[[ "$STATUS" -eq 0 ]] || exit "$STATUS"
ALREADY_ON_MODE="$(node -e 'const snapshot = require(process.argv[1]); process.stdout.write(snapshot.effectiveEnabled === true ? "1" : "0")' "$FLAG_SNAPSHOT_FILE")"
run_shell_step "p2-fin-live-spec" "cd '$CLIENT_DIR' && PLAYWRIGHT_MANUAL=1 E2E_MODE=live P2_FIN_LIVE_APPROVED=1 P2_FIN_LIVE_FINAL_STATE=restore P2_FIN_LIVE_ALREADY_ON='$ALREADY_ON_MODE' QA_ISSUE_ID='${QA_ISSUE_ID:-P2FLIVE}' P2_FIN_LIVE_MARKER_PREFIX='${P2_FIN_LIVE_MARKER_PREFIX:-${QA_ISSUE_ID:-P2FLIVE}}' P2_FIN_LIVE_REPORT_DIR='$REPORT_DIR' LIVE_SMOKE_BASE_URL='$PUBLIC_BASE_URL' npx playwright test tests/e2e/manual/p2-fin-live-payment-batch.spec.ts --workers=1 --reporter=list"
if [[ "${P2_FIN_LIVE_SKIP_MOBILE:-0}" == "1" ]]; then
echo "[p2-fin-live][SKIP] mobile-wecom P2_FIN_LIVE_SKIP_MOBILE=1" | tee -a "$SUMMARY_TXT"
else
run_shell_step "public-mobile-matrix" "cd '$CLIENT_DIR' && E2E_BASE_URL='$PUBLIC_BASE_URL' npx playwright test tests/e2e/dg7-mobile-information-dedupe.spec.ts tests/e2e/r124-mobile-entry-matrix.spec.ts --workers=1 --reporter=list"
run_shell_step "wecom-rendering-matrix" "cd '$CLIENT_DIR' && E2E_BASE_URL='$PUBLIC_BASE_URL' npx playwright test tests/e2e/r6-wecom-mobile-rendering-hardening.spec.ts --workers=1 --reporter=list"
fi