Set the calendar's daily capacity in the company details
The task calendar's daily maximum moves from the hidden setting jobs.daily_capacity_hours to shared.daily_capacity_hours, edited by the admin on the company details page. An empty field means 7.5 hours. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Modules\Jobs\Application\Services\TaskPlanner;
|
||||
use App\Modules\Shared\Application\UseCases\CompanyDetailsStore;
|
||||
use App\Modules\Shared\Application\UseCases\DailyCapacity;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
|
||||
@@ -76,6 +78,44 @@ it('falls back to the application name when the menu name is empty, even before
|
||||
->and($store->menuName())->toBe(config('app.name'));
|
||||
});
|
||||
|
||||
it('saves the calendar daily capacity, 7.5 hours when empty', function () {
|
||||
$this->actingAs(User::factory()->admin()->create());
|
||||
$capacity = app(DailyCapacity::class);
|
||||
|
||||
Livewire::test('shared::company')
|
||||
->assertSet('daily_capacity_hours', '')
|
||||
->set('name', 'Mediatalo Oy')
|
||||
->set('business_id', '0737546-2')
|
||||
->set('daily_capacity_hours', '6,5')
|
||||
->call('save')
|
||||
->assertHasNoErrors();
|
||||
|
||||
expect($capacity->minutes())->toBe(390)
|
||||
->and(app(TaskPlanner::class)->capacityMinutes())->toBe(390);
|
||||
|
||||
Livewire::test('shared::company')
|
||||
->assertSet('daily_capacity_hours', '6,5')
|
||||
->set('daily_capacity_hours', '')
|
||||
->call('save')
|
||||
->assertHasNoErrors();
|
||||
|
||||
expect($capacity->minutes())->toBe(450);
|
||||
});
|
||||
|
||||
it('rejects an invalid daily capacity without saving anything', function () {
|
||||
$this->actingAs(User::factory()->admin()->create());
|
||||
|
||||
Livewire::test('shared::company')
|
||||
->set('name', 'Mediatalo Oy')
|
||||
->set('business_id', '0737546-2')
|
||||
->set('daily_capacity_hours', '25')
|
||||
->call('save')
|
||||
->assertHasErrors(['daily_capacity_hours' => [__('company.errors.daily_capacity_hours')]]);
|
||||
|
||||
expect(app(CompanyDetailsStore::class)->get())->toBeNull()
|
||||
->and(app(DailyCapacity::class)->hours())->toBeNull();
|
||||
});
|
||||
|
||||
it('rejects a menu name over 100 characters', function () {
|
||||
$this->actingAs(User::factory()->admin()->create());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user