Filament Panel Tests
Tests for Filament panel resources using Livewire's test helpers. These test the panel UI components directly rather than HTTP endpoints.
Pattern
use function Pest\Livewire\livewire;
use App\Filament\Admin\Resources\MatterResource\Pages\ListMatters;
it('allows lawyer to see their assigned matters', function () {
$user = staffUser(role: 'LAWYER');
$matter = Matter::factory()->for($this->firm)->create();
MatterAttorney::factory()->create(['user_id' => $user->id, 'matter_id' => $matter->id]);
livewire(ListMatters::class)
->assertCanSeeTableRecords([$matter]);
});
Admin Panel — tests/Feature/Filament/Admin/
MatterResourceTest.php
List page
✓ renders for authenticated staff user
✓ LAWYER sees only their assigned matters
✓ FIRM_ADMIN sees all firm matters
✓ status filter narrows results correctly
✓ lead attorney filter works
Create page
✓ form renders with all required fields
✓ LAWYER can create a matter
✓ PARALEGAL cannot access create page (403)
✓ form validates required title field
✓ form validates status enum values
Edit page
✓ lead attorney can edit matter details
✓ non-team member cannot access edit page (403)
✓ status transition validation prevents invalid transitions
Actions
✓ GenerateInvoice action is visible for BILLING_ADMIN
✓ GenerateInvoice action is hidden for LAWYER role
✓ GenerateInvoice action dispatches GenerateInvoicePdfJob
✓ CloseMatter action requires confirmation modal
Relation Managers
✓ TimeEntriesRelationManager lists entries for the matter
✓ InvoicesRelationManager lists invoices for the matter
✓ DocumentsRelationManager lists documents for the matter
ClientResourceTest.php
List page
✓ renders for LAWYER role
✓ search by name filters results
Create page
✓ INDIVIDUAL type form shows first_name + last_name fields
✓ BUSINESS type form shows company_name field
✓ type toggle switches visible fields
✓ SSN field is visible for BILLING_ADMIN
✓ SSN field is hidden for PARALEGAL
Edit page
✓ INTERN role cannot access edit page (403)
InvoiceResourceTest.php
List page
✓ renders for BILLING_ADMIN
✓ LAWYER can view but not edit invoices
✓ status filter works
Detail page
✓ shows line items
✓ DownloadPdf action returns presigned URL
Actions
✓ MarkAsSent action transitions invoice from DRAFT to SENT
✓ MarkAsSent is blocked for APPROVED invoices (wrong transition)
✓ RecordPayment action creates a Payment record
UserProfileResourceTest.php
List page
✓ FIRM_ADMIN can list all staff profiles
✓ LAWYER cannot access user management (403)
Actions
✓ AssignRole action creates UserRoleAssignment
✓ DeactivateUser action sets is_active = false
✓ DeactivateUser does not hard-delete the user
Client Portal — tests/Feature/Filament/Client/ClientPortalTest.php
Matter list
✓ CLIENT_USER sees only matters linked to their client record
✓ CLIENT_USER cannot see another client's matters
Invoice list
✓ CLIENT_USER sees only invoices for their matters
✓ pay invoice action is visible for OUTSTANDING invoices
✓ pay invoice action is hidden for PAID invoices
Document list
✓ CLIENT_USER sees only documents shared with their matters
✓ download action returns presigned URL
Access control
✓ CLIENT_USER cannot access /admin panel
✓ CLIENT_USER cannot access /partner panel
Partner Portal — tests/Feature/Filament/Partner/PartnerPortalTest.php
Matter list
✓ PARTNER_ATTORNEY_USER sees only matters they are assigned to via matter_partner_attorneys
✓ cannot see matters from a different firm
Time entry
✓ can submit a time entry for an assigned matter
✓ cannot submit time entry for a matter they are not assigned to
Partner bill list
✓ sees bills issued to their partner firm
✓ cannot see bills for a different partner firm
Access control
✓ PARTNER_ATTORNEY_USER cannot access /admin panel
✓ PARTNER_ATTORNEY_USER cannot access /portal panel