# ALG 1 Calculator - Comprehensive Testing Guide

**Last Updated:** 2025-12-30

## Overview

This document provides a comprehensive testing guide for the Arbeitslosengeld Rechner (ALG 1 Calculator), covering all input combinations, edge cases, and expected behaviors. Use this guide to verify that all calculations are accurate and all inputs affect outputs correctly.

## Test Environment

- **Page URL:** `http://localhost:8003/tools/arbeitslosengeld-rechner`
- **Browser:** Chrome/Firefox/Safari (test in multiple browsers)
- **Console:** Open DevTools (F12) to check for JavaScript errors

## Test Categories

### 1. Children Impact Tests

**Purpose:** Verify that children correctly affects ALG percentage and baseALG, but NOT duration.

#### Test Case 1.1: Low Income - Children Should Show Difference

**Inputs:**

- Einkommen: `2000` (Netto)
- Alter: `35`
- Kinder vorhanden: `Nein` → then toggle to `Ja`
- Beschäftigungsmonate: `24`
- Nebenverdienst: `0`
- Region: `Westdeutschland`

**Expected Outputs (No Children):**

- ALG 1 Satz: `60%`
- Basis-ALG 1: `1.200,00 €`
- Arbeitslosengeld 1 (monatlich): `1.200,00 €`
- Anspruchsdauer: `12 Monate`

**Expected Outputs (With Children):**

- ALG 1 Satz: `67% (mit Kindern)`
- Basis-ALG 1: `1.340,00 €` (should be highlighted with blue ring)
- Arbeitslosengeld 1 (monatlich): `1.340,00 €`
- Anspruchsdauer: `12 Monate` (should NOT change)

**Verification:**

- [ ] Toggle children checkbox
- [ ] Verify ALG 1 Satz changes from 60% to 67%
- [ ] Verify Basis-ALG 1 card updates from 1200€ to 1340€
- [ ] Verify Basis-ALG 1 card shows blue ring/highlight when children=true
- [ ] Verify Basis-ALG 1 card label shows "(mit Kindern: +7%)" when children=true
- [ ] Verify main result (Arbeitslosengeld 1) updates from 1200€ to 1340€
- [ ] Verify Anspruchsdauer does NOT change (remains 12 months)
- [ ] Verify helper text appears below children toggle explaining the impact

#### Test Case 1.2: High Income - Both Capped

**Inputs:**

- Einkommen: `5000` (Netto)
- Alter: `35`
- Kinder vorhanden: `Nein` → then toggle to `Ja`
- Beschäftigungsmonate: `24`
- Nebenverdienst: `0`
- Region: `Westdeutschland`

**Expected Outputs (No Children):**

- Basis-ALG 1: `2.390,00 €` (capped)
- Final ALG 1: `2.390,00 €`

**Expected Outputs (With Children):**

- Basis-ALG 1: `2.390,00 €` (capped)
- Final ALG 1: `2.390,00 €` (same, because both are capped)

**Verification:**

- [ ] Both scenarios result in same final ALG 1 (2390€)
- [ ] Höchstbetrag card shows "(erreicht)" indicator
- [ ] Base ALG calculation shows higher value before capping, but final result is same

#### Test Case 1.3: Medium Income - Children Shows Difference

**Inputs:**

- Einkommen: `3000` (Netto)
- Alter: `35`
- Kinder vorhanden: `Nein` → then toggle to `Ja`
- Beschäftigungsmonate: `24`
- Nebenverdienst: `0`
- Region: `Westdeutschland`

**Expected Outputs (No Children):**

- Basis-ALG 1: `1.800,00 €`
- Final ALG 1: `1.800,00 €`

**Expected Outputs (With Children):**

- Basis-ALG 1: `2.010,00 €`
- Final ALG 1: `2.010,00 €`

**Verification:**

- [ ] Final ALG 1 increases from 1800€ to 2010€ when children toggled
- [ ] Difference: +210€ (7% increase)

#### Test Case 1.4: Children with Side Income

**Inputs:**

- Einkommen: `2000` (Netto)
- Alter: `35`
- Kinder vorhanden: `Nein` → then toggle to `Ja`
- Beschäftigungsmonate: `24`
- Nebenverdienst: `265`
- Region: `Westdeutschland`

**Expected Outputs (No Children):**

- Basis-ALG 1: `1.200,00 €`
- Nebenverdienst-Abzug: `240,00 €` (20% of 1200€)
- Final ALG 1: `960,00 €`

**Expected Outputs (With Children):**

- Basis-ALG 1: `1.340,00 €`
- Nebenverdienst-Abzug: `268,00 €` (20% of 1340€)
- Final ALG 1: `1.072,00 €`

