-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
feat: adding tests for instagram client #2454
Conversation
📝 WalkthroughWalkthroughThe pull request introduces comprehensive testing for the Instagram client package using Vitest. The changes include adding test suites for environment configuration validation and the Changes
Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
packages/client-instagram/__tests__/environment.test.ts (3)
10-32
: Test description could be more specific.The test case validates configuration but could better describe what makes the configuration "correct".
- it('validates correct Instagram configuration', async () => { + it('validates configuration with all required fields and valid values', async () => {
34-57
: Consider using test fixtures.Reduce duplication by moving the common configuration to a shared fixture.
const baseConfig = { INSTAGRAM_DRY_RUN: false, // ... other common fields }; const configWithBusinessAccount = { ...baseConfig, INSTAGRAM_BUSINESS_ACCOUNT_ID: 'business_123', };
73-73
: Be more specific with error assertions.Consider asserting the exact error message to ensure the right validation is failing.
- await expect(validateInstagramConfig(mockRuntime)).rejects.toThrow(); + await expect(validateInstagramConfig(mockRuntime)).rejects.toThrow(/Invalid username format/);Also applies to: 88-88
packages/client-instagram/__tests__/index.test.ts (2)
49-60
: Consider using type assertion for mock config.Add type safety to the configuration object.
- const mockConfig = { + const mockConfig: Required<InstagramConfig> = {
74-88
: Consider verifying initialization order.Add assertions to ensure services are initialized in the correct order.
expect(vi.mocked(elizaLogger.log).mock.calls).toEqual([ ['Instagram client configuration validated'], ['Instagram client initialized'], ['Instagram post service started'], ['Instagram interaction service started'] ]);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/client-instagram/__tests__/environment.test.ts
(1 hunks)packages/client-instagram/__tests__/index.test.ts
(1 hunks)packages/client-instagram/package.json
(1 hunks)
🔇 Additional comments (2)
packages/client-instagram/__tests__/index.test.ts (1)
8-45
: Well-structured mock setup!Clean and comprehensive mocking of all dependencies.
packages/client-instagram/package.json (1)
30-31
: LGTM!Good addition of Vitest with appropriate version constraint and standard test scripts.
Also applies to: 37-38
Relates to
#2453
Risks
Low: adding tests
Background
What does this PR do?
Adding tests for instagram client
What kind of change is this?
Features/test
Documentation changes needed?
None
Testing
Where should a reviewer start?
packages/client-instagram
Detailed testing steps
pnpm install in root
Navigate to directory
pnpm test