# 4. Affiliate Discount Codes — Test Cases

User Type: **Super Administrator**
Source: *Mi Digital Academy - Education CRM Features Document*
Spec: affiliate_discount_codes.md — every feature, sub-feature, and rule covered

---

## Test Execution Policy
- Zero tolerance: any deviation from documented behavior = FAILED = bug
- Every bug is immediately logged/reported (Bug ID, feature, sub-feature,
  expected vs actual, severity) and fixed 100% before the group passes
- Feature group passes only at 100% test pass rate

## Coverage Matrix
| Feature | Sub-feature / Rule | Test IDs |
|---------|--------------------|----------|
| 4.1 Permit Affiliates to Create Discount Codes (If Permitted) | Affiliate permission: the permission (the affiliates can create the codes, or not) | TC-SA-13-04-001 |
| 4.1 Permit Affiliates to Create Discount Codes (If Permitted) | Affiliate limits: the limits (the number of codes, the discount value, the scope) | TC-SA-13-04-002 |
| 4.1 Permit Affiliates to Create Discount Codes (If Permitted) | Affiliate scope: the scope (the codes, the items, the plans) | TC-SA-13-04-003 |
| 4.1 Permit Affiliates to Create Discount Codes (If Permitted) | Permission definition: the permission defined by the Super Admin (the permission, the limits, the scope) | TC-SA-13-04-001 |
| 4.1 Permit Affiliates to Create Discount Codes (If Permitted) | Code creation: the code created (the affiliate creates the code within the limits) | TC-SA-13-04-004 |
| 4.1 Permit Affiliates to Create Discount Codes (If Permitted) | Code record: the code recorded (the affiliate, the code, the discount, the scope) | TC-SA-13-04-005 |
| 4.1 Permit Affiliates to Create Discount Codes (If Permitted) | Audit logging of the permission definition and the code creation | TC-SA-13-04-006 |
| 4.1 Permit Affiliates to Create Discount Codes (If Permitted) | Rule: the affiliate permission is the control (the affiliates can create the codes, or not); the permission is the gate | TC-SA-13-04-001 |
| 4.1 Permit Affiliates to Create Discount Codes (If Permitted) | Rule: the affiliate limits are the boundaries (the number of codes, the discount value, the scope); the limits are the control | TC-SA-13-04-002 |
| 4.1 Permit Affiliates to Create Discount Codes (If Permitted) | Rule: the affiliate scope is the application (the codes, the items, the plans); the scope is the control | TC-SA-13-04-003 |
| 4.1 Permit Affiliates to Create Discount Codes (If Permitted) | Rule: a permission change (the permission, the limits, the scope updated) is recorded (the new permission, the new limits, the new scope); it is auditable | TC-SA-13-04-007 |
| 4.1 Permit Affiliates to Create Discount Codes (If Permitted) | Rule: the affiliate codes are visible (the affiliates, the codes, the discounts, the scopes); the affiliate codes are managed | TC-SA-13-04-008 |
| 4.1 Permit Affiliates to Create Discount Codes (If Permitted) | Rule: permission definition and code creation are audit-logged with the affiliate, code, and timestamp | TC-SA-13-04-006 |
| 4.2 Track Affiliate Code Usage | Usage tracking: the tracking (the code, the redemptions, the revenue, the affiliate) | TC-SA-13-04-009 |
| 4.2 Track Affiliate Code Usage | Usage scope: the scope (the affiliate, the codes) | TC-SA-13-04-010 |
| 4.2 Track Affiliate Code Usage | Redemption tracking: the redemptions (the number of redemptions per code) | TC-SA-13-04-011 |
| 4.2 Track Affiliate Code Usage | Revenue tracking: the revenue (the revenue per code, per affiliate) | TC-SA-13-04-012 |
| 4.2 Track Affiliate Code Usage | Usage view: the view (the usage per code, per affiliate) | TC-SA-13-04-013 |
| 4.2 Track Affiliate Code Usage | Usage record: the usage recorded (the affiliate, the code, the redemptions, the revenue) | TC-SA-13-04-014 |
| 4.2 Track Affiliate Code Usage | Audit logging of the usage tracking | TC-SA-13-04-015 |
| 4.2 Track Affiliate Code Usage | Rule: the usage tracking is explicit (the code, the redemptions, the revenue, the affiliate); the tracking is the visibility | TC-SA-13-04-009 |
| 4.2 Track Affiliate Code Usage | Rule: the usage scope is the affiliate and the codes; the scope is the control | TC-SA-13-04-010 |
| 4.2 Track Affiliate Code Usage | Rule: the redemption tracking is the count (the number of redemptions per code); the redemptions are the metric | TC-SA-13-04-011 |
| 4.2 Track Affiliate Code Usage | Rule: the revenue tracking is the value (the revenue per code, per affiliate); the revenue is the metric | TC-SA-13-04-012 |
| 4.2 Track Affiliate Code Usage | Rule: the usage is visible (the usage per code, per affiliate); the tracking is managed | TC-SA-13-04-013 |
| 4.2 Track Affiliate Code Usage | Rule: usage tracking is audit-logged with the affiliate, code, and timestamp | TC-SA-13-04-015 |

