Finish implementing test

This commit is contained in:
Marcus Moore 2025-02-20 12:40:05 -08:00
parent cf0ce1c5ea
commit 0190ccea27
No known key found for this signature in database

View file

@ -22,22 +22,32 @@ class CreateNotesTest extends TestCase
$this->markTestIncomplete(); $this->markTestIncomplete();
} }
public function testCanCreateNote() public function testCanCreateNoteForAsset()
{ {
// @todo: make dynamic?
$actor = User::factory()->editAssets()->create(); $actor = User::factory()->editAssets()->create();
$asset = Asset::factory()->create(); $asset = Asset::factory()->create();
$this->actingAs($actor) $this->actingAs($actor)
->withHeader('User-Agent', 'Custom User Agent For Test')
->post(route('notes.store'), [ ->post(route('notes.store'), [
'_token' => '_token-to-simulate-request-from-gui',
'id' => $asset->id, 'id' => $asset->id,
'type' => 'asset', 'type' => 'asset',
'note' => 'my special note', 'note' => 'my special note',
]) ])
->assertRedirect(route('hardware.show', $asset->id) . '#history'); ->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',
]);
} }
} }