F
Filamentβ€’7d ago
Aethyrion

Testing pagination on relation manager

Is it possible to test for subsequent table pages on a relation manager? I thought this test might have worked but it's failing:
public function test_the_next_page_of_addresses_can_be_seen(): void
{
$customer = Customer::factory()
->has(CustomerAddress::factory()->count(20), 'addresses')
->create();

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

$livewire
->call('gotoPage', 2)
->assertCanSeeTableRecords($customer->addresses->slice(offset: 10, length: 10))
;
}
public function test_the_next_page_of_addresses_can_be_seen(): void
{
$customer = Customer::factory()
->has(CustomerAddress::factory()->count(20), 'addresses')
->create();

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

$livewire
->call('gotoPage', 2)
->assertCanSeeTableRecords($customer->addresses->slice(offset: 10, length: 10))
;
}
No description
2 Replies
dissto
disstoβ€’7d ago
You probably need to pass the correct page name to it. I think by default goToPage would look for ?page=x But I think you'd need ?addressesRelationManagerPage=x So:
$livewire
->call('gotoPage', 2, 'addressesRelationManagerPage')
$livewire
->call('gotoPage', 2, 'addressesRelationManagerPage')
πŸ€”
Aethyrion
AethyrionOPβ€’7d ago
Yep - test is passing now πŸ‘ Thanks for your help @dissto 😁

Did you find this page helpful?