From 776812ad87c5a0e36e92682d871faa33a7afff07 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Tue, 1 Aug 2023 09:06:30 -0400 Subject: [PATCH] test: adjust tests for assertions on moderation categories --- .../Fixtures/Moderations/CreateResponseFixture.php | 8 ++++++++ tests/Fixtures/Moderation.php | 8 ++++++++ tests/Resources/Moderations.php | 7 ++++++- tests/Responses/Moderations/CreateResponseResult.php | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Testing/Responses/Fixtures/Moderations/CreateResponseFixture.php b/src/Testing/Responses/Fixtures/Moderations/CreateResponseFixture.php index c39c313d..0c03c74c 100644 --- a/src/Testing/Responses/Fixtures/Moderations/CreateResponseFixture.php +++ b/src/Testing/Responses/Fixtures/Moderations/CreateResponseFixture.php @@ -12,7 +12,11 @@ final class CreateResponseFixture 'categories' => [ 'hate' => false, 'hate/threatening' => true, + 'harassment' => false, + 'harassment/threatening' => false, 'self-harm' => false, + 'self-harm/intent' => false, + 'self-harm/instructions' => false, 'sexual' => false, 'sexual/minors' => false, 'violence' => true, @@ -21,7 +25,11 @@ final class CreateResponseFixture 'category_scores' => [ 'hate' => 0.22714105248451233, 'hate/threatening' => 0.4132447838783264, + 'harassment' => 0.1602763684674149, + 'harassment/threatening' => 0.1602763684674149, 'self-harm' => 0.005232391878962517, + 'self-harm/intent' => 0.005134391873962517, + 'self-harm/instructions' => 0.005132591874962517, 'sexual' => 0.01407341007143259, 'sexual/minors' => 0.0038522258400917053, 'violence' => 0.9223177433013916, diff --git a/tests/Fixtures/Moderation.php b/tests/Fixtures/Moderation.php index 6bcb88f2..322cbf25 100644 --- a/tests/Fixtures/Moderation.php +++ b/tests/Fixtures/Moderation.php @@ -13,7 +13,11 @@ function moderationResource(): array 'categories' => [ 'hate' => false, 'hate/threatening' => true, + 'harassment' => false, + 'harassment/threatening' => false, 'self-harm' => false, + 'self-harm/intent' => false, + 'self-harm/instructions' => false, 'sexual' => false, 'sexual/minors' => false, 'violence' => true, @@ -22,7 +26,11 @@ function moderationResource(): array 'category_scores' => [ 'hate' => 0.22714105248451233, 'hate/threatening' => 0.4132447838783264, + 'harassment' => 0.1602763684674149, + 'harassment/threatening' => 0.1602763684674149, 'self-harm' => 0.005232391878962517, + 'self-harm/intent' => 0.005134391873962517, + 'self-harm/instructions' => 0.005132591874962517, 'sexual' => 0.01407341007143259, 'sexual/minors' => 0.0038522258400917053, 'violence' => 0.9223177433013916, diff --git a/tests/Resources/Moderations.php b/tests/Resources/Moderations.php index 0a30f508..99248acb 100644 --- a/tests/Resources/Moderations.php +++ b/tests/Resources/Moderations.php @@ -25,11 +25,16 @@ expect($result->results[0]) ->flagged->toBeTrue() - ->categories->toHaveCount(7) + ->categories->toHaveCount(11) ->each->toBeInstanceOf(CreateResponseCategory::class); expect($result->results[0]->categories[Category::Hate->value]) ->category->toBe(Category::Hate) ->violated->toBe(false) ->score->toBe(0.22714105248451233); + + expect($result->results[0]->categories[Category::Violence->value]) + ->category->toBe(Category::Violence) + ->violated->toBe(true) + ->score->toBe(0.9223177433013916); }); diff --git a/tests/Responses/Moderations/CreateResponseResult.php b/tests/Responses/Moderations/CreateResponseResult.php index 99c57903..5196a984 100644 --- a/tests/Responses/Moderations/CreateResponseResult.php +++ b/tests/Responses/Moderations/CreateResponseResult.php @@ -8,7 +8,7 @@ expect($result) ->flagged->toBeTrue() - ->categories->toHaveCount(7) + ->categories->toHaveCount(11) ->each->toBeInstanceOf(CreateResponseCategory::class); });