106 lines
3.8 KiB
PHP
106 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\Browser;
|
|
|
|
use Laravel\Dusk\Browser;
|
|
use Tests\Browser\Concerns\InteractsWithWmsBrowser;
|
|
use Tests\Browser\Concerns\InteractsWithWmsData;
|
|
use Tests\DuskTestCase;
|
|
|
|
class PlatformAdministrationBrowserTest extends DuskTestCase
|
|
{
|
|
use InteractsWithWmsBrowser;
|
|
use InteractsWithWmsData;
|
|
|
|
public function test_platform_dashboard_displays_counts_pricing_cards_and_recent_companies(): void
|
|
{
|
|
$admin = $this->platformAdminUser();
|
|
$this->seedPlatformDashboardData();
|
|
|
|
$companyName = 'Abbott Logistics ' . uniqid();
|
|
$billingEmail = 'billing+' . uniqid() . '@abbott.example';
|
|
|
|
$this->browse(function (Browser $browser) use ($admin): void {
|
|
$browser->loginAs($admin)
|
|
->visit('/admin');
|
|
$this->assertSingleProfessionalHeader($browser, 'Platform');
|
|
});
|
|
}
|
|
|
|
public function test_company_administration_form_creates_company(): void
|
|
{
|
|
$admin = $this->platformAdminUser();
|
|
|
|
$unique = str_replace('.', '', uniqid('', true));
|
|
$companyName = 'Abbott Logistics ' . $unique;
|
|
$billingEmail = 'billing+' . $unique . '@abbott.example';
|
|
|
|
$this->browse(function (Browser $browser) use ($admin, $companyName, $billingEmail): void {
|
|
$browser->loginAs($admin)
|
|
->visit('/admin/companies');
|
|
|
|
$this->assertSingleProfessionalHeader($browser, 'Companies');
|
|
|
|
$browser->type('name', $companyName)
|
|
->type('billing_email', $billingEmail)
|
|
->select('status', 'active')
|
|
->press('Create')
|
|
->pause(500);
|
|
});
|
|
|
|
$this->assertDatabaseHas('companies', [
|
|
'name' => $companyName,
|
|
'billing_email' => $billingEmail,
|
|
'status' => 'active',
|
|
]);
|
|
|
|
$this->browse(function (Browser $browser) use ($admin, $companyName): void {
|
|
$browser->loginAs($admin)
|
|
->visit('/admin/companies')
|
|
->waitForText($companyName, 20)
|
|
->assertSee($companyName);
|
|
});
|
|
}
|
|
|
|
public function test_license_administration_form_issues_license(): void
|
|
{
|
|
$admin = $this->platformAdminUser();
|
|
$company = $this->tenantCompany(['name' => 'Licence Customer', 'slug' => 'licence-customer']);
|
|
|
|
$this->browse(function (Browser $browser) use ($admin, $company): void {
|
|
$browser->loginAs($admin)
|
|
->visit('/admin/licenses');
|
|
|
|
$this->assertSingleProfessionalHeader($browser, 'Licence Keys');
|
|
$browser->select('company_id', (string) $company->id)
|
|
->type('label', 'Browser Test Licence')
|
|
->select('plan', 'enterprise')
|
|
->type('max_users', '500')
|
|
->press('Issue')
|
|
->waitForText('Browser Test Licence', 10)
|
|
->assertSee('Browser Test Licence');
|
|
});
|
|
}
|
|
|
|
public function test_payment_administration_form_records_payment(): void
|
|
{
|
|
$admin = $this->platformAdminUser();
|
|
$company = $this->tenantCompany(['name' => 'Payment Customer', 'slug' => 'payment-customer']);
|
|
|
|
$this->browse(function (Browser $browser) use ($admin, $company): void {
|
|
$browser->loginAs($admin)
|
|
->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', 'Browser payment')
|
|
->press('Add')
|
|
->waitForText('Browser payment', 10)
|
|
->assertSee('Browser payment');
|
|
});
|
|
}
|
|
}
|