Deploy Ladill Hosting / deploy (push) Failing after 17s
Shared web hosting extracted from the platform monolith, with CI deploy to /var/www/ladill-hosting matching Bird/Domains/Email. Co-authored-by: Cursor <cursoragent@cursor.com>
82 lines
2.9 KiB
PHP
82 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\EmailTeamMember;
|
|
use App\Models\User;
|
|
use App\Services\Billing\BillingClient;
|
|
use App\Services\Mailbox\MailboxClient;
|
|
use App\Services\Payment\WalletPaymentService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Str;
|
|
use Mockery;
|
|
use Tests\TestCase;
|
|
|
|
class AccountPagesTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
Mockery::close();
|
|
parent::tearDown();
|
|
}
|
|
|
|
private function user(): User
|
|
{
|
|
return User::create(['public_id' => (string) Str::uuid(), 'name' => 'A', 'email' => 'a+'.uniqid().'@x.com']);
|
|
}
|
|
|
|
public function test_settings_page_renders(): void
|
|
{
|
|
$this->actingAs($this->user())->get(route('account.settings'))->assertOk()->assertSee('Mailbox defaults');
|
|
}
|
|
|
|
public function test_team_page_renders_with_owner(): void
|
|
{
|
|
$u = $this->user();
|
|
$this->actingAs($u)->get(route('account.team'))->assertOk()->assertSee('Owner')->assertSee($u->email);
|
|
}
|
|
|
|
public function test_team_invite_creates_member(): void
|
|
{
|
|
$u = $this->user();
|
|
$this->actingAs($u)->post(route('account.team.store'), ['email' => 'mate@x.com', 'role' => 'member'])
|
|
->assertRedirect();
|
|
$this->assertDatabaseHas('email_team_members', ['account_id' => $u->id, 'email' => 'mate@x.com', 'status' => 'invited']);
|
|
}
|
|
|
|
public function test_developers_page_and_token_lifecycle(): void
|
|
{
|
|
$u = $this->user();
|
|
$this->actingAs($u)->get(route('account.developers'))->assertOk()->assertSee('Create a token');
|
|
$this->actingAs($u)->post(route('account.developers.store'), ['name' => 'CI'])
|
|
->assertRedirect()->assertSessionHas('new_token');
|
|
$this->assertSame(1, $u->tokens()->count());
|
|
}
|
|
|
|
public function test_billing_page_renders(): void
|
|
{
|
|
$w = Mockery::mock(WalletPaymentService::class);
|
|
$w->shouldReceive('balanceMinor')->andReturn(5000);
|
|
$this->app->instance(WalletPaymentService::class, $w);
|
|
|
|
$b = Mockery::mock(BillingClient::class);
|
|
$b->shouldReceive('serviceLedger')->andReturn(['spent_minor' => 1000, 'credited_minor' => 0]);
|
|
$b->shouldReceive('balanceMinor')->andReturn(5000);
|
|
$this->app->instance(BillingClient::class, $b);
|
|
|
|
$m = Mockery::mock(MailboxClient::class);
|
|
$m->shouldReceive('forUser')->andReturn([['address' => 'a@x.com', 'is_paid' => true, 'status' => 'active', 'quota_mb' => 10240]]);
|
|
$this->app->instance(MailboxClient::class, $m);
|
|
|
|
$this->actingAs($this->user())->get(route('account.billing'))
|
|
->assertOk()->assertSee('Mailbox subscriptions')->assertSee('a@x.com')->assertSee('10 GB');
|
|
}
|
|
|
|
public function test_switch_account_rejects_inaccessible(): void
|
|
{
|
|
$this->actingAs($this->user())->post(route('account.switch'), ['account' => 999999])->assertForbidden();
|
|
}
|
|
}
|