65 lines
1.5 KiB
JavaScript
65 lines
1.5 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.commodityList",
|
|
"commodity.commodity_id",
|
|
"commodity.commodity_name",
|
|
"commodity.commodity_price",
|
|
"commodity.commodity_tag",
|
|
"commodity.commodity_photo",
|
|
"content-body-list-marker",
|
|
"entry.value.length > 1",
|
|
"formatListMarker(index)",
|
|
];
|
|
|
|
for (const snippet of requiredStrictRenderingSnippets) {
|
|
assert.equal(
|
|
source.includes(snippet),
|
|
true,
|
|
`ParsedValueView should render exact strict field: ${snippet}`
|
|
);
|
|
}
|
|
|
|
console.log("ParsedValueView strict field checks passed");
|