# Completed Edit V2 Smoke Test

## Preconditions
- Set `COMPLETED_EDIT_V2_ENABLED=1` in `.env`.
- Use a known completed registration token with at least one participant.
- Ensure `class_availability` has at least one enabled class/level pair.

## Test 1: Add Student (No Additional Charge)
1. Open `resume.php`, enter token, go to completed edit page.
2. Select `add_student`.
3. Add a student with valid required fields and a valid race/class/level.
4. Submit.
5. Expected UI: redirects to `confirmation-po.php` when charge delta is `<= 0`.
6. Expected DB:
   - New row in `participants` for the same `group_id`.
   - `Groups.total_cost` updated accordingly.

## Test 2: Add Student (Positive Delta)
1. Repeat add student with data that increases total cost.
2. Submit and complete payment in invoice/charge flow.
3. Expected UI: `invoice.php` then `confirmation-po.php`.
4. Expected DB:
   - One new `participants` row for the group.
   - One `payments` row with `payment_method='Credit Card'` and Stripe `transaction_id`.

## Test 3: Payment Idempotency
1. Re-submit the same payment callback with the same Stripe transaction id (simulate retry path).
2. Expected DB:
   - No duplicate row in `payments` for same `group_id` + `transaction_id`.

## Test 4: Edit Student Class/Level
1. Select `edit_student_class_level` for an existing participant.
2. Choose a valid enabled class/level pair.
3. Submit.
4. Expected DB:
   - Only participant `class` and `level` changed for selected participant.
   - No changes to participant name/age/gender/grade/race.

## Test 5: Reject Invalid Class/Level
1. Attempt to submit class/level combination disabled in `class_availability`.
2. Expected UI:
   - Remains in completed-edit context with flash error.
3. Expected DB:
   - No participant or group mutation.

## Test 6: Remove Student Request
1. Select `remove_student` and submit request.
2. Expected UI: redirect to `resume.php` with success flash message.
3. Expected DB:
   - Change log entry in `change_log`.
   - Participant row remains (admin-request semantics).

## Test 7: Admin Correction Request
1. Select `request_admin_correction`, submit text.
2. Expected UI: redirect to `resume.php` with success flash message.
3. Expected DB:
   - Change log entry with request notes.

## Test 8: Feature Flag Fallback
1. Set `COMPLETED_EDIT_V2_ENABLED=0`.
2. Repeat add/edit/remove flows.
3. Expected behavior:
   - Legacy handling path in `process.php` is used.
   - No fatal errors or broken redirects.
