|
@@ -65,9 +65,9 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- describe('GET /api/v1/admin/unified-advertisements', () => {
|
|
|
|
|
|
|
+ describe('GET /admin/unified-advertisements', () => {
|
|
|
it('应该允许超级管理员获取广告列表', async () => {
|
|
it('应该允许超级管理员获取广告列表', async () => {
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisements'].$get({
|
|
|
|
|
|
|
+ const response = await adminClient.$get({
|
|
|
query: { page: 1, pageSize: 10 }
|
|
query: { page: 1, pageSize: 10 }
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -88,7 +88,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该拒绝普通用户访问管理员接口', async () => {
|
|
it('应该拒绝普通用户访问管理员接口', async () => {
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisements'].$get({
|
|
|
|
|
|
|
+ const response = await adminClient.$get({
|
|
|
query: { page: 1, pageSize: 10 }
|
|
query: { page: 1, pageSize: 10 }
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -100,7 +100,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该拒绝未认证用户访问', async () => {
|
|
it('应该拒绝未认证用户访问', async () => {
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisements'].$get({
|
|
|
|
|
|
|
+ const response = await adminClient.$get({
|
|
|
query: { page: 1, pageSize: 10 }
|
|
query: { page: 1, pageSize: 10 }
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -108,7 +108,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- describe('POST /api/v1/admin/unified-advertisements', () => {
|
|
|
|
|
|
|
+ describe('POST /admin/unified-advertisements', () => {
|
|
|
it('应该允许超级管理员创建广告', async () => {
|
|
it('应该允许超级管理员创建广告', async () => {
|
|
|
const timestamp = Math.floor(Date.now() / 1000); // 10位时间戳
|
|
const timestamp = Math.floor(Date.now() / 1000); // 10位时间戳
|
|
|
const createData = {
|
|
const createData = {
|
|
@@ -121,7 +121,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
actionType: 1
|
|
actionType: 1
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisements'].$post({
|
|
|
|
|
|
|
+ const response = await adminClient.$post({
|
|
|
json: createData
|
|
json: createData
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -142,7 +142,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该拒绝普通用户创建广告', async () => {
|
|
it('应该拒绝普通用户创建广告', async () => {
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisements'].$post({
|
|
|
|
|
|
|
+ const response = await adminClient.$post({
|
|
|
json: {
|
|
json: {
|
|
|
title: '测试广告',
|
|
title: '测试广告',
|
|
|
typeId: testAdvertisementType.id,
|
|
typeId: testAdvertisementType.id,
|
|
@@ -159,7 +159,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- describe('PUT /api/v1/admin/unified-advertisements/:id', () => {
|
|
|
|
|
|
|
+ describe('PUT /admin/unified-advertisements/:id', () => {
|
|
|
it('应该允许超级管理员更新广告', async () => {
|
|
it('应该允许超级管理员更新广告', async () => {
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
const advertisementRepository = dataSource.getRepository(UnifiedAdvertisement);
|
|
const advertisementRepository = dataSource.getRepository(UnifiedAdvertisement);
|
|
@@ -183,7 +183,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
sort: 15
|
|
sort: 15
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisements/:id'].$put({
|
|
|
|
|
|
|
+ const response = await adminClient[':id'].$put({
|
|
|
param: { id: testAdvertisement.id },
|
|
param: { id: testAdvertisement.id },
|
|
|
json: updateData
|
|
json: updateData
|
|
|
}, {
|
|
}, {
|
|
@@ -203,7 +203,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- describe('DELETE /api/v1/admin/unified-advertisements/:id', () => {
|
|
|
|
|
|
|
+ describe('DELETE /admin/unified-advertisements/:id', () => {
|
|
|
it('应该允许超级管理员软删除广告', async () => {
|
|
it('应该允许超级管理员软删除广告', async () => {
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
const advertisementRepository = dataSource.getRepository(UnifiedAdvertisement);
|
|
const advertisementRepository = dataSource.getRepository(UnifiedAdvertisement);
|
|
@@ -221,7 +221,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
await advertisementRepository.save(testAdvertisement);
|
|
await advertisementRepository.save(testAdvertisement);
|
|
|
|
|
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisements/:id'].$delete({
|
|
|
|
|
|
|
+ const response = await adminClient[':id'].$delete({
|
|
|
param: { id: testAdvertisement.id }
|
|
param: { id: testAdvertisement.id }
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -470,9 +470,9 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- describe('GET /api/v1/admin/unified-advertisement-types', () => {
|
|
|
|
|
|
|
+ describe('GET /admin/unified-advertisement-types', () => {
|
|
|
it('应该允许超级管理员获取广告类型列表', async () => {
|
|
it('应该允许超级管理员获取广告类型列表', async () => {
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisement-types'].$get({
|
|
|
|
|
|
|
+ const response = await adminClient.$get({
|
|
|
query: { page: 1, pageSize: 10 }
|
|
query: { page: 1, pageSize: 10 }
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -504,7 +504,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
status: 1
|
|
status: 1
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisement-types'].$get({
|
|
|
|
|
|
|
+ const response = await adminClient.$get({
|
|
|
query: { page: 1, pageSize: 10, keyword: '测试类型搜索' }
|
|
query: { page: 1, pageSize: 10, keyword: '测试类型搜索' }
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -520,7 +520,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该支持状态筛选', async () => {
|
|
it('应该支持状态筛选', async () => {
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisement-types'].$get({
|
|
|
|
|
|
|
+ const response = await adminClient.$get({
|
|
|
query: { page: 1, pageSize: 10, status: 1 }
|
|
query: { page: 1, pageSize: 10, status: 1 }
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -536,7 +536,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该拒绝普通用户访问管理员接口', async () => {
|
|
it('应该拒绝普通用户访问管理员接口', async () => {
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisement-types'].$get({
|
|
|
|
|
|
|
+ const response = await adminClient.$get({
|
|
|
query: { page: 1, pageSize: 10 }
|
|
query: { page: 1, pageSize: 10 }
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -548,7 +548,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该拒绝未认证用户访问', async () => {
|
|
it('应该拒绝未认证用户访问', async () => {
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisement-types'].$get({
|
|
|
|
|
|
|
+ const response = await adminClient.$get({
|
|
|
query: { page: 1, pageSize: 10 }
|
|
query: { page: 1, pageSize: 10 }
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -556,7 +556,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- describe('GET /api/v1/admin/unified-advertisement-types/:id', () => {
|
|
|
|
|
|
|
+ describe('GET /admin/unified-advertisement-types/:id', () => {
|
|
|
it('应该允许超级管理员获取广告类型详情', async () => {
|
|
it('应该允许超级管理员获取广告类型详情', async () => {
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
const typeRepository = dataSource.getRepository(UnifiedAdvertisementType);
|
|
const typeRepository = dataSource.getRepository(UnifiedAdvertisementType);
|
|
@@ -570,7 +570,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
await typeRepository.save(testType);
|
|
await typeRepository.save(testType);
|
|
|
|
|
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisement-types/:id'].$get({
|
|
|
|
|
|
|
+ const response = await adminClient[':id'].$get({
|
|
|
param: { id: testType.id }
|
|
param: { id: testType.id }
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -589,7 +589,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该返回404对于不存在的类型', async () => {
|
|
it('应该返回404对于不存在的类型', async () => {
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisement-types/:id'].$get({
|
|
|
|
|
|
|
+ const response = await adminClient[':id'].$get({
|
|
|
param: { id: 999999 }
|
|
param: { id: 999999 }
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -601,7 +601,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- describe('POST /api/v1/admin/unified-advertisement-types', () => {
|
|
|
|
|
|
|
+ describe('POST /admin/unified-advertisement-types', () => {
|
|
|
it('应该允许超级管理员创建广告类型', async () => {
|
|
it('应该允许超级管理员创建广告类型', async () => {
|
|
|
const timestamp = Math.floor(Date.now() / 1000).toString().slice(-6);
|
|
const timestamp = Math.floor(Date.now() / 1000).toString().slice(-6);
|
|
|
const createData = {
|
|
const createData = {
|
|
@@ -611,7 +611,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
status: 1
|
|
status: 1
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisement-types'].$post({
|
|
|
|
|
|
|
+ const response = await adminClient.$post({
|
|
|
json: createData
|
|
json: createData
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -632,7 +632,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该拒绝普通用户创建广告类型', async () => {
|
|
it('应该拒绝普通用户创建广告类型', async () => {
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisement-types'].$post({
|
|
|
|
|
|
|
+ const response = await adminClient.$post({
|
|
|
json: {
|
|
json: {
|
|
|
name: '测试类型',
|
|
name: '测试类型',
|
|
|
code: 'test_type',
|
|
code: 'test_type',
|
|
@@ -660,7 +660,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
await typeRepository.save(existingType);
|
|
await typeRepository.save(existingType);
|
|
|
|
|
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisement-types'].$post({
|
|
|
|
|
|
|
+ const response = await adminClient.$post({
|
|
|
json: {
|
|
json: {
|
|
|
name: '新类型',
|
|
name: '新类型',
|
|
|
code: `dup_${timestamp}`,
|
|
code: `dup_${timestamp}`,
|
|
@@ -676,7 +676,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- describe('PUT /api/v1/admin/unified-advertisement-types/:id', () => {
|
|
|
|
|
|
|
+ describe('PUT /admin/unified-advertisement-types/:id', () => {
|
|
|
it('应该允许超级管理员更新广告类型', async () => {
|
|
it('应该允许超级管理员更新广告类型', async () => {
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
const typeRepository = dataSource.getRepository(UnifiedAdvertisementType);
|
|
const typeRepository = dataSource.getRepository(UnifiedAdvertisementType);
|
|
@@ -696,7 +696,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
remark: '更新后的备注'
|
|
remark: '更新后的备注'
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisement-types/:id'].$put({
|
|
|
|
|
|
|
+ const response = await adminClient[':id'].$put({
|
|
|
param: { id: testType.id },
|
|
param: { id: testType.id },
|
|
|
json: updateData
|
|
json: updateData
|
|
|
}, {
|
|
}, {
|
|
@@ -716,7 +716,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该返回404对于不存在的类型', async () => {
|
|
it('应该返回404对于不存在的类型', async () => {
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisement-types/:id'].$put({
|
|
|
|
|
|
|
+ const response = await adminClient[':id'].$put({
|
|
|
param: { id: 999999 },
|
|
param: { id: 999999 },
|
|
|
json: { name: '更新' }
|
|
json: { name: '更新' }
|
|
|
}, {
|
|
}, {
|
|
@@ -729,7 +729,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- describe('DELETE /api/v1/admin/unified-advertisement-types/:id', () => {
|
|
|
|
|
|
|
+ describe('DELETE /admin/unified-advertisement-types/:id', () => {
|
|
|
it('应该允许超级管理员软删除广告类型', async () => {
|
|
it('应该允许超级管理员软删除广告类型', async () => {
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
const typeRepository = dataSource.getRepository(UnifiedAdvertisementType);
|
|
const typeRepository = dataSource.getRepository(UnifiedAdvertisementType);
|
|
@@ -743,7 +743,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
await typeRepository.save(testType);
|
|
await typeRepository.save(testType);
|
|
|
|
|
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisement-types/:id'].$delete({
|
|
|
|
|
|
|
+ const response = await adminClient[':id'].$delete({
|
|
|
param: { id: testType.id }
|
|
param: { id: testType.id }
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -763,7 +763,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该返回404对于不存在的类型', async () => {
|
|
it('应该返回404对于不存在的类型', async () => {
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisement-types/:id'].$delete({
|
|
|
|
|
|
|
+ const response = await adminClient[':id'].$delete({
|
|
|
param: { id: 999999 }
|
|
param: { id: 999999 }
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -803,7 +803,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- describe('GET /advertisement-types', () => {
|
|
|
|
|
|
|
+ describe('GET /advertisement-types(用户端)', () => {
|
|
|
beforeEach(async () => {
|
|
beforeEach(async () => {
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
const typeRepository = dataSource.getRepository(UnifiedAdvertisementType);
|
|
const typeRepository = dataSource.getRepository(UnifiedAdvertisementType);
|
|
@@ -832,7 +832,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该返回有效的广告类型列表(status=1)', async () => {
|
|
it('应该返回有效的广告类型列表(status=1)', async () => {
|
|
|
- const response = await userClient['/api/v1/advertisement-types'].$get({
|
|
|
|
|
|
|
+ const response = await userClient.$get({
|
|
|
query: { page: 1, pageSize: 10 }
|
|
query: { page: 1, pageSize: 10 }
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -854,7 +854,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该支持关键词搜索', async () => {
|
|
it('应该支持关键词搜索', async () => {
|
|
|
- const response = await userClient['/api/v1/advertisement-types'].$get({
|
|
|
|
|
|
|
+ const response = await userClient.$get({
|
|
|
query: { page: 1, pageSize: 10, keyword: '首页' }
|
|
query: { page: 1, pageSize: 10, keyword: '首页' }
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -870,7 +870,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该拒绝未认证用户访问', async () => {
|
|
it('应该拒绝未认证用户访问', async () => {
|
|
|
- const response = await userClient['/api/v1/advertisement-types'].$get({
|
|
|
|
|
|
|
+ const response = await userClient.$get({
|
|
|
query: { page: 1, pageSize: 10 }
|
|
query: { page: 1, pageSize: 10 }
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -949,7 +949,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该能够在广告列表中包含类型信息', async () => {
|
|
it('应该能够在广告列表中包含类型信息', async () => {
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisements'].$get({
|
|
|
|
|
|
|
+ const response = await adminClient.$get({
|
|
|
query: { page: 1, pageSize: 10 }
|
|
query: { page: 1, pageSize: 10 }
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|
|
@@ -967,7 +967,7 @@ describe('统一广告模块集成测试', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该支持按类型ID筛选广告', async () => {
|
|
it('应该支持按类型ID筛选广告', async () => {
|
|
|
- const response = await adminClient['/api/v1/admin/unified-advertisements'].$get({
|
|
|
|
|
|
|
+ const response = await adminClient.$get({
|
|
|
query: { page: 1, pageSize: 10, typeId: testType.id }
|
|
query: { page: 1, pageSize: 10, typeId: testType.id }
|
|
|
}, {
|
|
}, {
|
|
|
headers: {
|
|
headers: {
|