You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dianshang-qianduan/tests/multistep-task-submit.stati...

32 lines
1.3 KiB
����Script

const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const test = require("node:test");
function readPage(relativePath) {
return fs.readFileSync(path.resolve(__dirname, "..", relativePath), "utf8");
}
test("实训19第五步提交动态答案并完成任务", () => {
const page = readPage("src/views/product/price.vue");
assert.match(page, /finalPricingSave:\s*"提交并完成实训"/);
assert.match(
page,
/async function saveStepFive\(\)\s*\{[\s\S]*?saveAction:\s*"SUBMIT",[\s\S]*?currentStep:\s*5,[\s\S]*?submitted:\s*true,[\s\S]*?dynamicStepAnswers:/
);
});
test("实训20第五步使用动态答案保存并在提交时完成任务", () => {
const page = readPage("src/views/assessment/optimization.vue");
assert.match(page, /const dynamicStepAnswers = ref\(\{\}\);/);
assert.match(
page,
/async function persistProgress\(saveAction = "SAVE"\)\s*\{[\s\S]*?step5:\s*buildStepFiveProgress\(\)[\s\S]*?dynamicStepAnswers:\s*JSON\.stringify\(dynamicStepAnswers\.value\)/
);
assert.match(page, /async function submitTask\(\)\s*\{[\s\S]*?persistProgress\("SUBMIT"\)/);
assert.match(page, /dynamicStepAnswers\.value = parseSavedJson\(res\?\.data\?\.dynamicStepAnswers\) \|\| \{\};/);
assert.doesNotMatch(page, /step5Answer:/);
});