const assert = require("assert"); const fs = require("fs"); const path = require("path"); const root = path.resolve(__dirname, ".."); const api = fs.readFileSync(path.join(root, "src/api/aiTrainingEvaluation.js"), "utf8"); const component = fs.readFileSync(path.join(root, "src/views/components/TrainingAiEvaluation.vue"), "utf8"); const page = fs.readFileSync(path.join(root, "src/views/training/GenericTrainingPage.vue"), "utf8"); assert(/`\/api\/student\/training-tasks\/\$\{taskKey\}\/ai-evaluation`/.test(api), "evaluation API should use the student task endpoint"); assert(/\/help/.test(api) && /\/assessment/.test(api), "evaluation API should expose help and assessment operations"); assert(/TrainingAiEvaluation/.test(page) && /:has-any-answer="hasAnyAnswer"/.test(page), "generic training page should pass meaningful answer state to AI evaluation"); assert(/form\.value/.test(page) && /workRows\.value/.test(page) && /processRows\.value/.test(page), "hasAnyAnswer should inspect all supported answer shapes"); assert(/\s*props\.taskKey/.test(component), "AI evaluation should load on mount and task changes"); assert(/AI助学/.test(component) && /AI助评/.test(component), "AI evaluation should offer separate help and assessment controls"); assert(/PROCESSING/.test(component) && /SUCCEEDED/.test(component), "AI evaluation should surface backend statuses"); assert(/!props\.hasAnyAnswer/.test(component), "AI actions should disable when no answer is available"); assert(/proxy\?\.\$modal\?\.confirm/.test(component), "assessment should request confirmation through the modal proxy"); assert(!/v-html/.test(component), "AI reports must be rendered as interpolated text, never v-html"); assert(/scoreCriteria/.test(component), "assessment should display score criteria"); assert(/retry/.test(component) || /重试/.test(component), "failed AI operations should expose a retry action");