test(chat): restore two-layer markdown contract counts
Spoken and report layers each keep a message-markdown shell and both must call renderProse; login hard-jumps drop from 4 to 3 after the onboarding suggestion effect went away. No product code.
This commit is contained in:
@@ -44,11 +44,30 @@ test("the pre-markdown fallback renders prose but never raw markdown", () => {
|
||||
assert.deepEqual(plainParagraphs("只有一段。"), ["只有一段。"]);
|
||||
|
||||
// And: one stable wrapper serves both paths, so no styling or caret is lost on upgrade.
|
||||
assert.equal(contentSource.match(/className="message-markdown"/g)?.length, 1);
|
||||
// 原值: contentSource.match(/className="message-markdown"/g)?.length === 1
|
||||
// 新值: 2
|
||||
// 原因: 回答改为两层可见性(口语层 + 折叠的完整分析),两层各有一个包裹。
|
||||
// 这条仍然数包裹个数,不得放宽成 >= 1——它防的是"升级到 markdown 时换了壳"。
|
||||
assert.equal(contentSource.match(/className="message-markdown"/g)?.length, 2);
|
||||
assert.match(contentSource, /className="message-answer"/);
|
||||
assert.match(contentSource, /TechniqueAuditDisclosure/);
|
||||
assert.match(contentSource, /<p key=\{index\}>\{paragraph\}<\/p>/);
|
||||
assert.match(contentSource, /plainParagraphs\(spoken\) \?\? \[\]/);
|
||||
// 原值: assert.match(contentSource, /plainParagraphs\(spoken\) \?\? \[\]/)
|
||||
// 新值: 断言 renderProse 内部的回退路径
|
||||
// 原因: 口语层与报告层共用 renderProse,plainParagraphs 只在它内部调用一次。
|
||||
assert.match(contentSource, /\(plainParagraphs\(text\) \?\? \[\]\)\.map/);
|
||||
|
||||
// 两层必须都走 renderProse,不得一层 markdown 一层裸文本。
|
||||
// 口语层若改成 {spoken} / renderMarkdown(spoken)、报告层仍走 renderProse(或反过来),
|
||||
// 下面的精确计数会从 2 掉到 1。不得改成 >= 1。
|
||||
assert.match(contentSource, /renderProse\(spoken,\s*renderMarkdown\)/);
|
||||
assert.match(contentSource, /renderProse\(report,\s*renderMarkdown\)/);
|
||||
assert.equal(
|
||||
contentSource.match(/renderProse\((?:spoken|report),\s*renderMarkdown\)/g)?.length,
|
||||
2,
|
||||
);
|
||||
assert.doesNotMatch(contentSource, /\{renderMarkdown\((?:spoken|report)\)\}/);
|
||||
assert.doesNotMatch(contentSource, />\{(?:spoken|report)\}<\/div>/);
|
||||
});
|
||||
|
||||
test("gsap loads on demand while keeping the reduced-motion gate", () => {
|
||||
|
||||
@@ -65,7 +65,12 @@ test("auth redirects stay hard document loads so stale session state cannot surv
|
||||
// without adding a `next` query to the login page.
|
||||
assert.match(pageSource, /function redirectToLogin\(\): never \{/);
|
||||
assert.match(pageSource, /persistLoginSessionReturn\(\);\n window\.location\.replace\("\/login"\);/);
|
||||
assert.equal(pageSource.match(/window\.location\.assign\("\/login"\)/g)?.length, 4);
|
||||
// 原值: pageSource.match(/window\.location\.assign\("\/login"\)/g)?.length === 4
|
||||
// 新值: 3
|
||||
// 原因: 8144fca2 删除建议问题请求,连同它的 OnboardingAuthenticationError 分支里
|
||||
// 那一次 window.location.assign("/login")。少的是调用点,不是把硬跳转换成了
|
||||
// router.push——同 test 里两条 doesNotMatch 仍然成立。
|
||||
assert.equal(pageSource.match(/window\.location\.assign\("\/login"\)/g)?.length, 3);
|
||||
assert.equal(pageSource.match(/window\.location\.replace\("\/login"\)/g)?.length, 1);
|
||||
assert.doesNotMatch(pageSource, /router\.push\("\/login"\)/);
|
||||
assert.doesNotMatch(pageSource, /router\.replace\("\/login"\)/);
|
||||
|
||||
Reference in New Issue
Block a user