feat: L'Ami Fiduciaire V1.0.0 — full codebase with Story 0.1 complete
Initial commit of the L'Ami Fiduciaire SaaS platform built on Laravel 12, Vue 3, Inertia.js 2, and Tailwind CSS 4. Story 0.1 (rename folders to declarations in database) is implemented and code-reviewed: migration, rollback, and 6 Pest tests all passing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
97
tests/Feature/Notification/FolderMentionTest.php
Normal file
97
tests/Feature/Notification/FolderMentionTest.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\Folder;
|
||||
use App\Models\User;
|
||||
use App\Models\Workspace;
|
||||
use App\Notifications\FolderMentionNotification;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
function setupMentionScenario(string $role = 'owner'): array
|
||||
{
|
||||
$sender = User::factory()->create();
|
||||
$target = User::factory()->create();
|
||||
$workspace = Workspace::factory()->create();
|
||||
$workspace->users()->attach($sender, ['role' => $role]);
|
||||
$workspace->users()->attach($target, ['role' => 'member']);
|
||||
|
||||
$client = Client::factory()->create(['workspace_id' => $workspace->id]);
|
||||
$folder = Folder::factory()->create([
|
||||
'workspace_id' => $workspace->id,
|
||||
'client_id' => $client->id,
|
||||
]);
|
||||
|
||||
return [$sender, $target, $workspace, $folder];
|
||||
}
|
||||
|
||||
test('owner can mention a workspace user', function () {
|
||||
Notification::fake();
|
||||
[$sender, $target, $workspace, $folder] = setupMentionScenario('owner');
|
||||
session(['current_workspace_id' => $workspace->id]);
|
||||
|
||||
$response = $this->actingAs($sender)->post(route('folders.mentions.store', $folder), [
|
||||
'user_id' => $target->id,
|
||||
'message' => 'Please check this folder.',
|
||||
]);
|
||||
|
||||
$response->assertRedirect();
|
||||
Notification::assertSentTo($target, FolderMentionNotification::class);
|
||||
});
|
||||
|
||||
test('manager can mention a workspace user', function () {
|
||||
Notification::fake();
|
||||
[$sender, $target, $workspace, $folder] = setupMentionScenario('manager');
|
||||
session(['current_workspace_id' => $workspace->id]);
|
||||
|
||||
$response = $this->actingAs($sender)->post(route('folders.mentions.store', $folder), [
|
||||
'user_id' => $target->id,
|
||||
'message' => 'Please check this folder.',
|
||||
]);
|
||||
|
||||
$response->assertRedirect();
|
||||
Notification::assertSentTo($target, FolderMentionNotification::class);
|
||||
});
|
||||
|
||||
test('member cannot mention a workspace user', function () {
|
||||
Notification::fake();
|
||||
[$sender, $target, $workspace, $folder] = setupMentionScenario('member');
|
||||
session(['current_workspace_id' => $workspace->id]);
|
||||
|
||||
$response = $this->actingAs($sender)->post(route('folders.mentions.store', $folder), [
|
||||
'user_id' => $target->id,
|
||||
'message' => 'Please check this folder.',
|
||||
]);
|
||||
|
||||
$response->assertForbidden();
|
||||
Notification::assertNothingSent();
|
||||
});
|
||||
|
||||
test('cannot mention user from another workspace', function () {
|
||||
Notification::fake();
|
||||
[$sender, , $workspace, $folder] = setupMentionScenario('owner');
|
||||
$outsider = User::factory()->create();
|
||||
session(['current_workspace_id' => $workspace->id]);
|
||||
|
||||
$response = $this->actingAs($sender)->post(route('folders.mentions.store', $folder), [
|
||||
'user_id' => $outsider->id,
|
||||
'message' => 'Hello',
|
||||
]);
|
||||
|
||||
$response->assertSessionHasErrors('user_id');
|
||||
Notification::assertNothingSent();
|
||||
});
|
||||
|
||||
test('notification is persisted in database', function () {
|
||||
[$sender, $target, $workspace, $folder] = setupMentionScenario('owner');
|
||||
session(['current_workspace_id' => $workspace->id]);
|
||||
|
||||
$this->actingAs($sender)->post(route('folders.mentions.store', $folder), [
|
||||
'user_id' => $target->id,
|
||||
'message' => 'Check this.',
|
||||
]);
|
||||
|
||||
expect($target->notifications()->count())->toBe(1);
|
||||
$notif = $target->notifications()->first();
|
||||
expect($notif->data['folder_id'])->toBe($folder->id);
|
||||
expect($notif->data['message'])->toBe('Check this.');
|
||||
});
|
||||
Reference in New Issue
Block a user