fixed bug with pricing controler and validation model

This commit is contained in:
Mark Gregory
2026-06-12 07:28:26 +01:00
parent 8391ece55a
commit fc077773ad
3 changed files with 39 additions and 19 deletions
+4 -2
View File
@@ -125,11 +125,13 @@
"@php artisan test"
],
"full-test": [
"lsof -ti tcp:9515 | xargs kill -9 2>/dev/null || true",
"./vendor/laravel/dusk/bin/chromedriver-mac-arm --port=9515 &",
"@php artisan test",
"@php artisan dusk"
],
"start-chrome": [
"lsof -ti tcp:9515 | xargs kill -9 2>/dev/null || true",
"./vendor/laravel/dusk/bin/chromedriver-mac-arm --port=9515 &"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
+22 -14
View File
@@ -9,7 +9,6 @@ use Modules\Platform\app\Models\LicenseKey;
use Modules\Platform\app\Models\Payment;
use Modules\Platform\app\Models\PlatformPrice;
use Modules\Warehouse\app\Models\Warehouse;
use Modules\Warehouse\app\Models\WarehouseValidationRule;
trait InteractsWithWmsData
{
@@ -85,10 +84,10 @@ trait InteractsWithWmsData
protected function seedPlatformPrices(): void
{
foreach ([
['basic', 'Basic', 'Starter WMS access', 'Core warehouse management for small teams.', 4900, 49000, 10, false, true, ['2 warehouses', '10 users', 'Standard support']],
['advanced', 'Advanced', 'Growing WMS operations', 'More users, warehouses and automation controls.', 14900, 149000, 20, true, true, ['5 warehouses', '100 users', 'Advanced support']],
['pro', 'Pro', 'Professional WMS command centre', 'Full operational visibility for larger teams.', 29900, 299000, 30, false, true, ['15 warehouses', '1000 users', 'Priority support']],
] as [$code, $name, $strapline, $description, $monthly, $annual, $sortOrder, $featured, $active, $features]) {
['basic', 'Basic', 'Starter WMS access', 'Core warehouse management for small teams.', 4900, 49000, 10, false, true, ['2 warehouses', '10 users', 'Standard support']],
['advanced', 'Advanced', 'Growing WMS operations', 'More users, warehouses and automation controls.', 14900, 149000, 20, true, true, ['5 warehouses', '100 users', 'Advanced support']],
['pro', 'Pro', 'Professional WMS command centre', 'Full operational visibility for larger teams.', 29900, 299000, 30, false, true, ['15 warehouses', '1000 users', 'Priority support']],
] as [$code, $name, $strapline, $description, $monthly, $annual, $sortOrder, $featured, $active, $features]) {
PlatformPrice::query()->updateOrCreate(
['code' => $code],
[
@@ -113,22 +112,27 @@ trait InteractsWithWmsData
$company ??= $this->tenantCompany();
$warehouse = Warehouse::query()->updateOrCreate(
['company_id' => $company->id, 'code' => $code],
[
'company_id' => $company->id,
'code' => $code,
],
[
'name' => $name,
'address' => 'Main Road, Nottingham',
'status' => 'active',
'address' => 'Main Road',
'timezone' => 'Europe/London',
],
);
WarehouseValidationRule::query()->updateOrCreate(
['warehouse_id' => $warehouse->id, 'rule_key' => 'batch-required'],
$warehouse->validationRules()->updateOrCreate(
[
'rule_key' => 'batch-required',
],
[
'name' => 'Require batch number',
'severity' => 'blocker',
'is_active' => true,
'configuration' => ['field' => 'batch_no'],
'severity' => 'error',
'configuration' => [
'field' => 'batch_number',
],
],
);
@@ -137,7 +141,11 @@ trait InteractsWithWmsData
protected function seedPlatformDashboardData(): void
{
$company = $this->tenantCompany(['name' => 'Customer One', 'slug' => 'customer-one']);
$company = $this->tenantCompany([
'name' => 'Customer One',
'slug' => 'customer-one',
]);
$this->seedWarehouse($company);
$this->seedPlatformPrices();
+13 -3
View File
@@ -17,22 +17,32 @@ class WarehouseBrowserTest extends DuskTestCase
public function test_tenant_warehouse_dashboard_and_administration_pages(): void
{
$user = $this->tenantUser();
$this->seedWarehouse($user->company);
$warehouse = $this->seedWarehouse($user->company);
$this->browse(function (Browser $browser) use ($user): void {
$this->browse(function (Browser $browser) use ($user, $warehouse): void {
$browser->loginAs($user)
->visit('/dashboard');
$this->assertSingleProfessionalHeaderExists($browser);
$browser->assertSee('Main Warehouse')
->visit('/warehouses');
$this->assertSingleProfessionalHeader($browser, 'Warehouses');
$browser->assertSee('Main Warehouse')
->visit('/warehouse-rules');
$this->assertSingleProfessionalHeader($browser, 'Validation Rules');
$browser->assertSee('Require batch number')
$browser->select('warehouse_id', (string) $warehouse->id)
->type('name', 'Require batch number')
->type('rule_key', 'batch-required')
->select('severity', 'error')
->type('configuration', '{"field":"batch_number"}')
->press('Add rule')
->waitForText('Require batch number', 10)
->assertSee('Require batch number')
->assertSee('batch-required');
});
}