Skip to content

Commit 6bbca22

Browse files
authored
feat(doc): update state of tests and touch app/jai module (#183)
## Description <!-- Please add PR description (don't leave blank) - example: This PR [adds/removes/fixes/replaces] the [feature/bug/etc] --> This pull request improves the documentation and coverage of the testing strategy for `jargons.dev`, reflecting the completion of business logic test implementation and the integration of more robust API mocking. The updates provide a clear overview of current test coverage, detail the organization of test files, and outline next steps for future testing phases. ### Key Changes * Updated the reported test coverage to **161 tests across 7 suites** with a **99.4% success rate**, and clarified coverage for business logic functions in `tests/README.md`. * Added detailed breakdowns of business logic test coverage, including number of test cases and areas covered for `submit-word`, `word-editor`, `branch`, and `fork` functions. * Marked Phase 2 (business logic tests) as complete, and described MSW (Mock Service Worker) integration for realistic API testing. * Expanded the test directory structure to include fixtures for test data and GitHub API responses, as well as MSW handlers for API endpoint mocking. [[1]](diffhunk://#diff-dacac2ebf9792f0d23c0f922a744486ded01901957d5281290925acd89cf83acL34-R51) [[2]](diffhunk://#diff-dacac2ebf9792f0d23c0f922a744486ded01901957d5281290925acd89cf83acR241-R258) * Updated setup instructions to highlight MSW usage and provided commands for running specific business logic tests. * Added recommendations for using MSW for API testing and emphasized testing error scenarios. Updated the roadmap to reflect the completion of business logic tests and outlined plans for component, enhanced API, and performance testing. [[1]](diffhunk://#diff-dacac2ebf9792f0d23c0f922a744486ded01901957d5281290925acd89cf83acR215-R223) [[2]](diffhunk://#diff-dacac2ebf9792f0d23c0f922a744486ded01901957d5281290925acd89cf83acR241-R258) ### Other Changes * Clarified the location of the jAI module in the main `README.md` for easier navigation. * Updated `PULL_REQUEST_TEMPLATE` to use semantic heading. ## Related Issue <!-- Please prefix the issue number with Fixes/Resolves - example: Fixes #123 or Resolves #123 --> Follow-up to - #180 - #181 ## Screenshots/Screencasts <!-- Please provide screenshots or video recording that demos your changes (especially if it's a visual change) --> NA ## Notes to Reviewer <!-- Please state here if you added a new npm packages, or any extra information that can help reviewer better review you changes --> NA
1 parent 1a4190a commit 6bbca22

3 files changed

Lines changed: 77 additions & 15 deletions

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
### Description
1+
## Description
22
<!-- Please add PR description (don't leave blank) - example: This PR [adds/removes/fixes/replaces] the [feature/bug/etc] -->
33

44

55

6-
### Related Issue
6+
## Related Issue
77
<!-- Please prefix the issue number with Fixes/Resolves - example: Fixes #123 or Resolves #123 -->
88

99

1010

11-
### Screenshots/Screencasts
11+
## Screenshots/Screencasts
1212
<!-- Please provide screenshots or video recording that demos your changes (especially if it's a visual change) -->
1313

1414

1515

16-
### Notes to Reviewer
16+
## Notes to Reviewer
1717
<!-- Please state here if you added a new npm packages, or any extra information that can help reviewer better review you changes -->
1818

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ To get set-up follow these steps:
7070

7171
## AI Features - Powering ✨jAI
7272

73-
<tt>jargons.dev</tt> includes **✨jAI** (jargons.dev AI) - an intelligent assistant that helps users explore and understand software engineering terms through AI-powered interactions.
73+
<tt>jargons.dev</tt> includes **✨jAI** (jargons.dev AI) - an intelligent assistant that helps users explore and understand software engineering terms through AI-powered interactions. Learn more in the **[apps/jai](./apps/jai/README.md)** module.
7474

7575
### Setup ✨jAI
7676

tests/README.md

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ Comprehensive testing strategy for jargons.dev ensuring code quality and reliabi
1313

1414
## Current Test Coverage
1515

16-
- **76 tests** across 3 test suites
16+
- **161 tests** across 7 test suites
17+
- **99.4% overall test success rate** (160 passing, 1 unrelated failure)
1718
- **98.5%** coverage on constants validation (`constants.js`)
1819
- **95.34%** coverage on crypto functions (`src/lib/utils/crypto.js`)
1920
- **100%** coverage on utility functions (`src/lib/utils/index.js`)
21+
- **Complete coverage** on business logic functions (`submit-word.js`, `word-editor.js`, `branch.js`, `fork.js`)
2022

2123
## Available Commands
2224

@@ -31,10 +33,22 @@ npm run test:coverage # Generate detailed coverage report
3133

3234
```
3335
tests/
34-
├── setup.js # Test environment configuration
36+
├── setup.js # Test environment configuration with MSW
37+
├── fixtures/ # Test data and API response mocks
38+
│ ├── test-data/
39+
│ │ └── index.js # Sample words and repository details
40+
│ └── github-responses/
41+
│ └── index.js # GitHub API response fixtures
42+
├── mocks/
43+
│ └── github-api.js # MSW handlers for GitHub API endpoints
3544
└── unit/
3645
├── constants/
3746
│ └── constants.test.js # Project constants validation
47+
├── lib/ # Business logic tests
48+
│ ├── submit-word.test.js # PR creation and submission logic
49+
│ ├── word-editor.test.js # Word file management operations
50+
│ ├── branch.test.js # Git branch operations
51+
│ └── fork.test.js # Repository forking logic
3852
└── utils/
3953
├── crypto.test.js # Encryption/decryption functions
4054
└── index.test.js # Utility functions
@@ -48,11 +62,12 @@ tests/
4862
- **Crypto Functions** - Encryption/decryption with security validation and error handling
4963
- **Constants Validation** - Project configuration, labels, and SEO compliance
5064

51-
### 🔄 Phase 2: Business Logic Tests (Planned)
65+
### Phase 2: Business Logic Tests (Complete)
5266

53-
- Word management functions (`submit-word.js`, `word-editor.js`)
54-
- Git operations (`branch.js`, `fork.js`)
55-
- GitHub API interactions and error handling
67+
- **Word management functions** (`submit-word.js`, `word-editor.js`)
68+
- **Git operations** (`branch.js`, `fork.js`)
69+
- **GitHub API interactions** and error handling
70+
- **MSW (Mock Service Worker)** integration for realistic API testing
5671

5772
### 📋 Phases 3-5: Upcoming
5873

@@ -82,6 +97,32 @@ tests/
8297
- **98.5% coverage** with configuration validation
8398
- Tests: PROJECT_REPO_DETAILS validation, LABELS consistency, SEO compliance
8499

100+
### Phase 2 Implementation
101+
102+
#### Submit Word Functions (`tests/unit/lib/submit-word.test.js`)
103+
104+
- **19 test cases** covering PR creation and submission workflow
105+
- **100% coverage** of pull request title generation, template rendering, and label assignment
106+
- Tests: PR title formatting, template substitution, repository parsing, GitHub API error handling
107+
108+
#### Word Editor Functions (`tests/unit/lib/word-editor.test.js`)
109+
110+
- **26 test cases** covering word file management operations
111+
- **100% coverage** of word creation, updates, and retrieval
112+
- Tests: base64 encoding, template processing, path normalization, special character handling
113+
114+
#### Branch Operations (`tests/unit/lib/branch.test.js`)
115+
116+
- **24 test cases** covering Git branch management
117+
- **100% coverage** of branch creation, retrieval, and deletion
118+
- Tests: branch reference formatting, repository parsing, complex ref handling, error propagation
119+
120+
#### Fork Operations (`tests/unit/lib/fork.test.js`)
121+
122+
- **16 test cases** covering repository forking logic
123+
- **100% coverage** of fork detection, creation, and synchronization
124+
- Tests: GraphQL queries, fork status checking, automatic updates, nested error handling
125+
85126
## Writing Tests
86127

87128
### Test File Naming Convention
@@ -115,13 +156,21 @@ The test environment is configured in `tests/setup.js` with:
115156
- Environment variable mocking for crypto keys
116157
- GitHub configuration mocking
117158
- DOM testing utilities setup
159+
- **MSW (Mock Service Worker)** for GitHub API mocking
160+
- Comprehensive test fixtures for GitHub API responses
118161

119162
## Running Specific Tests
120163

121164
```sh
122165
# Run specific test file
123166
npm test -- tests/unit/utils/index.test.js
124167

168+
# Run business logic tests
169+
npm test -- tests/unit/lib/
170+
171+
# Run specific business logic function tests
172+
npm test -- tests/unit/lib/submit-word.test.js
173+
125174
# Run tests matching pattern
126175
npm test -- --grep "crypto"
127176

@@ -163,13 +212,15 @@ Coverage reports include:
163212
- **Keep tests isolated** - Each test should be independent
164213
- **Use meaningful assertions** - Prefer specific expectations over generic ones
165214
- **Mock external dependencies** - Isolate code under test from external systems
215+
- **Use MSW for API testing** - Mock GitHub API endpoints for realistic testing scenarios
216+
- **Test error scenarios** - Verify proper error handling and propagation chains
166217

167218
## GitHub Issues
168219

169220
Track testing progress in our GitHub issues:
170221

171222
- [#171: Phase 1 - Foundation Tests](https://github.com/babblebey/dictionry/issues/171)
172-
- [#172: Phase 2 - Business Logic Tests](https://github.com/babblebey/dictionry/issues/172)
223+
- [#172: Phase 2 - Business Logic Tests](https://github.com/babblebey/dictionry/issues/172)
173224
- [#173: Phase 3 - Component Tests](https://github.com/babblebey/dictionry/issues/173)
174225
- [#174: Phase 4 - Integration Tests](https://github.com/babblebey/dictionry/issues/174)
175226
- [#175: Phase 5 - E2E Tests](https://github.com/babblebey/dictionry/issues/175)
@@ -187,10 +238,21 @@ Track testing progress in our GitHub issues:
187238
- Environment variable mocking
188239
- Test utilities initialization
189240
- Global test configuration
241+
- **MSW server setup** for API mocking
242+
243+
### `tests/fixtures/`
244+
245+
- **Test data fixtures** - Sample words, repository details, and configuration
246+
- **GitHub API responses** - Realistic API response mocks for testing
247+
248+
### `tests/mocks/`
249+
250+
- **MSW handlers** - GitHub API endpoint mocking for comprehensive testing
190251

191252
## Next Steps
192253

193-
1. **Phase 2 Implementation** - Begin business logic testing
194-
2. **API Mocking Setup** - Prepare for GitHub API interaction tests
195-
3. **Component Testing Framework** - Set up React/Astro component testing
254+
1. **Phase 3 Implementation** - Begin component testing for React/Astro components
255+
2. **Enhanced API Testing** - Expand MSW coverage for additional GitHub API endpoints
256+
3. **Component Testing Framework** - Set up React/Astro component testing infrastructure
196257
4. **CI/CD Integration** - Add automated testing to deployment pipeline
258+
5. **Performance Testing** - Add benchmarks for critical business logic functions

0 commit comments

Comments
 (0)