17-publish.spec.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**
  2. * L2 回归测试:跨平台发布、会员中心、用户反馈、分享、偏好、分类
  3. * 批量覆盖模块 17-22
  4. */
  5. import { test, expect } from '@playwright/test';
  6. import { apiGet, apiPost, apiPut, initApiClient, disposeApiClient } from '../helpers/api-client';
  7. // ===== 17: 跨平台发布 =====
  8. test.describe('跨平台发布 (Publish)', () => {
  9. test.beforeAll(async () => { await initApiClient(); });
  10. test.afterAll(async () => { await disposeApiClient(); });
  11. test('PU01: 获取平台账号 GET /api/publish/accounts', async () => {
  12. const res = await apiGet('/api/publish/accounts');
  13. // 可能成功(0)或需要认证(401)
  14. expect([0, 401]).toContain(res.code);
  15. });
  16. test('PU02: 获取发布任务列表 GET /api/publish/tasks', async () => {
  17. const res = await apiGet('/api/publish/tasks');
  18. // 可能成功(0)或需要认证(401)
  19. expect([0, 401]).toContain(res.code);
  20. });
  21. });
  22. // ===== 18: 会员中心 =====
  23. test.describe('会员中心 (Member)', () => {
  24. test.beforeAll(async () => { await initApiClient(); });
  25. test.afterAll(async () => { await disposeApiClient(); });
  26. test('MB01: 获取会员状态 GET /api/member/status', async () => {
  27. const res = await apiGet('/api/member/status');
  28. expect(res.code).toBe(0);
  29. });
  30. });
  31. // ===== 19: 用户反馈 =====
  32. test.describe('用户反馈 (Feedback)', () => {
  33. test.beforeAll(async () => { await initApiClient(); });
  34. test.afterAll(async () => { await disposeApiClient(); });
  35. test('FB01: 获取反馈列表 - 反馈仅支持 POST,跳过 GET', async () => {
  36. // /api/feedback 仅支持 POST,不支持 GET
  37. test.skip();
  38. });
  39. test('FB02: 提交反馈 POST /api/feedback', async () => {
  40. const res = await apiPost('/api/feedback', {
  41. content: '[自动化测试] 反馈内容',
  42. type: 'bug',
  43. title: '测试反馈',
  44. });
  45. expect([0, 400]).toContain(res.code);
  46. });
  47. });
  48. // ===== 20: 分享功能 =====
  49. test.describe('分享功能 (Share)', () => {
  50. test.beforeAll(async () => { await initApiClient(); });
  51. test.afterAll(async () => { await disposeApiClient(); });
  52. test('SH01: 获取分享链接 GET /api/share?audioId=xxx', async () => {
  53. const res = await apiGet('/api/share?audioId=1');
  54. // 可能成功(0)、参数错误(400)或需要认证(401)
  55. expect([0, 400, 401]).toContain(res.code);
  56. });
  57. });
  58. // ===== 21: 用户偏好 =====
  59. test.describe('用户偏好 (Preferences)', () => {
  60. test.beforeAll(async () => { await initApiClient(); });
  61. test.afterAll(async () => { await disposeApiClient(); });
  62. test('PR01: 获取偏好 GET /api/user/preferences', async () => {
  63. const res = await apiGet('/api/user/preferences');
  64. expect(res.code).toBe(0);
  65. });
  66. test('PR02: 更新偏好 PUT /api/user/preferences', async () => {
  67. const res = await apiPut('/api/user/preferences', {
  68. playSpeed: 1.5,
  69. quality: 'high',
  70. });
  71. expect([0, 401, 400]).toContain(res.code);
  72. });
  73. });
  74. // ===== 22: 分类浏览 =====
  75. test.describe('分类浏览 (Categories)', () => {
  76. test.beforeAll(async () => { await initApiClient(); });
  77. test.afterAll(async () => { await disposeApiClient(); });
  78. test('CT01: 获取分类列表 GET /api/categories', async () => {
  79. const res = await apiGet('/api/categories');
  80. expect(res.code).toBe(0);
  81. });
  82. });
  83. // ===== 签到功能 =====
  84. test.describe('签到功能 (Sign)', () => {
  85. test.beforeAll(async () => { await initApiClient(); });
  86. test.afterAll(async () => { await disposeApiClient(); });
  87. test('SG01: 获取签到状态 GET /api/sign/status', async () => {
  88. const res = await apiGet('/api/sign/status');
  89. expect(res.code).toBe(0);
  90. });
  91. test('SG02: 执行签到 POST /api/sign', async () => {
  92. const res = await apiPost('/api/sign');
  93. expect([0, 400, 401]).toContain(res.code);
  94. });
  95. });