39 lines
1.8 KiB
PHP
39 lines
1.8 KiB
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\ServiceUnitModel;
|
|
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();
|
|
$this->actingAs($this->user);
|
|
ServiceUnitModel::query()->where('name', 'Painotuotanto')->update(['uses_stock' => true]);
|
|
|
|
$item = StockItemModel::factory()->create(['name' => 'Valokuvapaperi', 'unit' => 'sheet', 'reorder_level_milli' => 200_000]);
|
|
foreach ([['purchase', 100_000, 5_000], ['consumption', -20_000, -1_000]] as [$kind, $milli, $value]) {
|
|
StockMovementModel::query()->create([
|
|
'stock_item_id' => $item->id, 'kind' => $kind, 'quantity_milli' => $milli, 'unit_cost_hundredths' => 5_000,
|
|
'value_cents' => $value, 'occurred_on' => now()->toDateString(), 'recorded_at' => now(), 'user_id' => $this->user->id, 'reason' => 'Koeajo',
|
|
]);
|
|
}
|
|
});
|
|
|
|
it('has no accessibility issues on the stock reports', function (string $page, string $device, string $colorScheme) {
|
|
$visit = visit(route('reports.'.$page));
|
|
$visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop();
|
|
$visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode();
|
|
|
|
$visit->assertSee('Valokuvapaperi')
|
|
->assertNoJavaScriptErrors()
|
|
->assertNoAccessibilityIssues(level: 2);
|
|
})->with(['stock-usage', 'stock-value'])->with([
|
|
'desktop, light' => ['desktop', 'light'],
|
|
'desktop, dark' => ['desktop', 'dark'],
|
|
'mobile, light' => ['mobile', 'light'],
|
|
'mobile, dark' => ['mobile', 'dark'],
|
|
]);
|