Let a service unit use stock and machines

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
2026-11-26 16:01:59 +02:00
co-authored by Claude Sonnet 5.5
parent d160854b79
commit 361a2974cf
16 changed files with 204 additions and 13 deletions
@@ -117,3 +117,33 @@ it('does not let the edited item be changed in the browser', function () {
Livewire::test('catalog::work-type-form', ['serviceUnit' => ($this->unit)('Markkinointi')->id])
->set('workTypeId', 1);
})->throws(CannotUpdateLockedPropertyException::class);
it('turns stock and machine features on for a service unit, but not for the shared unit', function () {
$print = ($this->unit)('Painotuotanto');
$shared = ($this->unit)('Kaikille yhteiset');
Livewire::test('catalog::service-unit-form', ['serviceUnit' => $print->id])
->assertSee(__('catalog.service_units.uses_stock'))
->set('usesStock', true)
->call('save')
->assertHasNoErrors();
expect($print->fresh()->uses_stock)->toBeTrue()
->and(app(CatalogQueries::class)->stockServiceUnitIds())->toBe([$print->id]);
Livewire::test('catalog::index')->assertSee(__('catalog.service_units.uses_stock_on'));
Livewire::test('catalog::service-unit-form', ['serviceUnit' => $shared->id])
->assertDontSee(__('catalog.service_units.uses_stock'))
->set('usesStock', true)
->call('save');
expect($shared->fresh()->uses_stock)->toBeFalse();
Livewire::test('catalog::service-unit-form', ['serviceUnit' => $print->id])
->assertSet('usesStock', true)
->set('usesStock', false)
->call('save');
expect(app(CatalogQueries::class)->stockServiceUnitIds())->toBe([]);
});