Files
AFC-Demo/tests/Feature/Livewire/Upload/IndexTest.php
T

101 lines
2.6 KiB
PHP
Raw Normal View History

<?php
use App\Models\User;
use Livewire\Volt\Volt;
it('requires authentication to access upload page', function () {
$response = $this->get('/upload');
$response->assertRedirect('/login');
});
it('can render upload page when authenticated', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = $this->get('/upload');
$response
->assertOk()
->assertSee('Upload neuer Transaktionen als CSV Datei')
->assertSee('Hochladen der Datei zur Verarbeitung durch die Trusted AI Plattform')
->assertSee('Select File')
->assertSee('Maximum file size: 50 MB')
->assertSee('https://upload.trai.mcs.local/api/upload')
->assertSee('Upload File')
->assertSee('Clear');
});
it('displays file input with correct attributes', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = $this->get('/upload');
$response
->assertOk()
->assertSee('type="file"', false)
->assertSee('id="file-upload"', false)
->assertSee('x-ref="fileInput"', false)
->assertSee('@change="selectFile"', false);
});
it('displays alpine.js data structure', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = $this->get('/upload');
$response
->assertOk()
->assertSee('x-data', false)
->assertSee('file: null', false)
->assertSee('uploading: false', false)
->assertSee('uploadStatus: null', false);
});
it('displays upload button with loading states', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = $this->get('/upload');
$response
->assertOk()
->assertSee('x-show="!uploading"', false)
->assertSee('Upload File')
->assertSee('x-show="uploading"', false)
->assertSee('Uploading...');
});
it('displays progress bar for upload state', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = $this->get('/upload');
$response
->assertOk()
->assertSee('x-show="uploading"', false)
->assertSee('Please wait while your file is being uploaded...');
});
it('displays callout for upload status messages', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = $this->get('/upload');
$response
->assertOk()
->assertSee('x-show="uploadStatus"', false)
->assertSee('x-bind:variant', false)
->assertSee('x-text="uploadMessage"', false);
});