Files
WMS/tests/Browser/PlatformAdministrationBrowserTest.php
T
2026-06-11 14:45:25 +01:00

102 lines
3.7 KiB
PHP

<?php
namespace Tests\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
use Tests\Browser\Concerns\InteractsWithWmsBrowser;
use Tests\Browser\Concerns\InteractsWithWmsData;
use Tests\DuskTestCase;
class PlatformAdministrationBrowserTest extends DuskTestCase
{
use DatabaseMigrations;
use InteractsWithWmsBrowser;
use InteractsWithWmsData;
public function test_platform_dashboard_displays_counts_pricing_cards_and_recent_companies(): void
{
$admin = $this->platformAdminUser();
$this->seedPlatformDashboardData();
$this->browse(function (Browser $browser) use ($admin): void {
$browser->loginAs($admin)
->visit('/admin')
->waitFor('.wms-page-hero', 5);
$this->assertSingleProfessionalHeader($browser, 'Platform');
$browser->assertSee('Basic')
->assertSee('Advanced')
->assertSee('Pro')
->assertSee('Customer One')
->assertSee('Prices');
});
}
public function test_company_administration_can_create_company_and_show_validation_errors(): void
{
$admin = $this->platformAdminUser();
$this->browse(function (Browser $browser) use ($admin): void {
$browser->loginAs($admin)
->visit('/admin/companies')
->waitFor('.wms-page-hero')
->press('Create')
->waitForText('The name field is required', 5)
->type('name', 'Abbott Logistics Limited')
->type('billing_email', 'billing@abbott.example')
->select('status', 'active')
->press('Create')
->waitForText('Abbott Logistics Limited', 5)
->assertSee('Company created.')
->assertSee('Abbott Logistics Limited');
});
}
public function test_license_administration_can_issue_license(): void
{
$admin = $this->platformAdminUser();
$this->tenantCompany(['name' => 'Licence Customer', 'slug' => 'licence-customer']);
$this->browse(function (Browser $browser) use ($admin): void {
$browser->loginAs($admin)
->visit('/admin/licenses')
->waitFor('.wms-page-hero')
->type('label', 'Enterprise Licence')
->select('plan', 'enterprise')
->type('max_users', '500')
->press('Issue')
->waitForText('Licence key issued', 5)
->assertSee('Enterprise Licence')
->assertSee('enterprise');
});
}
public function test_payment_administration_can_record_paid_pending_and_validation_paths(): void
{
$admin = $this->platformAdminUser();
$this->tenantCompany(['name' => 'Payment Customer', 'slug' => 'payment-customer']);
$this->browse(function (Browser $browser) use ($admin): void {
$browser->loginAs($admin)
->visit('/admin/payments')
->waitFor('.wms-page-hero')
->type('amount', '12345')
->type('currency', 'gbp')
->select('status', 'paid')
->type('description', 'Manual bank transfer')
->press('Add')
->waitForText('Payment record created.', 5)
->assertSee('Manual bank transfer')
->assertSee('GBP 123.45')
->select('status', 'pending')
->type('amount', '5000')
->type('description', 'Awaiting payment')
->press('Add')
->waitForText('Awaiting payment', 5)
->assertSee('pending');
});
}
}