feat: derive autoresponder schedule from backend

This commit is contained in:
Marek Miklewicz
2026-06-02 19:55:07 +02:00
parent a0bd158a2e
commit f3abc7b33f
19 changed files with 248 additions and 43 deletions
+48
View File
@@ -28,3 +28,51 @@ test('directadmin user hooks are clickable and point to reserved icon path', fun
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);
});