Files
crawler-plugin/admin-frontend-vue/tests/align-shop-records-row-buttons.test.ts
T

51 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
/** 对齐旧版 .btn-smshop/records/任务 域主操作按钮(编辑/凭证/删除/查看/发布/设最新/下载/明细)统一实心 small;纯复制链接辅助仍可 text。 */
function assertRowButtonSolid(source: string, action: string) {
assert.match(source, new RegExp(`<el-button[^>]*size="small"[^>]*@click="${action}`), `${action} 为 size=small 实心按钮`)
assert.doesNotMatch(source, new RegExp(`<el-button[^>]*link[^>]*@click="${action}`), `${action} 不再 link`)
assert.doesNotMatch(source, new RegExp(`<el-button[^>]*text[^>]*@click="${action}`), `${action} 不再 text`)
}
test('align_shop_manage_row_buttons_solid', () => {
const s = readSource('src/pages/shop/ShopManagePage.vue')
assertRowButtonSolid(s, 'openEdit')
assertRowButtonSolid(s, 'showCredential')
assertRowButtonSolid(s, 'remove')
})
test('align_shop_keys_row_buttons_solid', () => {
const s = readSource('src/pages/shop/ShopKeysPage.vue')
assertRowButtonSolid(s, 'openEdit')
assertRowButtonSolid(s, 'remove')
})
test('align_records_history_thumb_click_opens_preview', () => {
const s = readSource('src/pages/records/RecordsHistoryPage.vue')
assert.match(s, /class="thumb"[^>]*@click="openPreview\(h\)"/, '点击缩略图直接放大预览')
assert.doesNotMatch(s, /查看大图/, '无行内「查看大图」按钮')
})
test('align_digital_human_row_buttons_solid', () => {
const s = readSource('src/pages/records/RecordsDigitalHumanVersionPage.vue')
assertRowButtonSolid(s, 'release')
assertRowButtonSolid(s, 'setLatest')
assertRowButtonSolid(s, 'download')
assertRowButtonSolid(s, 'remove')
})
test('align_image_video_detail_and_download_solid', () => {
const s = readSource('src/pages/tasks/ImageVideoTasksPage.vue')
assertRowButtonSolid(s, 'openDetail')
assertRowButtonSolid(s, 'downloadVideo')
})
test('align_copy_link_aux_kept_text', () => {
// 辅助"复制链接"保留 text(非破坏主操作),避免被误伤。
const s = readSource('src/pages/tasks/ImageVideoTasksPage.vue')
assert.match(s, /<el-button[^>]*text[^>]*@click="copyLink/, '复制链接保留 text')
})