© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•13mo ago•
27 replies
Aethyrion

Testing modal form in resource relation

I want to test creating an address which is a sub-resource of customers but the form opens in a modal rather than go to a dedicated form page. How can I test this? I've tried the below and this isn't working

public function test_a_new_address_can_be_created(): void
{
    $customer = Customer::factory()->create();

    $livewire = Livewire::test(
        name: AddressesRelationManager::class,
        params: [
            'ownerRecord' => $customer,
            'pageClass' => EditCustomer::class,
        ],
    );

    $livewire
        ->mountTableAction('create')
        ->fillForm([
            'line_1' => $line1 = 'Test Line 1',
            'line_2' => $line2 = 'Test Line 2',
            'city' => $city = 'Test City',
            'state' => $state = 'Test State',
            'postal_code' => $postalCode = 'TE1 1ST',
            'type' => $type = AddressType::BILLING->value,
        ])
        ->callTableAction('create')
        ->assertHasNoFormErrors();

    $this->assertDatabaseHas(CustomerAddress::class, [
        'line_1' => $line1,
        'line_2' => $line2,
        'city' => $city,
        'state' => $state,
        'postal_code' => $postalCode,
        'type' => $type,
    ]);
}
public function test_a_new_address_can_be_created(): void
{
    $customer = Customer::factory()->create();

    $livewire = Livewire::test(
        name: AddressesRelationManager::class,
        params: [
            'ownerRecord' => $customer,
            'pageClass' => EditCustomer::class,
        ],
    );

    $livewire
        ->mountTableAction('create')
        ->fillForm([
            'line_1' => $line1 = 'Test Line 1',
            'line_2' => $line2 = 'Test Line 2',
            'city' => $city = 'Test City',
            'state' => $state = 'Test State',
            'postal_code' => $postalCode = 'TE1 1ST',
            'type' => $type = AddressType::BILLING->value,
        ])
        ->callTableAction('create')
        ->assertHasNoFormErrors();

    $this->assertDatabaseHas(CustomerAddress::class, [
        'line_1' => $line1,
        'line_2' => $line2,
        'city' => $city,
        'state' => $state,
        'postal_code' => $postalCode,
        'type' => $type,
    ]);
}
image.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Display Relationshipvalue in View-Form on Resource-Modal
FilamentFFilament / ❓┊help
3y ago
Modal in form Resource
FilamentFFilament / ❓┊help
3y ago
Testing modal form fields.
FilamentFFilament / ❓┊help
8mo ago
testing create data in modal form
FilamentFFilament / ❓┊help
3y ago