Initial commit: Integral Shop CRMEB Project

Backend: Spring Boot 2.2.6 + MyBatis Plus
- crmeb-admin: Admin API module
- crmeb-service: Business logic
- crmeb-common: Common utilities
- crmeb-front: Frontend API

Frontend: Vue 2.6.10 + Element UI 2.13.0
- Admin management system
- 454 Vue components

Analyzed by Miao Agent on 2026-02-28
Project Score: 5.5/10
Security: High Risk (JWT bypass, API over-permission)
This commit is contained in:
2026-02-28 04:10:52 +08:00
commit 0b3d8b6be6
2278 changed files with 310929 additions and 0 deletions

View File

@@ -0,0 +1,148 @@
/**
* 订单打印页 orderDetailPrint.vue 自动测试
* 对应路由: /order/detail/print?orderId=order90825177097014160084735
* 验证计划 order_print_product_details_97538140商品图片、商品编号、赠送积分列、合计行、复制文本
*/
import { shallowMount } from '@vue/test-utils';
import OrderDetailPrint from '@/views/order/orderDetailPrint.vue';
import { orderDetailApi } from '@/api/order';
jest.mock('@/api/order', () => ({
orderDetailApi: jest.fn(),
}));
const ORDER_ID = 'order90825177097014160084735';
const mockOrderData = {
orderId: ORDER_ID,
nikeName: '测试用户',
phone: '13800138000',
realName: '张三',
userPhone: '13900139000',
userAddress: '测试地址',
statusStr: { key: 'paid', value: '已支付' },
totalNum: 3,
proTotalPrice: '299.00',
payPostage: '0',
couponPrice: '0',
payPrice: '299.00',
deductionPrice: '0',
createTime: '2025-02-18 12:00:00',
payTypeStr: '微信支付',
orderInfoList: [
{
productId: '10086',
info: {
image: 'https://example.com/a.jpg',
productName: '商品A',
sku: '规格1',
price: 99,
payNum: 1,
giveIntegral: 10,
},
},
{
productId: '10087',
info: {
image: '',
productName: '商品B',
sku: '规格2',
price: 100,
payNum: 2,
giveIntegral: 0,
},
},
],
};
function createWrapper(routeQuery = { orderId: ORDER_ID }) {
return shallowMount(OrderDetailPrint, {
mocks: {
$route: { query: routeQuery, params: {} },
$message: { success: jest.fn(), error: jest.fn() },
},
});
}
function flushPromises() {
return new Promise((resolve) => setTimeout(resolve, 0));
}
describe('OrderDetailPrint.vue - 订单打印页商品明细', () => {
beforeEach(() => {
jest.clearAllMocks();
orderDetailApi.mockResolvedValue(mockOrderData);
});
it('使用 orderId=order90825177097014160084735 请求订单详情', async () => {
const wrapper = createWrapper({ orderId: ORDER_ID });
await flushPromises();
await wrapper.vm.$nextTick();
expect(orderDetailApi).toHaveBeenCalledWith({ orderNo: ORDER_ID });
});
it('显示商品图片列(第一列)及 50px 缩略图', async () => {
const wrapper = createWrapper();
await flushPromises();
await wrapper.vm.$nextTick();
const headers = wrapper.findAll('thead th');
expect(headers.at(0).text()).toBe('商品图片');
const firstBodyRow = wrapper.find('tbody tr');
const firstTd = firstBodyRow.findAll('td').at(0);
const img = firstTd.find('img.product-thumb');
expect(img.exists()).toBe(true);
expect(img.attributes('src')).toBe('https://example.com/a.jpg');
});
it('商品名称列下方显示编号', async () => {
const wrapper = createWrapper();
await flushPromises();
await wrapper.vm.$nextTick();
const firstBodyRow = wrapper.find('tbody tr');
const nameTd = firstBodyRow.findAll('td').at(1);
expect(nameTd.find('.product-id').text()).toContain('10086');
expect(nameTd.text()).toMatch(/编号[:]\s*10086/);
});
it('当有赠送积分时显示赠送积分列', async () => {
const wrapper = createWrapper();
await flushPromises();
await wrapper.vm.$nextTick();
const headerTexts = wrapper.findAll('thead th').wrappers.map((w) => w.text());
expect(headerTexts).toContain('赠送积分');
const firstRow = wrapper.find('tbody tr');
expect(firstRow.text()).toContain('10'); // 第一件商品 giveIntegral: 10
});
it('表格底部有合计行:数量合计与金额合计', async () => {
const wrapper = createWrapper();
await flushPromises();
await wrapper.vm.$nextTick();
const footer = wrapper.find('tfoot tr.summary-row');
expect(footer.exists()).toBe(true);
expect(footer.text()).toContain('合计');
expect(footer.text()).toContain('3'); // totalPayNum: 1+2
expect(footer.text()).toContain('299.00'); // proTotalPrice
});
it('formatOrderInfo 复制文本包含商品编号和赠送积分', async () => {
const wrapper = createWrapper();
await flushPromises();
await wrapper.vm.$nextTick();
const text = wrapper.vm.formatOrderInfo();
expect(text).toContain('编号:10086');
expect(text).toContain('赠送积分:10');
expect(text).toContain('【商品列表】');
});
it('无图片时显示占位', async () => {
const wrapper = createWrapper();
await flushPromises();
await wrapper.vm.$nextTick();
const rows = wrapper.findAll('tbody tr');
const secondRow = rows.at(1);
const imgTd = secondRow.findAll('td').at(0);
expect(imgTd.find('img').exists()).toBe(false);
expect(imgTd.text()).toContain('-');
});
});