import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { resolve } from "node:path";

const pages = [
  {
    file: "src/views/DeliveryManagementView.vue",
    snippets: [
      "import DrawerDataTable",
      "const expandedDeliveryItemRows",
      "const deliveryItemDrawerColumns",
      "<DrawerDataTable",
      "v-model:expanded-rows=\"expandedDeliveryItemRows\""
    ]
  },
  {
    file: "src/views/CompletionReceiptView.vue",
    snippets: [
      "import DrawerDataTable",
      "const expandedCompletionItemRows",
      "const completionItemDrawerColumns",
      "<DrawerDataTable",
      "v-model:expanded-rows=\"expandedCompletionItemRows\""
    ]
  },
  {
    file: "src/views/WorkOrderManagementView.vue",
    snippets: [
      "import DrawerDataTable",
      "const expandedWorkOrderMaterialRows",
      "const expandedWorkOrderOperationRows",
      "const workOrderMaterialDrawerColumns",
      "const workOrderOperationDrawerColumns",
      "v-model:expanded-rows=\"expandedWorkOrderMaterialRows\"",
      "v-model:expanded-rows=\"expandedWorkOrderOperationRows\""
    ]
  },
  {
    file: "src/views/PurchaseReceiptView.vue",
    snippets: [
      "import DrawerDataTable",
      "const expandedReceiptItemRows",
      "const receiptItemDrawerColumns",
      "<DrawerDataTable",
      "v-model:expanded-rows=\"expandedReceiptItemRows\""
    ]
  },
  {
    file: "src/views/ReturnManagementView.vue",
    snippets: [
      "import DrawerDataTable",
      "const expandedDispositionRows",
      "const dispositionDrawerColumns",
      "<DrawerDataTable",
      "v-model:expanded-rows=\"expandedDispositionRows\""
    ]
  },
  {
    file: "src/views/BomManagementView.vue",
    snippets: [
      "import DrawerDataTable",
      "const expandedBomItemRows",
      "const bomItemDrawerColumns",
      "<DrawerDataTable",
      "v-model:expanded-rows=\"expandedBomItemRows\""
    ]
  },
  {
    file: "src/views/ProcessRouteManagementView.vue",
    snippets: [
      "import DrawerDataTable",
      "const expandedRouteOperationRows",
      "const routeOperationDrawerColumns",
      "<DrawerDataTable",
      "v-model:expanded-rows=\"expandedRouteOperationRows\""
    ]
  },
  {
    file: "src/views/PurchaseOrderView.vue",
    snippets: [
      "import DrawerDataTable",
      "const expandedPurchaseOrderItemRows",
      "const purchaseOrderItemDrawerColumns",
      "<DrawerDataTable",
      "v-model:expanded-rows=\"expandedPurchaseOrderItemRows\""
    ]
  }
];

for (const page of pages) {
  const source = readFileSync(resolve(process.cwd(), page.file), "utf8");
  for (const snippet of page.snippets) {
    assert.ok(source.includes(snippet), `${page.file} missing drawer table migration snippet: ${snippet}`);
  }
}

console.log("drawer table migration static tests passed");
