Files
Toiminnanohjaus/tests/Browser/SalesAccessibilityTest.php
petriandClaude Sonnet 5.5 290936d8de Let quick sale quantities be typed and specify quick sale production
Each line on the quick sale page gets a quantity field beside the
minus and plus buttons: the typed quantity is saved on change or
Enter, 0 removes the line and an invalid value keeps the old one
with an error.

The specification gets section 19.7 for phase 5: products with a
production process are sold as orders that go to a machine's work
list, are marked made at the machine (booking material and hours)
and are then paid in cash or by card.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-26 07:22:14 +02:00

85 lines
3.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use App\Models\User;
use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\ProductModel;
use App\Modules\Sales\Infrastructure\Persistence\Eloquent\QuickSaleModel;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
beforeEach(function () {
$this->user = User::factory()->management()->create(['name' => 'Johtaja']);
$this->actingAs($this->user);
$this->photos = ProductModel::factory()->consumer()->withAutoHours(0.25)->create(['name' => 'Passikuvat', 'price_cents' => 1500]);
QuickSaleModel::factory()->withLine($this->photos, 2)->create(['user_id' => $this->user->id]);
});
it('has no accessibility issues on the quick sale pages and no sideways scrolling', function (string $page, string $device, string $colorScheme) {
$url = match ($page) {
'sell' => route('sales.sell'),
'sales' => route('sales.index'),
};
$visit = visit($url);
$visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop();
$visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode();
$visit->assertSee('Passikuvat')
->assertNoJavaScriptErrors()
->assertNoAccessibilityIssues(level: 2);
})->with(['sell', 'sales'])->with([
'desktop, light' => ['desktop', 'light'],
'desktop, dark' => ['desktop', 'dark'],
'mobile, light' => ['mobile', 'light'],
'mobile, dark' => ['mobile', 'dark'],
]);
it('adds products with their buttons and announces the sale', function () {
$button = '[wire\\:click="addProduct('.$this->photos->id.')"]';
$page = visit(route('sales.sell'));
$page->click('#products-heading ~ ul '.$button)
->click('#products-heading ~ ul '.$button)
->click('#products-heading ~ ul '.$button)
->assertSee('Yhteensä 45,00')
->assertSee('3 × 15,00')
->assertNoAccessibilityIssues(level: 2)
->fill('#quantity-'.$this->photos->id, '4')
->keys('#quantity-'.$this->photos->id, 'Enter')
->assertSee('4 × 15,00')
->assertSee('Yhteensä 60,00')
->assertNoAccessibilityIssues(level: 2)
->click('Kirjaa myynti')
->assertSee('kirjattu: 60,00')
->assertSee('Tunneillesi kirjattiin 1 h.')
->assertSee('Avaa kuitti')
->assertNoAccessibilityIssues(level: 2);
});
it('has no accessibility issues on the company details page', function (string $device, string $colorScheme) {
$this->actingAs(User::factory()->admin()->create());
$visit = visit(route('settings.company'));
$visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop();
$visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode();
$visit->assertSee('Yritystiedot')
->assertNoJavaScriptErrors()
->assertNoAccessibilityIssues(level: 2);
})->with([
'desktop, light' => ['desktop', 'light'],
'desktop, dark' => ['desktop', 'dark'],
'mobile, light' => ['mobile', 'light'],
'mobile, dark' => ['mobile', 'dark'],
]);
it('closes the cash day from its dialog', function () {
visit(route('sales.index'))
->click('Päätä kassapäivä')
->assertSee('Päätetäänkö kassapäivä?')
->assertNoAccessibilityIssues(level: 2)
->click('#close-dialog button:last-child')
->assertSee('Kassapäivä päätetty')
->assertSee('Avaa kassapäivä');
});