完成上传下载连接,公告管理与详情页面,求种区页面,轮播图折扣显示,修改部分bug

Change-Id: I86fc294e32911cb3426a8b16f90aca371f975c11
diff --git a/src/api/helpPost.test.js b/src/api/helpPost.test.js
index b445b4d..53e9e01 100644
--- a/src/api/helpPost.test.js
+++ b/src/api/helpPost.test.js
@@ -1,6 +1,6 @@
 import MockAdapter from 'axios-mock-adapter';

 import { api } from './auth'; // 添加api导入

-import { createPost, getPosts, getPostDetail, likePost, addPostComment,deletePost } from './helpPost';

+import { createHelpPost, getHelpPosts, getHelpPostDetail, likeHelpPost, addHelpPostComment,deleteHelpPost,searchHelpPosts } from './helpPost';

 

 describe('求助帖API', () => {

   let mockAxios;

@@ -13,7 +13,7 @@
     mockAxios.restore();

   });

 

-  describe('createPost - 创建求助帖', () => {

+  describe('createHelpPost - 创建求助帖', () => {

     it('应该正确发送无图片帖子数据', async () => {

       const postData = {

         title: '测试标题',

@@ -30,7 +30,7 @@
         return [201, { code: 201 }];

       });

 

-      const response = await createPost(postData.title, postData.content, postData.authorId);

+      const response = await createHelpPost(postData.title, postData.content, postData.authorId);

       expect(response.status).toBe(201);

     });

   });

@@ -48,7 +48,7 @@
       return [201, { code: 201 }];

     });

 

-    const response = await createPost(

+    const response = await createHelpPost(

       postData.title, 

       postData.content, 

       postData.authorId, 

@@ -58,7 +58,7 @@
   });

 

 

-  describe('getPosts - 获取求助帖列表', () => {

+  describe('getHelpPosts - 获取求助帖列表', () => {

     it('应该支持分页参数', async () => {

       const page = 2, size = 10;

       mockAxios.onGet('/help/posts', { params: { page, size } }).reply(200, {

@@ -66,57 +66,21 @@
         data: []

       });

 

-      const response = await getPosts(page, size);

+      const response = await getHelpPosts(page, size);

       expect(response.status).toBe(200);

     });

   });

 

-  describe('likePost - 点赞求助帖', () => {

+  describe('likeHelpPost - 点赞求助帖', () => {

     it('应该正确发送点赞请求', async () => {

       mockAxios.onPost('/help/posts/post123/like').reply(200, { code: 200 });

-      const response = await likePost('post123');

+      const response = await likeHelpPost('post123');

       expect(response.status).toBe(200);

     });

   });

 

-  describe('addPostComment - 添加帖子评论', () => {

-    it('应该正确发送评论数据(无图片)', async () => {

-      const postId = 'post456';

-      const commentData = {

-        authorId: 'user1',

-        content: '测试评论'

-      };

-      

-      mockAxios.onPost(`/help/posts/${postId}/comments`).reply(config => {

-        const data = config.data;

-        expect(data.get('authorId')).toBe(commentData.authorId);

-        expect(data.get('content')).toBe(commentData.content);

-        expect(data.has('image')).toBe(false);

-        return [200, { code: 200 }];

-      });

-      

-      const response = await addPostComment('post456', commentData);

-      expect(response.status).toBe(200);

-    });

-    it('应该正确处理带图片的评论', async () => {

-      const postId = 'post456';

-      const commentData = {

-        authorId: 'user1',

-        content: '测试评论',

-        commentImage: new File(['content'], 'comment.jpg')

-      };

-      

-      mockAxios.onPost(`/help/posts/${postId}/comments`).reply(config => {

-        const data = config.data;

-        expect(data.get('image')).toBeInstanceOf(File);

-        return [200, { code: 200 }];

-      });

-

-      const response = await addPostComment(postId, commentData);

-      expect(response.status).toBe(200);

-    });

-  });

-  describe('deletePost - 删除帖子', () => {

+  

+  describe('deleteHelpPost - 删除帖子', () => {

     it('应该正确发送删除请求', async () => {

       const postId = 'post789';

       const authorId = 'user1';

@@ -126,8 +90,28 @@
         return [200, { code: 200 }];

       });

 

-      const response = await deletePost(postId, authorId);

+      const response = await deleteHelpPost(postId, authorId);

       expect(response.status).toBe(200);

     });

   });

+  describe('searchHelpPosts - 搜索求助帖', () => {

+      it('应该正确发送搜索请求', async () => {

+        const keyword = '测试';

+        const page = 1, size = 5;

+        

+        mockAxios.onGet('/help/posts/search', {

+          params: { keyword, page, size }

+        }).reply(200, {

+          code: 200,

+          data: {

+            records: [],

+            total: 0

+          }

+        });

+  

+        const response = await searchHelpPosts(keyword, page, size);

+        expect(response.status).toBe(200);

+        expect(response.data.data).toBeDefined();

+      });

+    });

 });
\ No newline at end of file