Show country on the device list beside IP.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -59,4 +59,40 @@ class DeviceCountryTest extends TestCase
|
||||
$this->assertSame('FR', $device->resolvedCountry());
|
||||
$this->assertSame('1.2.3.4(法国)', $device->formattedIp());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function device_list_includes_country_column(): void
|
||||
{
|
||||
Device::query()->create([
|
||||
'device_id' => 'dev-country-cn',
|
||||
'ip' => '8.8.8.8',
|
||||
'country' => 'CN',
|
||||
]);
|
||||
Device::query()->create([
|
||||
'device_id' => 'dev-country-visit',
|
||||
'ip' => '1.2.3.4',
|
||||
]);
|
||||
PageVisit::query()->create([
|
||||
'channel_id' => '0.0.01',
|
||||
'client_uid' => 'bbbbbbbbbbbbbbbb',
|
||||
'ip' => '1.2.3.4',
|
||||
'country' => 'FR',
|
||||
]);
|
||||
|
||||
$admin = Admin::query()->create(['username' => 'admin', 'password' => 'admin123']);
|
||||
$this->actingAs($admin, 'admin')
|
||||
->get(route('admin.devices.index'))
|
||||
->assertOk()
|
||||
->assertSee('国家');
|
||||
|
||||
$rows = $this->actingAs($admin, 'admin')
|
||||
->getJson(route('admin.devices.data'))
|
||||
->assertOk()
|
||||
->json('data');
|
||||
$byId = collect($rows)->keyBy('device_id');
|
||||
$this->assertSame('CN', $byId['dev-country-cn']['country']);
|
||||
$this->assertSame('中国', $byId['dev-country-cn']['country_label']);
|
||||
$this->assertSame('FR', $byId['dev-country-visit']['country']);
|
||||
$this->assertSame('法国', $byId['dev-country-visit']['country_label']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user