# 5. Optimization — Test Cases

User Type: **Super Administrator**
Source: *Mi Digital Academy - Education CRM Features Document*
Spec: optimization.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 |
|---------|--------------------|----------|
| 5.1 Database Query Optimization | Optimization | TC-SA-24-05-001 |
| 5.1 Database Query Optimization | Query | TC-SA-24-05-002 |
| 5.1 Database Query Optimization | Time | TC-SA-24-05-003 |
| 5.1 Database Query Optimization | Optimization status | TC-SA-24-05-004 |
| 5.1 Database Query Optimization | Optimization count | TC-SA-24-05-005 |
| 5.1 Database Query Optimization | Optimization period | TC-SA-24-05-006 |
| 5.1 Database Query Optimization | Optimization view | TC-SA-24-05-007 |
| 5.1 Database Query Optimization | Audit logging of the database query optimization | TC-SA-24-05-008 |
| 5.1 Database Query Optimization | Rule: the optimization is the improvement/tuning | TC-SA-24-05-001 |
| 5.1 Database Query Optimization | Rule: the query is the request/operation | TC-SA-24-05-002 |
| 5.1 Database Query Optimization | Rule: the time is the duration/length | TC-SA-24-05-003 |
| 5.1 Database Query Optimization | Rule: the optimization status is the state/control | TC-SA-24-05-004 |
| 5.1 Database Query Optimization | Rule: the queries are fast — optimization is managed | TC-SA-24-05-007 |
| 5.1 Database Query Optimization | Rule: audit-logged with optimization, query, and timestamp | TC-SA-24-05-008 |
| 5.2 Page Load Speed Optimization | Optimization | TC-SA-24-05-009 |
| 5.2 Page Load Speed Optimization | Page | TC-SA-24-05-010 |
| 5.2 Page Load Speed Optimization | Time | TC-SA-24-05-011 |
| 5.2 Page Load Speed Optimization | Optimization status | TC-SA-24-05-012 |
| 5.2 Page Load Speed Optimization | Optimization count | TC-SA-24-05-013 |
| 5.2 Page Load Speed Optimization | Optimization period | TC-SA-24-05-014 |
| 5.2 Page Load Speed Optimization | Optimization view | TC-SA-24-05-015 |
| 5.2 Page Load Speed Optimization | Audit logging of the page load speed optimization | TC-SA-24-05-016 |
| 5.2 Page Load Speed Optimization | Rule: the optimization is the improvement/tuning | TC-SA-24-05-009 |
| 5.2 Page Load Speed Optimization | Rule: the page is the screen/view | TC-SA-24-05-010 |
| 5.2 Page Load Speed Optimization | Rule: the time is the duration/length | TC-SA-24-05-011 |
| 5.2 Page Load Speed Optimization | Rule: the optimization status is the state/control | TC-SA-24-05-012 |
| 5.2 Page Load Speed Optimization | Rule: the pages load fast — optimization is managed | TC-SA-24-05-015 |
| 5.2 Page Load Speed Optimization | Rule: audit-logged with optimization, page, and timestamp | TC-SA-24-05-016 |
| 5.3 Caching Management | Cache | TC-SA-24-05-017 |
| 5.3 Caching Management | Content | TC-SA-24-05-018 |
| 5.3 Caching Management | Expiry | TC-SA-24-05-019 |
| 5.3 Caching Management | Cache status | TC-SA-24-05-020 |
| 5.3 Caching Management | Cache count | TC-SA-24-05-021 |
| 5.3 Caching Management | Cache view | TC-SA-24-05-022 |
| 5.3 Caching Management | Cache export | TC-SA-24-05-023 |
| 5.3 Caching Management | Audit logging of the caching management | TC-SA-24-05-024 |
| 5.3 Caching Management | Rule: the cache is the store/copy | TC-SA-24-05-017 |
| 5.3 Caching Management | Rule: the content is the asset/subject | TC-SA-24-05-018 |
| 5.3 Caching Management | Rule: the expiry is the limit/end | TC-SA-24-05-019 |
| 5.3 Caching Management | Rule: the cache status is the state/control | TC-SA-24-05-020 |
| 5.3 Caching Management | Rule: the content is cached — management is managed | TC-SA-24-05-022 |
| 5.3 Caching Management | Rule: audit-logged with cache, expiry, and timestamp | TC-SA-24-05-024 |
| 5.4 Progressive Web App (PWA) Capabilities | Capability | TC-SA-24-05-025 |
| 5.4 Progressive Web App (PWA) Capabilities | Feature | TC-SA-24-05-026 |
| 5.4 Progressive Web App (PWA) Capabilities | State | TC-SA-24-05-027 |
| 5.4 Progressive Web App (PWA) Capabilities | Capability status | TC-SA-24-05-028 |
| 5.4 Progressive Web App (PWA) Capabilities | Capability count | TC-SA-24-05-029 |
| 5.4 Progressive Web App (PWA) Capabilities | Capability view | TC-SA-24-05-030 |
| 5.4 Progressive Web App (PWA) Capabilities | Capability export | TC-SA-24-05-031 |
| 5.4 Progressive Web App (PWA) Capabilities | Audit logging of the PWA capability configuration | TC-SA-24-05-032 |
| 5.4 Progressive Web App (PWA) Capabilities | Rule: the capability is the readiness/preparedness | TC-SA-24-05-025 |
| 5.4 Progressive Web App (PWA) Capabilities | Rule: the feature is the function/ability | TC-SA-24-05-026 |
| 5.4 Progressive Web App (PWA) Capabilities | Rule: the state is the condition/phase | TC-SA-24-05-027 |
| 5.4 Progressive Web App (PWA) Capabilities | Rule: the capability status is the state/control | TC-SA-24-05-028 |
| 5.4 Progressive Web App (PWA) Capabilities | Rule: the platform works offline — capability is managed | TC-SA-24-05-030 |
| 5.4 Progressive Web App (PWA) Capabilities | Rule: audit-logged with capability, feature, and timestamp | TC-SA-24-05-032 |

