Let a service unit use stock and machines
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -24,9 +24,14 @@ class FakeCatalogQueries implements CatalogQueries
|
||||
$this->workTypes[$serviceUnitId][] = new WorkTypeSummary($id, $serviceUnitId, null, $name, true);
|
||||
}
|
||||
|
||||
public function addServiceUnit(int $id, string $name, bool $active = true, bool $shared = false): void
|
||||
public function addServiceUnit(int $id, string $name, bool $active = true, bool $shared = false, bool $usesStock = false): void
|
||||
{
|
||||
$this->serviceUnits[$id] = new ServiceUnitSummary($id, $name, $shared, $active);
|
||||
$this->serviceUnits[$id] = new ServiceUnitSummary($id, $name, $shared, $active, $usesStock);
|
||||
}
|
||||
|
||||
public function stockServiceUnitIds(): array
|
||||
{
|
||||
return array_values(array_keys(array_filter($this->serviceUnits, fn (ServiceUnitSummary $unit): bool => $unit->isActive && $unit->usesStock)));
|
||||
}
|
||||
|
||||
public function tree(bool $includeInactive = true): array
|
||||
|
||||
@@ -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([]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user