**Verification:**

- [ ] Side income reduction increases with children (because it's based on baseALG)
- [ ] Final ALG 1 is higher with children despite higher reduction

### 2. All Inputs Impact Tests

#### Test Case 2.1: Income Change Affects Amount

**Inputs:**

- Einkommen: `1000` → change to `3000` (Netto)
- Alter: `35`
- Kinder vorhanden: `Nein`
- Beschäftigungsmonate: `24`
- Nebenverdienst: `0`
- Region: `Westdeutschland`

**Expected:**

- Final ALG 1: `600,00 €` → `1.800,00 €`
- Duration: `12 Monate` (unchanged)

**Verification:**

- [ ] Final ALG 1 increases proportionally with income
- [ ] Duration does NOT change

#### Test Case 2.2: Age Affects Duration Only (Age >= 50)

**Inputs:**

- Einkommen: `2000` (Netto)
- Alter: `35` → change to `55`
- Kinder vorhanden: `Nein`
- Beschäftigungsmonate: `24`
- Nebenverdienst: `0`
- Region: `Westdeutschland`

**Expected:**

- Final ALG 1: `1.200,00 €` (unchanged)
- Duration: `12 Monate` → `22 Monate`

**Verification:**

- [ ] Final ALG 1 does NOT change
- [ ] Duration increases from 12 to 22 months

#### Test Case 2.3: Employment Months Affects Duration Only

**Inputs:**

- Einkommen: `2000` (Netto)
- Alter: `35`
- Kinder vorhanden: `Nein`
- Beschäftigungsmonate: `12` → change to `24`
- Nebenverdienst: `0`
- Region: `Westdeutschland`

**Expected:**

- Final ALG 1: `1.200,00 €` (unchanged)
- Duration: `6 Monate` → `12 Monate`

**Verification:**

- [ ] Final ALG 1 does NOT change
- [ ] Duration increases from 6 to 12 months

#### Test Case 2.4: Side Income Affects Final Amount

**Inputs:**

- Einkommen: `2000` (Netto)
- Alter: `35`
- Kinder vorhanden: `Nein`
- Beschäftigungsmonate: `24`
- Nebenverdienst: `0` → change to `265`
- Region: `Westdeutschland`

**Expected:**

- Final ALG 1: `1.200,00 €` → `960,00 €`
- Nebenverdienst-Abzug card appears: `240,00 €`
- Duration: `12 Monate` (unchanged)

**Verification:**

- [ ] Final ALG 1 decreases when side income added
- [ ] Nebenverdienst-Abzug card appears and shows correct reduction
- [ ] Duration does NOT change

#### Test Case 2.5: Region Affects Amount When Capped

**Inputs:**

- Einkommen: `5000` (Netto)
- Alter: `35`
- Kinder vorhanden: `Nein`
- Beschäftigungsmonate: `24`
- Nebenverdienst: `0`
- Region: `Westdeutschland` → change to `Ostdeutschland`

**Expected:**

- Final ALG 1: `2.390,00 €` → `2.320,00 €`
- Höchstbetrag card updates: `2.390,00 €` → `2.320,00 €`

**Verification:**

- [ ] Final ALG 1 changes when region changes (when capped)
- [ ] Höchstbetrag card shows correct regional maximum

#### Test Case 2.6: Region Does NOT Affect When Not Capped

**Inputs:**

- Einkommen: `2000` (Netto)
- Alter: `35`
- Kinder vorhanden: `Nein`
- Beschäftigungsmonate: `24`
- Nebenverdienst: `0`
- Region: `Westdeutschland` → change to `Ostdeutschland`

**Expected:**

- Final ALG 1: `1.200,00 €` (unchanged)
- Höchstbetrag card updates: `2.390,00 €` → `2.320,00 €` (but not reached)

**Verification:**

- [ ] Final ALG 1 does NOT change (below both caps)
- [ ] Höchstbetrag card shows different values but "(erreicht)" indicator not shown

### 3. Edge Case Tests

#### Test Case 3.1: Exact Maximum Cap (West)

**Inputs:**

- Einkommen: `3983.33` (Netto) - results in exactly 2390€ baseALG
- Alter: `35`
- Kinder vorhanden: `Nein`
- Beschäftigungsmonate: `24`
- Nebenverdienst: `0`
- Region: `Westdeutschland`

**Expected:**

- Basis-ALG 1: `2.390,00 €` (exactly at cap)
- Höchstbetrag card shows "(erreicht)"
- Final ALG 1: `2.390,00 €`

**Verification:**

- [ ] Base ALG equals maximum cap
- [ ] Capped indicator shows correctly

#### Test Case 3.2: Side Income Exactly at Freibetrag

**Inputs:**

- Einkommen: `2000` (Netto)
- Alter: `35`
- Kinder vorhanden: `Nein`
- Beschäftigungsmonate: `24`
- Nebenverdienst: `165`
- Region: `Westdeutschland`

**Expected:**

- Nebenverdienst-Abzug: `0,00 €` (no reduction)
- Final ALG 1: `1.200,00 €` (unchanged)

**Verification:**

- [ ] No reduction applied
- [ ] Nebenverdienst-Abzug card does NOT appear (or shows 0€)

#### Test Case 3.3: Side Income at Reduction Thresholds

**Test 3.3a: 265€ Side Income (100€ over Freibetrag)**

- Nebenverdienst: `265`
- Expected Reduction: `240,00 €` (20% of 1200€)
- Expected Final ALG 1: `960,00 €`

**Test 3.3b: 365€ Side Income (200€ over Freibetrag)**

- Nebenverdienst: `365`
- Expected Reduction: `480,00 €` (40% of 1200€)
- Expected Final ALG 1: `720,00 €`

**Test 3.3c: 565€ Side Income (400€ over Freibetrag)**

- Nebenverdienst: `565`
- Expected Reduction: `960,00 €` (80% of 1200€ - maximum)
- Expected Final ALG 1: `240,00 €`

**Verification:**

- [ ] Each threshold shows correct reduction
- [ ] Reduction uses discrete 100€ steps (e.g., 264€ = 0€ reduction, 265€ = 240€ reduction)

#### Test Case 3.4: Age Exactly 50

**Inputs:**

- Einkommen: `2000` (Netto)
- Alter: `50`
- Kinder vorhanden: `Nein`
- Beschäftigungsmonate: `24`
- Nebenverdienst: `0`
- Region: `Westdeutschland`

**Expected:**

- Duration: `12 Monate` (no age increase yet)
- Final ALG 1: `1.200,00 €`

**Verification:**

- [ ] Duration is 12 months (boundary case)

#### Test Case 3.5: Employment Months Exactly 12

**Inputs:**

- Einkommen: `2000` (Netto)
- Alter: `35`
- Kinder vorhanden: `Nein`
- Beschäftigungsmonate: `12`
- Nebenverdienst: `0`
- Region: `Westdeutschland`

**Expected:**

- Duration: `6 Monate` (minimum)
- Final ALG 1: `1.200,00 €`

**Verification:**

- [ ] Duration is 6 months (minimum entitlement)

#### Test Case 3.6: Brutto to Netto Conversion

**Inputs:**

- Einkommen: `2500` (Brutto) vs `2000` (Netto)
- Alter: `35`
- Kinder vorhanden: `Nein`
- Beschäftigungsmonate: `24`
- Nebenverdienst: `0`
- Region: `Westdeutschland`

**Expected:**

- Both should result in similar final ALG 1 (2500 brutto ≈ 2000 netto × 0.80)
- Nettoeinkommen card should show ~2000€ for brutto input

**Verification:**

- [ ] Brutto 2500€ converts to ~2000€ netto
- [ ] Final ALG 1 is similar for both inputs

### 4. UI/UX Tests

#### Test Case 4.1: Children Toggle Visual Feedback

**Verification:**

- [ ] Helper text appears below children toggle
- [ ] Helper text changes when toggle changes
- [ ] Basis-ALG 1 card shows blue ring/highlight when children=true
- [ ] Basis-ALG 1 card label shows "(mit Kindern: +7%)" when children=true
- [ ] ALG 1 Satz card shows "(mit Kindern)" when children=true

#### Test Case 4.2: Real-time Calculation Updates

**Verification:**

- [ ] Changing any input triggers recalculation automatically
- [ ] Results update without page refresh
- [ ] No console errors during calculation
- [ ] Debouncing works (no excessive calculations)

#### Test Case 4.3: Error Handling

**Test Cases:**

- Empty income → Error message appears
- Income = 0 → Error message appears
- Income > 10000 → Error message appears
- Age < 16 → Error message appears
- Age > 67 → Error message appears
- Employment months < 12 → Error message appears
- Side income < 0 → Error message appears

**Verification:**

- [ ] Error messages display correctly
- [ ] Results section hidden when error occurs
- [ ] Error messages are user-friendly

### 5. Export Functionality Tests

#### Test Case 5.1: Excel Export

**Steps:**

1. Perform a calculation
2. Click "Als Excel exportieren" button
3. Verify file downloads
4. Open file and verify data

**Verification:**

- [ ] Excel file downloads successfully
- [ ] File contains all input and output data
- [ ] Data is correctly formatted
- [ ] Children status is included in export

#### Test Case 5.2: PDF Export

**Steps:**

1. Perform a calculation
2. Click "Als PDF exportieren" button
3. Verify PDF downloads
4. Open PDF and verify content

**Verification:**

- [ ] PDF file downloads successfully
- [ ] PDF contains all calculation results
- [ ] Layout is correct
- [ ] Children status is included in PDF

### 6. Browser Compatibility Tests

**Browsers to Test:**

- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)

