UPDATED TESTS wirr dusk
This commit is contained in:
@@ -17,80 +17,73 @@ class PlatformPricingBrowserTest extends DuskTestCase
|
||||
|
||||
public function test_platform_pricing_page_shows_customer_card_grid_only_for_active_prices(): void
|
||||
{
|
||||
$user = $this->tenantUser();
|
||||
$admin = $this->platformAdminUser();
|
||||
$this->seedPlatformPrices();
|
||||
|
||||
PlatformPrice::query()->updateOrCreate(
|
||||
['code' => 'hidden'],
|
||||
[
|
||||
'name' => 'Hidden',
|
||||
'monthly_amount' => 1,
|
||||
'monthly_amount' => 999,
|
||||
'currency' => 'gbp',
|
||||
'features' => [],
|
||||
'sort_order' => 99,
|
||||
'is_featured' => false,
|
||||
'is_active' => false,
|
||||
'is_featured' => false,
|
||||
],
|
||||
);
|
||||
|
||||
$this->browse(function (Browser $browser) use ($user): void {
|
||||
$browser->loginAs($user)
|
||||
->visit('/platform/pricing')
|
||||
->waitFor('.wms-page-hero', 5);
|
||||
$this->browse(function (Browser $browser) use ($admin): void {
|
||||
$browser->loginAs($admin)
|
||||
->visit('/platform/pricing');
|
||||
|
||||
$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
|
||||
public function test_admin_price_crud_pages_and_actions_are_browser_reachable(): 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')
|
||||
->visit('/admin/prices');
|
||||
|
||||
$this->assertSingleProfessionalHeader($browser, 'Platform Prices');
|
||||
$browser->assertSee('Basic')
|
||||
->assertSee('Advanced')
|
||||
->assertSee('Pro')
|
||||
->visit('/admin/prices/create');
|
||||
|
||||
$this->assertSingleProfessionalHeader($browser, 'Create Price');
|
||||
$browser->assertPresent('input[name="name"]')
|
||||
->assertPresent('input[name="monthly_amount"]')
|
||||
->type('name', 'Ultimate Browser')
|
||||
->type('code', 'ultimate-browser')
|
||||
->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');
|
||||
->type('features', "Unlimited warehouses\nUnlimited users")
|
||||
->press('Create price')
|
||||
->waitForLocation('/admin/prices', 10)
|
||||
->assertSee('Ultimate Browser');
|
||||
});
|
||||
|
||||
$price = PlatformPrice::query()->where('code', 'ultimate-browser')->firstOrFail();
|
||||
|
||||
$this->browse(function (Browser $browser) use ($admin, $price): void {
|
||||
$browser->loginAs($admin)
|
||||
->visit('/admin/prices/' . $price->id . '/edit');
|
||||
|
||||
$this->assertSingleProfessionalHeader($browser, 'Edit Ultimate Browser');
|
||||
$browser->type('strapline', 'Updated from Dusk')
|
||||
->press('Save changes')
|
||||
->waitForLocation('/admin/prices', 10)
|
||||
->assertSee('Updated from Dusk');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user