---

## 5.1 Database Query Optimization

### TC-SA-24-05-001 — Database queries are optimized with optimization, query, time, and date
**Type:** Positive
**Covers:** 5.1 → Optimization; Rule: the optimization is the improvement/tuning
**Preconditions:** Super Admin logged in; slow database queries exist that can be optimized
**Steps:**
1. Open the Database Query Optimization view
2. Select a slow query and apply the optimization
3. Verify the query time improves after the optimization
**Expected Result:** The optimization of the queries (optimization, query, time, date) is done and the query time improves; the optimization is the improvement/tuning of the query
**Priority:** Critical

### TC-SA-24-05-002 — A specific query can be selected and optimized
**Type:** Positive
**Covers:** 5.1 → Query; Rule: the query is the request/operation
**Preconditions:** Super Admin logged in; multiple database queries exist
**Steps:**
1. Open the Database Query Optimization view
2. Select a specific query
3. Verify the query details (type, date) and its time data are shown
**Expected Result:** The selected query (the request of the database, with its type and date) is shown with its time data; the query is the operation being optimized
**Priority:** High

### TC-SA-24-05-003 — Query time is displayed as the correct duration before and after optimization
**Type:** Positive
**Covers:** 5.1 → Time; Rule: the time is the duration/length
**Preconditions:** Super Admin logged in; a query has been optimized
**Steps:**
1. Open the Database Query Optimization view
2. View the time of the query before optimization
3. View the time of the query after optimization and verify both durations are exact
**Expected Result:** The time of the query is displayed as the exact duration before and after the optimization; the time is the length of the query and both values match the independently measured durations
**Priority:** High

