- MacroImportController + LabelImportController: POST endpoints accepting uploaded .bin files,
delegating to MacrosImportService / LabelsImportService and returning import stats / warnings as JSON.
Generic German 422 error if parser rejects the file.
- MacroAssignmentController: index renders Settings Inertia page with assignments / macros / labels /
collections / last-import metadata. store/update/destroy/reorder for global MacroAssignment rows.
- ServiceMacroOverrideController: store snapshots all matching global MacroAssignments into
service-specific rows when a service opts to override; destroy removes both override and
service-specific assignments. storeAssignment / updateAssignment / destroyAssignment manage the
per-service rows directly.
- routes/web.php: 12 new named routes inside the auth middleware group; reorder route placed before
{macroAssignment} parameter route to avoid capture conflict.
- Tests: 19 new Pest tests across 4 feature files (54 assertions). Full suite 376 passed.
42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Http\UploadedFile;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
test('macro import requires authentication', function () {
|
|
$response = $this->post(route('settings.macros.import'), []);
|
|
$response->assertRedirect(route('login'));
|
|
});
|
|
|
|
test('macro import returns json with stats on valid file', function () {
|
|
$user = User::factory()->create();
|
|
$response = $this->actingAs($user)
|
|
->post(route('settings.macros.import'), [
|
|
'file' => new UploadedFile(base_path('tests/fixtures/macros-sample.bin'), 'macros.bin', null, null, true),
|
|
]);
|
|
|
|
$response->assertStatus(200)
|
|
->assertJsonStructure(['stats' => ['new', 'updated', 'disabled', 're_enabled'], 'warnings']);
|
|
});
|
|
|
|
test('macro import returns 422 on invalid file', function () {
|
|
$user = User::factory()->create();
|
|
$response = $this->actingAs($user)
|
|
->post(route('settings.macros.import'), [
|
|
'file' => UploadedFile::fake()->create('notamacro.bin', 1),
|
|
]);
|
|
|
|
$response->assertStatus(422);
|
|
});
|
|
|
|
test('macro import without file returns validation error', function () {
|
|
$user = User::factory()->create();
|
|
$response = $this->actingAs($user)
|
|
->postJson(route('settings.macros.import'), []);
|
|
|
|
$response->assertStatus(422);
|
|
});
|