Explorar o código

✅ (api-test): tipitaka-chapter-channels 用固定章节坐标,不再要求包含 fixture channel

原断言要求列表里有 fixture channel,fixture 换成系统 channel 后必然失败
(该接口按设计不列系统 channel)。改为 fixtures.php 公共坐标 93/5(与 server 无关),
只校验能列出版本、行的形状与排序。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
visuddhinanda hai 9 horas
pai
achega
c977f6fb70
Modificáronse 2 ficheiros con 16 adicións e 23 borrados
  1. 12 23
      api-test/cases/10_tipitaka_chapter_channels.php
  2. 4 0
      api-test/fixtures.php

+ 12 - 23
api-test/cases/10_tipitaka_chapter_channels.php

@@ -5,25 +5,18 @@ use \WikipaliApi\Api\TipitakaChapterChannelsApi;
 /*
  * 一章有哪些 channel 及完成度:GET /v3/tipitaka-chapter-channels/{book}/{para}
  *
- * 只读、无写操作。章节坐标从 fixture channel 自己的进度里取(各服务器数据不同),
- * 再核对这一章的列表里有它。fixture channel 是公开的,匿名就看得到。
+ * 只读、无写操作。章节坐标取 fixtures.php 的 chapter_channels_book / chapter_channels_para
+ * (与 server 无关),核对这一章能匿名列出版本、行的形状与排序对。
  * 可见性矩阵(私有 / 共享 / 群组)、排序、N+1 由 api-v13 的 TipitakaChapterChannelV3Test 覆盖。
  */
 
-/** fixture channel 有进度的某一章的 [book, para] */
+/** 有若干译文版本的某一章的 [book, para] */
 function chapter_channel_coord(): array
 {
-    $res = raw('GET', '/v3/progress', ['channels' => fixtures()['channel'], 'per_page' => 1]);
-    assert_status(200, $res, '取 fixture channel 的章节进度');
-    $row = $res['body']['data'][0] ?? null;
-    if (! $row) {
-        skip('fixture channel 在这台服务器上没有章节进度');
-    }
-
-    return [(int) $row['book'], (int) $row['para']];
+    return [(int) fixtures()['chapter_channels_book'], (int) fixtures()['chapter_channels_para']];
 }
 
-test('GET /v3/tipitaka-chapter-channels/{book}/{para} → 200,含 fixture channel', function () {
+test('GET /v3/tipitaka-chapter-channels/{book}/{para} → 200,列出版本', function () {
     [$book, $para] = chapter_channel_coord();
     $res = request(fn () => api(TipitakaChapterChannelsApi::class)
         ->getApiV3TipitakaChapterChannelsBookParaWithHttpInfo($book, $para, 200));
@@ -31,20 +24,16 @@ test('GET /v3/tipitaka-chapter-channels/{book}/{para} → 200,含 fixture chan
     assert_has_key('data', $res['body'], 'tipitaka-chapter-channels');
     assert_has_key('meta', $res['body'], 'tipitaka-chapter-channels');
 
-    $hit = null;
+    if ($res['body']['data'] === []) {
+        fail('tipitaka-chapter-channels:应返回至少一个版本');
+    }
     foreach ($res['body']['data'] as $row) {
-        if (($row['channel']['id'] ?? null) === fixtures()['channel']) {
-            $hit = $row;
+        assert_eq($book, $row['book'] ?? null, 'book');
+        assert_eq($para, $row['para'] ?? null, 'para');
+        foreach (['id', 'progress', 'views', 'updated_at', 'channel', 'studio'] as $key) {
+            assert_has_key($key, $row, 'tipitaka-chapter-channels 行');
         }
     }
-    if (! $hit) {
-        fail('tipitaka-chapter-channels:应包含 fixture channel');
-    }
-    assert_eq($book, $hit['book'] ?? null, 'book');
-    assert_eq($para, $hit['para'] ?? null, 'para');
-    foreach (['id', 'progress', 'views', 'updated_at', 'studio'] as $key) {
-        assert_has_key($key, $hit, 'tipitaka-chapter-channels 行');
-    }
 
     // 按完成度降序
     $progress = array_column($res['body']['data'], 'progress');

+ 4 - 0
api-test/fixtures.php

@@ -12,6 +12,10 @@ return [
     // 一个 translation 类型、有翻译进度与译文数据的 channel
     'channel' => '4414c96e-4903-11ef-af72-571c3fee08e6',
 
+    // tipitaka-chapter-channels 用的章节坐标:一章有若干译文版本即可,与 server 无关
+    'chapter_channels_book' => 93,
+    'chapter_channels_para' => 5,
+
     // reactions / reactions/tally 用的 target(collection)
     'target_id' => '5b4511c1-c99f-47e7-9798-97b9e5229e18',