### TC-SA-24-05-004 — Optimization status is shown as optimized or pending
**Type:** Edge
**Covers:** 5.1 → Optimization status; Rule: the optimization status is the state/control
**Preconditions:** Super Admin logged in; queries exist in both optimized and pending states
**Steps:**
1. View a query that has been optimized and verify its status
2. View a query that is awaiting optimization and verify its status
3. Verify the status always matches the actual optimization state
**Expected Result:** The optimization status is displayed as optimized or pending and always matches the actual state; a pending query is never shown as optimized; the status is the state/control
**Priority:** High

### TC-SA-24-05-005 — Optimization count is accurate
**Type:** Positive
**Covers:** 5.1 → Optimization count
**Preconditions:** Super Admin logged in; multiple optimizations have occurred
**Steps:**
1. Open the Database Query Optimization view
2. View the optimization count (count of the optimizations)
3. Manually count the optimizations and compare
**Expected Result:** The optimization count shows the exact count of the optimizations; the count is the measure and matches the actual optimizations
**Priority:** High

### TC-SA-24-05-006 — Optimization period can be set to daily, weekly, or monthly
**Type:** Positive
**Covers:** 5.1 → Optimization period
**Preconditions:** Super Admin logged in; optimization history exists across multiple periods
**Steps:**
1. Open the Database Query Optimization view
2. Set the optimization period to daily, then weekly, then monthly
3. Verify the displayed optimization data matches the selected period
**Expected Result:** The period of the optimization (daily, weekly, monthly) can be set and the optimization data shown matches the selected period; the period is the scope of the watch
**Priority:** High

### TC-SA-24-05-007 — Optimization view shows optimizations, queries, times, and dates
**Type:** Positive
**Covers:** 5.1 → Optimization view; Rule: the queries are fast — optimization is managed
**Preconditions:** Super Admin logged in; optimization data exists
**Steps:**
1. Open the optimization view
2. Verify the view lists the optimizations, the queries, the times, and the dates
3. Verify the queries are visible and the improvement is complete
**Expected Result:** The optimization view displays the optimizations, the queries, the times, and the dates; the queries are fast and the optimization is managed
**Priority:** Medium

### TC-SA-24-05-008 — Database query optimization is audit-logged
**Type:** Positive
**Covers:** 5.1 → Audit logging of the database query optimization; Rule: audit-logged with optimization, query, and timestamp
**Preconditions:** Super Admin logged in; audit log accessible
**Steps:**
1. Perform a database query optimization action (optimize a query)
2. Open the audit log
3. Verify an entry exists with the optimization, the query, and the timestamp
**Expected Result:** The database query optimization is audit-logged with the optimization, the query, and the timestamp
**Priority:** Critical

## 5.2 Page Load Speed Optimization

### TC-SA-24-05-009 — Page load speed is optimized with optimization, page, time, and date
**Type:** Positive
**Covers:** 5.2 → Optimization; Rule: the optimization is the improvement/tuning
**Preconditions:** Super Admin logged in; slow pages exist that can be optimized
**Steps:**
1. Open the Page Load Speed Optimization view
2. Select a slow page and apply the optimization
3. Verify the page load time improves after the optimization
**Expected Result:** The optimization of the pages (optimization, page, time, date) is done and the page load time improves; the optimization is the improvement/tuning of the page
**Priority:** Critical

### TC-SA-24-05-010 — A specific page can be selected and optimized
**Type:** Positive
**Covers:** 5.2 → Page; Rule: the page is the screen/view
**Preconditions:** Super Admin logged in; multiple platform pages exist
**Steps:**
1. Open the Page Load Speed Optimization view
2. Select a specific page
3. Verify the page details (name, date) and its load time data are shown
**Expected Result:** The selected page (the screen of the platform, with its name and date) is shown with its load time data; the page is the view being optimized
**Priority:** High

### TC-SA-24-05-011 — Load time is displayed as the correct duration before and after optimization
**Type:** Positive
**Covers:** 5.2 → Time; Rule: the time is the duration/length
**Preconditions:** Super Admin logged in; a page has been optimized
**Steps:**
1. Open the Page Load Speed Optimization view
2. View the time of the load before optimization
3. View the time of the load after optimization and verify both durations are exact
**Expected Result:** The time of the load is displayed as the exact duration before and after the optimization; the time is the length of the load and both values match the independently measured durations
**Priority:** High

