|
@@ -1,12 +1,11 @@
|
|
|
import { describe, it, expect, beforeEach } from 'vitest';
|
|
import { describe, it, expect, beforeEach } from 'vitest';
|
|
|
import { testClient } from 'hono/testing';
|
|
import { testClient } from 'hono/testing';
|
|
|
import { IntegrationTestDatabase, setupIntegrationDatabaseHooksWithEntities } from '@d8d/shared-test-util';
|
|
import { IntegrationTestDatabase, setupIntegrationDatabaseHooksWithEntities } from '@d8d/shared-test-util';
|
|
|
-import { JWTUtil } from '@d8d/shared-utils';
|
|
|
|
|
import { UserEntityMt, RoleMt } from '@d8d/user-module-mt';
|
|
import { UserEntityMt, RoleMt } from '@d8d/user-module-mt';
|
|
|
import { FileMt } from '@d8d/file-module-mt';
|
|
import { FileMt } from '@d8d/file-module-mt';
|
|
|
-import createFeieRoutes from '../../src/routes/feie.routes';
|
|
|
|
|
|
|
+import { FeieMtRoutes } from '../../src/routes';
|
|
|
import { FeiePrinterMt, FeiePrintTaskMt, FeieConfigMt } from '../../src/entities';
|
|
import { FeiePrinterMt, FeiePrintTaskMt, FeieConfigMt } from '../../src/entities';
|
|
|
-import { FeieTestFactory } from '../factories/feie-test-factory';
|
|
|
|
|
|
|
+import { FeieTestDataFactory } from '../utils/test-data-factory';
|
|
|
|
|
|
|
|
// 设置集成测试钩子
|
|
// 设置集成测试钩子
|
|
|
setupIntegrationDatabaseHooksWithEntities([
|
|
setupIntegrationDatabaseHooksWithEntities([
|
|
@@ -14,9 +13,9 @@ setupIntegrationDatabaseHooksWithEntities([
|
|
|
])
|
|
])
|
|
|
|
|
|
|
|
describe('飞鹅打印多租户API集成测试', () => {
|
|
describe('飞鹅打印多租户API集成测试', () => {
|
|
|
- let client: ReturnType<typeof testClient<ReturnType<typeof createFeieRoutes>>>;
|
|
|
|
|
- let testFactory: FeieTestFactory;
|
|
|
|
|
|
|
+ let client: ReturnType<typeof testClient<typeof FeieMtRoutes>>;
|
|
|
let userToken: string;
|
|
let userToken: string;
|
|
|
|
|
+ let adminToken: string;
|
|
|
let otherUserToken: string;
|
|
let otherUserToken: string;
|
|
|
let otherTenantUserToken: string;
|
|
let otherTenantUserToken: string;
|
|
|
let testUser: UserEntityMt;
|
|
let testUser: UserEntityMt;
|
|
@@ -28,33 +27,33 @@ describe('飞鹅打印多租户API集成测试', () => {
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
|
|
|
// 创建测试客户端
|
|
// 创建测试客户端
|
|
|
- client = testClient(createFeieRoutes(dataSource));
|
|
|
|
|
-
|
|
|
|
|
- // 创建测试工厂
|
|
|
|
|
- testFactory = new FeieTestFactory(dataSource);
|
|
|
|
|
|
|
+ client = testClient(FeieMtRoutes);
|
|
|
|
|
|
|
|
// 创建测试用户
|
|
// 创建测试用户
|
|
|
- testUser = await testFactory.createTestUser(1);
|
|
|
|
|
- otherUser = await testFactory.createTestUser(1);
|
|
|
|
|
- otherTenantUser = await testFactory.createTestUser(2);
|
|
|
|
|
|
|
+ testUser = await FeieTestDataFactory.createTestUser(dataSource, 1);
|
|
|
|
|
+ otherUser = await FeieTestDataFactory.createTestUser(dataSource, 1);
|
|
|
|
|
+ otherTenantUser = await FeieTestDataFactory.createTestUser(dataSource, 2);
|
|
|
|
|
|
|
|
// 生成JWT令牌
|
|
// 生成JWT令牌
|
|
|
- userToken = JWTUtil.generateToken({ id: testUser.id, username: testUser.username, tenantId: 1 });
|
|
|
|
|
- otherUserToken = JWTUtil.generateToken({ id: otherUser.id, username: otherUser.username, tenantId: 1 });
|
|
|
|
|
- otherTenantUserToken = JWTUtil.generateToken({ id: otherTenantUser.id, username: otherTenantUser.username, tenantId: 2 });
|
|
|
|
|
|
|
+ userToken = FeieTestDataFactory.generateUserToken(testUser);
|
|
|
|
|
+ adminToken = FeieTestDataFactory.generateAdminToken(1);
|
|
|
|
|
+ otherUserToken = FeieTestDataFactory.generateUserToken(otherUser);
|
|
|
|
|
+ otherTenantUserToken = FeieTestDataFactory.generateUserToken(otherTenantUser);
|
|
|
|
|
|
|
|
// 创建飞鹅API配置
|
|
// 创建飞鹅API配置
|
|
|
- await testFactory.createFullFeieConfig(1);
|
|
|
|
|
- await testFactory.createFullFeieConfig(2);
|
|
|
|
|
|
|
+ await FeieTestDataFactory.createFullFeieConfig(dataSource, 1);
|
|
|
|
|
+ await FeieTestDataFactory.createFullFeieConfig(dataSource, 2);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
describe('租户数据隔离验证', () => {
|
|
describe('租户数据隔离验证', () => {
|
|
|
it('应该只能访问自己租户的打印机', async () => {
|
|
it('应该只能访问自己租户的打印机', async () => {
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+
|
|
|
// 创建租户1的打印机
|
|
// 创建租户1的打印机
|
|
|
- const tenant1Printer = await testFactory.createTestPrinter(1);
|
|
|
|
|
|
|
+ const tenant1Printer = await FeieTestDataFactory.createTestPrinter(dataSource, 1);
|
|
|
|
|
|
|
|
// 创建租户2的打印机
|
|
// 创建租户2的打印机
|
|
|
- const tenant2Printer = await testFactory.createTestPrinter(2);
|
|
|
|
|
|
|
+ const tenant2Printer = await FeieTestDataFactory.createTestPrinter(dataSource, 2);
|
|
|
|
|
|
|
|
// 使用租户1的用户查询打印机列表
|
|
// 使用租户1的用户查询打印机列表
|
|
|
const response = await client.printers.$get({
|
|
const response = await client.printers.$get({
|
|
@@ -78,8 +77,10 @@ describe('飞鹅打印多租户API集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('不应该访问其他租户的打印机详情', async () => {
|
|
it('不应该访问其他租户的打印机详情', async () => {
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+
|
|
|
// 创建租户2的打印机
|
|
// 创建租户2的打印机
|
|
|
- const otherTenantPrinter = await testFactory.createTestPrinter(2);
|
|
|
|
|
|
|
+ const otherTenantPrinter = await FeieTestDataFactory.createTestPrinter(dataSource, 2);
|
|
|
|
|
|
|
|
// 使用租户1的用户尝试访问租户2的打印机
|
|
// 使用租户1的用户尝试访问租户2的打印机
|
|
|
const response = await client['printers/:printerSn'].$get({
|
|
const response = await client['printers/:printerSn'].$get({
|
|
@@ -95,8 +96,10 @@ describe('飞鹅打印多租户API集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该正确过滤跨租户打印机访问', async () => {
|
|
it('应该正确过滤跨租户打印机访问', async () => {
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+
|
|
|
// 创建租户1的打印机
|
|
// 创建租户1的打印机
|
|
|
- const tenant1Printer = await testFactory.createTestPrinter(1);
|
|
|
|
|
|
|
+ const tenant1Printer = await FeieTestDataFactory.createTestPrinter(dataSource, 1);
|
|
|
|
|
|
|
|
// 使用租户2的用户尝试访问租户1的打印机
|
|
// 使用租户2的用户尝试访问租户1的打印机
|
|
|
const response = await client['printers/:printerSn'].$get({
|
|
const response = await client['printers/:printerSn'].$get({
|
|
@@ -114,9 +117,11 @@ describe('飞鹅打印多租户API集成测试', () => {
|
|
|
|
|
|
|
|
describe('打印机管理功能验证', () => {
|
|
describe('打印机管理功能验证', () => {
|
|
|
it('应该能够查询打印机列表', async () => {
|
|
it('应该能够查询打印机列表', async () => {
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+
|
|
|
// 创建测试打印机
|
|
// 创建测试打印机
|
|
|
- const printer1 = await testFactory.createTestPrinter(1, { printerName: '打印机1' });
|
|
|
|
|
- const printer2 = await testFactory.createTestPrinter(1, { printerName: '打印机2' });
|
|
|
|
|
|
|
+ const printer1 = await FeieTestDataFactory.createTestPrinter(dataSource, 1, { printerName: '打印机1' });
|
|
|
|
|
+ const printer2 = await FeieTestDataFactory.createTestPrinter(dataSource, 1, { printerName: '打印机2' });
|
|
|
|
|
|
|
|
// 查询打印机列表
|
|
// 查询打印机列表
|
|
|
const response = await client.printers.$get({
|
|
const response = await client.printers.$get({
|
|
@@ -138,9 +143,11 @@ describe('飞鹅打印多租户API集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该能够根据名称搜索打印机', async () => {
|
|
it('应该能够根据名称搜索打印机', async () => {
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+
|
|
|
// 创建测试打印机
|
|
// 创建测试打印机
|
|
|
- const printer1 = await testFactory.createTestPrinter(1, { printerName: '测试打印机A' });
|
|
|
|
|
- const printer2 = await testFactory.createTestPrinter(1, { printerName: '其他打印机' });
|
|
|
|
|
|
|
+ const printer1 = await FeieTestDataFactory.createTestPrinter(dataSource, 1, { printerName: '测试打印机A' });
|
|
|
|
|
+ const printer2 = await FeieTestDataFactory.createTestPrinter(dataSource, 1, { printerName: '其他打印机' });
|
|
|
|
|
|
|
|
// 搜索打印机
|
|
// 搜索打印机
|
|
|
const response = await client.printers.$get({
|
|
const response = await client.printers.$get({
|
|
@@ -162,9 +169,11 @@ describe('飞鹅打印多租户API集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该能够设置默认打印机', async () => {
|
|
it('应该能够设置默认打印机', async () => {
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+
|
|
|
// 创建两个打印机
|
|
// 创建两个打印机
|
|
|
- const printer1 = await testFactory.createTestPrinter(1, { printerName: '打印机1', isDefault: 1 });
|
|
|
|
|
- const printer2 = await testFactory.createTestPrinter(1, { printerName: '打印机2', isDefault: 0 });
|
|
|
|
|
|
|
+ const printer1 = await FeieTestDataFactory.createTestPrinter(dataSource, 1, { printerName: '打印机1', isDefault: 1 });
|
|
|
|
|
+ const printer2 = await FeieTestDataFactory.createTestPrinter(dataSource, 1, { printerName: '打印机2', isDefault: 0 });
|
|
|
|
|
|
|
|
// 设置打印机2为默认
|
|
// 设置打印机2为默认
|
|
|
const response = await client['printers/:printerSn/set-default'].$post({
|
|
const response = await client['printers/:printerSn/set-default'].$post({
|
|
@@ -184,7 +193,6 @@ describe('飞鹅打印多租户API集成测试', () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 验证打印机1不再是默认
|
|
// 验证打印机1不再是默认
|
|
|
- const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
const updatedPrinter1 = await dataSource.getRepository(FeiePrinterMt).findOne({
|
|
const updatedPrinter1 = await dataSource.getRepository(FeiePrinterMt).findOne({
|
|
|
where: { tenantId: 1, printerSn: printer1.printerSn }
|
|
where: { tenantId: 1, printerSn: printer1.printerSn }
|
|
|
});
|
|
});
|
|
@@ -196,8 +204,9 @@ describe('飞鹅打印多租户API集成测试', () => {
|
|
|
let testPrinter: FeiePrinterMt;
|
|
let testPrinter: FeiePrinterMt;
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
beforeEach(async () => {
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
// 创建测试打印机
|
|
// 创建测试打印机
|
|
|
- testPrinter = await testFactory.createTestPrinter(1);
|
|
|
|
|
|
|
+ testPrinter = await FeieTestDataFactory.createTestPrinter(dataSource, 1);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it.skip('应该能够创建打印任务 - 需要实际飞鹅API连接', async () => {
|
|
it.skip('应该能够创建打印任务 - 需要实际飞鹅API连接', async () => {
|
|
@@ -233,9 +242,11 @@ describe('飞鹅打印多租户API集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该能够查询打印任务列表', async () => {
|
|
it('应该能够查询打印任务列表', async () => {
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+
|
|
|
// 创建测试打印任务
|
|
// 创建测试打印任务
|
|
|
- const task1 = await testFactory.createTestPrintTask(1, testPrinter.printerSn);
|
|
|
|
|
- const task2 = await testFactory.createTestPrintTask(1, testPrinter.printerSn);
|
|
|
|
|
|
|
+ const task1 = await FeieTestDataFactory.createTestPrintTask(dataSource, 1, testPrinter.printerSn);
|
|
|
|
|
+ const task2 = await FeieTestDataFactory.createTestPrintTask(dataSource, 1, testPrinter.printerSn);
|
|
|
|
|
|
|
|
// 查询打印任务列表
|
|
// 查询打印任务列表
|
|
|
const response = await client.tasks.$get({
|
|
const response = await client.tasks.$get({
|
|
@@ -257,12 +268,14 @@ describe('飞鹅打印多租户API集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该能够根据打印机筛选打印任务', async () => {
|
|
it('应该能够根据打印机筛选打印任务', async () => {
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+
|
|
|
// 创建另一个打印机
|
|
// 创建另一个打印机
|
|
|
- const otherPrinter = await testFactory.createTestPrinter(1);
|
|
|
|
|
|
|
+ const otherPrinter = await FeieTestDataFactory.createTestPrinter(dataSource, 1);
|
|
|
|
|
|
|
|
// 创建测试打印任务
|
|
// 创建测试打印任务
|
|
|
- const task1 = await testFactory.createTestPrintTask(1, testPrinter.printerSn);
|
|
|
|
|
- const task2 = await testFactory.createTestPrintTask(1, otherPrinter.printerSn);
|
|
|
|
|
|
|
+ const task1 = await FeieTestDataFactory.createTestPrintTask(dataSource, 1, testPrinter.printerSn);
|
|
|
|
|
+ const task2 = await FeieTestDataFactory.createTestPrintTask(dataSource, 1, otherPrinter.printerSn);
|
|
|
|
|
|
|
|
// 根据打印机筛选
|
|
// 根据打印机筛选
|
|
|
const response = await client.tasks.$get({
|
|
const response = await client.tasks.$get({
|
|
@@ -497,4 +510,155 @@ describe('飞鹅打印多租户API集成测试', () => {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ // 新增:越权访问防护测试
|
|
|
|
|
+ describe('越权访问防护验证', () => {
|
|
|
|
|
+ it('应该拒绝访问其他用户的打印机详情', async () => {
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+
|
|
|
|
|
+ // 为otherUser创建打印机
|
|
|
|
|
+ const otherUserPrinter = await FeieTestDataFactory.createTestPrinter(dataSource, 1);
|
|
|
|
|
+
|
|
|
|
|
+ // testUser尝试访问otherUser的打印机
|
|
|
|
|
+ const response = await client['printers/:printerSn'].$get({
|
|
|
|
|
+ param: { printerSn: otherUserPrinter.printerSn }
|
|
|
|
|
+ }, {
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${userToken}` // testUser的token
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 应该返回404,因为打印机查询包含租户ID过滤
|
|
|
|
|
+ expect(response.status).toBe(404);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('应该拒绝跨租户访问打印机详情', async () => {
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+
|
|
|
|
|
+ // 为otherTenantUser创建打印机(租户2)
|
|
|
|
|
+ const otherTenantPrinter = await FeieTestDataFactory.createTestPrinter(dataSource, 2);
|
|
|
|
|
+
|
|
|
|
|
+ // testUser(租户1)尝试访问otherTenantUser(租户2)的打印机
|
|
|
|
|
+ const response = await client['printers/:printerSn'].$get({
|
|
|
|
|
+ param: { printerSn: otherTenantPrinter.printerSn }
|
|
|
|
|
+ }, {
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${userToken}` // 租户1的用户
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 应该返回404,因为租户ID不匹配
|
|
|
|
|
+ expect(response.status).toBe(404);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 新增:边界条件测试
|
|
|
|
|
+ describe('边界条件测试', () => {
|
|
|
|
|
+ it('应该处理打印机名称为空的情况', async () => {
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+
|
|
|
|
|
+ // 创建打印机名称为空的打印机
|
|
|
|
|
+ const printer = await FeieTestDataFactory.createTestPrinter(dataSource, 1, { printerName: '' });
|
|
|
|
|
+
|
|
|
|
|
+ // 查询打印机列表
|
|
|
|
|
+ const response = await client.printers.$get({
|
|
|
|
|
+ query: {}
|
|
|
|
|
+ }, {
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${userToken}`
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(200);
|
|
|
|
|
+ if (response.status === 200) {
|
|
|
|
|
+ const data = await response.json();
|
|
|
|
|
+ expect(data.success).toBe(true);
|
|
|
|
|
+ // 应该能正常返回,即使打印机名称为空
|
|
|
|
|
+ expect(data.data.data).toHaveLength(1);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('应该处理打印机状态无效的情况', async () => {
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+
|
|
|
|
|
+ // 创建状态为无效的打印机
|
|
|
|
|
+ const printer = await FeieTestDataFactory.createTestPrinter(dataSource, 1, { printerStatus: 'INVALID_STATUS' });
|
|
|
|
|
+
|
|
|
|
|
+ // 查询打印机列表
|
|
|
|
|
+ const response = await client.printers.$get({
|
|
|
|
|
+ query: {}
|
|
|
|
|
+ }, {
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${userToken}`
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(200);
|
|
|
|
|
+ if (response.status === 200) {
|
|
|
|
|
+ const data = await response.json();
|
|
|
|
|
+ expect(data.success).toBe(true);
|
|
|
|
|
+ // 应该能正常返回,即使状态无效
|
|
|
|
|
+ expect(data.data.data).toHaveLength(1);
|
|
|
|
|
+ expect(data.data.data[0].printerStatus).toBe('INVALID_STATUS');
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 新增:管理员权限测试
|
|
|
|
|
+ describe('管理员权限验证', () => {
|
|
|
|
|
+ it('管理员应该能够访问所有打印机', async () => {
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+
|
|
|
|
|
+ // 创建多个打印机
|
|
|
|
|
+ const printer1 = await FeieTestDataFactory.createTestPrinter(dataSource, 1, { printerName: '管理员打印机1' });
|
|
|
|
|
+ const printer2 = await FeieTestDataFactory.createTestPrinter(dataSource, 1, { printerName: '管理员打印机2' });
|
|
|
|
|
+
|
|
|
|
|
+ // 管理员查询打印机列表
|
|
|
|
|
+ const response = await client.printers.$get({
|
|
|
|
|
+ query: {}
|
|
|
|
|
+ }, {
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${adminToken}`
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(200);
|
|
|
|
|
+ if (response.status === 200) {
|
|
|
|
|
+ const data = await response.json();
|
|
|
|
|
+ expect(data.success).toBe(true);
|
|
|
|
|
+ // 管理员应该能看到所有打印机
|
|
|
|
|
+ expect(data.data.data).toHaveLength(2);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('管理员应该能够更新打印机配置', async () => {
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+
|
|
|
|
|
+ // 创建打印机
|
|
|
|
|
+ const printer = await FeieTestDataFactory.createTestPrinter(dataSource, 1);
|
|
|
|
|
+
|
|
|
|
|
+ // 管理员更新打印机
|
|
|
|
|
+ const updateData = {
|
|
|
|
|
+ printerName: '管理员更新后的打印机',
|
|
|
|
|
+ printerType: '80mm'
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const response = await client['printers/:printerSn'].$put({
|
|
|
|
|
+ param: { printerSn: printer.printerSn },
|
|
|
|
|
+ json: updateData
|
|
|
|
|
+ }, {
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${adminToken}`
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(200);
|
|
|
|
|
+ if (response.status === 200) {
|
|
|
|
|
+ const data = await response.json();
|
|
|
|
|
+ expect(data.success).toBe(true);
|
|
|
|
|
+ expect(data.data.printerName).toBe('管理员更新后的打印机');
|
|
|
|
|
+ expect(data.data.printerType).toBe('80mm');
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|