Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Parkreiner wants to merge7 commits intomain
base:main
Choose a base branch
Loading
frommes/logs-flake

Conversation

Parkreiner
Copy link
Member

@ParkreinerParkreiner commentedMay 23, 2025
edited
Loading

Closescoder/internal#644

Changes made

  • RedefineduseAgentLogs to support dependency injection for how the websocket connection is created
  • Redefined the test suite foruseAgentLogs to work as a set of unit tests
  • Moved our mock websocket logic into a general test helper file
  • Updated the test helper for generating logs so that each log is guaranteed to have a different timestamp

Notes

  • This PR doesn't add any additional test cases, but with the new logic in place, it should be easy to add a lot more
    • If I had more time today, I would've added a test to assert that logs are sorted by timestamp before returning, since websocket messages aren't guaranteed to be in order

@ParkreinerParkreiner self-assigned thisMay 23, 2025
@@ -0,0 +1,135 @@
import type { WebSocketEventType } from "utils/OneWayWebSocket";

export type MockWebSocketPublisher = Readonly<{
Copy link
MemberAuthor

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

Comment on lines +18 to +22
// 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 {
Copy link
MemberAuthor

@ParkreinerParkreinerMay 23, 2025
edited
Loading

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

@ParkreinerParkreiner changed the titlerefactor: update useAgentLogs tests as unit testsrefactor: redefine useAgentLogs tests as unit testsMay 23, 2025
@BrunoQuaresma
Copy link
Collaborator

I have to put more time to review this, but I'm starting to think it adds more complex than value to be honest 🤔

Copy link
Collaborator

@BrunoQuaresmaBrunoQuaresma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Up!

@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelJun 6, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@BrunoQuaresmaBrunoQuaresmaBrunoQuaresma left review comments

At least 1 approving review is required to merge this pull request.

Assignees

@ParkreinerParkreiner

Labels
staleThis issue is like stale bread.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

flake: useAgentLogs
2 participants
@Parkreiner@BrunoQuaresma

[8]ページ先頭

©2009-2025 Movatter.jp