## 4.1 Permit Affiliates to Create Discount Codes (If Permitted)

### TC-SA-13-04-001 — Permission definition: the permission defined by the Super Admin (the permission, the limits, the scope); the permission is the gate
**Type:** Positive
**Covers:** 4.1 → Affiliate permission: the permission (the affiliates can create the codes, or not); Permission definition: the permission defined by the Super Admin (the permission, the limits, the scope); Rule: the affiliate permission is the control (the affiliates can create the codes, or not); the permission is the gate
**Preconditions:** The Super Admin opens the affiliate discount codes.
**Steps:**
1. Configure the affiliate code permission: the permission (the affiliates can create the codes, or not), the limits (the number of codes, the discount value, the scope), and the scope (the codes, the items, the plans).
2. Save the permission.
3. Verify the affiliate code permission is live and the affiliates create the codes within the limits.
**Expected Result:** The affiliate code permission is defined (the permission, the limits, the scope) — the permission is the gate.
**Priority:** Critical

### TC-SA-13-04-002 — Affiliate limits: the limits (the number of codes, the discount value, the scope); the limits are the boundaries
**Type:** Negative
**Covers:** 4.1 → Affiliate limits: the limits (the number of codes, the discount value, the scope); Rule: the affiliate limits are the boundaries (the number of codes, the discount value, the scope); the limits are the control
**Preconditions:** The affiliate code permission is live with a limit of 5 codes and a max discount value.
**Steps:**
1. As an affiliate, create 5 codes — verify all succeed.
2. As the affiliate, attempt to create a 6th code — verify it is rejected (the number-of-codes limit is enforced).
3. As the affiliate, attempt to create a code with a discount value above the limit — verify it is rejected (the discount-value limit is enforced).
**Expected Result:** The affiliate limits are enforced — the affiliates create the codes within the boundaries.
**Priority:** Critical

### TC-SA-13-04-003 — Affiliate scope: the scope (the codes, the items, the plans); the scope is the application
**Type:** Positive
**Covers:** 4.1 → Affiliate scope: the scope (the codes, the items, the plans); Rule: the affiliate scope is the application (the codes, the items, the plans); the scope is the control
**Preconditions:** The affiliate code permission is live with a scope.
**Steps:**
1. Open the affiliate scope.
2. Verify the scope is the codes, the items, the plans the affiliate codes apply to.
3. Verify the scope is the application and the control.
**Expected Result:** The affiliate scope is the codes, the items, the plans — the scope is the application.
**Priority:** High

### TC-SA-13-04-004 — Code creation: the code created (the affiliate creates the code within the limits); the permission is enforced
**Type:** Positive
**Covers:** 4.1 → Code creation: the code created (the affiliate creates the code within the limits)
**Preconditions:** The affiliate code permission is live (permission granted, limits set).
**Steps:**
1. As an affiliate, create a code (the code, the discount, the scope) within the limits.
2. Verify the code is created and live.
3. Verify the code is created within the limits (the permission is enforced).
**Expected Result:** The affiliate code is created within the limits — the permission is enforced.
**Priority:** Critical

### TC-SA-13-04-005 — Code record: the code recorded (the affiliate, the code, the discount, the scope); the code is recorded
**Type:** Positive
**Covers:** 4.1 → Code record: the code recorded (the affiliate, the code, the discount, the scope)
**Preconditions:** An affiliate has created a code.
**Steps:**
1. Open the code record.
2. Verify it shows the affiliate, the code, the discount, and the scope.
**Expected Result:** The affiliate code is recorded — the affiliate, the code, the discount, and the scope are shown.
**Priority:** High

### TC-SA-13-04-006 — Permission definition and code creation are audit-logged with the affiliate, code, and timestamp
**Type:** Positive
**Covers:** 4.1 → Audit logging of the permission definition and the code creation; Rule: permission definition and code creation are audit-logged with the affiliate, code, and timestamp
**Preconditions:** Permission definition and code creation events have occurred.
**Steps:**
1. Open the audit trail and filter by "affiliate code".
2. Verify entries show the affiliate, the code, and the timestamp.
**Expected Result:** The permission definition and code creation are audit-logged with the affiliate, code, and timestamp.
**Priority:** Critical

### TC-SA-13-04-007 — A permission change (the permission, the limits, the scope updated) is recorded (the new permission, the new limits, the new scope); it is auditable
**Type:** Positive
**Covers:** 4.1 → Rule: a permission change (the permission, the limits, the scope updated) is recorded (the new permission, the new limits, the new scope); it is auditable
**Preconditions:** The affiliate code permission is live.
**Steps:**
1. Change the permission (the new permission, the new limits, the new scope).
2. Verify the permission is updated.
3. Verify the change is recorded and auditable.
**Expected Result:** The permission change is recorded (the new permission, the new limits, the new scope) — it is auditable.
**Priority:** High

