Issue with Tenancy-enabled test

I am in the process of developing a test that uses a resource situated within a panel, which has tenancy functionality enabled. However, I'm encountering challenges in getting the test to function as expected. Below is the PHP code snippet representing the test:
it('can see own chargers', function () {
$user = User::factory()->create();
$this->actingAs($user);

$team = Team::factory()->create();
$team->users()->attach($user);

$chargers = Charger::factory()->count(10)->create();

livewire(ChargerResource\Pages\ListChargers::class, [
'tenant' => $team,
])->assertCanSeeTableRecords($chargers);
});
it('can see own chargers', function () {
$user = User::factory()->create();
$this->actingAs($user);

$team = Team::factory()->create();
$team->users()->attach($user);

$chargers = Charger::factory()->count(10)->create();

livewire(ChargerResource\Pages\ListChargers::class, [
'tenant' => $team,
])->assertCanSeeTableRecords($chargers);
});
Upon execution, I'm confronted with the following error message:
FAILED Tests\Feature\Filament\App\ChargerResourceTest > it can see own chargers ViewException
Missing required parameter for [Route: filament.app.resources.chargers.view] [URI: app/{tenant}/chargers/{record}/overview] [Missing parameter: tenant].
FAILED Tests\Feature\Filament\App\ChargerResourceTest > it can see own chargers ViewException
Missing required parameter for [Route: filament.app.resources.chargers.view] [URI: app/{tenant}/chargers/{record}/overview] [Missing parameter: tenant].
Any assistance in resolving this issue would be greatly appreciated.
2 Replies
Patrick Boivin
Patrick Boivin15mo ago
Not sure but could this be related to a custom action inside of the ListChargers page?
Disouric
DisouricOP15mo ago
source of ListChargers:
<?php

namespace App\Filament\App\Resources\ChargerResource\Pages;

use App\Filament\App\Resources\ChargerResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListChargers extends ListRecords
{
protected static string $resource = ChargerResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}
<?php

namespace App\Filament\App\Resources\ChargerResource\Pages;

use App\Filament\App\Resources\ChargerResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListChargers extends ListRecords
{
protected static string $resource = ChargerResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}
Ah wait, I understand. Let me check something.
Want results from more Discord servers?
Add your server