|
6 | 6 | use App\Jobs\ExportGedCom; |
7 | 7 | use App\Models\Gedcom; |
8 | 8 | use App\Models\User; |
| 9 | +use Filament\Forms\Components\FileUpload; |
9 | 10 | use Illuminate\Foundation\Testing\RefreshDatabase; |
10 | 11 | use Illuminate\Support\Facades\Auth; |
11 | 12 | use Illuminate\Support\Facades\Queue; |
@@ -74,4 +75,31 @@ public function test_export_gedcom_does_not_dispatch_without_authenticated_user( |
74 | 75 |
|
75 | 76 | Queue::assertNotPushed(ExportGedCom::class); |
76 | 77 | } |
| 78 | + |
| 79 | + public function test_file_upload_component_accepts_ged_files_via_mime_type_map(): void |
| 80 | + { |
| 81 | + $upload = FileUpload::make('filename') |
| 82 | + ->acceptedFileTypes(['.ged', '.gramps', 'text/plain', 'application/xml', 'text/xml']) |
| 83 | + ->mimeTypeMap(['ged' => 'text/plain', 'gramps' => 'application/xml']); |
| 84 | + |
| 85 | + $mimeTypeMap = $upload->getMimeTypeMap(); |
| 86 | + |
| 87 | + $this->assertArrayHasKey('ged', $mimeTypeMap, '.ged extension should have a MIME type mapping'); |
| 88 | + $this->assertEquals('text/plain', $mimeTypeMap['ged'], '.ged files should map to text/plain'); |
| 89 | + $this->assertArrayHasKey('gramps', $mimeTypeMap, '.gramps extension should have a MIME type mapping'); |
| 90 | + $this->assertEquals('application/xml', $mimeTypeMap['gramps'], '.gramps files should map to application/xml'); |
| 91 | + } |
| 92 | + |
| 93 | + public function test_file_upload_component_accepted_file_types_includes_ged_extension(): void |
| 94 | + { |
| 95 | + $upload = FileUpload::make('filename') |
| 96 | + ->acceptedFileTypes(['.ged', '.gramps', 'text/plain', 'application/xml', 'text/xml']) |
| 97 | + ->mimeTypeMap(['ged' => 'text/plain', 'gramps' => 'application/xml']); |
| 98 | + |
| 99 | + $acceptedTypes = $upload->getAcceptedFileTypes(); |
| 100 | + |
| 101 | + $this->assertContains('.ged', $acceptedTypes, 'FileUpload should accept .ged files'); |
| 102 | + $this->assertContains('.gramps', $acceptedTypes, 'FileUpload should accept .gramps files'); |
| 103 | + $this->assertContains('text/plain', $acceptedTypes, 'FileUpload should accept text/plain MIME type'); |
| 104 | + } |
77 | 105 | } |
0 commit comments