### TC-SA-24-05-012 — Optimization status is shown as optimized or pending
**Type:** Edge
**Covers:** 5.2 → Optimization status; Rule: the optimization status is the state/control
**Preconditions:** Super Admin logged in; pages exist in both optimized and pending states
**Steps:**
1. View a page that has been optimized and verify its status
2. View a page that is awaiting optimization and verify its status
3. Verify the status always matches the actual optimization state
**Expected Result:** The optimization status is displayed as optimized or pending and always matches the actual state; a pending page is never shown as optimized; the status is the state/control
**Priority:** High

### TC-SA-24-05-013 — Optimization count is accurate
**Type:** Positive
**Covers:** 5.2 → Optimization count
**Preconditions:** Super Admin logged in; multiple optimizations have occurred
**Steps:**
1. Open the Page Load Speed Optimization view
2. View the optimization count (count of the optimizations)
3. Manually count the optimizations and compare
**Expected Result:** The optimization count shows the exact count of the optimizations; the count is the measure and matches the actual optimizations
**Priority:** High

### TC-SA-24-05-014 — Optimization period can be set to daily, weekly, or monthly
**Type:** Positive
**Covers:** 5.2 → Optimization period
**Preconditions:** Super Admin logged in; optimization history exists across multiple periods
**Steps:**
1. Open the Page Load Speed Optimization view
2. Set the optimization period to daily, then weekly, then monthly
3. Verify the displayed optimization data matches the selected period
**Expected Result:** The period of the optimization (daily, weekly, monthly) can be set and the optimization data shown matches the selected period; the period is the scope of the watch
**Priority:** High

### TC-SA-24-05-015 — Optimization view shows optimizations, pages, times, and dates
**Type:** Positive
**Covers:** 5.2 → Optimization view; Rule: the pages load fast — optimization is managed
**Preconditions:** Super Admin logged in; optimization data exists
**Steps:**
1. Open the optimization view
2. Verify the view lists the optimizations, the pages, the times, and the dates
3. Verify the pages are visible and the improvement is complete
**Expected Result:** The optimization view displays the optimizations, the pages, the times, and the dates; the pages load fast and the optimization is managed
**Priority:** Medium

### TC-SA-24-05-016 — Page load speed optimization is audit-logged
**Type:** Positive
**Covers:** 5.2 → Audit logging of the page load speed optimization; Rule: audit-logged with optimization, page, and timestamp
**Preconditions:** Super Admin logged in; audit log accessible
**Steps:**
1. Perform a page load speed optimization action (optimize a page)
2. Open the audit log
3. Verify an entry exists with the optimization, the page, and the timestamp
**Expected Result:** The page load speed optimization is audit-logged with the optimization, the page, and the timestamp
**Priority:** Critical

## 5.3 Caching Management

### TC-SA-24-05-017 — Caching is managed with cache, content, expiry, and date
**Type:** Positive
**Covers:** 5.3 → Cache; Rule: the cache is the store/copy
**Preconditions:** Super Admin logged in; content exists and caching is enabled
**Steps:**
1. Open the Caching Management view
2. Observe the cache entries (cache, content, expiry, date)
3. Verify the cache holds copies of the platform content
**Expected Result:** The cache of the platform is managed and displayed with the cache, the content, the expiry, and the date; the cache is the store/copy of the content
**Priority:** Critical

### TC-SA-24-05-018 — A specific content item can be selected and its cache inspected
**Type:** Positive
**Covers:** 5.3 → Content; Rule: the content is the asset/subject
**Preconditions:** Super Admin logged in; multiple content types exist in the cache
**Steps:**
1. Open the Caching Management view
2. Select a specific content item
3. Verify the content details (type, date) and its cache data are shown
**Expected Result:** The selected content (the content of the platform, with its type and date) is shown with its cache data; the content is the asset/subject being cached
**Priority:** High

