Ver Fonte

test(api-v13): assessment 的 score 改用整数,补「带小数 → 422」

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
visuddhinanda há 18 horas atrás
pai
commit
88bc35347f

+ 6 - 5
api-v13/tests/Feature/DiscussionV3Test.php

@@ -556,7 +556,7 @@ it('lets only the sentence manager assess a sentence, publicly and without notif
     $owner = makeStudio('owner');
     $owner = makeStudio('owner');
     $target = makeTargetSentence($owner);
     $target = makeTargetSentence($owner);
     $payload = ['target_type' => 'sentence', 'target_id' => $target, 'type' => 'assessment',
     $payload = ['target_type' => 'sentence', 'target_id' => $target, 'type' => 'assessment',
-        'severity' => 'mqm', 'score' => 87.5, 'content' => '术语一致,语序略生硬'];
+        'severity' => 'mqm', 'score' => 87, 'content' => '术语一致,语序略生硬'];
 
 
     $this->postJson('/api/v3/discussions', $payload)->assertUnauthorized();
     $this->postJson('/api/v3/discussions', $payload)->assertUnauthorized();
     $this->postJson('/api/v3/discussions', $payload, authHeader(makeStudio('stranger')))->assertForbidden();
     $this->postJson('/api/v3/discussions', $payload, authHeader(makeStudio('stranger')))->assertForbidden();
@@ -566,7 +566,7 @@ it('lets only the sentence manager assess a sentence, publicly and without notif
         ->assertCreated()
         ->assertCreated()
         ->assertJsonPath('data.type', 'assessment')
         ->assertJsonPath('data.type', 'assessment')
         ->assertJsonPath('data.severity', 'mqm')
         ->assertJsonPath('data.severity', 'mqm')
-        ->assertJsonPath('data.score', 87.5)
+        ->assertJsonPath('data.score', 87)
         ->assertJsonPath('data.title', null)
         ->assertJsonPath('data.title', null)
         ->assertJsonPath('data.content', '术语一致,语序略生硬')
         ->assertJsonPath('data.content', '术语一致,语序略生硬')
         ->assertJsonPath('data.abilities', ['update' => true, 'delete' => true, 'close' => false, 'reply' => true])
         ->assertJsonPath('data.abilities', ['update' => true, 'delete' => true, 'close' => false, 'reply' => true])
@@ -574,7 +574,7 @@ it('lets only the sentence manager assess a sentence, publicly and without notif
     Log::shouldNotHaveReceived('debug', fn (string $message) => $message === 'mq publish');
     Log::shouldNotHaveReceived('debug', fn (string $message) => $message === 'mq publish');
 
 
     // 公开:匿名看得到;不带 type 的列表不列评估
     // 公开:匿名看得到;不带 type 的列表不列评估
-    $this->getJson("/api/v3/discussions/{$id}")->assertOk()->assertJsonPath('data.score', 87.5);
+    $this->getJson("/api/v3/discussions/{$id}")->assertOk()->assertJsonPath('data.score', 87);
     $base = "/api/v3/discussions?target_type=sentence&target_id={$target}";
     $base = "/api/v3/discussions?target_type=sentence&target_id={$target}";
     $this->getJson($base)->assertJsonCount(0, 'data');
     $this->getJson($base)->assertJsonCount(0, 'data');
     $this->getJson("{$base}&type=assessment")->assertJsonCount(1, 'data');
     $this->getJson("{$base}&type=assessment")->assertJsonCount(1, 'data');
@@ -617,6 +617,7 @@ it('validates assessment input', function () {
     $post(['score' => null])->assertStatus(422)->assertJsonValidationErrors('score');
     $post(['score' => null])->assertStatus(422)->assertJsonValidationErrors('score');
     $post(['score' => 101])->assertStatus(422)->assertJsonValidationErrors('score');
     $post(['score' => 101])->assertStatus(422)->assertJsonValidationErrors('score');
     $post(['score' => -1])->assertStatus(422)->assertJsonValidationErrors('score');
     $post(['score' => -1])->assertStatus(422)->assertJsonValidationErrors('score');
+    $post(['score' => 80.5])->assertStatus(422)->assertJsonValidationErrors('score');   // 只收整数
     $post(['severity' => null])->assertStatus(422)->assertJsonValidationErrors('severity');
     $post(['severity' => null])->assertStatus(422)->assertJsonValidationErrors('severity');
     $post(['severity' => 'has space'])->assertStatus(422)->assertJsonValidationErrors('severity');
     $post(['severity' => 'has space'])->assertStatus(422)->assertJsonValidationErrors('severity');
     $post(['severity' => str_repeat('a', 17)])->assertStatus(422)->assertJsonValidationErrors('severity');
     $post(['severity' => str_repeat('a', 17)])->assertStatus(422)->assertJsonValidationErrors('severity');
@@ -643,9 +644,9 @@ it('updates an assessment score and method, and keeps it apart from other types'
     $patch($topic, ['type' => 'assessment'])->assertStatus(422)->assertJsonValidationErrors('type');
     $patch($topic, ['type' => 'assessment'])->assertStatus(422)->assertJsonValidationErrors('type');
     $patch($topic, ['score' => 10])->assertStatus(422)->assertJsonValidationErrors('score');
     $patch($topic, ['score' => 10])->assertStatus(422)->assertJsonValidationErrors('score');
 
 
-    $patch($assessment, ['score' => 66.25, 'severity' => 'llm-judge', 'content' => '复核'])
+    $patch($assessment, ['score' => 66, 'severity' => 'llm-judge', 'content' => '复核'])
         ->assertOk()
         ->assertOk()
-        ->assertJsonPath('data.score', 66.25)
+        ->assertJsonPath('data.score', 66)
         ->assertJsonPath('data.severity', 'llm-judge')
         ->assertJsonPath('data.severity', 'llm-judge')
         ->assertJsonPath('data.content', '复核');
         ->assertJsonPath('data.content', '复核');
 });
 });

+ 6 - 6
api-v13/tests/Feature/ReadingAnnotationsTest.php

@@ -169,7 +169,7 @@ it('leaves issue markup out of plain text output but keeps the glossary term', f
 
 
 /* ------------------------------------------------------------------ 评估 */
 /* ------------------------------------------------------------------ 评估 */
 
 
-it('marks an assessed sentence with a check coloured by score, after any issue mark', function (float $score, string $level) {
+it('marks an assessed sentence with a check coloured by score, after any issue mark', function (int $score, string $level) {
     [$channel, $sentence] = makeAnnotatedSentence();
     [$channel, $sentence] = makeAnnotatedSentence();
     makeAnchored($sentence->uid, 'issue', ['severity' => 'warning']);
     makeAnchored($sentence->uid, 'issue', ['severity' => 'warning']);
     $assessment = makeAnchored($sentence->uid, 'assessment', ['title' => null, 'severity' => 'mqm', 'score' => $score]);
     $assessment = makeAnchored($sentence->uid, 'assessment', ['title' => null, 'severity' => 'mqm', 'score' => $score]);
@@ -182,9 +182,9 @@ it('marks an assessed sentence with a check coloured by score, after any issue m
         ->toContain('<i class="ti ti-circle-check"></i>')
         ->toContain('<i class="ti ti-circle-check"></i>')
         ->and(mb_strpos($display, 'anno-issue-mark'))->toBeLessThan(mb_strpos($display, 'anno-assessment-mark'));
         ->and(mb_strpos($display, 'anno-issue-mark'))->toBeLessThan(mb_strpos($display, 'anno-assessment-mark'));
 })->with([
 })->with([
-    'high' => [80.0, 'high'],
-    'medium' => [79.99, 'medium'],
-    'low' => [12.5, 'low'],
+    'high' => [80, 'high'],
+    'medium' => [79, 'medium'],
+    'low' => [12, 'low'],
 ]);
 ]);
 
 
 it('drops the cache when an assessment is rescored, and leaves it out of plain text', function () {
 it('drops the cache when an assessment is rescored, and leaves it out of plain text', function () {
@@ -193,8 +193,8 @@ it('drops the cache when an assessment is rescored, and leaves it out of plain t
 
 
     expect(readFirstParagraph($channel))->toContain('data-score="30"');
     expect(readFirstParagraph($channel))->toContain('data-score="30"');
 
 
-    $assessment->forceFill(['score' => 95.5])->save();
-    expect(readFirstParagraph($channel))->toContain('data-score="95.5"')->toContain('anno-assessment-high');
+    $assessment->forceFill(['score' => 95])->save();
+    expect(readFirstParagraph($channel))->toContain('data-score="95"')->toContain('anno-assessment-high');
 
 
     $text = app(PaliContentService::class)->readParagraph(9101, 1, $channel, 'text')['display'];
     $text = app(PaliContentService::class)->readParagraph(9101, 1, $channel, 'text')['display'];
     expect($text)->toBe('first sentence');
     expect($text)->toBe('first sentence');