feat: complete Epic 0 — foundation migration & infrastructure setup
Stories 0.2-0.5: rename folders→declarations (backend+frontend), configure Redis for cache/queue/sessions, add foundation database migrations (permissions, archived_at), replace DeclarationStatus enum with architecture lifecycle values, create DeclarationObserver for status transition validation and auto-archive, fix controller status transitions to respect observer rules. 93 tests pass (240 assertions). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,17 +1,26 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\Declaration;
|
||||
use App\Models\User;
|
||||
use App\Notifications\FolderMentionNotification;
|
||||
use App\Models\Workspace;
|
||||
use App\Notifications\DeclarationMentionNotification;
|
||||
|
||||
test('user can mark own notification as read', function () {
|
||||
$user = User::factory()->create();
|
||||
$user->notify(new FolderMentionNotification(
|
||||
folderId: 1,
|
||||
folderTitle: 'Test Folder',
|
||||
mentionedById: 999,
|
||||
mentionedByName: 'Admin',
|
||||
message: 'Please review.',
|
||||
url: '/folders/1',
|
||||
$workspace = Workspace::factory()->create();
|
||||
$workspace->users()->attach($user, ['role' => 'owner']);
|
||||
$client = Client::factory()->create(['workspace_id' => $workspace->id]);
|
||||
$declaration = Declaration::factory()->create([
|
||||
'workspace_id' => $workspace->id,
|
||||
'client_id' => $client->id,
|
||||
]);
|
||||
$mentionedBy = User::factory()->create();
|
||||
|
||||
$user->notify(new DeclarationMentionNotification(
|
||||
$declaration,
|
||||
$mentionedBy,
|
||||
'Please review.',
|
||||
));
|
||||
|
||||
$notification = $user->notifications()->first();
|
||||
@@ -27,13 +36,19 @@ test('user can mark own notification as read', function () {
|
||||
test('cannot mark another user notification as read', function () {
|
||||
$user = User::factory()->create();
|
||||
$other = User::factory()->create();
|
||||
$other->notify(new FolderMentionNotification(
|
||||
folderId: 1,
|
||||
folderTitle: 'Test',
|
||||
mentionedById: 999,
|
||||
mentionedByName: 'Admin',
|
||||
message: 'Hey.',
|
||||
url: '/folders/1',
|
||||
$workspace = Workspace::factory()->create();
|
||||
$workspace->users()->attach($other, ['role' => 'owner']);
|
||||
$client = Client::factory()->create(['workspace_id' => $workspace->id]);
|
||||
$declaration = Declaration::factory()->create([
|
||||
'workspace_id' => $workspace->id,
|
||||
'client_id' => $client->id,
|
||||
]);
|
||||
$mentionedBy = User::factory()->create();
|
||||
|
||||
$other->notify(new DeclarationMentionNotification(
|
||||
$declaration,
|
||||
$mentionedBy,
|
||||
'Hey.',
|
||||
));
|
||||
|
||||
$notification = $other->notifications()->first();
|
||||
@@ -44,15 +59,20 @@ test('cannot mark another user notification as read', function () {
|
||||
|
||||
test('user can mark all notifications as read', function () {
|
||||
$user = User::factory()->create();
|
||||
$workspace = Workspace::factory()->create();
|
||||
$workspace->users()->attach($user, ['role' => 'owner']);
|
||||
$client = Client::factory()->create(['workspace_id' => $workspace->id]);
|
||||
$mentionedBy = User::factory()->create();
|
||||
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$user->notify(new FolderMentionNotification(
|
||||
folderId: $i,
|
||||
folderTitle: "Folder $i",
|
||||
mentionedById: 999,
|
||||
mentionedByName: 'Admin',
|
||||
message: "Message $i",
|
||||
url: "/folders/$i",
|
||||
$declaration = Declaration::factory()->create([
|
||||
'workspace_id' => $workspace->id,
|
||||
'client_id' => $client->id,
|
||||
]);
|
||||
$user->notify(new DeclarationMentionNotification(
|
||||
$declaration,
|
||||
$mentionedBy,
|
||||
"Message $i",
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user