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

const indexPath = path.resolve(__dirname, "../../src/views/ccdiProject/index.vue");
const indexSource = fs.readFileSync(indexPath, "utf8");

assert(
  indexSource.includes("handleSubmitProject(data)"),
  "项目创建成功回调应接收创建接口返回的数据"
);

assert(
  indexSource.includes("path: `/ccdiProject/detail/${data.projectId}`"),
  "项目创建成功后应跳转到新项目详情页"
);

assert(
  indexSource.includes('query: { tab: "upload" }') ||
    indexSource.includes("query: { tab: 'upload' }"),
  "项目创建成功后应显式激活上传数据页签"
);

assert(
  !/handleSubmitProject\(data\)\s*\{[\s\S]*?this\.getList\(\)\s*\/\/ 刷新列表[\s\S]*?\}/.test(indexSource),
  "项目创建成功后不应只刷新列表"
);

console.log("project-create-upload-jump test passed");
