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

97 lines
3.5 KiB
PHP

<?php
namespace Tests\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
use Modules\Platform\app\Models\PlatformPrice;
use Tests\Browser\Concerns\InteractsWithWmsBrowser;
use Tests\Browser\Concerns\InteractsWithWmsData;
use Tests\DuskTestCase;
class PlatformPricingBrowserTest extends DuskTestCase
{
use DatabaseMigrations;
use InteractsWithWmsBrowser;
use InteractsWithWmsData;
public function test_platform_pricing_page_shows_customer_card_grid_only_for_active_prices(): void
{
$user = $this->tenantUser();
$this->seedPlatformPrices();
PlatformPrice::query()->updateOrCreate(
['code' => 'hidden'],
[
'name' => 'Hidden',
'monthly_amount' => 1,
'currency' => 'gbp',
'features' => [],
'sort_order' => 99,
'is_featured' => false,
'is_active' => false,
],
);
$this->browse(function (Browser $browser) use ($user): void {
$browser->loginAs($user)
->visit('/platform/pricing')
->waitFor('.wms-page-hero', 5);
$this->assertSingleProfessionalHeader($browser, 'Pricing');
$browser->assertSee('Basic')
->assertSee('Advanced')
->assertSee('Pro')
->assertSee('£49.00')
->assertDontSee('Hidden');
});
}
public function test_admin_price_crud_create_edit_delete_and_validation_paths(): void
{
$admin = $this->platformAdminUser();
$this->seedPlatformPrices();
$this->browse(function (Browser $browser) use ($admin): void {
$browser->loginAs($admin)
->visit('/admin/prices')
->waitFor('.wms-page-hero')
->assertSee('Basic')
->clickLink('Create Price')
->waitForLocation('/admin/prices/create')
->waitFor('.wms-page-hero')
->press('Save Price')
->waitForText('The name field is required', 5)
->type('name', 'Ultimate Plan')
->type('code', 'ultimate-plan')
->type('strapline', 'Unlimited WMS operations')
->type('badge_label', 'Enterprise')
->type('monthly_amount', '499.00')
->type('annual_amount', '4990.00')
->type('currency', 'gbp')
->type('sort_order', '40')
->type('description', 'Unlimited warehouses and users for enterprise operators.')
->type('features', "Unlimited warehouses\nUnlimited users\nPriority support")
->check('is_featured')
->check('is_active')
->press('Save Price')
->waitForLocation('/admin/prices')
->assertSee('Price created.')
->assertSee('Ultimate Plan')
->clickLink('Edit')
->waitFor('.wms-page-hero')
->type('name', 'Ultimate Plus')
->type('monthly_amount', '599.00')
->press('Update Price')
->waitForLocation('/admin/prices')
->assertSee('Price updated.')
->assertSee('Ultimate Plus')
->press('Delete')
->acceptDialog()
->waitForText('Price deleted.', 5)
->assertDontSee('Ultimate Plus');
});
}
}