# Business Logic Model — Unit 4: Lieve woorden ## Navigation flow ```mermaid sequenceDiagram box rgba(246,224,94,0.4) Visitor participant V as Visitor end box rgba(99,179,237,0.4) Testimonials participant C as Carousel participant L as LiveRegion end V->>C: Next button, dot, arrow key or swipe C->>C: Compute target page, looping at the ends C->>C: Scroll to the target slide, instantly under reduced motion C->>L: Page changed to n L-->>V: Announces Review n van m ``` Text alternative: a navigation action makes the carousel compute the target page (looping), scroll to it (instantly under reduced motion) and report the new page to a polite live region, which announces "Review n van m". The carousel state (current page, scrolling, dragging, looping) is Chakra's `Carousel` (Ark UI); this unit does not reimplement it. Our own logic is limited to the pure functions below and wiring `onPageChange` to the live region. ## Pure functions (`web/src/lib/`) | Function | Input → output | Rules | |---|---|---| | `visibleTestimonials(items: Testimonial[]): Testimonial[]` | raw list → shown list | BR-REV-01 | | `slideLabel(index: number, count: number): string` | `(1, 2)` → `'Review 2 van 2'` (index is zero-based) | BR-REV-08/09 | ## Testable properties (PBT-01) | Function | Category | Property | |---|---|---| | `visibleTestimonials` | Invariant | Every result meets the invariants; ids unique | | `visibleTestimonials` | Invariant | Result is a subsequence of the input | | `visibleTestimonials` | Idempotency | Applying it twice equals applying it once | | `visibleTestimonials` | Oracle | Valid, unique input comes back unchanged | | `slideLabel` | Round-trip | The two numbers parsed back from the label are `index + 1` and `count` | | `slideLabel` | Invariant | For `0 ≤ index < count` the label has the form `Review n van m` with `1 ≤ n ≤ m` | The looping and paging itself is Chakra's (tested upstream); our component tests cover the behaviour at our boundary: loop from last to first, announcement text, controls hidden for one review, nothing rendered for none. PBT-06 (stateful) is N/A because the state machine is not ours. Generators (PBT-07) in `src/test/arbitraries.ts`: `testimonial` (valid; slug ids, non-blank texts, image with positive size), `uniqueTestimonials`, `anyTestimonial` (incl. blank quote/author/shoot, empty src, zero size, duplicate ids).