Page MenuHomePhorge

D4229.1775205522.diff
No OneTemporary

Authored By
Unknown
Size
9 KB
Referenced Files
None
Subscribers
None

D4229.1775205522.diff

diff --git a/config.demo/src/.env b/config.demo/src/.env
--- a/config.demo/src/.env
+++ b/config.demo/src/.env
@@ -30,7 +30,7 @@
WEBMAIL_URL=/roundcubemail/
SUPPORT_URL=/support
-SUPPORT_EMAIL=
+SUPPORT_EMAIL=support@example.com
LOG_CHANNEL=stdout
LOG_SLOW_REQUESTS=5
diff --git a/config.dev/src/.env b/config.dev/src/.env
--- a/config.dev/src/.env
+++ b/config.dev/src/.env
@@ -29,7 +29,7 @@
WEBMAIL_URL=/roundcubemail/
SUPPORT_URL=/support
-SUPPORT_EMAIL=
+SUPPORT_EMAIL=support@example.com
LOG_CHANNEL=stack
LOG_SLOW_REQUESTS=5
diff --git a/config.prod/src/.env b/config.prod/src/.env
--- a/config.prod/src/.env
+++ b/config.prod/src/.env
@@ -28,7 +28,6 @@
WEBMAIL_URL=/roundcubemail/
SUPPORT_URL=/support
-SUPPORT_EMAIL=
LOG_CHANNEL=stdout
LOG_SLOW_REQUESTS=5
diff --git a/src/app/Http/Middleware/DevelConfig.php b/src/app/Http/Middleware/DevelConfig.php
--- a/src/app/Http/Middleware/DevelConfig.php
+++ b/src/app/Http/Middleware/DevelConfig.php
@@ -1,6 +1,7 @@
<?php
namespace App\Http\Middleware;
+use Illuminate\Support\Facades\Cache;
use Closure;
@@ -31,6 +32,19 @@
if (!empty($provider)) {
\config(['services.payment_provider' => $provider]);
}
+
+ // Pick up config set in Tests\Browser::withConfig
+ // This wouldn't technically need to be in a middleware,
+ // but this way we ensure it's propagated during the next request.
+ if (Cache::has('duskconfig')) {
+ $configJson = Cache::get('duskconfig');
+ $configValues = json_decode($configJson, true);
+ if (!empty($configValues)) {
+ foreach ($configValues as $key => $value) {
+ \config([$key => $value]);
+ }
+ }
+ }
}
return $next($request);
diff --git a/src/resources/themes/default/lang/en/support.php b/src/resources/themes/default/lang/en/support.php
--- a/src/resources/themes/default/lang/en/support.php
+++ b/src/resources/themes/default/lang/en/support.php
@@ -1,7 +1,12 @@
<?php
return [
-
+ 'title' => "Contact Support",
+ 'text1' => "Our technical support team is here to provide help, should you run into issues."
+ . " You won’t have to talk to computers or navigate voice menus, but have actual human beings answering you personally.",
+ 'text2' => "This support is already included in your subscription fee, so there are no further costs for you."
+ . " If you have issues with your :site account, or questions about our product before you sign up, please contact us.",
+ 'contact' => "Contact Support",
'doc1' => "Our documentation contains answers to most frequently asked questions and much more.",
'doc2' => "Are you looking for an instant answer to your question or a quick solution for your problem, our Knowledgebase is where you will likely find it.",
'documentation' => "Documentation",
diff --git a/src/resources/themes/default/pages/support.blade.php b/src/resources/themes/default/pages/support.blade.php
--- a/src/resources/themes/default/pages/support.blade.php
+++ b/src/resources/themes/default/pages/support.blade.php
@@ -1,13 +1,40 @@
-<div id="support" class="card">
- <div class="card-body">
- <h3 class="card-title text-center">@lang('theme::support.documentation')</h3>
- <p class="card-text">
- @lang('theme::support.doc1')
- <br><br>
- @lang('theme::support.doc2')
- </p>
- </div>
- <div class="card-footer text-center">
- <a href="https://kb.kolab.org" class="btn btn-primary">@lang('theme::support.search-kb')</a>
+@php($support_email = \config('app.support_email'))
+
+<div id="support">
+@isset($support_email)
+ <div class="row row-cols-1 row-cols-md-2 g-2">
+ <div class="col">
+@endisset
+ <div class="card">
+ <div class="card-body">
+ <h3 class="card-title text-center">@lang('theme::support.documentation')</h3>
+ <p class="card-text">
+ @lang('theme::support.doc1')
+ <br/><br/>
+ @lang('theme::support.doc2')
+ </p>
+ </div>
+ <div class="card-footer text-center">
+ <a href="https://kb.kolab.org" class="btn btn-primary">@lang('theme::support.search-kb')</a>
+ </div>
+ </div>
+@isset($support_email)
+ </div>
+ <div class="col">
+ <div class="card">
+ <div class="card-body">
+ <h3 class="card-title text-center">@lang('theme::support.title')</h3>
+ <p class="card-text">
+ @lang('theme::support.text1')
+ <br/><br/>
+ @lang('theme::support.text2', ['site' => config('app.name')])
+ </p>
+ </div>
+ <div class="card-footer text-center">
+ <a href="/support/contact" class="btn btn-primary">@lang('theme::support.contact')</a>
+ </div>
+ </div>
+ </div>
+@endisset
</div>
</div>
diff --git a/src/tests/Browser.php b/src/tests/Browser.php
--- a/src/tests/Browser.php
+++ b/src/tests/Browser.php
@@ -2,7 +2,7 @@
namespace Tests;
-use Facebook\WebDriver\WebDriverKeys;
+use Illuminate\Support\Facades\Cache;
use PHPUnit\Framework\Assert;
use Tests\Browser\Components\Error;
use Tests\Browser\Components\Toast;
@@ -306,4 +306,18 @@
return $this;
}
+
+ /**
+ * Store custom config values in the cache to be picked up in the DevelConfig middleware on the next request.
+ *
+ * This allows to propagte custom config values to the server that interacts with the browser.
+ *
+ * @param array $config
+ * @return $this
+ */
+ public function withConfig(array $config)
+ {
+ Cache::put('duskconfig', json_encode($config));
+ return $this;
+ }
}
diff --git a/src/tests/Browser/SupportTest.php b/src/tests/Browser/SupportTest.php
--- a/src/tests/Browser/SupportTest.php
+++ b/src/tests/Browser/SupportTest.php
@@ -16,14 +16,18 @@
public function testSupportForm(): void
{
$this->browse(function (Browser $browser) {
- $browser->visit('/')
+ $browser->withConfig(['app.support_email' => ""])
+ ->visit('/')
->within(new Menu(), function ($browser) {
$browser->clickMenuItem('support');
})
->waitFor('#support')
- ->assertSeeIn('.card-title', 'Contact Support')
- ->assertSeeIn('a.btn-primary', 'Contact Support')
- ->click('a.btn-primary')
+ ->assertElementsCount('.card-title', 2)
+ ->with('.row .col:last-child', function ($card) {
+ $card->assertSeeIn('.card-title', 'Contact Support')
+ ->assertSeeIn('.btn-primary', 'Contact Support')
+ ->click('.btn-primary');
+ })
->with(new Dialog('#support-dialog'), function (Browser $browser) {
$browser->assertSeeIn('@title', 'Contact Support')
->assertFocused('#support-user')
@@ -39,7 +43,9 @@
->click('@button-cancel');
})
->assertMissing('#support-dialog')
- ->click('a.btn-primary')
+ ->with('.row .col:last-child', function ($card) {
+ $card->click('.btn-primary');
+ })
->with(new Dialog('#support-dialog'), function (Browser $browser) {
$browser->assertSeeIn('@title', 'Contact Support')
->assertFocused('#support-user')
@@ -48,9 +54,26 @@
->assertValue('#support-body', 'Body')
->click('@button-action');
})
- // Note: This line assumes SUPPORT_EMAIL is not set in config
->assertToast(Toast::TYPE_ERROR, 'Failed to submit the support request')
->assertVisible('#support-dialog');
});
}
+
+ /**
+ * Test disabled support contact form
+ */
+ public function testNoSupportForm(): void
+ {
+ $this->browse(function (Browser $browser) {
+ $browser->withConfig(['app.support_email' => null])
+ ->visit('/')
+ ->within(new Menu(), function ($browser) {
+ $browser->clickMenuItem('support');
+ })
+ ->waitFor('#support')
+ ->assertElementsCount('.card-title', 1)
+ ->assertSeeIn('.card-title', 'Documentation')
+ ->assertSeeIn('.btn-primary', 'Search Knowledgebase');
+ });
+ }
}
diff --git a/src/tests/TestCaseTrait.php b/src/tests/TestCaseTrait.php
--- a/src/tests/TestCaseTrait.php
+++ b/src/tests/TestCaseTrait.php
@@ -15,6 +15,7 @@
use Carbon\Carbon;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Support\Facades\Queue;
+use Illuminate\Support\Facades\Cache;
use PHPUnit\Framework\Assert;
trait TestCaseTrait
@@ -732,6 +733,8 @@
);
$this->publicDomainUser->assignPackage($packageKolab);
+
+ Cache::forget('duskconfig');
}
public function tearDown(): void
@@ -756,6 +759,8 @@
$this->deleteTestUser($this->publicDomainUser->email);
}
+ Cache::forget('duskconfig');
+
parent::tearDown();
}
}

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 3, 8:38 AM (14 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18823283
Default Alt Text
D4229.1775205522.diff (9 KB)

Event Timeline