feat: menric

This commit is contained in:
hashbro
2026-09-06 04:01:52 +08:00
parent d4c096ed4a
commit 9626fcc598
4 changed files with 212 additions and 10 deletions
+13 -5
View File
@@ -53,6 +53,11 @@ class PhotoReadTest extends TestCase
$this->actingAs($a, 'admin')
->get(route('admin.devices.photo', [$device, $photo->id]))
->assertOk();
$this->assertSame(0, PhotoRead::query()->count());
$this->actingAs($a, 'admin')
->get(route('admin.devices.photo', [$device, $photo->id, 'seen' => 1]))
->assertOk();
$this->assertSame(1, PhotoRead::query()->count());
$row = PhotoRead::query()->first();
@@ -71,7 +76,7 @@ class PhotoReadTest extends TestCase
->assertJsonPath('data.0.read', 0);
$this->actingAs($a, 'admin')
->get(route('admin.devices.photo', [$device, $photo->id]))
->get(route('admin.devices.photo', [$device, $photo->id, 'seen' => 1]))
->assertOk();
$this->assertSame(1, PhotoRead::query()->count());
}
@@ -108,11 +113,13 @@ class PhotoReadTest extends TestCase
$this->storePng($device, 'b.png');
PhotoRead::mark($seen, 'admin', (int) $admin->id);
$this->actingAs($admin, 'admin')
$tab = $this->actingAs($admin, 'admin')
->getJson(route('admin.devices.tabData', [$device, 'tab' => 'photos', 'read' => '0']))
->assertOk()
->assertJsonPath('count', 1)
->assertJsonPath('data.0.read', 0);
$this->assertStringContainsString('seen=1', (string) $tab->json('data.0.url'));
}
#[Test]
@@ -136,16 +143,17 @@ class PhotoReadTest extends TestCase
$photo = $this->storePng($device);
$this->actingAs($admin, 'admin')
->get(route('admin.devices.photo', [$device, $photo->id]))
->get(route('admin.devices.photo', [$device, $photo->id, 'seen' => 1]))
->assertOk();
$this->actingAs($agent, 'agent')
$list = $this->actingAs($agent, 'agent')
->getJson(route('user.photos.data'))
->assertOk()
->assertJsonPath('data.0.read', 0);
$this->assertStringNotContainsString('seen=1', (string) $list->json('data.0.url'));
$this->actingAs($agent, 'agent')
->get(route('user.devices.photo', [$device, $photo->id]))
->get(route('user.devices.photo', [$device, $photo->id, 'seen' => 1]))
->assertOk();
$this->assertSame(2, PhotoRead::query()->count());