**Verification:**

- [ ] All calculations work correctly in all browsers
- [ ] UI displays correctly in all browsers
- [ ] No JavaScript errors in console
- [ ] Alpine.js reactivity works in all browsers

## Automated Test Script

Run the comprehensive test suite:

```bash
python3 tests/arbeitslosengeld_rechner_comprehensive_test.py
```

**Expected Result:** All 17 tests pass

## Manual Testing Checklist

### Pre-Testing Setup

- [ ] Clear browser cache
- [ ] Open browser DevTools (F12)
- [ ] Navigate to calculator page
- [ ] Verify page loads without errors

### Children Impact Testing

- [ ] Test Case 1.1: Low income with/without children
- [ ] Test Case 1.2: High income with/without children (both capped)
- [ ] Test Case 1.3: Medium income with/without children
- [ ] Test Case 1.4: Children with side income

### All Inputs Impact Testing

- [ ] Test Case 2.1: Income change
- [ ] Test Case 2.2: Age change (>=50)
- [ ] Test Case 2.3: Employment months change
- [ ] Test Case 2.4: Side income change
- [ ] Test Case 2.5: Region change (when capped)
- [ ] Test Case 2.6: Region change (when not capped)

### Edge Case Testing

- [ ] Test Case 3.1: Exact maximum cap
- [ ] Test Case 3.2: Side income at freibetrag
- [ ] Test Case 3.3: Side income thresholds
- [ ] Test Case 3.4: Age exactly 50
- [ ] Test Case 3.5: Employment months exactly 12
- [ ] Test Case 3.6: Brutto to netto conversion

