The YDB Capacity Calculator includes a comprehensive browser-based smoke test suite that validates core functionality without requiring any external dependencies or build tools.
- Open
test-runner.htmlin your web browser - Click the "▶ Run All Tests" button
- View the results in real-time
You can open the test runner in several ways:
Option 1: Direct File Access
# macOS
open test-runner.html
# Linux
xdg-open test-runner.html
# Windows
start test-runner.htmlOption 2: Local Web Server
# Using Python 3
python3 -m http.server 8000
# Using Python 2
python -m SimpleHTTPServer 8000
# Using Node.js (if you have http-server installed)
npx http-serverThen navigate to: http://localhost:8000/test-runner.html
Option 3: VS Code Live Server
- Install the "Live Server" extension
- Right-click on
test-runner.html - Select "Open with Live Server"
The smoke test suite covers the following areas:
- Storage server calculations (HDD and NVMe)
- CPU cores server calculations
- RAM server calculations
- Dominant resource identification
- Minimum server count enforcement
- Provided capacity calculations
- Initial mode verification
- Button text updates on mode change
- Positive cores per server validation
- Positive RAM per server validation
- VDisks per PDisk range validation (HDD and NVMe)
- System core reservation (2 cores)
- NVMe core reservation (6 cores per device)
- HDD core reservation (0.5 cores per device)
- System RAM reservation (4 GB)
- NVMe RAM reservation (6 GB per device)
- HDD RAM reservation (2 GB per device)
- Storage group size (9 VDisks)
- Minimum reserve (18 VDisks)
- Reserve percentage (1%)
- Reserve calculation for various cluster sizes
- Zero storage requirements
- Zero compute requirements
- Minimum server count (9 servers)
- Large server counts
- Insufficient resources per server
- Complete servers-needed calculation flow
- Complete resources-provided calculation flow
The test runner displays:
- Total Tests: Number of tests executed
- Passed: Number of successful tests (green)
- Failed: Number of failed tests (red)
- Duration: Total execution time in milliseconds
- ✓ Passed (green): Test completed successfully
- ✗ Failed (red): Test failed with error details
- Running (yellow): Test is currently executing
- Click on a test suite header to expand/collapse test details
- Failed tests show error messages with expected vs. actual values
- Use "Expand/Collapse All" to toggle all suites at once
The test runner includes a lightweight testing framework with the following utilities:
// Basic assertion
assert(condition, message)
// Equality assertion
assertEqual(actual, expected, message)
// Approximate equality (for floating-point comparisons)
assertApproxEqual(actual, expected, tolerance, message)
// Greater than assertion
assertGreaterThan(actual, expected, message)runner.suite('My Test Suite', [
{
name: 'Test description',
fn: () => {
const result = myFunction(input);
assertEqual(result, expectedValue, 'Should return expected value');
}
}
]);To add new tests to the suite:
- Open
test-runner.htmlin a text editor - Locate the test suites section (search for
runner.suite) - Add a new suite or add tests to an existing suite:
runner.suite('New Test Suite', [
{
name: 'New test case',
fn: () => {
// Your test code here
const result = someFunction();
assertEqual(result, expectedValue);
}
}
]);- Save the file and refresh the browser
- Run the tests to verify your new tests work
After making changes to the calculator code:
- Save your changes to
js/calculator.jsorjs/core.js - Refresh the test runner page in your browser
- Click "Run All Tests" to verify nothing broke
- Review any failed tests and fix issues
- Run tests after every significant code change
- Add new tests when adding new features
- Update tests when changing existing functionality
- Keep the test runner open in a separate browser tab during development
Problem: Clicking "Run All Tests" does nothing
Solutions:
- Check browser console for JavaScript errors (F12 → Console)
- Ensure
js/core.jsis loaded correctly - Verify the file path is correct relative to the test runner
Problem: Every test shows as failed
Solutions:
- Verify
js/core.jscontains the calculation functions - Check that functions are properly exported
- Ensure no syntax errors in the core JavaScript files
Problem: One or more specific tests fail
Solutions:
- Read the error message carefully
- Check if the expected values in the test match the business rules
- Verify the calculation logic in
js/core.js - Update test expectations if business rules have changed
The test runner works in all modern browsers:
- Chrome/Edge (recommended)
- Firefox
- Safari
- Opera
Note: Internet Explorer is not supported.
Before committing code changes:
# 1. Make your changes
# 2. Open test-runner.html in browser
# 3. Run all tests
# 4. Verify all tests pass
# 5. Commit your changes
git add .
git commit -m "Your commit message"When reviewing pull requests:
- Check out the branch
- Run the smoke tests
- Verify all tests pass
- Review any new tests added
The test suite is designed to run quickly:
- Typical execution time: 50-200ms
- Number of tests: 32 tests across 7 suites
- No external dependencies: Runs entirely in the browser
The smoke tests focus on:
- ✅ Core calculation logic
- ✅ Business rule validation
- ✅ Edge case handling
- ✅ Integration between components
The smoke tests do NOT cover:
- ❌ UI interactions (clicking buttons, filling forms)
- ❌ Visual appearance and styling
- ❌ Browser-specific behavior
- ❌ Performance under load
- ❌ Network requests or API calls
For comprehensive UI testing, consider using tools like Selenium, Playwright, or Cypress.
Potential improvements to the test suite:
- UI Testing: Add tests that interact with the actual DOM
- localStorage Testing: Verify data persistence
- Visual Regression: Screenshot comparison tests
- Performance Testing: Measure calculation speed
- Accessibility Testing: ARIA and keyboard navigation
- Cross-browser Testing: Automated testing across browsers
If you encounter issues with the test suite:
- Check this documentation first
- Review the browser console for errors
- Verify your changes didn't break the core functions
- Create an issue with:
- Browser and version
- Test failure details
- Steps to reproduce
The smoke test suite provides:
- ✅ Fast feedback on code changes
- ✅ No setup or dependencies required
- ✅ Easy to run and understand
- ✅ Comprehensive coverage of core functionality
- ✅ Clear pass/fail indicators
- ✅ Detailed error messages
Run the tests frequently to catch issues early and maintain code quality!