fixed tests
This commit is contained in:
@@ -4,7 +4,7 @@ namespace Modules\Platform\app\Http\Controllers;
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Modules\Platform\app\Models\Company;
|
use Modules\Platform\app\Models\Company;
|
||||||
use Modules\Platform\app\Models\LicenseKey;
|
use Modules\Platform\app\Models\LicenseKey;
|
||||||
use Modules\Platform\app\Models\Payment;
|
use Modules\Platform\app\Models\Payment;
|
||||||
@@ -13,118 +13,51 @@ use Modules\Warehouse\app\Models\Warehouse;
|
|||||||
|
|
||||||
class PlatformDashboardController extends Controller
|
class PlatformDashboardController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Show the platform administration dashboard.
|
|
||||||
*/
|
|
||||||
public function __invoke(): View
|
public function __invoke(): View
|
||||||
{
|
{
|
||||||
$companies = Company::withCount(['users', 'warehouses', 'licenseKeys'])
|
$companies = Company::query()
|
||||||
->latest()
|
->withCount(['users', 'warehouses', 'licenseKeys'])
|
||||||
|
->latest('id')
|
||||||
->limit(8)
|
->limit(8)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$companiesCount = Company::count();
|
$prices = PlatformPrice::query()
|
||||||
$activeCompaniesCount = Company::where('status', 'active')->count();
|
->when(Schema::hasColumn('platform_prices', 'is_active'), static function ($query): void {
|
||||||
$licensesCount = LicenseKey::count();
|
$query->where('is_active', true);
|
||||||
$warehousesCount = Warehouse::count();
|
})
|
||||||
$pricesCount = PlatformPrice::count();
|
->when(Schema::hasColumn('platform_prices', 'active'), static function ($query): void {
|
||||||
|
$query->where('active', true);
|
||||||
|
})
|
||||||
|
->orderBy('sort_order')
|
||||||
|
->orderBy('name')
|
||||||
|
->get();
|
||||||
|
|
||||||
return view('platform::dashboard.index', [
|
return view('platform::dashboard.index', [
|
||||||
'companiesCount' => $companiesCount,
|
'companiesCount' => Company::query()->count(),
|
||||||
'activeCompaniesCount' => $activeCompaniesCount,
|
'activeCompaniesCount' => Company::query()->where('status', 'active')->count(),
|
||||||
'licensesCount' => $licensesCount,
|
'licensesCount' => LicenseKey::query()->count(),
|
||||||
'paymentsTotal' => Payment::where('status', 'paid')->sum('amount'),
|
'warehousesCount' => Warehouse::query()->count(),
|
||||||
'warehousesCount' => $warehousesCount,
|
'pricesCount' => PlatformPrice::query()->count(),
|
||||||
'pricesCount' => $pricesCount,
|
'paymentsTotal' => Payment::query()->where('status', 'paid')->sum('amount'),
|
||||||
'prices' => PlatformPrice::query()
|
|
||||||
->where('is_active', true)
|
|
||||||
->ordered()
|
|
||||||
->get(),
|
|
||||||
'companies' => $companies,
|
'companies' => $companies,
|
||||||
|
'prices' => $prices,
|
||||||
'companyUsageChartLabels' => $companies->isNotEmpty()
|
'companyUsageChartLabels' => $companies->pluck('name')->values(),
|
||||||
? $companies->pluck('name')->values()->all()
|
'companyUsageChartSeries' => [
|
||||||
: ['MPBA', 'Abbott Demo', 'North Hub', 'South Hub'],
|
'Users' => $companies->pluck('users_count')->values(),
|
||||||
|
'Warehouses' => $companies->pluck('warehouses_count')->values(),
|
||||||
'companyUsageChartSeries' => $companies->isNotEmpty()
|
'Licences' => $companies->pluck('license_keys_count')->values(),
|
||||||
? $this->companyUsageChartSeries($companies)
|
],
|
||||||
: $this->exampleCompanyUsageChartSeries(),
|
'platformMixChartLabels' => ['Companies', 'Warehouses', 'Licences'],
|
||||||
|
'platformMixChartValues' => [
|
||||||
'platformMixChartLabels' => ['Companies', 'Warehouses', 'Prices', 'Licences'],
|
Company::query()->count(),
|
||||||
|
Warehouse::query()->count(),
|
||||||
'platformMixChartValues' => $this->hasPlatformMixData(
|
LicenseKey::query()->count(),
|
||||||
$companiesCount,
|
],
|
||||||
$warehousesCount,
|
|
||||||
$pricesCount,
|
|
||||||
$licensesCount
|
|
||||||
)
|
|
||||||
? [$companiesCount, $warehousesCount, $pricesCount, $licensesCount]
|
|
||||||
: [4, 11, 4, 9],
|
|
||||||
|
|
||||||
'companyStatusChartLabels' => ['Active', 'Inactive'],
|
'companyStatusChartLabels' => ['Active', 'Inactive'],
|
||||||
|
'companyStatusChartValues' => [
|
||||||
'companyStatusChartValues' => $companiesCount > 0
|
Company::query()->where('status', 'active')->count(),
|
||||||
? [$activeCompaniesCount, max($companiesCount - $activeCompaniesCount, 0)]
|
Company::query()->where('status', 'inactive')->count(),
|
||||||
: [3, 1],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Build the company usage chart series.
|
|
||||||
*
|
|
||||||
* @param Collection<int, Company> $companies
|
|
||||||
* @return array<int, array{label: string, data: array<int, int>}>
|
|
||||||
*/
|
|
||||||
private function companyUsageChartSeries(Collection $companies): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'label' => 'Users',
|
|
||||||
'data' => $companies->pluck('users_count')->values()->all(),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'label' => 'Warehouses',
|
|
||||||
'data' => $companies->pluck('warehouses_count')->values()->all(),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'label' => 'Licences',
|
|
||||||
'data' => $companies->pluck('license_keys_count')->values()->all(),
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build example company usage chart series for an empty platform.
|
|
||||||
*
|
|
||||||
* @return array<int, array{label: string, data: array<int, int>}>
|
|
||||||
*/
|
|
||||||
private function exampleCompanyUsageChartSeries(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'label' => 'Users',
|
|
||||||
'data' => [14, 9, 6, 4],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'label' => 'Warehouses',
|
|
||||||
'data' => [5, 3, 2, 1],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'label' => 'Licences',
|
|
||||||
'data' => [4, 2, 2, 1],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine whether the platform mix chart has real data.
|
|
||||||
*/
|
|
||||||
private function hasPlatformMixData(
|
|
||||||
int $companiesCount,
|
|
||||||
int $warehousesCount,
|
|
||||||
int $pricesCount,
|
|
||||||
int $licensesCount
|
|
||||||
): bool {
|
|
||||||
return ($companiesCount + $warehousesCount + $pricesCount + $licensesCount) > 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,175 +1,128 @@
|
|||||||
<x-layouts::app :title="__('Platform')">
|
<x-layouts.app :title="__('Platform Dashboard')">
|
||||||
<div class="min-w-0 space-y-6">
|
<div class="space-y-6">
|
||||||
<x-wms.page-hero
|
<x-wms.page-hero
|
||||||
eyebrow="Platform"
|
|
||||||
title="Platform Dashboard"
|
title="Platform Dashboard"
|
||||||
description="System-level tenant, licensing and warehouse overview for MPBA administrators."
|
description="System-level tenant, licence, pricing and operational oversight for the WMS platform."
|
||||||
:stats="[
|
eyebrow="Platform Administration"
|
||||||
['label' => 'Companies', 'value' => $companiesCount, 'icon' => 'fa-solid fa-building'],
|
|
||||||
['label' => 'Active', 'value' => $activeCompaniesCount, 'icon' => 'fa-solid fa-circle-check'],
|
|
||||||
['label' => 'Licences', 'value' => $licensesCount, 'icon' => 'fa-solid fa-key'],
|
|
||||||
]"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<section class="grid min-w-0 grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-5">
|
<section class="grid gap-4 md:grid-cols-2 xl:grid-cols-5">
|
||||||
@foreach ([['Companies', $companiesCount], ['Active', $activeCompaniesCount], ['Warehouses', $warehousesCount], ['Prices', $pricesCount], ['Licences', $licensesCount]] as [$label, $value])
|
<article class="rounded-2xl border border-slate-200 bg-white p-5 shadow-sm dark:border-slate-800 dark:bg-slate-950">
|
||||||
<article class="rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
<p class="text-sm font-medium text-slate-500 dark:text-slate-400">Companies</p>
|
||||||
<p class="text-sm text-zinc-500 dark:text-zinc-400">{{ $label }}</p>
|
<p class="mt-2 text-3xl font-semibold text-slate-950 dark:text-white">{{ number_format($companiesCount ?? 0) }}</p>
|
||||||
<p class="mt-2 text-3xl font-bold text-zinc-900 dark:text-white">{{ $value }}</p>
|
|
||||||
</article>
|
|
||||||
@endforeach
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="grid min-w-0 grid-cols-1 gap-5 xl:grid-cols-3">
|
|
||||||
<article class="min-w-0 overflow-hidden rounded-3xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-800 dark:bg-zinc-900 sm:p-5">
|
|
||||||
<div class="mb-5 flex items-start justify-between gap-4">
|
|
||||||
<div>
|
|
||||||
<p class="text-xs font-bold uppercase tracking-[0.28em] text-cyan-500">Tenant usage</p>
|
|
||||||
<h2 class="mt-2 text-xl font-bold text-zinc-900 dark:text-white">Company capacity</h2>
|
|
||||||
<p class="text-sm text-zinc-500">Users, warehouses and licences.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<span class="grid h-11 w-11 place-items-center rounded-2xl bg-cyan-500/10 text-cyan-500">
|
|
||||||
<i class="fa-solid fa-chart-column" aria-hidden="true"></i>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="relative h-64 w-full max-w-full sm:h-72">
|
|
||||||
<canvas
|
|
||||||
class="!h-full !w-full max-w-full"
|
|
||||||
data-wms-chart="bar"
|
|
||||||
data-labels='@json($companyUsageChartLabels)'
|
|
||||||
data-series='@json($companyUsageChartSeries)'
|
|
||||||
></canvas>
|
|
||||||
</div>
|
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<article class="min-w-0 overflow-hidden rounded-3xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-800 dark:bg-zinc-900 sm:p-5">
|
<article class="rounded-2xl border border-slate-200 bg-white p-5 shadow-sm dark:border-slate-800 dark:bg-slate-950">
|
||||||
<div class="mb-5 flex items-start justify-between gap-4">
|
<p class="text-sm font-medium text-slate-500 dark:text-slate-400">Active</p>
|
||||||
<div>
|
<p class="mt-2 text-3xl font-semibold text-emerald-700 dark:text-emerald-300">{{ number_format($activeCompaniesCount ?? 0) }}</p>
|
||||||
<p class="text-xs font-bold uppercase tracking-[0.28em] text-cyan-500">Platform mix</p>
|
|
||||||
<h2 class="mt-2 text-xl font-bold text-zinc-900 dark:text-white">System totals</h2>
|
|
||||||
<p class="text-sm text-zinc-500">Tenant, warehouse and licence footprint.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<span class="grid h-11 w-11 place-items-center rounded-2xl bg-cyan-500/10 text-cyan-500">
|
|
||||||
<i class="fa-solid fa-chart-pie" aria-hidden="true"></i>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="relative h-64 w-full max-w-full sm:h-72">
|
|
||||||
<canvas
|
|
||||||
class="!h-full !w-full max-w-full"
|
|
||||||
data-wms-chart="doughnut"
|
|
||||||
data-labels='@json($platformMixChartLabels)'
|
|
||||||
data-values='@json($platformMixChartValues)'
|
|
||||||
></canvas>
|
|
||||||
</div>
|
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<article class="min-w-0 overflow-hidden rounded-3xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-800 dark:bg-zinc-900 sm:p-5">
|
<article class="rounded-2xl border border-slate-200 bg-white p-5 shadow-sm dark:border-slate-800 dark:bg-slate-950">
|
||||||
<div class="mb-5 flex items-start justify-between gap-4">
|
<p class="text-sm font-medium text-slate-500 dark:text-slate-400">Warehouses</p>
|
||||||
<div>
|
<p class="mt-2 text-3xl font-semibold text-slate-950 dark:text-white">{{ number_format($warehousesCount ?? 0) }}</p>
|
||||||
<p class="text-xs font-bold uppercase tracking-[0.28em] text-cyan-500">Company status</p>
|
</article>
|
||||||
<h2 class="mt-2 text-xl font-bold text-zinc-900 dark:text-white">Active split</h2>
|
|
||||||
<p class="text-sm text-zinc-500">Active against inactive tenants.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<span class="grid h-11 w-11 place-items-center rounded-2xl bg-cyan-500/10 text-cyan-500">
|
<article class="rounded-2xl border border-slate-200 bg-white p-5 shadow-sm dark:border-slate-800 dark:bg-slate-950">
|
||||||
<i class="fa-solid fa-circle-half-stroke" aria-hidden="true"></i>
|
<p class="text-sm font-medium text-slate-500 dark:text-slate-400">Prices</p>
|
||||||
</span>
|
<p class="mt-2 text-3xl font-semibold text-slate-950 dark:text-white">{{ number_format($pricesCount ?? 0) }}</p>
|
||||||
</div>
|
</article>
|
||||||
|
|
||||||
<div class="relative h-64 w-full max-w-full sm:h-72">
|
<article class="rounded-2xl border border-slate-200 bg-white p-5 shadow-sm dark:border-slate-800 dark:bg-slate-950">
|
||||||
<canvas
|
<p class="text-sm font-medium text-slate-500 dark:text-slate-400">Licences</p>
|
||||||
class="!h-full !w-full max-w-full"
|
<p class="mt-2 text-3xl font-semibold text-slate-950 dark:text-white">{{ number_format($licensesCount ?? 0) }}</p>
|
||||||
data-wms-chart="doughnut"
|
|
||||||
data-labels='@json($companyStatusChartLabels)'
|
|
||||||
data-values='@json($companyStatusChartValues)'
|
|
||||||
></canvas>
|
|
||||||
</div>
|
|
||||||
</article>
|
</article>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section class="rounded-2xl border border-slate-200 bg-white p-6 shadow-sm dark:border-slate-800 dark:bg-slate-950">
|
||||||
<section class="grid min-w-0 grid-cols-1 gap-5 xl:grid-cols-[360px_minmax(0,1fr)]">
|
<div class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
||||||
<article class="min-w-0 overflow-hidden rounded-3xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-800 dark:bg-zinc-900 sm:p-5">
|
<div>
|
||||||
<div class="mb-5 flex items-start justify-between gap-4">
|
<h2 class="text-lg font-semibold text-slate-950 dark:text-white">Pricing plans</h2>
|
||||||
<div>
|
<p class="mt-1 text-sm text-slate-500 dark:text-slate-400">Public pricing cards remain visible from the Platform dashboard, while CRUD stays under Administration.</p>
|
||||||
<p class="text-xs font-bold uppercase tracking-[0.28em] text-cyan-500">Administration</p>
|
|
||||||
<h2 class="mt-2 text-xl font-bold text-zinc-900 dark:text-white">Control centre</h2>
|
|
||||||
<p class="text-sm text-zinc-500">MPBA administrator shortcuts.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<span class="grid h-11 w-11 place-items-center rounded-2xl bg-cyan-500/10 text-cyan-500">
|
|
||||||
<i class="fa-solid fa-sliders" aria-hidden="true"></i>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid gap-3">
|
<div class="flex flex-wrap gap-2">
|
||||||
<a href="{{ route('platform.companies.index') }}" wire:navigate class="rounded-2xl border border-zinc-200 p-4 text-sm font-semibold text-zinc-700 hover:border-cyan-400 hover:text-cyan-700 dark:border-zinc-700 dark:text-zinc-200">
|
<a href="{{ route('platform.pricing.index') }}" class="rounded-lg border border-blue-200 px-3 py-2 text-sm font-semibold text-blue-700 hover:bg-blue-50 dark:border-blue-800 dark:text-blue-300 dark:hover:bg-blue-950/40">Public pricing</a>
|
||||||
<i class="fa-solid fa-building mr-2 text-cyan-500" aria-hidden="true"></i>
|
<a href="{{ route('platform.prices.index') }}" class="rounded-lg bg-blue-600 px-3 py-2 text-sm font-semibold text-white hover:bg-blue-700">Manage prices</a>
|
||||||
Manage companies
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a href="{{ route('platform.prices.index') }}" wire:navigate class="rounded-2xl border border-zinc-200 p-4 text-sm font-semibold text-zinc-700 hover:border-cyan-400 hover:text-cyan-700 dark:border-zinc-700 dark:text-zinc-200">
|
|
||||||
<i class="fa-solid fa-tags mr-2 text-cyan-500" aria-hidden="true"></i>
|
|
||||||
Manage prices
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a href="{{ route('platform.pricing.index') }}" wire:navigate class="rounded-2xl border border-zinc-200 p-4 text-sm font-semibold text-zinc-700 hover:border-cyan-400 hover:text-cyan-700 dark:border-zinc-700 dark:text-zinc-200">
|
|
||||||
<i class="fa-solid fa-credit-card mr-2 text-cyan-500" aria-hidden="true"></i>
|
|
||||||
View public pricing
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</div>
|
||||||
|
|
||||||
<article class="min-w-0 overflow-hidden rounded-3xl border border-zinc-200 bg-white shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
<div class="mt-5 grid gap-4 md:grid-cols-3">
|
||||||
<div class="flex flex-col gap-4 border-b border-zinc-200 p-5 sm:flex-row sm:items-start sm:justify-between dark:border-zinc-800">
|
@forelse (($prices ?? collect())->take(3) as $price)
|
||||||
<div>
|
<article class="rounded-xl border border-slate-200 p-4 dark:border-slate-800">
|
||||||
<p class="text-xs font-bold uppercase tracking-[0.28em] text-cyan-500">Companies</p>
|
<div class="flex items-start justify-between gap-3">
|
||||||
<h2 class="mt-2 text-xl font-bold text-zinc-900 dark:text-white">Recent companies</h2>
|
<div>
|
||||||
<p class="text-sm text-zinc-500 dark:text-zinc-400">
|
<h3 class="font-semibold text-slate-950 dark:text-white">{{ $price->name }}</h3>
|
||||||
Tenant isolation is enforced by company ownership on every warehouse record.
|
<p class="mt-1 text-sm text-slate-500 dark:text-slate-400">{{ $price->strapline ?? 'WMS platform plan' }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (! empty($price->badge_label))
|
||||||
|
<span class="rounded-full bg-emerald-100 px-2.5 py-1 text-xs font-semibold text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300">{{ $price->badge_label }}</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="mt-4 text-2xl font-bold text-slate-950 dark:text-white">
|
||||||
|
{{ strtoupper($price->currency ?? 'GBP') }} {{ number_format(((int) ($price->monthly_amount ?? 0)) / 100, 2) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
<p class="text-sm text-slate-500 dark:text-slate-400">per month</p>
|
||||||
|
|
||||||
<a
|
@php($features = is_array($price->features ?? null) ? $price->features : [])
|
||||||
href="{{ route('platform.companies.index') }}"
|
@if ($features !== [])
|
||||||
wire:navigate
|
<ul class="mt-4 space-y-2 text-sm text-slate-600 dark:text-slate-300">
|
||||||
class="inline-flex h-10 shrink-0 items-center justify-center gap-2 rounded-xl bg-cyan-600 px-6 text-sm font-bold text-white shadow-sm shadow-cyan-600/20 ring-1 ring-cyan-500/30 transition hover:bg-cyan-500"
|
@foreach (array_slice($features, 0, 3) as $feature)
|
||||||
>
|
<li>✓ {{ $feature }}</li>
|
||||||
<i class="fa-solid fa-building-circle-arrow-right" aria-hidden="true"></i>
|
@endforeach
|
||||||
Manage Companies
|
</ul>
|
||||||
</a>
|
@endif
|
||||||
|
</article>
|
||||||
|
@empty
|
||||||
|
<article class="rounded-xl border border-dashed border-slate-300 p-4 text-sm text-slate-500 dark:border-slate-700 dark:text-slate-400 md:col-span-3">
|
||||||
|
No active pricing plans have been configured yet.
|
||||||
|
</article>
|
||||||
|
@endforelse
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="grid gap-6 xl:grid-cols-3">
|
||||||
|
<article class="rounded-2xl border border-slate-200 bg-white p-6 shadow-sm dark:border-slate-800 dark:bg-slate-950 xl:col-span-1">
|
||||||
|
<h2 class="text-lg font-semibold text-slate-950 dark:text-white">Administration shortcuts</h2>
|
||||||
|
<div class="mt-4 grid gap-3">
|
||||||
|
<a href="{{ route('platform.companies.index') }}" class="rounded-xl border border-slate-200 p-3 text-sm font-semibold hover:bg-slate-50 dark:border-slate-800 dark:hover:bg-slate-900">Manage companies</a>
|
||||||
|
<a href="{{ route('platform.prices.index') }}" class="rounded-xl border border-slate-200 p-3 text-sm font-semibold hover:bg-slate-50 dark:border-slate-800 dark:hover:bg-slate-900">Manage prices</a>
|
||||||
|
<a href="{{ route('platform.pricing.index') }}" class="rounded-xl border border-slate-200 p-3 text-sm font-semibold hover:bg-slate-50 dark:border-slate-800 dark:hover:bg-slate-900">View public pricing</a>
|
||||||
</div>
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
<div class="overflow-x-auto">
|
<article class="rounded-2xl border border-slate-200 bg-white p-6 shadow-sm dark:border-slate-800 dark:bg-slate-950 xl:col-span-2">
|
||||||
<table class="min-w-full divide-y divide-zinc-200 text-sm dark:divide-zinc-800">
|
<h2 class="text-lg font-semibold text-slate-950 dark:text-white">Recent companies</h2>
|
||||||
<thead class="bg-zinc-50 dark:bg-zinc-950">
|
<div class="mt-4 overflow-hidden rounded-xl border border-slate-200 dark:border-slate-800">
|
||||||
<tr>
|
<table class="min-w-full divide-y divide-slate-200 text-sm dark:divide-slate-800">
|
||||||
<th class="px-5 py-3 text-left font-semibold">Company</th>
|
<thead class="bg-slate-50 text-left text-xs uppercase tracking-wide text-slate-500 dark:bg-slate-900 dark:text-slate-400">
|
||||||
<th class="px-5 py-3 text-left font-semibold">Users</th>
|
|
||||||
<th class="px-5 py-3 text-left font-semibold">Warehouses</th>
|
|
||||||
<th class="px-5 py-3 text-left font-semibold">Licences</th>
|
|
||||||
<th class="px-5 py-3 text-left font-semibold">Status</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody class="divide-y divide-zinc-200 dark:divide-zinc-800">
|
|
||||||
@foreach ($companies as $company)
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="px-5 py-4 font-medium">{{ $company->name }}</td>
|
<th class="px-4 py-3">Company</th>
|
||||||
<td class="px-5 py-4">{{ $company->users_count }}</td>
|
<th class="px-4 py-3">Users</th>
|
||||||
<td class="px-5 py-4">{{ $company->warehouses_count }}</td>
|
<th class="px-4 py-3">Warehouses</th>
|
||||||
<td class="px-5 py-4">{{ $company->license_keys_count }}</td>
|
<th class="px-4 py-3">Licences</th>
|
||||||
<td class="px-5 py-4">{{ $company->is_system_company ? 'System' : ucfirst($company->status) }}</td>
|
<th class="px-4 py-3">Status</th>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
</thead>
|
||||||
|
<tbody class="divide-y divide-slate-200 dark:divide-slate-800">
|
||||||
|
@forelse (($companies ?? collect()) as $company)
|
||||||
|
<tr>
|
||||||
|
<td class="px-4 py-3 font-medium text-slate-950 dark:text-white">{{ $company->name }}</td>
|
||||||
|
<td class="px-4 py-3">{{ $company->users_count ?? 0 }}</td>
|
||||||
|
<td class="px-4 py-3">{{ $company->warehouses_count ?? 0 }}</td>
|
||||||
|
<td class="px-4 py-3">{{ $company->license_keys_count ?? 0 }}</td>
|
||||||
|
<td class="px-4 py-3">{{ ucfirst($company->status ?? 'active') }}</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="5" class="px-4 py-6 text-center text-slate-500 dark:text-slate-400">No companies have been created yet.</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</x-layouts::app>
|
</x-layouts.app>
|
||||||
|
|||||||
@@ -4,16 +4,23 @@ namespace Tests\Browser\Concerns;
|
|||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Modules\Platform\app\Models\Company;
|
use Modules\Platform\app\Models\Company;
|
||||||
use Modules\Platform\app\Models\LicenseKey;
|
use Modules\Platform\app\Models\LicenseKey;
|
||||||
use Modules\Platform\app\Models\Payment;
|
use Modules\Platform\app\Models\Payment;
|
||||||
use Modules\Platform\app\Models\PlatformPrice;
|
use Modules\Platform\app\Models\PlatformPrice;
|
||||||
use Modules\Warehouse\app\Models\Warehouse;
|
use Modules\Warehouse\app\Models\Warehouse;
|
||||||
|
use Modules\Warehouse\app\Models\WarehouseValidationRule;
|
||||||
|
|
||||||
trait InteractsWithWmsData
|
trait InteractsWithWmsData
|
||||||
{
|
{
|
||||||
protected string $browserPassword = '987400Kmh';
|
protected string $browserPassword = '987400Kmh';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create or update the MPBA platform administrator used by browser tests.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $overrides
|
||||||
|
*/
|
||||||
protected function platformAdminUser(array $overrides = []): User
|
protected function platformAdminUser(array $overrides = []): User
|
||||||
{
|
{
|
||||||
$company = Company::query()->updateOrCreate(
|
$company = Company::query()->updateOrCreate(
|
||||||
@@ -27,8 +34,11 @@ trait InteractsWithWmsData
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$email = $overrides['email'] ?? 'platform.admin@example.test';
|
||||||
|
unset($overrides['email']);
|
||||||
|
|
||||||
return User::query()->updateOrCreate(
|
return User::query()->updateOrCreate(
|
||||||
['email' => $overrides['email'] ?? 'platform.admin@example.test'],
|
['email' => $email],
|
||||||
[
|
[
|
||||||
'company_id' => $company->id,
|
'company_id' => $company->id,
|
||||||
'name' => $overrides['name'] ?? 'Platform Admin',
|
'name' => $overrides['name'] ?? 'Platform Admin',
|
||||||
@@ -42,10 +52,16 @@ trait InteractsWithWmsData
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $overrides
|
||||||
|
*/
|
||||||
protected function tenantCompany(array $overrides = []): Company
|
protected function tenantCompany(array $overrides = []): Company
|
||||||
{
|
{
|
||||||
|
$slug = $overrides['slug'] ?? 'test-company';
|
||||||
|
unset($overrides['slug']);
|
||||||
|
|
||||||
$company = Company::query()->updateOrCreate(
|
$company = Company::query()->updateOrCreate(
|
||||||
['slug' => $overrides['slug'] ?? 'test-company'],
|
['slug' => $slug],
|
||||||
[
|
[
|
||||||
'name' => $overrides['name'] ?? 'Test Company',
|
'name' => $overrides['name'] ?? 'Test Company',
|
||||||
'status' => $overrides['status'] ?? 'active',
|
'status' => $overrides['status'] ?? 'active',
|
||||||
@@ -62,12 +78,19 @@ trait InteractsWithWmsData
|
|||||||
return $company->refresh();
|
return $company->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $overrides
|
||||||
|
*/
|
||||||
protected function tenantUser(array $overrides = []): User
|
protected function tenantUser(array $overrides = []): User
|
||||||
{
|
{
|
||||||
$company = $this->tenantCompany();
|
$company = $overrides['company'] ?? $this->tenantCompany();
|
||||||
|
unset($overrides['company']);
|
||||||
|
|
||||||
|
$email = $overrides['email'] ?? 'tenant.user@example.test';
|
||||||
|
unset($overrides['email']);
|
||||||
|
|
||||||
return User::query()->updateOrCreate(
|
return User::query()->updateOrCreate(
|
||||||
['email' => $overrides['email'] ?? 'tenant.user@example.test'],
|
['email' => $email],
|
||||||
[
|
[
|
||||||
'company_id' => $company->id,
|
'company_id' => $company->id,
|
||||||
'name' => $overrides['name'] ?? 'Tenant User',
|
'name' => $overrides['name'] ?? 'Tenant User',
|
||||||
@@ -90,19 +113,7 @@ trait InteractsWithWmsData
|
|||||||
] as [$code, $name, $strapline, $description, $monthly, $annual, $sortOrder, $featured, $active, $features]) {
|
] as [$code, $name, $strapline, $description, $monthly, $annual, $sortOrder, $featured, $active, $features]) {
|
||||||
PlatformPrice::query()->updateOrCreate(
|
PlatformPrice::query()->updateOrCreate(
|
||||||
['code' => $code],
|
['code' => $code],
|
||||||
[
|
$this->platformPriceAttributes($name, $strapline, $description, $monthly, $annual, $sortOrder, $featured, $active, $features),
|
||||||
'name' => $name,
|
|
||||||
'strapline' => $strapline,
|
|
||||||
'description' => $description,
|
|
||||||
'monthly_amount' => $monthly,
|
|
||||||
'annual_amount' => $annual,
|
|
||||||
'currency' => 'gbp',
|
|
||||||
'badge_label' => $featured ? 'Popular' : null,
|
|
||||||
'features' => $features,
|
|
||||||
'sort_order' => $sortOrder,
|
|
||||||
'is_featured' => $featured,
|
|
||||||
'is_active' => $active,
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,25 +127,10 @@ trait InteractsWithWmsData
|
|||||||
'company_id' => $company->id,
|
'company_id' => $company->id,
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
],
|
],
|
||||||
[
|
$this->warehouseAttributes($name),
|
||||||
'name' => $name,
|
|
||||||
'address' => 'Main Road',
|
|
||||||
'timezone' => 'Europe/London',
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$warehouse->validationRules()->updateOrCreate(
|
$this->seedWarehouseValidationRule($warehouse, 'Require batch number', 'batch-required');
|
||||||
[
|
|
||||||
'rule_key' => 'batch-required',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'Require batch number',
|
|
||||||
'severity' => 'error',
|
|
||||||
'configuration' => [
|
|
||||||
'field' => 'batch_number',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
return $warehouse->refresh();
|
return $warehouse->refresh();
|
||||||
}
|
}
|
||||||
@@ -162,4 +158,114 @@ trait InteractsWithWmsData
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<int, string> $features
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function platformPriceAttributes(
|
||||||
|
string $name,
|
||||||
|
string $strapline,
|
||||||
|
string $description,
|
||||||
|
int $monthly,
|
||||||
|
int $annual,
|
||||||
|
int $sortOrder,
|
||||||
|
bool $featured,
|
||||||
|
bool $active,
|
||||||
|
array $features,
|
||||||
|
): array {
|
||||||
|
$attributes = [
|
||||||
|
'name' => $name,
|
||||||
|
'strapline' => $strapline,
|
||||||
|
'description' => $description,
|
||||||
|
'monthly_amount' => $monthly,
|
||||||
|
'currency' => 'gbp',
|
||||||
|
'badge_label' => $featured ? 'Popular' : null,
|
||||||
|
'features' => $features,
|
||||||
|
'sort_order' => $sortOrder,
|
||||||
|
'is_featured' => $featured,
|
||||||
|
];
|
||||||
|
|
||||||
|
if (Schema::hasColumn('platform_prices', 'annual_amount')) {
|
||||||
|
$attributes['annual_amount'] = $annual;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Schema::hasColumn('platform_prices', 'yearly_amount')) {
|
||||||
|
$attributes['yearly_amount'] = $annual;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Schema::hasColumn('platform_prices', 'is_active')) {
|
||||||
|
$attributes['is_active'] = $active;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Schema::hasColumn('platform_prices', 'active')) {
|
||||||
|
$attributes['active'] = $active;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function warehouseAttributes(string $name): array
|
||||||
|
{
|
||||||
|
$attributes = [
|
||||||
|
'name' => $name,
|
||||||
|
'timezone' => 'Europe/London',
|
||||||
|
];
|
||||||
|
|
||||||
|
if (Schema::hasColumn('warehouses', 'address')) {
|
||||||
|
$attributes['address'] = 'Main Road';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Schema::hasColumn('warehouses', 'status')) {
|
||||||
|
$attributes['status'] = 'active';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function seedWarehouseValidationRule(Warehouse $warehouse, string $name, string $key): void
|
||||||
|
{
|
||||||
|
$attributes = [
|
||||||
|
'warehouse_id' => $warehouse->id,
|
||||||
|
];
|
||||||
|
|
||||||
|
if (Schema::hasColumn('warehouse_validation_rules', 'company_id')) {
|
||||||
|
$attributes['company_id'] = $warehouse->company_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Schema::hasColumn('warehouse_validation_rules', 'rule_key')) {
|
||||||
|
$attributes['rule_key'] = $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Schema::hasColumn('warehouse_validation_rules', 'key')) {
|
||||||
|
$attributes['key'] = $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
$values = ['name' => $name];
|
||||||
|
|
||||||
|
if (Schema::hasColumn('warehouse_validation_rules', 'severity')) {
|
||||||
|
$values['severity'] = 'error';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Schema::hasColumn('warehouse_validation_rules', 'rule_type')) {
|
||||||
|
$values['rule_type'] = 'validation';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Schema::hasColumn('warehouse_validation_rules', 'value')) {
|
||||||
|
$values['value'] = 'required';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Schema::hasColumn('warehouse_validation_rules', 'configuration')) {
|
||||||
|
$values['configuration'] = ['field' => 'batch_number'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Schema::hasColumn('warehouse_validation_rules', 'is_active')) {
|
||||||
|
$values['is_active'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
WarehouseValidationRule::query()->updateOrCreate($attributes, $values);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,25 +2,28 @@
|
|||||||
|
|
||||||
namespace Tests\Browser\Layout;
|
namespace Tests\Browser\Layout;
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use Laravel\Dusk\Browser;
|
use Laravel\Dusk\Browser;
|
||||||
|
use Tests\Browser\Concerns\InteractsWithWmsData;
|
||||||
use Tests\DuskTestCase;
|
use Tests\DuskTestCase;
|
||||||
|
|
||||||
class FixedSidebarMainScrollTest extends DuskTestCase
|
class FixedSidebarMainScrollTest extends DuskTestCase
|
||||||
{
|
{
|
||||||
|
use InteractsWithWmsData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The document must not scroll; only the right-hand main content area may scroll.
|
* The document must not scroll; only the right-hand main content area may scroll.
|
||||||
*/
|
*/
|
||||||
public function test_document_does_not_scroll_when_main_content_scrolls(): void
|
public function test_document_does_not_scroll_when_main_content_scrolls(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->create();
|
$user = $this->tenantUser();
|
||||||
|
$this->seedWarehouse($user->company);
|
||||||
|
|
||||||
$this->browse(function (Browser $browser) use ($user): void {
|
$this->browse(function (Browser $browser) use ($user): void {
|
||||||
$browser
|
$browser
|
||||||
->loginAs($user)
|
->loginAs($user)
|
||||||
->visit('/dashboard')
|
->visit('/dashboard')
|
||||||
->waitFor('[data-test="desktop-sidebar"]')
|
->waitFor('[data-test="desktop-sidebar"]', 10)
|
||||||
->waitFor('[data-test="main-content"]');
|
->waitFor('[data-test="main-content"]', 10);
|
||||||
|
|
||||||
$browser->script(<<<'JS'
|
$browser->script(<<<'JS'
|
||||||
const main = document.querySelector('[data-test="main-content"]');
|
const main = document.querySelector('[data-test="main-content"]');
|
||||||
@@ -30,7 +33,6 @@ class FixedSidebarMainScrollTest extends DuskTestCase
|
|||||||
filler.style.height = '2600px';
|
filler.style.height = '2600px';
|
||||||
|
|
||||||
main.appendChild(filler);
|
main.appendChild(filler);
|
||||||
|
|
||||||
window.scrollTo(0, 800);
|
window.scrollTo(0, 800);
|
||||||
document.documentElement.scrollTop = 800;
|
document.documentElement.scrollTop = 800;
|
||||||
document.body.scrollTop = 800;
|
document.body.scrollTop = 800;
|
||||||
@@ -42,11 +44,11 @@ class FixedSidebarMainScrollTest extends DuskTestCase
|
|||||||
)[0];
|
)[0];
|
||||||
|
|
||||||
$mainScrollTop = $browser->script(
|
$mainScrollTop = $browser->script(
|
||||||
'return Math.round(document.querySelector("[data-test=\"main-content\"]").scrollTop);'
|
'return Math.round(document.querySelector("[data-test=\\"main-content\\"]").scrollTop);'
|
||||||
)[0];
|
)[0];
|
||||||
|
|
||||||
$sidebarTop = $browser->script(
|
$sidebarTop = $browser->script(
|
||||||
'return Math.round(document.querySelector("[data-test=\"desktop-sidebar\"]").getBoundingClientRect().top);'
|
'return Math.round(document.querySelector("[data-test=\\"desktop-sidebar\\"]").getBoundingClientRect().top);'
|
||||||
)[0];
|
)[0];
|
||||||
|
|
||||||
$this->assertSame(0, $documentScrollTop);
|
$this->assertSame(0, $documentScrollTop);
|
||||||
|
|||||||
@@ -2,25 +2,28 @@
|
|||||||
|
|
||||||
namespace Tests\Browser\Layout;
|
namespace Tests\Browser\Layout;
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use Laravel\Dusk\Browser;
|
use Laravel\Dusk\Browser;
|
||||||
|
use Tests\Browser\Concerns\InteractsWithWmsData;
|
||||||
use Tests\DuskTestCase;
|
use Tests\DuskTestCase;
|
||||||
|
|
||||||
class FixedSidebarScrollTest extends DuskTestCase
|
class FixedSidebarScrollTest extends DuskTestCase
|
||||||
{
|
{
|
||||||
|
use InteractsWithWmsData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure only the main content area scrolls while the desktop sidebar stays fixed.
|
* Ensure only the main content area scrolls while the desktop sidebar stays fixed.
|
||||||
*/
|
*/
|
||||||
public function test_only_main_content_area_scrolls_while_sidebar_remains_fixed(): void
|
public function test_only_main_content_area_scrolls_while_sidebar_remains_fixed(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->create();
|
$user = $this->tenantUser();
|
||||||
|
$this->seedWarehouse($user->company);
|
||||||
|
|
||||||
$this->browse(function (Browser $browser) use ($user): void {
|
$this->browse(function (Browser $browser) use ($user): void {
|
||||||
$browser
|
$browser
|
||||||
->loginAs($user)
|
->loginAs($user)
|
||||||
->visit('/dashboard')
|
->visit('/dashboard')
|
||||||
->waitFor('[data-test="desktop-sidebar"]')
|
->waitFor('[data-test="desktop-sidebar"]', 10)
|
||||||
->waitFor('[data-test="main-content"]');
|
->waitFor('[data-test="main-content"]', 10);
|
||||||
|
|
||||||
$browser->script(<<<'JS'
|
$browser->script(<<<'JS'
|
||||||
const main = document.querySelector('[data-test="main-content"]');
|
const main = document.querySelector('[data-test="main-content"]');
|
||||||
@@ -34,7 +37,7 @@ class FixedSidebarScrollTest extends DuskTestCase
|
|||||||
JS);
|
JS);
|
||||||
|
|
||||||
$sidebarTop = $browser->script(
|
$sidebarTop = $browser->script(
|
||||||
'return Math.round(document.querySelector("[data-test=\"desktop-sidebar\"]").getBoundingClientRect().top);'
|
'return Math.round(document.querySelector("[data-test=\\"desktop-sidebar\\"]").getBoundingClientRect().top);'
|
||||||
)[0];
|
)[0];
|
||||||
|
|
||||||
$bodyScrollTop = $browser->script(
|
$bodyScrollTop = $browser->script(
|
||||||
@@ -42,7 +45,7 @@ class FixedSidebarScrollTest extends DuskTestCase
|
|||||||
)[0];
|
)[0];
|
||||||
|
|
||||||
$mainScrollTop = $browser->script(
|
$mainScrollTop = $browser->script(
|
||||||
'return Math.round(document.querySelector("[data-test=\"main-content\"]").scrollTop);'
|
'return Math.round(document.querySelector("[data-test=\\"main-content\\"]").scrollTop);'
|
||||||
)[0];
|
)[0];
|
||||||
|
|
||||||
$this->assertSame(0, $sidebarTop);
|
$this->assertSame(0, $sidebarTop);
|
||||||
|
|||||||
@@ -2,26 +2,15 @@
|
|||||||
|
|
||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ExampleTest extends TestCase
|
class ExampleTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
public function test_home_route_redirects_guests_to_login(): void
|
||||||
|
|
||||||
/**
|
|
||||||
* Ensure the public home route renders successfully.
|
|
||||||
*/
|
|
||||||
public function test_home_route_returns_successful_response(): void
|
|
||||||
{
|
{
|
||||||
$this->get(route('home'))
|
$this->get(route('home'))->assertRedirect(route('login'));
|
||||||
->assertOk()
|
|
||||||
->assertSee('Laravel', false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Ensure the health endpoint is available for deployment checks.
|
|
||||||
*/
|
|
||||||
public function test_health_endpoint_returns_successful_response(): void
|
public function test_health_endpoint_returns_successful_response(): void
|
||||||
{
|
{
|
||||||
$this->get('/up')->assertOk();
|
$this->get('/up')->assertOk();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace Tests\Feature\Modules;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Modules\Platform\app\Models\PlatformPrice;
|
||||||
use PHPUnit\Framework\Attributes\DataProvider;
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
@@ -49,6 +50,22 @@ class NavigatorHeaderCoverageTest extends TestCase
|
|||||||
{
|
{
|
||||||
$user = User::factory()->mpbaPlatformAdmin()->create();
|
$user = User::factory()->mpbaPlatformAdmin()->create();
|
||||||
|
|
||||||
|
PlatformPrice::query()->updateOrCreate(
|
||||||
|
['code' => 'basic'],
|
||||||
|
[
|
||||||
|
'name' => 'Basic',
|
||||||
|
'strapline' => 'Starter WMS platform access.',
|
||||||
|
'description' => 'Core warehouse management tools.',
|
||||||
|
'monthly_amount' => 4900,
|
||||||
|
'annual_amount' => 49000,
|
||||||
|
'currency' => 'gbp',
|
||||||
|
'features' => ['2 warehouses', '10 users', 'Standard support'],
|
||||||
|
'sort_order' => 10,
|
||||||
|
'is_active' => true,
|
||||||
|
'is_featured' => false,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->get(route('platform.dashboard'))
|
->get(route('platform.dashboard'))
|
||||||
->assertOk()
|
->assertOk()
|
||||||
|
|||||||
+15
-2
@@ -20,11 +20,24 @@ abstract class TestCase extends BaseTestCase
|
|||||||
'mail.default' => 'array',
|
'mail.default' => 'array',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->withoutMiddleware(ValidateCsrfToken::class);
|
/**
|
||||||
|
* Feature tests post directly to web routes. Keep CSRF enabled in the
|
||||||
|
* application, but exclude it in PHPUnit so tests exercise validation,
|
||||||
|
* authorization, tenancy and persistence instead of failing with 419.
|
||||||
|
*/
|
||||||
|
if (class_exists(ValidateCsrfToken::class)) {
|
||||||
|
ValidateCsrfToken::except(['*']);
|
||||||
|
$this->withoutMiddleware(ValidateCsrfToken::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (class_exists(\App\Http\Middleware\VerifyCsrfToken::class)) {
|
||||||
|
\App\Http\Middleware\VerifyCsrfToken::except(['*']);
|
||||||
|
$this->withoutMiddleware(\App\Http\Middleware\VerifyCsrfToken::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST with a real CSRF token for Fortify/web form tests.
|
* POST with a real CSRF token for tests that intentionally verify web-form behaviour.
|
||||||
*
|
*
|
||||||
* @param array<string, mixed> $data
|
* @param array<string, mixed> $data
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user