### UI/UX Testing

- [ ] Test Case 4.1: Children toggle visual feedback
- [ ] Test Case 4.2: Real-time calculation updates
- [ ] Test Case 4.3: Error handling

### Export Testing

- [ ] Test Case 5.1: Excel export
- [ ] Test Case 5.2: PDF export

### Browser Compatibility

- [ ] Chrome
- [ ] Firefox
- [ ] Safari
- [ ] Edge

## Common Issues and Solutions

### Issue: Children toggle doesn't update results

**Solution:** Check Alpine.js watcher is correctly set up:

```javascript
this.$watch("hasChildren", () => {
  if (this.incomeAmount && this.age) {
    this.debouncedCalculate();
  }
});
```

### Issue: Base ALG card doesn't highlight when children=true

**Solution:** Verify CSS classes:

```html
:class="calculationBreakdown.hasChildren ? 'ring-2 ring-blue-200 bg-blue-50/30'
: ''"
```

### Issue: Helper text doesn't appear

**Solution:** Verify `x-show` and `x-cloak` directives are correct

### Issue: Side income reduction incorrect

**Solution:** Verify formula uses `Math.floor(excess / 100)` for discrete steps

## Success Criteria

All tests pass when:

- ✅ Children correctly affects ALG percentage and baseALG
- ✅ Children does NOT affect duration
- ✅ All inputs affect outputs as per legal requirements
- ✅ UI clearly shows when children affects calculation
- ✅ No calculation errors or edge case bugs
- ✅ Export functionality works correctly
- ✅ All browsers display correctly

## Related Cursor Rules

When working with ALG 1 calculator testing, the following Cursor rules apply:

- **[tools-pages-reference.mdc](../../../../.cursor/rules/tools-pages-reference.mdc)** - Testing patterns and troubleshooting
- **[tools-pages-core-validation.mdc](../../../../.cursor/rules/tools-pages-core-validation.mdc)** - Validation patterns
- **[tools-pages-alg1-calculator.mdc](../../../../.cursor/rules/tools-pages-alg1-calculator.mdc)** - ALG 1 calculator specific patterns

## References

- Legal Research: `alg1-legal-research-2025.md`
- Calculation Formulas: `alg1-calculation-formulas-2025.md`
- Test Script: `tests/arbeitslosengeld_rechner_comprehensive_test.py`
- Code Implementation: `v2/pages/tools_arbeitslosengeld_rechner.php`
