-
Notifications
You must be signed in to change notification settings - Fork 895
refactor: redefine useAgentLogs tests as unit tests #18019
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
@@ -0,0 +1,135 @@ | |||
import type { WebSocketEventType } from "utils/OneWayWebSocket"; | |||
|
|||
export type MockWebSocketPublisher = Readonly<{ |
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.
The entire contents of the file were basically copy-pasted from the other test file. The only change was that the publisher type is now exported and was renamed to be a little more clear
// Make sure that the logs generated each have unique timestamps, so | ||
// that we can test whether they're being sorted properly before being | ||
// returned by the hook | ||
const logDate = new Date(baseDate.getTime() + i * millisecondsInOneMinute); | ||
return { |
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.
Like I said in the PR body, I didn't add a test to assert the sorting functionality yet, but I updated the test helper anyway, so that I can make sure the old/new sets of logs created in the test case are guaranteed to be different, and there's no risk of false positives
I have to put more time to review this, but I'm starting to think it adds more complex than value to be honest 🤔 |
Closes coder/internal#644
Changes made
useAgentLogs
to support dependency injection for how the websocket connection is createduseAgentLogs
to work as a set of unit testsNotes