31 lines
1.3 KiB
JavaScript
31 lines
1.3 KiB
JavaScript
|
|
import fs from 'node:fs'
|
||
|
|
import path from 'node:path'
|
||
|
|
import { fileURLToPath } from 'node:url'
|
||
|
|
|
||
|
|
const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
||
|
|
const pageDir = path.join(currentDir, '..')
|
||
|
|
const taskPanelSource = fs.readFileSync(path.join(pageDir, 'components/DbmsTaskPanel.vue'), 'utf8')
|
||
|
|
|
||
|
|
const checks = [
|
||
|
|
['backup table select supports multiple values', /<el-select[\s\S]*v-model="backupForm\.targetNames"[\s\S]*\bmultiple\b/.test(taskPanelSource)],
|
||
|
|
['backup table select keeps collapsed tags tooltip', /<el-select[\s\S]*v-model="backupForm\.targetNames"[\s\S]*\bcollapse-tags-tooltip\b/.test(taskPanelSource)],
|
||
|
|
[
|
||
|
|
'backup table select displays at most two selected table tags before collapsing',
|
||
|
|
/<el-select[\s\S]*v-model="backupForm\.targetNames"[\s\S]*:max-collapse-tags="2"/.test(taskPanelSource)
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'backup table select dropdown should not force a two-column option grid',
|
||
|
|
!/\.dbms-table-select-popper \.el-select-dropdown__list\s*\{[\s\S]*grid-template-columns:\s*repeat\(2/.test(taskPanelSource)
|
||
|
|
]
|
||
|
|
]
|
||
|
|
|
||
|
|
const failures = checks.filter(([, passed]) => !passed)
|
||
|
|
|
||
|
|
if (failures.length) {
|
||
|
|
console.error('dbms task panel table select contract failed:')
|
||
|
|
failures.forEach(([message]) => console.error(`- ${message}`))
|
||
|
|
process.exit(1)
|
||
|
|
}
|
||
|
|
|
||
|
|
console.log('dbms task panel table select contract passed')
|