# Task 27 Test Audit

Date: 2026-03-16

## Existing Test Coverage

### Base / Smoke
- `tests/Feature/AdminAuthTest.php`
  - admin login/logout flow
  - unauthenticated dashboard redirect
  - permission middleware behavior
  - super admin bypass behavior
- `tests/Feature/AdminDashboardRouteSmokeTest.php`
  - dashboard page renders
  - selected auxiliary admin routes render
- `tests/Feature/AdminLocalizationTest.php`
  - localization behavior for admin routes
- `tests/Feature/RolePermissionSeederTest.php`
  - seeder roles and permissions smoke coverage

### Core
- `tests/Feature/BranchTest.php`
  - branch CRUD
  - branch permission checks
  - branch validation rules
  - branch scopes and soft-delete restore
- `tests/Feature/Core/SettingTest.php`
  - settings page access
  - settings update
  - branch override fallback behavior
- `tests/Feature/NumberSequenceTest.php`
  - number sequence service behavior
  - uniqueness and branch/year scoping

### Finance
- `tests/Feature/Finance/FiscalYearModuleTest.php`
  - fiscal year creation
  - quarterly period generation
  - fiscal period close flow
  - unauthorized access
- No current automated coverage for:
  - chart of accounts
  - journals
  - journal entries
  - posting engine
  - trial balance
  - general ledger
  - income statement

### Generic Form / Security
- `tests/Feature/FormSecurityTest.php`
  - CSRF
  - several injection and sanitization scenarios
  - protected-field / privilege edge cases
- `tests/Feature/FormSubmissionTest.php`
  - admin user, roles, permissions, profile, login form flows
- `tests/Feature/FormValidationTest.php`
  - general validation and submission behavior around admin forms

## Coverage Gaps By Module Group

### Core gaps
- missing explicit fiscal periods test class
- missing cost centers tests
- branch tests still use legacy permission names like `core.branches.edit` instead of newer route-level update naming patterns

### Finance gaps
- no tests for account hierarchy CRUD and translated titles
- no tests for journals CRUD
- no tests for journal entry header/line persistence
- no tests for posting success and failure rules
- no tests for report query correctness:
  - trial balance
  - general ledger
  - income statement

### Inventory gaps
- no `tests/Feature/Inventory/` coverage currently
- missing warehouses CRUD tests
- missing items CRUD and stock-only item rules
- missing stock movement validation and totals tests
- missing stock report filter and aggregate tests

### Sales gaps
- no `tests/Feature/Sales/` coverage currently
- missing customers CRUD tests
- missing sales order line persistence tests
- missing invoice calculation tests
- missing sales report filter and total tests

### HR gaps
- no `tests/Feature/HR/` coverage currently
- missing employees CRUD tests
- missing payroll net salary calculation and status tests
- missing payroll summary aggregate/filter tests

### System gaps
- no `tests/Feature/System/` coverage currently
- missing notifications permission and mark-as-read tests
- missing audit logs permission/filter tests
- existing dashboard smoke test should be extended to assert KPI page loads under `system.dashboard.view`

## Recommended Task 27 Execution Order

1. Core
   - extend existing coverage for fiscal periods and cost centers
2. Finance
   - prioritize posting engine and journal entry persistence
3. Inventory
   - cover CRUD plus stock movement rules
4. Sales
   - cover order/invoice calculations and reports
5. HR
   - cover payroll calculations and summaries
6. System
   - cover notifications, audit logs, and dashboard analytics

## Notes

- Current automated coverage is concentrated in pre-existing admin/auth/core flows.
- Most roadmap tasks from Task 06 onward do not yet have dedicated feature tests.
- Task 27 should mostly add new tests, not refactor modules, unless a failing test proves a bug.
