Repository navigation
test(app-shell): 同步 pseudoRouteSegments 里的第二份 MetadataRedirectStub,并用整链断言钉住 (#3669) - #3691
Merged
Merged
Conversation
…整链断言钉住 (#3669) 第二份 MetadataRedirectStub 自称逐字转录宿主 MetadataRedirect,但 #3658 把宿主 改为直接构造 canonical `…/metadata/:type` 后未同步,仍构造已废弃的 `component/metadata/resource?type=` 别名。被它喂的两条 `system/metadata/*` 用例 因此在测一条生产中已不存在的两跳链,却始终是绿的 —— 断言只钉终点,而终点在 一跳与两跳下逐字节相同。 - stub 按 7883c02 后的宿主实现逐字同步(可执行代码经机器比对逐字节一致); - LocationProbe 升级为链记录器,renderConsoleAt 返回整条重定向链; - 两条受影响用例从 it.each 表中提出为独立 it,改断整条链(原有断言全部保留)。 #3638 落的输入面回归断言与近似段族断言一行未动。测试-only,无 changeset。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3669
前提复核(先证实,再动手)
issue 正文在最新
origin/main(e98702190,已含 PR #3671)上逐条命中,前提成立:packages/app-shell/src/console/__tests__/AppContent.pseudoRouteSegments.test.tsx:218-233的第二份MetadataRedirectStub,docblock 自称 "VERBATIM transcription … Keep the regex and the target construction identical to the original",target 构造仍是别名拼法;apps/console/src/AppContent.tsx:88-102的MetadataRedirect自7883c0250(PR fix(console): 宿主重定向直发规范 metadata 路由,不再绕已废弃的 component/metadata 别名 (#3639) #3658)起已改为直接构造…/metadata/:type[/:name];前置条件也实测过:PR #3671(第一份 stub 的同步,本单的直接模板)已落 main(
e98702190),手法照抄。失真是实测出来的
动手前先只给
LocationProbe加链记录、不动 stub,把五条链打了出来(用一条必失败的断言让 vitest 把实际数组打进 diff — 该仓 reporter 吞console.log):/apps/ghost/system/metadata/object[system/metadata/object, **component/metadata/resource?type=object**, metadata/object]/apps/setup/system/metadata/object[system/metadata/object, **component/metadata/resource?type=object**, metadata/object]/apps/ghost/component/metadata/resource?type=datasource[component/metadata/resource?type=datasource, metadata/datasource]/apps/ghost/component/metadata/directory[component/metadata/directory, metadata]/apps/setup/component/metadata/resource?type=datasource[component/metadata/resource?type=datasource, metadata/datasource]两点确认:链记录器确实能看到中间站(否则后面的逆向验证就是空壳);issue 点名的两条都在测两跳链,且中间站正是已废弃的别名。
顺带一条比 issue 正文多出来的事实:本文件里 stub 的另外两条臂从未被执行过 —— 没有任何用例走
system/metadata(typeless)或system/metadata/:type/:name,所以只有metadataType && !itemName这一条臂在跑,跑了两次。改了什么
1. stub 同步(逐字转录恢复为真)
机器比对过(剥掉注释后
diff):同步后 stub 函数体与宿主MetadataRedirect函数体可执行代码逐字节一致,唯一差异是宿主多带的三行注释(那三行 stub 改前也没有)。docblock 改为注明转录对象、出处 commit(
7883c0250/ #3658),并明说「逐字」是一句需要持续兑现的声明 —— 它在7883c0250到本单之间就是假的。2. 整链断言(防复发)
LocationProbe升级为链记录器,renderConsoleAt返回整条链。这是必要的:旧断言只钉最终 pathname(setup 那条连 pathname 都不钉,只钉 testid),而一跳与两跳的终点逐字节相同,所以 stub 失真时没有任何断言会红。3. 两条受影响用例提为独立
it两条都原本是
it.each表里的行,而共享的表体只能钉终点,钉不了跳数。所以把这两行提出来,写成独立it并断言整条链 —— 原有断言一条不少地保留(data-active-app为crm、无app-not-available-retry、pathname),再加上整链与「链中不含component/metadata」。表里其余 11 行 + 4 行、以及 #3638 落的近似段族断言一行未动(见 diff:全文件只有这两行被移除)。
覆盖清点
stub 改直达后,这两条用例不再顺路经过 with-app 分支的
component/metadata/resource/*(packages/app-shell/src/console/AppContent.tsx:792)。清点结果:没有任何路由因此失去全仓唯一覆盖,不需要补用例。AppContent.tsx:792component/metadata/resource/*:337(/apps/ghost/…?type=datasource)与 setup 家族表(/apps/setup/…?type=datasource)—— 两条都直接进入别名,不经 stubAppContent.tsx:791component/metadata/directory:338(/apps/ghost/component/metadata/directory),直接进入;且该路由本就没有经过 stub 的覆盖 —— stub 的 typeless 臂在本文件从未被执行AppContent.tsx:663component/metadata/resource/*/apps/setup/…?type=datasource(metadataApps = [])AppContent.tsx:662component/metadata/directoryAppContent.noAppComponentRoutes.test.tsx)这与 #3661 的处境不同,原因 issue 的⚠️ 说对了:那边零应用分支的 directory 别名只有 stub 的 typeless 臂在跑,所以 #3671 必须补一条接住;本文件对应的别名覆盖全部来自直接进入的用例,stub 是否途经它们都不影响。
逆向验证(先预测,后运行)
预测:只把 stub 的 target 构造回退成别名(docblock 与断言保持不动),应当恰好两条用例转红 —— 即新提出的两条 host-rewrite 用例;红的形态应为链正中多出一个别名条目、首尾条目不变,同时两条
component/metadata缺席断言翻为 true。其余 34 条(含输入面回归表与近似段族)应全程绿。方向为常规「红」,不存在反转 —— 整链断言是数组逐位相等,长度一变必红。实跑,与预测逐条一致:
两张 diff 各只多出一行:
这两张 diff 本身就是本单为什么会静默发生的直接证据:两条链的首尾条目完全没动,只有中间多了一站。旧的「只断终点」断言在结构上就不可能红。
门禁
type-check前先跑了pnpm --workspace-concurrency=2 --filter '@object-ui/app-shell^...' build(新 worktree 未构建依赖会报一片Cannot find module '@object-ui/*',AGENTS.md §9 陈旧产物陷阱的镜像)。changeset
不写:本 PR 只改一个测试文件,零生产代码改动,对包的发布物与运行时行为没有任何影响,不属于用户可见变更(与 PR #3671 同判)。
越界发现
无。本次未发现新的越界问题。
🤖 Generated with Claude Code
https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
Generated by Claude Code