30 lines
2.0 KiB
JavaScript
30 lines
2.0 KiB
JavaScript
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const root = path.resolve(__dirname, '..');
|
|
const moduleSource = fs.readFileSync(path.join(root, 'prototype-src/modules/07-overseas-business.html'), 'utf8');
|
|
const appSource = fs.readFileSync(path.join(root, 'prototype-src/app.js'), 'utf8');
|
|
|
|
for (const pageId of ['page-domestic-purchase-detail', 'page-overseas-purchase-detail']) {
|
|
const start = moduleSource.indexOf(`id="${pageId}"`);
|
|
assert.ok(start >= 0, `${pageId} is missing`);
|
|
const end = moduleSource.indexOf('<div class="page"', start + 1);
|
|
const page = moduleSource.slice(start, end < 0 ? moduleSource.length : end);
|
|
assert.ok(page.includes('<h3>操作记录</h3>'), `${pageId} is missing 操作记录`);
|
|
assert.ok(!page.includes('进销存明细'), `${pageId} still exposes 进销存明细`);
|
|
assert.ok(!page.includes('-detail-ledger'), `${pageId} still exposes the ledger DOM id`);
|
|
}
|
|
|
|
assert.ok(!appSource.includes('inventoryTransactions:'), 'purchase data still defines inventoryTransactions');
|
|
assert.ok(!appSource.includes('domestic-detail-ledger'), 'domestic purchase renderer still targets the ledger DOM');
|
|
assert.ok(!appSource.includes('overseas-detail-ledger'), 'overseas purchase renderer still targets the ledger DOM');
|
|
assert.match(appSource, /operationRecords:/, 'purchase data does not define operationRecords');
|
|
assert.match(appSource, /r\.operationRecords/, 'domestic or overseas detail does not read operationRecords');
|
|
assert.match(appSource, /domestic-detail-operation-records/, 'domestic operation-record renderer is missing');
|
|
assert.match(appSource, /overseas-detail-operation-records/, 'overseas operation-record renderer is missing');
|
|
const expectedHeaderRow = '<th>操作时间</th><th>操作内容</th><th>操作人</th><th>操作结果</th><th>备注</th>';
|
|
assert.ok(appSource.split(expectedHeaderRow).length - 1 >= 2, 'both detail renderers must output the five operation-record headers');
|
|
|
|
console.log('PURCHASE_ORDER_OPERATION_RECORDS_CHECK_PASS');
|