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,
]);
}