test(tenant): cover split website types and migration
This commit is contained in:
@@ -12,7 +12,7 @@ use App\Domains\Notification\Events\PasswordResetRequested;
|
||||
use App\Domains\Notification\Services\NotificationMailService;
|
||||
use App\Domains\Purchase\Models\Purchase;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use App\Domains\Tenant\Models\WebsiteType;
|
||||
use App\Domains\Tenant\Models\AdminWebsiteType;
|
||||
use App\Domains\Ticket\Models\Ticket;
|
||||
use Barryvdh\DomPDF\ServiceProvider as DomPdfServiceProvider;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
@@ -74,7 +74,7 @@ class NotificationMailServiceTest extends TestCase
|
||||
|
||||
public function test_it_sends_a_branded_welcome_email(): void
|
||||
{
|
||||
$this->useWebsiteTypeBranding();
|
||||
$this->useAdminWebsiteTypeBranding();
|
||||
|
||||
app(NotificationMailService::class)->sendWelcome($this->user->id, $this->tenant->codigo);
|
||||
app(NotificationMailService::class)->sendWelcome($this->user->id, $this->tenant->codigo);
|
||||
@@ -83,18 +83,17 @@ class NotificationMailServiceTest extends TestCase
|
||||
|
||||
Mail::assertSent(Mailable::class, function (Mailable $mail): bool {
|
||||
$mail->assertTo('ada@example.com');
|
||||
$mail->assertHasSubject('Bienvenido a OnTicket');
|
||||
$mail->assertHasSubject('Bienvenido a Mail Tenant');
|
||||
|
||||
return str_contains($mail->render(), 'Ada Lovelace')
|
||||
&& str_contains($mail->render(), 'OnTicket')
|
||||
&& ! str_contains($mail->render(), 'Mail Tenant')
|
||||
&& str_contains($mail->render(), 'border-top: 4px solid #ff7006');
|
||||
&& str_contains($mail->render(), 'Mail Tenant')
|
||||
&& str_contains($mail->render(), 'border-top: 4px solid #112233');
|
||||
});
|
||||
}
|
||||
|
||||
public function test_it_sends_a_branded_password_reset_email(): void
|
||||
{
|
||||
$this->useWebsiteTypeBranding();
|
||||
$this->useAdminWebsiteTypeBranding();
|
||||
$attempt = $this->user->resetPasswordAttempts()->create([
|
||||
'codigo' => '0123',
|
||||
]);
|
||||
@@ -112,15 +111,13 @@ class NotificationMailServiceTest extends TestCase
|
||||
|
||||
Mail::assertSent(Mailable::class, function (Mailable $mail): bool {
|
||||
$mail->assertTo('ada@example.com');
|
||||
$mail->assertHasSubject('Código para recuperar tu contraseña - OnTicket');
|
||||
$mail->assertHasSubject('Código para recuperar tu contraseña - Mail Tenant');
|
||||
$rendered = $mail->render();
|
||||
|
||||
return str_contains($rendered, '0123')
|
||||
&& str_contains($rendered, 'Ada Lovelace')
|
||||
&& str_contains($rendered, 'OnTicket')
|
||||
&& ! str_contains($rendered, 'Mail Tenant')
|
||||
&& str_contains($rendered, '#ff7006')
|
||||
&& ! str_contains($rendered, 'border: 2px solid #112233');
|
||||
&& str_contains($rendered, 'Mail Tenant')
|
||||
&& str_contains($rendered, '#112233');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -147,13 +144,13 @@ class NotificationMailServiceTest extends TestCase
|
||||
|
||||
public function test_it_links_scanner_password_resets_to_the_scanner_domain(): void
|
||||
{
|
||||
$websiteType = WebsiteType::query()->create([
|
||||
$websiteType = AdminWebsiteType::query()->create([
|
||||
'codigo' => 'scanner-mail',
|
||||
'nombre' => 'Scanner Mail',
|
||||
'dominio' => 'admin.mail.local',
|
||||
'scanner_domain' => 'scanner.mail.local',
|
||||
]);
|
||||
$this->tenant->update(['website_type_code' => $websiteType->codigo]);
|
||||
$this->tenant->update(['admin_website_type_code' => $websiteType->codigo]);
|
||||
$attempt = $this->user->resetPasswordAttempts()->create([
|
||||
'codigo' => '0123',
|
||||
'reason' => ResetPasswordAttempt::REASON_STAFF_CREATED,
|
||||
@@ -181,11 +178,11 @@ class NotificationMailServiceTest extends TestCase
|
||||
|
||||
public function test_administrator_creation_has_custom_copy_and_the_existing_code_and_link(): void
|
||||
{
|
||||
$websiteType = WebsiteType::query()->create([
|
||||
$websiteType = AdminWebsiteType::query()->create([
|
||||
'codigo' => 'admin-mail', 'nombre' => 'Admin Mail',
|
||||
'dominio' => 'admin.mail.local', 'scanner_domain' => 'scanner.mail.local',
|
||||
]);
|
||||
$this->tenant->update(['website_type_code' => $websiteType->codigo]);
|
||||
$this->tenant->update(['admin_website_type_code' => $websiteType->codigo]);
|
||||
$attempt = $this->user->resetPasswordAttempts()->create([
|
||||
'codigo' => '0456', 'reason' => ResetPasswordAttempt::REASON_ADMINISTRATOR_CREATED,
|
||||
]);
|
||||
@@ -226,7 +223,7 @@ class NotificationMailServiceTest extends TestCase
|
||||
|
||||
public function test_it_sends_one_purchase_confirmation_with_generated_tickets_attached(): void
|
||||
{
|
||||
$this->useWebsiteTypeBranding();
|
||||
$this->useAdminWebsiteTypeBranding();
|
||||
$purchase = Purchase::query()->create([
|
||||
'tenant_codigo' => $this->tenant->codigo,
|
||||
'user_id' => $this->user->id,
|
||||
@@ -443,9 +440,9 @@ class NotificationMailServiceTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
private function useWebsiteTypeBranding(): void
|
||||
private function useAdminWebsiteTypeBranding(): void
|
||||
{
|
||||
$websiteType = WebsiteType::query()->create([
|
||||
$websiteType = AdminWebsiteType::query()->create([
|
||||
'codigo' => 'onticket',
|
||||
'nombre' => 'OnTicket',
|
||||
'dominio' => 'onticket.local',
|
||||
@@ -456,7 +453,7 @@ class NotificationMailServiceTest extends TestCase
|
||||
'login_header_footer_color' => '#838383',
|
||||
]);
|
||||
|
||||
$this->tenant->update(['website_type_code' => $websiteType->codigo]);
|
||||
$this->tenant->unsetRelation('websiteType');
|
||||
$this->tenant->update(['admin_website_type_code' => $websiteType->codigo]);
|
||||
$this->tenant->unsetRelation('adminWebsiteType');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user