Add modular layered architecture with Customers module
Introduce a modular monolith under app/Modules with Domain, Application, Infrastructure and Presentation layers. - Shared module: DomainException base, TransactionManager and an EventDispatcher that publishes events after commit. - Customers module: Customer entity, CustomerName and BusinessId (Y-tunnus checksum) value objects, RegisterCustomer/UpdateCustomer use cases, CustomerQueries read contract, Eloquent repository, and Livewire list and form pages with Finnish translations. - Pest arch tests enforce layer and module dependency rules for every module; Larastan (level 6) added as a dev dependency. - Raise Flux error text contrast to meet WCAG 2.2 AA. - Document the architecture in docs/architecture.md and CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Modules\Customers\Infrastructure\Persistence\Eloquent\CustomerModel;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
$this->actingAs(User::factory()->create());
|
||||
});
|
||||
|
||||
it('has no accessibility issues on the customer pages', function (string $routeName, string $device, string $colorScheme) {
|
||||
$customer = CustomerModel::factory()->company('0737546-2')->create(['name' => 'Mainos Oy']);
|
||||
|
||||
$page = visit($routeName === 'customers.edit' ? route($routeName, $customer->id) : route($routeName));
|
||||
|
||||
$page = $device === 'mobile' ? $page->on()->mobile() : $page->on()->desktop();
|
||||
$page = $colorScheme === 'dark' ? $page->inDarkMode() : $page->inLightMode();
|
||||
|
||||
$page->assertNoJavaScriptErrors()
|
||||
->assertNoAccessibilityIssues(level: 2);
|
||||
})->with([
|
||||
'list' => 'customers.index',
|
||||
'create' => 'customers.create',
|
||||
'edit' => 'customers.edit',
|
||||
])->with([
|
||||
'desktop, light' => ['desktop', 'light'],
|
||||
'desktop, dark' => ['desktop', 'dark'],
|
||||
'mobile, light' => ['mobile', 'light'],
|
||||
'mobile, dark' => ['mobile', 'dark'],
|
||||
]);
|
||||
|
||||
it('shows form errors without accessibility issues', function (string $colorScheme) {
|
||||
$page = visit(route('customers.create'));
|
||||
$page = $colorScheme === 'dark' ? $page->inDarkMode() : $page->inLightMode();
|
||||
|
||||
$page->fill('[wire\\:model="form.name"]', 'Mainos Oy')
|
||||
->fill('[wire\\:model="form.business_id"]', '0737546-3')
|
||||
->press('Tallenna')
|
||||
->assertSee('Y-tunnus ei ole kelvollinen.')
|
||||
->assertNoAccessibilityIssues(level: 2);
|
||||
})->with(['light', 'dark']);
|
||||
|
||||
it('creates a customer with the keyboard alone', function () {
|
||||
visit(route('customers.create'))
|
||||
->keys('html > body', 'Tab')
|
||||
->assertScript('document.activeElement.textContent.trim()', 'Siirry pääsisältöön')
|
||||
->keys('a[href="#main-content"]', 'Tab')
|
||||
->assertScript('document.activeElement.getAttribute("wire:model")', 'form.name')
|
||||
->type('[wire\\:model="form.name"]', 'Mainos Oy')
|
||||
->keys('[wire\\:model="form.name"]', 'Enter')
|
||||
->assertPathIs('/customers')
|
||||
->assertSee('Asiakas Mainos Oy lisätty.');
|
||||
});
|
||||
Reference in New Issue
Block a user