refactor: kb & station & terminal
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Filament\Resources\TerminalResource;
|
||||
use App\Filament\Resources\TerminalResource\Pages\CreateTerminal;
|
||||
use App\Filament\Resources\TerminalResource\Pages\EditTerminal;
|
||||
use App\Filament\Resources\TerminalResource\Pages\ListTerminals;
|
||||
use App\Models\Station;
|
||||
use App\Models\Terminal;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
@@ -57,11 +58,13 @@ class TerminalResourceTest extends TestCase
|
||||
/** @test */
|
||||
public function it_can_create_terminal(): void
|
||||
{
|
||||
$station = Station::factory()->create();
|
||||
|
||||
$newData = [
|
||||
'name' => '测试终端',
|
||||
'code' => 'TEST-0001',
|
||||
'ip_address' => '192.168.1.100',
|
||||
'station_id' => 1,
|
||||
'station_id' => $station->id,
|
||||
'diagram_url' => 'https://example.com/diagram.html',
|
||||
];
|
||||
|
||||
@@ -161,11 +164,13 @@ class TerminalResourceTest extends TestCase
|
||||
{
|
||||
$terminal = Terminal::factory()->create();
|
||||
|
||||
$station = Station::factory()->create();
|
||||
|
||||
$newData = [
|
||||
'name' => '更新后的终端',
|
||||
'code' => $terminal->code,
|
||||
'ip_address' => '192.168.1.200',
|
||||
'station_id' => 2,
|
||||
'station_id' => $station->id,
|
||||
];
|
||||
|
||||
Livewire::test(EditTerminal::class, ['record' => $terminal->getRouteKey()])
|
||||
@@ -239,10 +244,12 @@ class TerminalResourceTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_can_group_by_station(): void
|
||||
public function it_can_group_by_group(): void
|
||||
{
|
||||
Terminal::factory()->count(3)->create(['station_id' => 1]);
|
||||
Terminal::factory()->count(2)->create(['station_id' => 2]);
|
||||
$station1 = Station::factory()->create();
|
||||
$station2 = Station::factory()->create();
|
||||
Terminal::factory()->count(3)->create(['station_id' => $station1->id]);
|
||||
Terminal::factory()->count(2)->create(['station_id' => $station2->id]);
|
||||
|
||||
// 测试分组功能是否可用
|
||||
$component = Livewire::test(ListTerminals::class);
|
||||
|
||||
Reference in New Issue
Block a user