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

const componentPath = path.resolve(
  __dirname,
  "../../src/views/ccdiProject/components/detail/UploadData.vue"
);
const source = fs.readFileSync(componentPath, "utf8");

const dialogIndex = source.indexOf(':visible.sync="batchUploadDialogVisible"');
assert.notStrictEqual(dialogIndex, -1, "未找到批量上传流水文件弹窗");

const dialogEndIndex = source.indexOf("</el-dialog>", dialogIndex);
assert.notStrictEqual(dialogEndIndex, -1, "未找到批量上传流水文件弹窗结束标签");

const dialogSource = source.slice(dialogIndex, dialogEndIndex);
const uploadMatch = dialogSource.match(/<el-upload([\s\S]*?)>/);
assert(uploadMatch, "未找到批量上传区域的 el-upload 组件");

assert(
  /(:show-file-list|show-file-list)\s*=\s*"false"/.test(uploadMatch[1]),
  "批量上传区域必须关闭 el-upload 默认文件列表，避免与自定义文件列表重复显示"
);

assert(
  /class="selected-files"/.test(dialogSource),
  "批量上传弹窗应保留自定义已选文件列表"
);

console.log("upload-data-batch-upload test passed");
