fix(web): refresh default usage log date range#6251
Conversation
WalkthroughUsage-log query construction was moved to a dedicated module. Shared time-range helpers now preserve explicit boundaries and dynamic defaults, while both log filter bars use the new model for display, updates, reset behavior, and active-filter detection. ChangesUsage-log filtering
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/default/src/features/usage-logs/lib/filter.test.ts`:
- Around line 19-20: Replace the node:test and node:assert/strict imports in
web/default/src/features/usage-logs/lib/filter.test.ts:19-20 with Vitest’s
describe, test, and expect imports. Migrate assert.equal and assert.deepEqual
assertions at lines 42-53 and 65-71 to expect(...).toBe(...) and
expect(...).toEqual(...), and update lines 84-89 to the appropriate Vitest
matcher such as toBeUndefined().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 031a073f-5671-4df7-9b70-53b68a46867a
📒 Files selected for processing (8)
web/default/src/features/usage-logs/api.tsweb/default/src/features/usage-logs/components/common-logs-filter-bar.tsxweb/default/src/features/usage-logs/components/task-logs-filter-bar.tsxweb/default/src/features/usage-logs/lib/filter.test.tsweb/default/src/features/usage-logs/lib/filter.tsweb/default/src/features/usage-logs/lib/index.tsweb/default/src/features/usage-logs/lib/query.tsweb/default/src/features/usage-logs/lib/utils.ts
| import assert from 'node:assert/strict' | ||
| import { describe, test } from 'node:test' |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Use Vitest instead of Node's test runner.
As per coding guidelines, unit tests for utility functions and pure logic must be written with Vitest. The shared root cause here is the use of node:test and node:assert/strict instead of Vitest's describe, test, and expect APIs.
web/default/src/features/usage-logs/lib/filter.test.ts#L19-L20: Replacenode:testandnode:assert/strictimports withimport { describe, test, expect } from 'vitest'.web/default/src/features/usage-logs/lib/filter.test.ts#L42-L53: Rewrite theseassert.equalandassert.deepEqualassertions to use Vitest'sexpect(...).toBe(...)andexpect(...).toEqual(...).web/default/src/features/usage-logs/lib/filter.test.ts#L65-L71: Migrate these assertions to Vitest'sexpectAPI.web/default/src/features/usage-logs/lib/filter.test.ts#L84-L89: Migrate these assertions to Vitest'sexpectAPI (e.g., usingexpect(...).toBeUndefined()).
📍 Affects 1 file
web/default/src/features/usage-logs/lib/filter.test.ts#L19-L20(this comment)web/default/src/features/usage-logs/lib/filter.test.ts#L42-L53web/default/src/features/usage-logs/lib/filter.test.ts#L65-L71web/default/src/features/usage-logs/lib/filter.test.ts#L84-L89
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@web/default/src/features/usage-logs/lib/filter.test.ts` around lines 19 - 20,
Replace the node:test and node:assert/strict imports in
web/default/src/features/usage-logs/lib/filter.test.ts:19-20 with Vitest’s
describe, test, and expect imports. Migrate assert.equal and assert.deepEqual
assertions at lines 42-53 and 65-71 to expect(...).toBe(...) and
expect(...).toEqual(...), and update lines 84-89 to the appropriate Vitest
matcher such as toBeUndefined().
Source: Coding guidelines
Important
📝 变更描述 / Description
(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
(请在此粘贴截图、关键日志或测试报告,以证明变更生效)
Summary by CodeRabbit
Bug Fixes
Tests