Add stock items, groups and movements at a moving average cost
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\ServiceUnitModel;
|
||||
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 Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
$this->user = User::factory()->management()->create(['name' => 'Johtaja']);
|
||||
$this->actingAs($this->user);
|
||||
ServiceUnitModel::factory()->usingStock()->create(['name' => 'Painotuotanto']);
|
||||
$group = StockItemGroupModel::factory()->create(['name' => 'Paperit']);
|
||||
$this->item = StockItemModel::factory()->create([
|
||||
'stock_item_group_id' => $group->id,
|
||||
'name' => 'Valokuvapaperi',
|
||||
'unit' => 'sheet',
|
||||
'reorder_level_milli' => 50_000,
|
||||
'average_cost_hundredths' => 5_000,
|
||||
]);
|
||||
StockMovementModel::query()->create([
|
||||
'stock_item_id' => $this->item->id, 'kind' => 'purchase', 'quantity_milli' => 40_000, 'unit_cost_hundredths' => 5_000,
|
||||
'value_cents' => 2_000, 'occurred_on' => now()->toDateString(), 'recorded_at' => now(), 'user_id' => $this->user->id,
|
||||
]);
|
||||
});
|
||||
|
||||
it('has no accessibility issues on the stock pages and no sideways scrolling', function (string $page, string $device, string $colorScheme) {
|
||||
$url = match ($page) {
|
||||
'index' => route('inventory.index'),
|
||||
'item' => route('inventory.items.show', $this->item->id),
|
||||
'form' => route('inventory.items.edit', $this->item->id),
|
||||
'groups' => route('inventory.groups'),
|
||||
};
|
||||
|
||||
$visit = visit($url);
|
||||
$visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop();
|
||||
$visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode();
|
||||
|
||||
$visit->assertSee(match ($page) {
|
||||
'groups' => 'Paperit', 'form' => __('inventory.form.edit_title'), default => 'Valokuvapaperi'
|
||||
})
|
||||
->assertNoJavaScriptErrors()
|
||||
->assertNoAccessibilityIssues(level: 2);
|
||||
})->with(['index', 'item', 'form', 'groups'])->with([
|
||||
'desktop, light' => ['desktop', 'light'],
|
||||
'desktop, dark' => ['desktop', 'dark'],
|
||||
'mobile, light' => ['mobile', 'light'],
|
||||
'mobile, dark' => ['mobile', 'dark'],
|
||||
]);
|
||||
|
||||
it('reverses a movement in a dialog that returns focus', function () {
|
||||
visit(route('inventory.items.show', $this->item->id))
|
||||
->assertSee(__('inventory.status.reorder'))
|
||||
->click(__('inventory.item.reverse'))
|
||||
->assertSee(__('inventory.item.reverse_title'))
|
||||
->assertNoAccessibilityIssues(level: 2)
|
||||
->click(__('inventory.item.reverse_confirm'))
|
||||
->assertSee('Vastakirjaus kirjattu')
|
||||
->assertScript('document.activeElement.id', 'item-status');
|
||||
});
|
||||
Reference in New Issue
Block a user