79 lines
3.7 KiB
PHP
79 lines
3.7 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
test('mockup and planned UI do not expose backend terms', function (): void {
|
|
foreach (glob(dirname(__DIR__, 2) . '/docs/mockups/*.html') ?: [] as $file) {
|
|
$html = file_get_contents($file) ?: '';
|
|
assert_false(stripos($html, 'Exim') !== false, basename($file) . ' exposes Exim');
|
|
assert_false(stripos($html, 'DirectAdmin API') !== false, basename($file) . ' exposes API');
|
|
assert_false(stripos($html, 'backend.sh') !== false, basename($file) . ' exposes backend script');
|
|
}
|
|
});
|
|
|
|
test('mockup forms include calendar classes and delete confirmation view', function (): void {
|
|
$create = file_get_contents(dirname(__DIR__, 2) . '/docs/mockups/02-dodaj.html') ?: '';
|
|
$delete = file_get_contents(dirname(__DIR__, 2) . '/docs/mockups/04-podglad-usun.html') ?: '';
|
|
assert_contains('br-restore-calendar', $create);
|
|
assert_contains('br-calendar-grid', $create);
|
|
assert_contains('Potwierdź usunięcie', $delete);
|
|
assert_false(stripos($delete, 'checkbox') !== false);
|
|
});
|
|
|
|
test('directadmin user hooks are clickable and point to reserved icon path', function (): void {
|
|
$img = file_get_contents(PLUGIN_ROOT . '/hooks/user_img.html') ?: '';
|
|
$txt = file_get_contents(PLUGIN_ROOT . '/hooks/user_txt.html') ?: '';
|
|
|
|
assert_contains('<a href="/CMD_PLUGINS/global-autoresponder/index.html"', $img);
|
|
assert_contains('<img src="/CMD_PLUGINS/global-autoresponder/images/user_icon.svg"', $img);
|
|
assert_contains('<a href="/CMD_PLUGINS/global-autoresponder/index.html"', $txt);
|
|
assert_contains('Globalne autorespondery', $txt);
|
|
});
|
|
|
|
test('rule form uses minute time input and no summary box in exim mode', function (): void {
|
|
require_once PLUGIN_ROOT . '/exec/lib/Settings.php';
|
|
require_once PLUGIN_ROOT . '/exec/lib/Lang.php';
|
|
require_once PLUGIN_ROOT . '/exec/lib/DirectAdminUser.php';
|
|
require_once PLUGIN_ROOT . '/exec/lib/CsrfGuard.php';
|
|
require_once PLUGIN_ROOT . '/exec/lib/RuleRepository.php';
|
|
require_once PLUGIN_ROOT . '/exec/lib/AuditLog.php';
|
|
require_once PLUGIN_ROOT . '/exec/lib/AppContext.php';
|
|
require_once PLUGIN_ROOT . '/exec/handlers/_form_helpers.php';
|
|
|
|
$settingsPath = TEST_TMP . '/form.conf';
|
|
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\nGLOBAL_AUTORESPONDER_BACKEND=exim\n");
|
|
$settings = Settings::load($settingsPath);
|
|
$ctx = new AppContext(
|
|
new DirectAdminUser('alice', 'enhanced', 'pl', TEST_TMP . '/config'),
|
|
$settings,
|
|
new RuleRepository(TEST_TMP . '/data'),
|
|
new CsrfGuard('secret', 'alice', 'sid'),
|
|
Lang::load('pl', $settings),
|
|
new AuditLog(TEST_TMP . '/audit.log')
|
|
);
|
|
|
|
$html = render_rule_form($ctx, 'create', null);
|
|
assert_contains('type="time"', $html);
|
|
assert_contains('step="60"', $html);
|
|
assert_false(strpos($html, 'summary-card') !== false, 'Summary box should not be rendered in create/edit form');
|
|
assert_contains('Temat', $html);
|
|
assert_contains('Treść wiadomości', $html);
|
|
});
|
|
|
|
test('rule form uses native period selector in da mode', function (): void {
|
|
$settingsPath = TEST_TMP . '/form-da.conf';
|
|
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\nGLOBAL_AUTORESPONDER_BACKEND=da\n");
|
|
$settings = Settings::load($settingsPath);
|
|
$ctx = new AppContext(
|
|
new DirectAdminUser('alice', 'enhanced', 'pl', TEST_TMP . '/config'),
|
|
$settings,
|
|
new RuleRepository(TEST_TMP . '/data'),
|
|
new CsrfGuard('secret', 'alice', 'sid'),
|
|
Lang::load('pl', $settings),
|
|
new AuditLog(TEST_TMP . '/audit.log')
|
|
);
|
|
$html = render_rule_form($ctx, 'create', null);
|
|
assert_contains('name="start_value_period"', $html);
|
|
assert_contains('Rano', $html);
|
|
assert_false(strpos($html, 'type="time"') !== false);
|
|
});
|