|
|
@@ -84,6 +84,25 @@ final class PoliciesControllerTest extends AppTestCase
|
|
|
self::assertCount(2, $body['thresholds']);
|
|
|
}
|
|
|
|
|
|
+ public function testAdminCanCreatePolicyWithoutThresholds(): void
|
|
|
+ {
|
|
|
+ // The UI's create form deliberately omits the threshold matrix
|
|
|
+ // ("configure on edit page after creation"). A policy with zero
|
|
|
+ // thresholds is valid per SPEC §4 (absent row = category not
|
|
|
+ // considered) and may still emit manual blocks.
|
|
|
+ $token = $this->createToken(TokenKind::Admin, role: Role::Admin);
|
|
|
+ $response = $this->request(
|
|
|
+ 'POST',
|
|
|
+ '/api/v1/admin/policies',
|
|
|
+ ['Authorization' => 'Bearer ' . $token, 'Content-Type' => 'application/json'],
|
|
|
+ json_encode(['name' => 'empty', 'include_manual_blocks' => true]) ?: null,
|
|
|
+ );
|
|
|
+ self::assertSame(201, $response->getStatusCode());
|
|
|
+ $body = $this->decode($response);
|
|
|
+ self::assertSame('empty', $body['name']);
|
|
|
+ self::assertSame([], $body['thresholds']);
|
|
|
+ }
|
|
|
+
|
|
|
public function testCreateRejectsDuplicateName(): void
|
|
|
{
|
|
|
$token = $this->createToken(TokenKind::Admin, role: Role::Admin);
|