const assert = require("assert");
const fs = require("fs");
const path = require("path");

const apiPath = path.resolve(__dirname, "../../src/api/ccdiProject.js");
const indexPath = path.resolve(__dirname, "../../src/views/ccdiProject/index.vue");

const apiSource = fs.readFileSync(apiPath, "utf8");
const indexSource = fs.readFileSync(indexPath, "utf8");

assert(apiSource.includes("url: '/ccdi/project/history'"), "应接通历史项目列表真实接口");
assert(apiSource.includes("url: '/ccdi/project/import'"), "应接通历史项目导入真实接口");
assert(indexSource.includes("this.$router.push({"), "导入成功后应跳转到详情页");
assert(
  indexSource.includes("path: `/ccdiProject/detail/${project.projectId}`")
    || indexSource.includes("path: `/ccdiProject/detail/${data.projectId}`"),
  "导入成功后应跳转到新项目详情页"
);
assert(indexSource.includes("历史项目导入任务已开始"), "成功提示文案应说明历史导入任务已开始");

console.log("project-import-history-submit-flow test passed");
