UPDATED TESTS wirr dusk

This commit is contained in:
Mark Gregory
2026-06-11 14:51:28 +01:00
parent cad45a870d
commit a55b98cf38
13 changed files with 300 additions and 359 deletions
@@ -4,6 +4,9 @@ namespace Tests\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
use Modules\Platform\app\Models\Company;
use Modules\Platform\app\Models\LicenseKey;
use Modules\Platform\app\Models\Payment;
use Tests\Browser\Concerns\InteractsWithWmsBrowser;
use Tests\Browser\Concerns\InteractsWithWmsData;
use Tests\DuskTestCase;
@@ -21,81 +24,78 @@ class PlatformAdministrationBrowserTest extends DuskTestCase
$this->browse(function (Browser $browser) use ($admin): void {
$browser->loginAs($admin)
->visit('/admin')
->waitFor('.wms-page-hero', 5);
->visit('/admin');
$this->assertSingleProfessionalHeader($browser, 'Platform');
$browser->assertSee('Basic')
->assertSee('Advanced')
->assertSee('Pro')
->assertSee('Customer One')
->assertSee('Prices');
->assertSee('Customer One');
});
}
public function test_company_administration_can_create_company_and_show_validation_errors(): void
public function test_company_administration_form_creates_company(): 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')
->visit('/admin/companies');
$this->assertSingleProfessionalHeader($browser, 'Companies');
$browser->type('name', 'Abbott Logistics Limited')
->type('billing_email', 'billing@abbott.example')
->select('status', 'active')
->press('Create')
->waitForText('Abbott Logistics Limited', 5)
->assertSee('Company created.')
->waitForText('Abbott Logistics Limited', 10)
->assertSee('Abbott Logistics Limited');
});
$this->assertDatabaseHas('companies', ['slug' => 'abbott-logistics-limited']);
}
public function test_license_administration_can_issue_license(): void
public function test_license_administration_form_issues_license(): void
{
$admin = $this->platformAdminUser();
$this->tenantCompany(['name' => 'Licence Customer', 'slug' => 'licence-customer']);
$company = $this->tenantCompany(['name' => 'Licence Customer', 'slug' => 'licence-customer']);
$this->browse(function (Browser $browser) use ($admin): void {
$this->browse(function (Browser $browser) use ($admin, $company): void {
$browser->loginAs($admin)
->visit('/admin/licenses')
->waitFor('.wms-page-hero')
->type('label', 'Enterprise Licence')
->visit('/admin/licenses');
$this->assertSingleProfessionalHeader($browser, 'Licence Keys');
$browser->select('company_id', (string) $company->id)
->type('label', 'Browser Licence')
->select('plan', 'enterprise')
->type('max_users', '500')
->press('Issue')
->waitForText('Licence key issued', 5)
->assertSee('Enterprise Licence')
->assertSee('enterprise');
->waitForText('Browser Licence', 10)
->assertSee('Browser Licence');
});
$this->assertDatabaseHas('license_keys', ['company_id' => $company->id, 'label' => 'Browser Licence']);
}
public function test_payment_administration_can_record_paid_pending_and_validation_paths(): void
public function test_payment_administration_form_records_payment(): void
{
$admin = $this->platformAdminUser();
$this->tenantCompany(['name' => 'Payment Customer', 'slug' => 'payment-customer']);
$company = $this->tenantCompany(['name' => 'Payment Customer', 'slug' => 'payment-customer']);
$this->browse(function (Browser $browser) use ($admin): void {
$this->browse(function (Browser $browser) use ($admin, $company): void {
$browser->loginAs($admin)
->visit('/admin/payments')
->waitFor('.wms-page-hero')
->visit('/admin/payments');
$this->assertSingleProfessionalHeader($browser, 'Payments and Overrides');
$browser->select('company_id', (string) $company->id)
->type('amount', '12345')
->type('currency', 'gbp')
->select('status', 'paid')
->type('description', 'Manual bank transfer')
->type('description', 'Browser payment')
->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');
->waitForText('Browser payment', 10)
->assertSee('Browser payment');
});
$this->assertDatabaseHas('payments', ['company_id' => $company->id, 'description' => 'Browser payment']);
}
}