90 lines
3.2 KiB
PHP
90 lines
3.2 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
|
|
{
|
|
$admin = $this->platformAdminUser();
|
|
$this->seedPlatformPrices();
|
|
PlatformPrice::query()->updateOrCreate(
|
|
['code' => 'hidden'],
|
|
[
|
|
'name' => 'Hidden',
|
|
'monthly_amount' => 999,
|
|
'currency' => 'gbp',
|
|
'features' => [],
|
|
'sort_order' => 99,
|
|
'is_active' => false,
|
|
'is_featured' => false,
|
|
],
|
|
);
|
|
|
|
$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')
|
|
->assertDontSee('Hidden');
|
|
});
|
|
}
|
|
|
|
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');
|
|
|
|
$this->assertSingleProfessionalHeader($browser, '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('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');
|
|
});
|
|
}
|
|
}
|