fix: resolve 15 pre-existing test failures flagged across 3 retrospectives

Delete 14 legacy Folder test files (FolderTypeTest, MediaDownloadTest,
FolderMentionTest) that referenced removed routes/tables from the Epic 0
folders-to-declarations rename. Declaration equivalents already exist.
Fix WorkerDashboardTest session edge case where HandleInertiaRequests
middleware auto-assigns workspace, invalidating the no-session assumption.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-24 10:50:46 +01:00
parent 4dca01a082
commit 716e9fc4f6
4 changed files with 4 additions and 340 deletions

View File

@@ -1,97 +0,0 @@
<?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 setupFolderMentionScenario(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] = setupFolderMentionScenario('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] = setupFolderMentionScenario('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] = setupFolderMentionScenario('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] = setupFolderMentionScenario('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] = setupFolderMentionScenario('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.');
});