This guide covers testing procedures for CacheFriendlyMemory, including automated tests and manual testing checklists.
# Install dependencies (first time only)
npm install
# Run all tests (watch mode)
npm test
# Run all tests once (recommended for CI)
npm test -- --run
# Run tests with UI
npm run test:ui
# Run tests with coverage report
npm run test:coverage -- --run
# Run linter to check for import errors
npm run linttests/unit/- Pure function unit tests (fast, no dependencies)tests/integration/- Workflow integration tests (slower, test complete flows)tests/fixtures/- Mock objects and test datatests/setup.js- Global test configuration
- Open SillyTavern and navigate to Extensions → CacheFriendlyMemory
- Ensure "Show Progress Bar" is enabled in settings
- Click the "Compact Now" button
- Verify: Toast notification appears with spinner icon and "Compacting: 0/X batches (0%)" text
- Verify: Toast updates after each batch is processed (e.g., "Compacting: 1/3 batches (33%)")
- Verify: Settings panel shows inline progress if the panel is open
- Verify: Progress disappears when compaction completes
- Verify: Success message appears (if configured)
- Open a chat with enough messages for compaction (120+ recommended)
- Type
/cfm-compactin the chat input - Verify: Toast notification appears immediately
- Verify: Progress updates as batches are compressed
- Verify: Progress disappears when compaction completes
- Verify: Response message appears in chat with compaction results
- Ensure "Auto Compact" is enabled
- Set "Compact Threshold" to a low value (e.g., 5) to trigger easily
- Send a character message to push message count over threshold
- Verify: Toast notification appears automatically
- Verify: Progress updates during auto-compaction
- Verify: Progress disappears when complete
- Verify: Chat continues normally after compaction
-
With Show Progress Bar = true:
- Open settings panel before triggering compaction
- Trigger compaction
- Verify: Inline progress shows in settings panel (current/total batches, percentage)
- Verify: Toast notification also appears
-
With Show Progress Bar = false:
- Set "Show Progress Bar" to false in settings
- Trigger compaction
- Verify: Toast notification appears
- Verify: No inline progress in settings panel
- Verify: Settings panel status text is not affected
-
With Settings Panel Closed:
- Close the CacheFriendlyMemory settings panel
- Trigger compaction
- Verify: Toast notification appears
- Verify: Compaction completes successfully
- Verify: No errors occur from missing DOM elements
-
API Error During Compaction:
- Configure a connection profile with invalid credentials or unreachable API
- Trigger compaction
- Verify: Toast notification appears at start
- Verify: Progress indicator disappears when error occurs
- Verify: Error message is displayed to user
- Verify: Console shows error with context (in debug mode)
- Verify: Extension continues to function after error
-
Network Timeout:
- Configure very short timeout in API settings (if available)
- Trigger compaction on a large chat
- Verify: Progress indicator is cleaned up on timeout
- Verify: User receives timeout notification
-
With Debug Mode = true:
- Enable "Debug Mode" in settings
- Open browser console (F12)
- Trigger compaction
- Verify: Console shows
[CacheFriendlyMemory] DEBUG - Starting compaction progress: totalBatches=N - Verify: Console shows
[CacheFriendlyMemory] DEBUG - Compaction progress: X/Y batches (Z%)for each update - Verify: Console shows
[CacheFriendlyMemory] DEBUG - Compaction progress completed: compacted N messages
-
With Debug Mode = false:
- Disable "Debug Mode" in settings
- Open browser console
- Trigger compaction
- Verify: No DEBUG messages appear in console
- Verify: Regular log messages (if any) appear
-
Compaction Speed:
- Time compaction with progress UI enabled
- Time compaction with progress UI disabled (if possible)
- Verify: No significant performance impact from progress updates
-
Large Chat Compaction:
- Test with a chat with 500+ messages
- Trigger compaction
- Verify: Progress updates smoothly
- Verify: No UI lag or freezing
- Verify: Browser remains responsive
-
Empty Chat:
- Trigger compaction on new chat with few messages
- Verify: No progress indicator appears
- Verify: "Nothing to compact" message appears (if configured)
-
Already Compacted:
- Trigger compaction on a chat that was just compacted
- Verify: No progress indicator appears
- Verify: "Already compacted" or similar message appears
-
Rapid Compaction Triggers:
- Click "Compact Now" button multiple times rapidly
- Verify: Only one compaction runs at a time
- Verify: Progress indicators don't overlap or duplicate
- Install extension in
public/scripts/extensions/third-party/CacheFriendlyMemory/ - Reload SillyTavern
- Verify: Extension appears in Extensions menu
- Verify: Extension is enabled by default (or can be enabled)
- Verify: Settings panel opens correctly
- Verify: No console errors on load
- Change various settings (thresholds, chunk sizes, etc.)
- Reload SillyTavern
- Verify: Settings are preserved
- Verify: Settings display correctly in UI
- Compact a chat
- Save the chat
- Load the chat in a new session
- Verify: Compaction metadata is preserved
- Verify: Stats show correct values
- Verify: Messages have correct compression level flags
-
/cfm-compact:- Verify: Compacts chat
- Verify: Shows progress (v0.4.0+)
- Verify: Returns summary of compaction
-
/cfm-status:- Verify: Shows current stats
- Verify: Displays message counts by level
-
/cfm-export:- Verify: Exports data to JSON
- Verify: JSON is valid and complete
- Open CacheFriendlyMemory settings
- Enable "Debug Mode" checkbox
- Open browser console (F12)
- All operations will log verbose messages prefixed with
[CacheFriendlyMemory]
-
No progress indicator appears:
- Check if compaction is actually running (check debug logs)
- Verify "Show Progress Bar" setting if expecting inline progress
- Check console for JavaScript errors
-
Progress indicator doesn't disappear:
- Check if compaction completed successfully (check debug logs)
- Reload page if UI stuck
- Check console for errors in progress.js
-
Compaction is slow:
- Verify connection profile is correctly configured
- Check API response times in debug logs
- Reduce chunk sizes if needed
When reporting bugs, include:
- SillyTavern version
- CacheFriendlyMemory version (check CHANGELOG.md or manifest.json)
- Browser and version
- Steps to reproduce
- Expected behavior
- Actual behavior
- Console output (with debug mode enabled)
- Settings configuration (export from extension settings)