|
|
@@ -69,6 +69,48 @@ final class CrudPagesTest extends AppTestCase
|
|
|
self::assertStringContainsString('moderate', (string) $response->getBody());
|
|
|
}
|
|
|
|
|
|
+ public function testPolicyEditAlignsThresholdsToCategoryRows(): void
|
|
|
+ {
|
|
|
+ // Regression: |merge of {(int_id): val} renumbered the keys via
|
|
|
+ // PHP array_merge, shifting each rendered value up one row and
|
|
|
+ // leaving the last category blank. Use category IDs that are not
|
|
|
+ // a 0-based sequence so any reindexing is observable.
|
|
|
+ $this->enqueueApiResponse(200, [
|
|
|
+ 'id' => 1, 'name' => 'custom', 'description' => null,
|
|
|
+ 'include_manual_blocks' => true,
|
|
|
+ 'thresholds' => [
|
|
|
+ ['category_id' => 11, 'category_slug' => 'scanners', 'threshold' => 40.0],
|
|
|
+ ['category_id' => 12, 'category_slug' => 'indexer', 'threshold' => 30.0],
|
|
|
+ ['category_id' => 13, 'category_slug' => 'malicious', 'threshold' => 20.0],
|
|
|
+ ['category_id' => 14, 'category_slug' => 'load', 'threshold' => 10.0],
|
|
|
+ ],
|
|
|
+ 'created_at' => '2026-04-29T10:00:00Z',
|
|
|
+ ]);
|
|
|
+ $this->enqueueApiResponse(200, ['items' => [
|
|
|
+ ['id' => 11, 'slug' => 'scanners', 'name' => 'Scanners', 'description' => null, 'decay_function' => 'exponential', 'decay_param' => 14.0, 'is_active' => true],
|
|
|
+ ['id' => 12, 'slug' => 'indexer', 'name' => 'Indexer', 'description' => null, 'decay_function' => 'exponential', 'decay_param' => 14.0, 'is_active' => true],
|
|
|
+ ['id' => 13, 'slug' => 'malicious', 'name' => 'Malicious', 'description' => null, 'decay_function' => 'exponential', 'decay_param' => 14.0, 'is_active' => true],
|
|
|
+ ['id' => 14, 'slug' => 'load', 'name' => 'Load', 'description' => null, 'decay_function' => 'exponential', 'decay_param' => 14.0, 'is_active' => true],
|
|
|
+ ], 'total' => 4]);
|
|
|
+
|
|
|
+ $response = $this->request('GET', '/app/policies/1');
|
|
|
+ self::assertSame(200, $response->getStatusCode());
|
|
|
+ $body = (string) $response->getBody();
|
|
|
+
|
|
|
+ foreach ([
|
|
|
+ ['scanners', '40'],
|
|
|
+ ['indexer', '30'],
|
|
|
+ ['malicious', '20'],
|
|
|
+ ['load', '10'],
|
|
|
+ ] as [$slug, $val]) {
|
|
|
+ self::assertMatchesRegularExpression(
|
|
|
+ '/name="thresholds\[' . preg_quote($slug, '/') . '\]"[^>]*value="' . $val . '"/',
|
|
|
+ $body,
|
|
|
+ "row {$slug} must render value {$val}",
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function testReportersListRenders(): void
|
|
|
{
|
|
|
$this->enqueueApiResponse(200, ['data' => [
|