17-publish.spec.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. expect(res.code).toBe(0);
  14. });
  15. test('PU02: 获取发布任务列表 GET /api/publish/tasks', async () => {
  16. const res = await apiGet('/api/publish/tasks');
  17. expect(res.code).toBe(0);
  18. });
  19. });
  20. // ===== 18: 会员中心 =====
  21. test.describe('会员中心 (Member)', () => {
  22. test.beforeAll(async () => { await initApiClient(); });
  23. test.afterAll(async () => { await disposeApiClient(); });
  24. test('MB01: 获取会员状态 GET /api/member/status', async () => {
  25. const res = await apiGet('/api/member/status');
  26. expect(res.code).toBe(0);
  27. });
  28. });
  29. // ===== 19: 用户反馈 =====
  30. test.describe('用户反馈 (Feedback)', () => {
  31. test.beforeAll(async () => { await initApiClient(); });
  32. test.afterAll(async () => { await disposeApiClient(); });
  33. test('FB01: 获取反馈列表 GET /api/feedback', async () => {
  34. const res = await apiGet('/api/feedback');
  35. expect(res.code).toBe(0);
  36. });
  37. test('FB02: 提交反馈 POST /api/feedback', async () => {
  38. const res = await apiPost('/api/feedback', {
  39. content: '[自动化测试] 反馈内容',
  40. type: 'bug',
  41. });
  42. expect([0, 400, 401]).toContain(res.code);
  43. });
  44. });
  45. // ===== 20: 分享功能 =====
  46. test.describe('分享功能 (Share)', () => {
  47. test.beforeAll(async () => { await initApiClient(); });
  48. test.afterAll(async () => { await disposeApiClient(); });
  49. test('SH01: 获取分享链接 GET /api/share', async () => {
  50. const res = await apiGet('/api/share');
  51. expect(res.code).toBe(0);
  52. });
  53. });
  54. // ===== 21: 用户偏好 =====
  55. test.describe('用户偏好 (Preferences)', () => {
  56. test.beforeAll(async () => { await initApiClient(); });
  57. test.afterAll(async () => { await disposeApiClient(); });
  58. test('PR01: 获取偏好 GET /api/user/preferences', async () => {
  59. const res = await apiGet('/api/user/preferences');
  60. expect(res.code).toBe(0);
  61. });
  62. test('PR02: 更新偏好 PUT /api/user/preferences', async () => {
  63. const res = await apiPut('/api/user/preferences', {
  64. playSpeed: 1.5,
  65. quality: 'high',
  66. });
  67. expect([0, 401, 400]).toContain(res.code);
  68. });
  69. });
  70. // ===== 22: 分类浏览 =====
  71. test.describe('分类浏览 (Categories)', () => {
  72. test.beforeAll(async () => { await initApiClient(); });
  73. test.afterAll(async () => { await disposeApiClient(); });
  74. test('CT01: 获取分类列表 GET /api/categories', async () => {
  75. const res = await apiGet('/api/categories');
  76. expect(res.code).toBe(0);
  77. });
  78. });
  79. // ===== 签到功能 =====
  80. test.describe('签到功能 (Sign)', () => {
  81. test.beforeAll(async () => { await initApiClient(); });
  82. test.afterAll(async () => { await disposeApiClient(); });
  83. test('SG01: 获取签到状态 GET /api/sign/status', async () => {
  84. const res = await apiGet('/api/sign/status');
  85. expect(res.code).toBe(0);
  86. });
  87. test('SG02: 执行签到 POST /api/sign', async () => {
  88. const res = await apiPost('/api/sign');
  89. expect([0, 400, 401]).toContain(res.code);
  90. });
  91. });