From 0190ccea27ccc665a95806cbd90a22dd3a6b0ccf Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 20 Feb 2025 12:40:05 -0800 Subject: [PATCH] Finish implementing test --- tests/Feature/Notes/CreateNotesTest.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/Feature/Notes/CreateNotesTest.php b/tests/Feature/Notes/CreateNotesTest.php index a42d501bb9..789991adb0 100644 --- a/tests/Feature/Notes/CreateNotesTest.php +++ b/tests/Feature/Notes/CreateNotesTest.php @@ -22,22 +22,32 @@ class CreateNotesTest extends TestCase $this->markTestIncomplete(); } - public function testCanCreateNote() + public function testCanCreateNoteForAsset() { - // @todo: make dynamic? - $actor = User::factory()->editAssets()->create(); $asset = Asset::factory()->create(); $this->actingAs($actor) + ->withHeader('User-Agent', 'Custom User Agent For Test') ->post(route('notes.store'), [ + '_token' => '_token-to-simulate-request-from-gui', 'id' => $asset->id, 'type' => 'asset', 'note' => 'my special note', ]) ->assertRedirect(route('hardware.show', $asset->id) . '#history'); - // @todo: assert action log created with expected data + $this->assertDatabaseHas('action_logs', [ + 'created_by' => $actor->id, + 'action_type' => 'note added', + 'target_id' => null, + 'target_type' => null, + 'note' => 'my special note', + 'item_type' => Asset::class, + 'item_id' => $asset->id, + 'action_source' => 'gui', + 'user_agent' => 'Custom User Agent For Test', + ]); } }