diff --git a/scripts/regression-long-answer-section-skeleton.mjs b/scripts/regression-long-answer-section-skeleton.mjs new file mode 100644 index 0000000..31fead1 --- /dev/null +++ b/scripts/regression-long-answer-section-skeleton.mjs @@ -0,0 +1,129 @@ +import assert from "assert"; +import { readFileSync } from "fs"; +import { dirname, resolve } from "path"; +import { fileURLToPath } from "url"; + +const scriptDir = dirname(fileURLToPath(import.meta.url)); +const detailPagePath = resolve( + scriptDir, + "../src/pages/ChatMain/ChatLongAnswer/index.vue" +); +const parsedValuePath = resolve( + scriptDir, + "../src/pages/ChatMain/ChatLongAnswer/ParsedValueView.vue" +); +const detailStylePath = resolve( + scriptDir, + "../src/pages/ChatMain/ChatLongAnswer/styles/index.scss" +); +const skeletonComponentPath = resolve( + scriptDir, + "../src/pages/ChatMain/ChatLongAnswer/LongAnswerSectionSkeleton.vue" +); + +const detailPageSource = readFileSync(detailPagePath, "utf8"); +const parsedValueSource = readFileSync(parsedValuePath, "utf8"); +const detailStyleSource = readFileSync(detailStylePath, "utf8"); +const skeletonComponentSource = readFileSync(skeletonComponentPath, "utf8"); + +assert.match( + detailPageSource, + /const\s+streamFinished\s*=\s*ref/, + "long answer page should track whether the forwarded stream has finished" +); + +assert.match( + detailPageSource, + /import\s+LongAnswerSectionSkeleton\s+from\s+"\.\/LongAnswerSectionSkeleton\.vue"/, + "long answer page should use a sibling skeleton component" +); + +assert.doesNotMatch( + detailPageSource, + /DEFERRED_SPECIAL_SECTION_KEYS/, + "long answer page should not use a special-key whitelist for section skeletons" +); + +assert.doesNotMatch( + detailPageSource, + /LONG_TEXT_KEYS\.(sceneImage|contentImage|spotLocate|questionSuggest|commodityList|photoList|aigcComponet)/, + "section skeleton readiness should not be tied to named special keys" +); + +assert.match( + detailPageSource, + / + + + + + + + + + + + diff --git a/src/pages/ChatMain/ChatLongAnswer/index.vue b/src/pages/ChatMain/ChatLongAnswer/index.vue index 3c49859..8481a82 100644 --- a/src/pages/ChatMain/ChatLongAnswer/index.vue +++ b/src/pages/ChatMain/ChatLongAnswer/index.vue @@ -19,8 +19,11 @@