fix(ci): isolate layout persistence, accept a detached HEAD, auth the aggregate lane

editor-host cases share one localStorage: setSession hydrates the previous case's layout for the same session id, so a persisted treeOpen:false decided whether the next case mounted its tree at all (the two Windows-lane failures). The file now clears it and the tree-seam call counters per test. smoke.spec asserted a branch name in a PR checkout, where HEAD is detached: it now compares git's own symbolic ref and status.detached. The aggregate lane exchanges its launch token for a signature cookie before probing /sidebar/api, because the plugin's native connection admission authenticates; the token is never echoed (redacted in the failure tail).
This commit is contained in:
hairyf committed 2026-10-13 23:13:07 +08:00
1 parent 4e1056fe66
commit aae39e49ca
4 files changed
+94 -12

No files matched your search

+12 -9
View File
@@ -89,19 +89,22 @@ $DSH_CMD plugin --profile web add "file:$TARBALL"
say "启动 dsh web(--port ${PORT},日志 ${LOG_DIR})…"
e2e_start_dsh_web "$OUT_LOG" "$ERR_LOG"
# 等待启动 URL 或进程退出(最多 120s)。这里有意只取 origin:0.1.2-alpha.1+
# 的就绪行是 `…/?token=<43字符>` 鉴权 URL,但下方的探活全部打插件的
# /sidebar/api/* 路由——webserver carrier 不做鉴权(只有 /api、index 与
# remote.mux 升级在 browser auth 之后),origin 拼路径即正确且两版通用。
E2E_READY_RE='http://127\.0\.0\.1:[0-9]+'
# 等待完整启动 URL(保留 token);插件的 native Connection admission 也要
# 鉴权。先用启动 URL 兑换 cookie,再以 origin 拼 API 路径,绝不打印 token。
E2E_READY_RE='dsh web: http://127\.0\.0\.1:[0-9]+[^ ]*'
E2E_READY_PICK=tail
e2e_wait_dsh_web_ready "$OUT_LOG" || true
if [ -z "$URL" ]; then
warn "out log 尾部:$(tail -5 "$OUT_LOG" 2>/dev/null || true)"
warn "err log 尾部:$(tail -5 "$ERR_LOG" 2>/dev/null || true)"
warn "out log 尾部:$(tail -5 "$OUT_LOG" 2>/dev/null | sed -E 's/([?&]token=)[^&[:space:]]+/\1[redacted]/g' || true)"
warn "err log 尾部:$(tail -5 "$ERR_LOG" 2>/dev/null | sed -E 's/([?&]token=)[^&[:space:]]+/\1[redacted]/g' || true)"
die "dsh web 未在 120s 内启动"
fi
LAUNCH_URL="$URL"
URL="${LAUNCH_URL%%/\?*}"
say "已启动:$URL"
COOKIE_JAR="$SCRATCH/auth.cookies"
# curl 默认不跟随 303;cookie jar 在既有 scratch/trap 清理范围内。
curl -fsS --cookie-jar "$COOKIE_JAR" -o /dev/null "$LAUNCH_URL" || die "启动 token 兑换失败"
# ── 断言 ────────────────────────────────────────────────────────────────────
if grep -q "duplicate prefix route" "$ERR_LOG" "$OUT_LOG" 2>/dev/null; then
@@ -113,13 +116,13 @@ fi
# 的理由:/sidebar/api 是插件自己 fence 的 prefix 路由,未注册的方法统统 404,
# 所以 {"ok":true} 只可能来自插件真实注册的 handler —— generic missing-route
# 404 无法冒充(P2: Probe a real sidebar API method)。
RESP="$(curl -s -X POST "$URL/sidebar/api/settings.get" 2>/dev/null || true)"
RESP="$(curl -s --cookie "$COOKIE_JAR" -X POST "$URL/sidebar/api/settings.get" 2>/dev/null || true)"
if ! printf '%s' "$RESP" | grep -q '"ok":true'; then
die "/sidebar/api/settings.get 未返回 ok:true(响应:$(printf '%s' "$RESP" | head -c 200))"
fi
say "/sidebar/api/settings.get → ok:true(真实 handler 存活)"
STATUS="$(curl -s -o /dev/null -w '%{http_code}' -X POST "$URL/sidebar/api/__e2e_unknown__" 2>/dev/null || true)"
STATUS="$(curl -s --cookie "$COOKIE_JAR" -o /dev/null -w '%{http_code}' -X POST "$URL/sidebar/api/__e2e_unknown__" 2>/dev/null || true)"
say "/sidebar/api POST 未知方法 → HTTP ${STATUS}(期望 404)"
[ "$STATUS" = "404" ] || die "/sidebar/api 未知方法未按预期返回 404(HTTP ${STATUS})"