151 lines
3.8 KiB
JavaScript
151 lines
3.8 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
import { resolve } from "node:path";
|
|
|
|
const source = await readFile(
|
|
resolve("src/pages/ChatMain/ChatLongAnswer/ParsedValueView.vue"),
|
|
"utf8"
|
|
);
|
|
|
|
const forbiddenCompatibilitySnippets = [
|
|
"valueObj.image_url",
|
|
"valueObj.image,",
|
|
"valueObj.image_id",
|
|
"valueObj.content_image",
|
|
"valueObj.sopt_name",
|
|
"valueObj.name",
|
|
"valueObj.title",
|
|
"valueObj.sopt_description",
|
|
"valueObj.description",
|
|
"valueObj.desc",
|
|
"valueObj.sopt_longitude",
|
|
"valueObj.longitude",
|
|
"valueObj.lng",
|
|
"valueObj.sopt_latitude",
|
|
"valueObj.latitude",
|
|
"valueObj.lat",
|
|
"valueObj.sopt_tag",
|
|
"valueObj.tag",
|
|
"valueObj.type",
|
|
"value?.questions",
|
|
"value?.items",
|
|
"value?.list",
|
|
];
|
|
|
|
for (const snippet of forbiddenCompatibilitySnippets) {
|
|
assert.equal(
|
|
source.includes(snippet),
|
|
false,
|
|
`ParsedValueView should not guess compatibility field: ${snippet}`
|
|
);
|
|
}
|
|
|
|
const requiredStrictRenderingSnippets = [
|
|
"LONG_TEXT_KEYS.sceneImage",
|
|
"LONG_TEXT_KEYS.contentImage",
|
|
"LONG_TEXT_KEYS.commodityList",
|
|
"LONG_TEXT_KEYS.photoList",
|
|
"LONG_TEXT_KEYS.aigcComponet",
|
|
"shouldRenderSpotLocate",
|
|
"shouldRenderQuestionSuggest",
|
|
"shouldRenderCommodityList",
|
|
"shouldRenderPhotoList",
|
|
"shouldRenderAigcComponet",
|
|
"getRenderEntriesForObject",
|
|
"commodity.commodity_id",
|
|
"commodity.commodity_name",
|
|
"commodity.commodity_price",
|
|
"commodity.commodity_tag",
|
|
"commodity.commodity_photo",
|
|
"<swiper",
|
|
"<swiper-item",
|
|
"photo.photo_name",
|
|
"photo.photo_description",
|
|
"photo.photo_url",
|
|
"aigc.background",
|
|
"aigc.title",
|
|
"aigc.description",
|
|
"aigc.jumpUrl",
|
|
"jumpAigcClick",
|
|
"getAccessToken",
|
|
"navigateTo",
|
|
"content-body-list-card",
|
|
];
|
|
|
|
for (const snippet of requiredStrictRenderingSnippets) {
|
|
assert.equal(
|
|
source.includes(snippet),
|
|
true,
|
|
`ParsedValueView should render exact strict field: ${snippet}`
|
|
);
|
|
}
|
|
|
|
const removedInnerSpecialEntrySnippets = [
|
|
"createSpecialFieldEntry",
|
|
"entry.type === 'question-suggest'",
|
|
"entry.type === 'photo-list'",
|
|
"entry.type === 'aigc-componet'",
|
|
"entry.type === 'commodity-list'",
|
|
"entry.type === 'spot-locate'",
|
|
];
|
|
|
|
for (const snippet of removedInnerSpecialEntrySnippets) {
|
|
assert.equal(
|
|
source.includes(snippet),
|
|
false,
|
|
`ParsedValueView should keep special fields at the top level only: ${snippet}`
|
|
);
|
|
}
|
|
|
|
const removedFlatFieldSnippets = [
|
|
"preparationSectionTitle",
|
|
"preparationSectionItems",
|
|
"sectionSuggestionTitle",
|
|
"sectionSuggestionContent",
|
|
"pitfallSectionTitle",
|
|
"pitfallSectionItems",
|
|
"viewSectionTitle",
|
|
"viewSectionItems",
|
|
"suggestionSectionTitle",
|
|
"suggestionSectionContent",
|
|
"lightReminderTitle",
|
|
"lightReminderItems",
|
|
];
|
|
|
|
for (const snippet of removedFlatFieldSnippets) {
|
|
assert.equal(
|
|
source.includes(`LONG_TEXT_KEYS.${snippet}`),
|
|
false,
|
|
`ParsedValueView should not reference removed flat field: ${snippet}`
|
|
);
|
|
}
|
|
|
|
const removedStructuredConfigSnippets = [
|
|
"STRUCTURED_SECTION_CONFIG",
|
|
"isGenericObjectSectionField",
|
|
"content-body-section-dot",
|
|
"content-body-section-list",
|
|
"LONG_TEXT_KEYS.preparationSection",
|
|
"LONG_TEXT_KEYS.sectionSuggestion",
|
|
"LONG_TEXT_KEYS.pitfallSection",
|
|
"LONG_TEXT_KEYS.viewSection",
|
|
"LONG_TEXT_KEYS.suggestionSection",
|
|
"LONG_TEXT_KEYS.lightReminder",
|
|
"LONG_TEXT_KEYS.photoSpotSection",
|
|
"LONG_TEXT_KEYS.phoneSection",
|
|
"LONG_TEXT_KEYS.decisionSection",
|
|
"LONG_TEXT_KEYS.routeWarning",
|
|
"LONG_TEXT_KEYS.tourRoutes",
|
|
"LONG_TEXT_KEYS.facilitiesAlongTheWay",
|
|
];
|
|
|
|
for (const snippet of removedStructuredConfigSnippets) {
|
|
assert.equal(
|
|
source.includes(snippet),
|
|
false,
|
|
`ParsedValueView should use generic section rendering instead of configured field: ${snippet}`
|
|
);
|
|
}
|
|
|
|
console.log("ParsedValueView strict field checks passed");
|