-
-
Notifications
You must be signed in to change notification settings - Fork 187
Expand file tree
/
Copy pathWebGroupsCatalogTest.php
More file actions
61 lines (52 loc) · 2.37 KB
/
Copy pathWebGroupsCatalogTest.php
File metadata and controls
61 lines (52 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
// SourceBans++ (c) 2014-2026 SourceBans++ Dev Team
// Licensed under the Elastic License 2.0.
// See LICENSE.txt for the full license text and THIRD-PARTY-NOTICES.txt for attributions.
declare(strict_types=1);
namespace Sbpp\Tests\Integration;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use Sbpp\View\AdminGroupsListView;
/**
* Pins the client-side master-detail catalog contract: the View
* carries a JSON blob, the list template emits it, and the page
* handler builds the payload from `$web_group_list`.
*/
final class WebGroupsCatalogTest extends TestCase
{
public function testAdminGroupsListViewExposesCatalogJsonProperty(): void
{
$ref = new ReflectionClass(AdminGroupsListView::class);
$this->assertTrue(
$ref->hasProperty('web_groups_catalog_json'),
'AdminGroupsListView must expose web_groups_catalog_json for the client selector',
);
}
public function testGroupsListTemplateEmitsCatalogAndClientSelector(): void
{
$src = (string) file_get_contents(ROOT . 'themes/default/page_admin_groups_list.tpl');
$this->assertStringContainsString('id="web-groups-catalog"', $src);
$this->assertStringContainsString('data-testid="web-groups-catalog"', $src);
$this->assertStringContainsString('{$web_groups_catalog_json nofilter}', $src);
$this->assertStringContainsString('data-testid="group-detail-name"', $src);
$this->assertStringContainsString('data-testid="group-detail-members"', $src);
$this->assertStringContainsString('history.pushState', $src);
$this->assertStringContainsString('Discard unsaved changes', $src);
}
public function testGroupsListHandlerBuildsCatalogJson(): void
{
$src = php_strip_whitespace(ROOT . 'pages/admin.groups.php');
$this->assertStringContainsString('$web_groups_catalog', $src);
$this->assertStringContainsString('web_groups_catalog_json', $src);
$this->assertStringContainsString('JSON_HEX_TAG', $src);
$this->assertStringContainsString('JSON_THROW_ON_ERROR', $src);
}
public function testSpaceY2UtilityExistsForServerGroupTiles(): void
{
$css = (string) file_get_contents(ROOT . 'themes/default/css/theme.css');
$this->assertStringContainsString(
'.space-y-2 > * + * { margin-top: 0.5rem; }',
$css,
);
}
}