### TC-SA-13-04-008 — The affiliate codes are visible (the affiliates, the codes, the discounts, the scopes); the affiliate codes are managed
**Type:** Positive
**Covers:** 4.1 → Rule: the affiliate codes are visible (the affiliates, the codes, the discounts, the scopes); the affiliate codes are managed
**Preconditions:** Multiple affiliates have created codes.
**Steps:**
1. Open the affiliate codes view.
2. Verify the affiliates, the codes, the discounts, and the scopes are visible.
3. Verify the affiliate codes are managed.
**Expected Result:** The affiliate codes are visible — the affiliates, the codes, the discounts, and the scopes are shown.
**Priority:** Medium

## 4.2 Track Affiliate Code Usage

### TC-SA-13-04-009 — Usage tracking: the tracking (the code, the redemptions, the revenue, the affiliate); the tracking is the visibility
**Type:** Positive
**Covers:** 4.2 → Usage tracking: the tracking (the code, the redemptions, the revenue, the affiliate); Rule: the usage tracking is explicit (the code, the redemptions, the revenue, the affiliate); the tracking is the visibility
**Preconditions:** Affiliate codes have been redeemed.
**Steps:**
1. View the affiliate code usage: the codes (the affiliate codes), the redemptions (the number of redemptions per code), the revenue (the revenue per code), and the affiliates (the affiliate per code).
2. Verify the usage is explicit and visible.
**Expected Result:** The affiliate code usage is tracked — the code, the redemptions, the revenue, and the affiliate are visible.
**Priority:** Critical

### TC-SA-13-04-010 — Usage scope: the scope (the affiliate, the codes); the scope is the tracking
**Type:** Positive
**Covers:** 4.2 → Usage scope: the scope (the affiliate, the codes); Rule: the usage scope is the affiliate and the codes; the scope is the control
**Preconditions:** The affiliate code usage is tracked.
**Steps:**
1. Open the usage scope.
2. Verify the scope is the affiliate and the codes.
3. Verify the scope is the control for the tracking.
**Expected Result:** The usage scope is the affiliate and the codes — the scope is the control.
**Priority:** Medium

### TC-SA-13-04-011 — Redemption tracking: the redemptions (the number of redemptions per code); the redemptions are the metric
**Type:** Positive
**Covers:** 4.2 → Redemption tracking: the redemptions (the number of redemptions per code); Rule: the redemption tracking is the count (the number of redemptions per code); the redemptions are the metric
**Preconditions:** An affiliate code has been redeemed multiple times.
**Steps:**
1. View the redemption tracking for the code.
2. Verify the number of redemptions per code is shown.
3. Verify the redemptions are the metric.
**Expected Result:** The redemption tracking shows the number of redemptions per code — the redemptions are the metric.
**Priority:** High

### TC-SA-13-04-012 — Revenue tracking: the revenue (the revenue per code, per affiliate); the revenue is the metric
**Type:** Positive
**Covers:** 4.2 → Revenue tracking: the revenue (the revenue per code, per affiliate); Rule: the revenue tracking is the value (the revenue per code, per affiliate); the revenue is the metric
**Preconditions:** Affiliate codes have generated revenue.
**Steps:**
1. View the revenue tracking.
2. Verify the revenue per code and per affiliate is shown.
3. Verify the revenue is the metric.
**Expected Result:** The revenue tracking shows the revenue per code and per affiliate — the revenue is the metric.
**Priority:** High

### TC-SA-13-04-013 — Usage view: the view (the usage per code, per affiliate); the usage is visible and the tracking is managed
**Type:** Positive
**Covers:** 4.2 → Usage view: the view (the usage per code, per affiliate); Rule: the usage is visible (the usage per code, per affiliate); the tracking is managed
**Preconditions:** Multiple affiliate codes have usage.
**Steps:**
1. Open the usage view.
2. Verify the usage per code and per affiliate is visible.
3. For a specific affiliate code, view the code's usage (the redemptions, the revenue, the period).
4. Verify the tracking is managed.
**Expected Result:** The usage is visible — the usage per code and per affiliate is shown.
**Priority:** High

### TC-SA-13-04-014 — Usage record: the usage recorded (the affiliate, the code, the redemptions, the revenue); the export is the record
**Type:** Positive
**Covers:** 4.2 → Usage record: the usage recorded (the affiliate, the code, the redemptions, the revenue)
**Preconditions:** Affiliate code usage has been tracked.
**Steps:**
1. Open the usage record.
2. Verify it shows the affiliate, the code, the redemptions, and the revenue.
3. Export the usage (the usage report, the period) and verify the export is the record.
**Expected Result:** The usage is recorded — the affiliate, the code, the redemptions, and the revenue are shown and exportable.
**Priority:** High

### TC-SA-13-04-015 — Usage tracking is audit-logged with the affiliate, code, and timestamp
**Type:** Positive
**Covers:** 4.2 → Audit logging of the usage tracking; Rule: usage tracking is audit-logged with the affiliate, code, and timestamp
**Preconditions:** Affiliate code usage tracking events have occurred.
**Steps:**
1. Open the audit trail and filter by "affiliate code usage".
2. Verify entries show the affiliate, the code, and the timestamp.
**Expected Result:** The usage tracking is audit-logged with the affiliate, code, and timestamp.
**Priority:** Critical
