Record used material on tasks and suggest workflow steps' default materials

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
2026-11-26 16:28:16 +02:00
co-authored by Claude Sonnet 5.5
parent 30132deb0e
commit bca1eed166
41 changed files with 1521 additions and 19 deletions
+34 -1
View File
@@ -2,17 +2,21 @@
use App\Models\User;
use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\ServiceUnitModel;
use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\WorkTypeModel;
use App\Modules\Inventory\Infrastructure\Persistence\Eloquent\StockItemGroupModel;
use App\Modules\Inventory\Infrastructure\Persistence\Eloquent\StockItemModel;
use App\Modules\Inventory\Infrastructure\Persistence\Eloquent\StockMovementModel;
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\CustomerJobModel;
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\TaskModel;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
uses(RefreshDatabase::class);
beforeEach(function () {
$this->user = User::factory()->management()->create(['name' => 'Johtaja']);
$this->actingAs($this->user);
ServiceUnitModel::factory()->usingStock()->create(['name' => 'Painotuotanto']);
ServiceUnitModel::query()->where('name', 'Painotuotanto')->update(['uses_stock' => true]);
$group = StockItemGroupModel::factory()->create(['name' => 'Paperit']);
$this->item = StockItemModel::factory()->create([
'stock_item_group_id' => $group->id,
@@ -61,3 +65,32 @@ it('reverses a movement in a dialog that returns focus', function () {
->assertSee('Vastakirjaus kirjattu')
->assertScript('document.activeElement.id', 'item-status');
});
it('records material on a task card with the keyboard and without accessibility issues', function (string $device, string $colorScheme) {
$print = ServiceUnitModel::query()->where('name', 'Painotuotanto')->sole();
$print->update(['uses_stock' => true]);
$job = CustomerJobModel::factory()->create(['name' => 'Ikkunateippaus', 'status' => 'order']);
DB::table('customer_job_service_unit')->where('customer_job_id', $job->id)->update(['service_unit_id' => $print->id]);
$task = TaskModel::factory()->create([
'customer_job_id' => $job->id,
'work_type_id' => WorkTypeModel::query()->where('name', 'asennus')->value('id'),
'title' => 'Asennus',
]);
$visit = visit(route('jobs.show', $job->id).'#task-'.$task->id);
$visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop();
$visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode();
$visit->assertSee(__('inventory.task.title'))
->fill('#task-'.$task->id.'-material-search', 'valoku')
->assertSee('1 osuma')
->click('[wire\:click="selectItem('.$this->item->id.')"]')
->fill('#task-'.$task->id.'-material-quantity', '2')
->keys('#task-'.$task->id.'-material-quantity', 'Enter')
->assertSee('Kirjattu Valokuvapaperi 2')
->assertNoJavaScriptErrors()
->assertNoAccessibilityIssues(level: 2);
})->with([
'desktop, light' => ['desktop', 'light'],
'mobile, dark' => ['mobile', 'dark'],
]);