### TC-SA-24-05-019 — Cache expiry can be set and is enforced exactly
**Type:** Edge
**Covers:** 5.3 → Expiry; Rule: the expiry is the limit/end
**Preconditions:** Super Admin logged in; a cache entry exists with a configurable expiry
**Steps:**
1. Set the expiry of the cache (time, date) for a content item
2. Verify the cache entry is still cached just before the expiry time
3. Verify the cache entry is expired exactly at/after the expiry time
**Expected Result:** The expiry of the cache (time, date) can be set and is enforced exactly; the cache is valid before the expiry and expired at/after it with no early expiry and no stale retention; the expiry is the limit/end
**Priority:** High

### TC-SA-24-05-020 — Cache status is shown as cached, expired, or cleared
**Type:** Positive
**Covers:** 5.3 → Cache status; Rule: the cache status is the state/control
**Preconditions:** Super Admin logged in; cache entries exist in cached, expired, and cleared states
**Steps:**
1. View a cached entry and verify its status
2. View an expired entry and verify its status
3. Clear an entry and verify its status
**Expected Result:** The cache status is displayed as cached, expired, or cleared and always matches the actual state; the status is the state/control
**Priority:** High

### TC-SA-24-05-021 — Cache count is accurate
**Type:** Positive
**Covers:** 5.3 → Cache count
**Preconditions:** Super Admin logged in; multiple cache entries exist
**Steps:**
1. Open the Caching Management view
2. View the cache count (count of the caches)
3. Manually count the cache entries and compare
**Expected Result:** The cache count shows the exact count of the caches; the count is the measure and matches the actual cache entries
**Priority:** High

### TC-SA-24-05-022 — Cache view shows caches, content, expiries, and dates
**Type:** Positive
**Covers:** 5.3 → Cache view; Rule: the content is cached — management is managed
**Preconditions:** Super Admin logged in; cache data exists
**Steps:**
1. Open the cache view
2. Verify the view lists the caches, the content, the expiries, and the dates
3. Verify the content is visible and the control is complete
**Expected Result:** The cache view displays the caches, the content, the expiries, and the dates; the content is cached and the management is managed
**Priority:** Medium

### TC-SA-24-05-023 — Cache export works, including a zero-row selection
**Type:** Edge
**Covers:** 5.3 → Cache export
**Preconditions:** Super Admin logged in; a content type with cache entries and a content type with no cache entries exist
**Steps:**
1. Export the caches for a content type with entries and verify the file contents
2. Export the caches for a content type with no entries
3. Verify the zero-row export completes without error
**Expected Result:** The export of the caches (caches, format, content) produces a valid file matching the selected format and content; the zero-row export completes cleanly with an empty-but-valid file and no error
**Priority:** Medium

### TC-SA-24-05-024 — Caching management is audit-logged
**Type:** Positive
**Covers:** 5.3 → Audit logging of the caching management; Rule: audit-logged with cache, expiry, and timestamp
**Preconditions:** Super Admin logged in; audit log accessible
**Steps:**
1. Perform a caching management action (set an expiry / clear a cache)
2. Open the audit log
3. Verify an entry exists with the cache, the expiry, and the timestamp
**Expected Result:** The caching management is audit-logged with the cache, the expiry, and the timestamp
**Priority:** Critical

## 5.4 Progressive Web App (PWA) Capabilities

### TC-SA-24-05-025 — PWA capabilities are provided with capability, feature, state, and date
**Type:** Positive
**Covers:** 5.4 → Capability; Rule: the capability is the readiness/preparedness
**Preconditions:** Super Admin logged in; PWA capabilities are configured
**Steps:**
1. Open the PWA Capabilities view
2. Observe the capability entries (capability, feature, state, date)
3. Verify the platform works offline for the provided capabilities
**Expected Result:** The capability of the PWA is provided with the capability, the feature, the state, and the date; the capability is the readiness/preparedness of the platform and the platform works offline
**Priority:** Critical

