Fix test expectation for fs.readFile call count in agent-service.test.ts#92
Conversation
The test "should reuse existing session if already started" expected fs.readFile to be called 1 time, but startConversation calls it 2 times on first call (loadSession + loadMetadata). The second call correctly reuses the in-memory session. Co-authored-by: GTheMachine <156854865+GTheMachine@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a failing test by correcting the expected call count for fs.readFile in the "should reuse existing session if already started" test case. The test was previously expecting 1 call but actually receives 2 calls because startConversation invokes both loadSession() and loadMetadata() on its first invocation.
- Updated the assertion from
toHaveBeenCalledTimes(1)totoHaveBeenCalledTimes(2)to reflect actual behavior - Added explanatory comment to clarify why 2 calls are expected
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // First call reads session file and metadata file (2 calls) | ||
| // Second call should reuse in-memory session (no additional calls) |
There was a problem hiding this comment.
The comment is slightly ambiguous. Consider clarifying that "First call" refers to the first invocation of startConversation (not the first readFile call). For example: "First startConversation invocation reads session file and metadata file (2 calls). Second invocation should reuse in-memory session (no additional calls)"
| // First call reads session file and metadata file (2 calls) | |
| // Second call should reuse in-memory session (no additional calls) | |
| // First startConversation invocation reads session file and metadata file (2 calls) | |
| // Second startConversation invocation should reuse in-memory session (no additional calls) |
The test "should reuse existing session if already started" expected
fs.readFileto be called once, butstartConversationactually calls it twice on first invocation: once forloadSession()and once forloadMetadata().Changes
toHaveBeenCalledTimes(1)totoHaveBeenCalledTimes(2)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.