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

56 lines
3.4 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_old_btn', () => {
const s = readSource('src/pages/shop/ShopManagePage.vue')
assert.match(s, /class="btn btn-sm"[^>]*@click="openEdit\(row\)"/, '编辑用旧版 btn-sm 实心小按钮')
assert.match(s, /class="btn btn-sm btn-secondary"[^>]*@click="showCredential\(row\)"/, '凭证用旧版 btn-sm btn-secondary')
assert.match(s, /class="btn btn-sm btn-danger"[^>]*@click="remove\(row\)"/, '删除用旧版 btn-sm btn-danger')
assert.doesNotMatch(s, /el-button[^>]*@click="openEdit/, '行内不再用 EP 按钮')
assert.match(s, /window\.confirm\(`确定删除店铺/, '删除确认原生 confirm 对齐旧版')
})
test('align_shop_keys_row_buttons_old_btn', () => {
const s = readSource('src/pages/shop/ShopKeysPage.vue')
assert.match(s, /class="btn btn-sm"[^>]*@click="openEdit\(row\)"/, '编辑用旧版 btn-sm 实心小按钮')
assert.match(s, /class="btn btn-sm btn-danger"[^>]*@click="remove\(row\)"/, '删除用旧版 btn-sm btn-danger')
assert.doesNotMatch(s, /el-button[^>]*@click="openEdit/, '行内不再用 EP 按钮')
})
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_old_btn', () => {
const s = readSource('src/pages/records/RecordsDigitalHumanVersionPage.vue')
assert.match(s, /class="btn btn-sm"[^>]*@click="release\(row\)"/, '发布用旧版 btn-sm')
assert.match(s, /class="btn btn-sm"[^>]*@click="setLatest\(row\)"/, '设为最新用旧版 btn-sm')
assert.match(s, /class="btn btn-sm btn-secondary"[^>]*@click="download\(row\)"/, '下载用旧版 btn-sm btn-secondary')
assert.match(s, /class="btn btn-sm btn-danger"[^>]*@click="remove\(row\)"/, '删除用旧版 btn-sm btn-danger')
assert.doesNotMatch(s, /el-button[^>]*@click="release/, '行内不再用 EP 按钮')
assert.match(s, /window\.confirm\(text\)/, '确认走原生 confirm 对齐旧版')
})
test('align_image_video_detail_and_download_old_btn', () => {
const s = readSource('src/pages/tasks/ImageVideoTasksPage.vue')
assert.match(s, /class="btn btn-sm btn-secondary"[^>]*@click="downloadVideo\(task, index, video\)"/, '视频下载为旧版 btn-sm btn-secondary')
assert.match(s, /class="btn btn-sm"[^>]*@click="copyLink\(video\.displayUrl\)"/, '复制链接为旧版 btn-sm')
})
test('align_copy_link_aux_old_btn', () => {
// 辅助"复制链接"为旧版 btn-sm 小按钮。
const s = readSource('src/pages/tasks/ImageVideoTasksPage.vue')
assert.match(s, /class="btn btn-sm"[^>]*@click="copyLink/, '复制链接用 btn-sm')
})