### TC-SA-24-05-026 — A specific PWA feature can be selected and inspected
**Type:** Positive
**Covers:** 5.4 → Feature; Rule: the feature is the function/ability
**Preconditions:** Super Admin logged in; multiple PWA features exist
**Steps:**
1. Open the PWA Capabilities view
2. Select a specific feature
3. Verify the feature details (name, date) and its state are shown
**Expected Result:** The selected feature (the feature of the PWA, with its name and date) is shown with its state; the feature is the function/ability being provided
**Priority:** High

### TC-SA-24-05-027 — Feature state is displayed as enabled or disabled
**Type:** Positive
**Covers:** 5.4 → State; Rule: the state is the condition/phase
**Preconditions:** Super Admin logged in; PWA features exist in both enabled and disabled states
**Steps:**
1. Open the PWA Capabilities view
2. View the state of an enabled feature and a disabled feature
3. Verify the states are shown as enabled or disabled
**Expected Result:** The state of the feature is displayed as enabled or disabled and always matches the actual configuration; the state is the condition/phase of the feature
**Priority:** High

### TC-SA-24-05-028 — Capability status is shown as ready or not-ready
**Type:** Edge
**Covers:** 5.4 → Capability status; Rule: the capability status is the state/control
**Preconditions:** Super Admin logged in; PWA capabilities exist in ready and not-ready states
**Steps:**
1. View a capability that is fully configured and verify its status
2. View a capability with a missing dependency and verify its status
3. Verify the status always matches the actual readiness
**Expected Result:** The capability status is displayed as ready or not-ready and always matches the actual readiness; a capability with a missing dependency is never shown as ready; the status is the state/control
**Priority:** High

### TC-SA-24-05-029 — Capability count is accurate
**Type:** Positive
**Covers:** 5.4 → Capability count
**Preconditions:** Super Admin logged in; multiple PWA capabilities exist
**Steps:**
1. Open the PWA Capabilities view
2. View the capability count (count of the capabilities)
3. Manually count the capabilities and compare
**Expected Result:** The capability count shows the exact count of the capabilities; the count is the measure and matches the actual capabilities
**Priority:** High

### TC-SA-24-05-030 — Capability view shows capabilities, features, states, and dates
**Type:** Positive
**Covers:** 5.4 → Capability view; Rule: the platform works offline — capability is managed
**Preconditions:** Super Admin logged in; capability data exists
**Steps:**
1. Open the capability view
2. Verify the view lists the capabilities, the features, the states, and the dates
3. Verify the offline readiness is visible and the readiness is complete
**Expected Result:** The capability view displays the capabilities, the features, the states, and the dates; the platform works offline and the capability is managed
**Priority:** Medium

### TC-SA-24-05-031 — Capability export works, including a zero-row selection
**Type:** Edge
**Covers:** 5.4 → Capability export
**Preconditions:** Super Admin logged in; a feature with capabilities and a feature with no capabilities exist
**Steps:**
1. Export the capabilities for a feature with capabilities and verify the file contents
2. Export the capabilities for a feature with no capabilities
3. Verify the zero-row export completes without error
**Expected Result:** The export of the capabilities (capabilities, format, feature) produces a valid file matching the selected format and feature; the zero-row export completes cleanly with an empty-but-valid file and no error
**Priority:** Medium

### TC-SA-24-05-032 — PWA capability configuration is audit-logged
**Type:** Positive
**Covers:** 5.4 → Audit logging of the PWA capability configuration; Rule: audit-logged with capability, feature, and timestamp
**Preconditions:** Super Admin logged in; audit log accessible
**Steps:**
1. Perform a PWA capability configuration action (enable/disable a feature)
2. Open the audit log
3. Verify an entry exists with the capability, the feature, and the timestamp
**Expected Result:** The PWA capability configuration is audit-logged with the capability, the feature, and the timestamp
**Priority:** Critical
