-
Notifications
You must be signed in to change notification settings - Fork 3
fix: resolve failing tests in gh-desktop-release-notification and gh-core-tag-notification #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…core-tag-notification This commit fixes test failures that occurred due to MongoDB connection attempts during test execution. The root cause was that the database module was being imported and initialized (with top-level await) before test mocks could be applied. Changes made: 1. **Test Mocking Strategy**: Converted from jest.mock() to Bun's mock.module() with dynamic imports, ensuring mocks are set up before modules are loaded. 2. **Test Files Updated**: - app/tasks/gh-desktop-release-notification/index.spec.ts - app/tasks/gh-core-tag-notification/index.spec.ts 3. **Mock Implementation**: Replaced Jest-style mocks with Bun-native mocking patterns using tracking arrays to monitor function calls. 4. **Test Fixes**: Corrected expected text formats to match actual implementation (repo name format: "Comfy-Org/desktop" vs "desktop"). 5. **Environment Setup**: Added MONGODB_URI to test setup to prevent connection attempts to production databases during tests. All 16 tests now pass successfully without attempting MongoDB connections. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ease-notification Replace verbose manual mock reassignment in beforeEach with a cleaner factory pattern: - Introduce createMockState() factory function to generate fresh state - Use createMockCollection() that references mockState via closure - Replace imperative mock reassignment with declarative state reset - Support per-test customization via findOneImpl/findOneAndUpdateImpl - Reduce boilerplate and improve readability Benefits: - Less verbose: no need to reassign mock functions in beforeEach - More functional: state creation is pure and predictable - More flexible: easy per-test customization without mutation - Better maintainability: cleaner separation of concerns 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…tification Apply the same factory pattern improvements as gh-desktop-release-notification: - Introduce createMockState() factory for fresh test state - Use createMockCollection() with closure over mockState - Replace imperative reassignments with declarative state reset - Support per-test customization via findOneImpl/findOneAndUpdateImpl - Simplify beforeEach by removing manual mock function reassignments This brings consistency across the codebase and improves test maintainability. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add pull_request trigger to test workflow so tests run on PRs targeting main branch. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
Summary
This PR fixes test failures in GitHub Actions CI and improves test code quality with a cleaner mocking pattern.
Root Cause
The tests were failing because:
src/db/index.ts) uses top-levelawaitto initialize MongoDB connectionjest.mock()) were not being applied before module imports in Bun's test runnerChanges Made
Test Infrastructure (Initial Fix)
jest.mock()withmock.module()frombun:testawait import()to ensure mocks are set up before modules are loadedsrc/test/msw-setup.tsto prevent production database connectionsCode Quality Improvements (Refactoring)
createMockState()factory function for fresh test statecreateMockCollection()that referencesmockStatevia closurebeforeEachfindOneImplandfindOneAndUpdateImplfor easy test-specific behaviorFiles Modified
app/tasks/gh-desktop-release-notification/index.spec.ts- Converted to Bun-native mocking + factory patternapp/tasks/gh-core-tag-notification/index.spec.ts- Converted to Bun-native mocking + factory patternsrc/test/msw-setup.ts- Added MONGODB_URI environment variable for testsTest Corrections
Test Results
✅ All 16 tests now pass:
```
16 pass
0 fail
23 expect() calls
Ran 16 tests across 2 files. [237.00ms]
```
Benefits of Refactoring
Related Issue
Fixes failing tests from: https://github.com/Comfy-Org/Comfy-PR/actions/runs/19085256036/job/54523916169
🤖 Generated with Claude Code