chore(entities): Layer 1 unit tests for @agenta/entities molecules#4339
chore(entities): Layer 1 unit tests for @agenta/entities molecules#4339bekossy wants to merge 5 commits into
Conversation
…ion functions - Implement unit tests for createEntityDraftState in draft-state.test.ts, covering initial state, updates, draft clearing, and custom isDirty functionality. - Add tests for loadable store functionality in loadable-store.test.ts, including default state, mode switching, connected source updates, and instance isolation. - Create tests for normalizeValueForComparison in normalize.test.ts, ensuring correct handling of various data types and structures. - Configure Vitest to output test results in JUnit format and set up coverage reporting in vitest.config.ts. - Generate initial JUnit test results file for CI integration.
…et molecule - Implemented unit tests for revision table state atoms and reducers, covering initial state, column and row operations, and pending changes. - Created unit tests for testcase molecule, validating molecule shape, ID tracking, actions, and selection draft operations. - Added unit tests for testset molecule, focusing on filter atoms, draft operations, local entity creation, and null-safe selectors. - Updated Vitest configuration to include path aliasing for @agenta/ui to avoid unnecessary transformations during testing.
- Implement comprehensive unit tests for environmentMolecule covering molecule shape, isNewEntity, draft operations, null-safe selectors, and lifecycle. - Introduce unit tests for traceSpanMolecule focusing on molecule shape, local data API, derived atoms, draft operations, isNew detection, and lifecycle management.
…lts and coverage Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbitRelease Notes
WalkthroughThis pull request adds a comprehensive Vitest unit testing infrastructure for the ChangesTest Suite Implementation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
🧹 Nitpick comments (2)
web/packages/agenta-entities/tests/unit/draft-state.test.ts (1)
22-26: ⚡ Quick winUse
interfacefor theNoteobject shape.Replace the
type Note = { ... }declaration with aninterface Note { ... }to match repository TypeScript conventions.As per coding guidelines,
**/*.{ts,tsx}: Prefer interface for defining object shapes in TypeScript.web/packages/agenta-entities/tests/unit/molecule.test.ts (1)
24-28: ⚡ Quick winUse
interfacefor thePostobject shape.Switch
type Post = { ... }tointerface Post { ... }to align with the project’s TypeScript style rule.As per coding guidelines,
**/*.{ts,tsx}: Prefer interface for defining object shapes in TypeScript.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 61bbb062-768e-4316-aab6-7f03a8e42c31
⛔ Files ignored due to path filters (1)
web/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (17)
web/packages/agenta-entities/.gitignoreweb/packages/agenta-entities/package.jsonweb/packages/agenta-entities/src/testset/state/paginatedStore.tsweb/packages/agenta-entities/tests/__mocks__/agenta-ui.tsweb/packages/agenta-entities/tests/unit/__smoke__/entity-imports.test.tsweb/packages/agenta-entities/tests/unit/draft-state.test.tsweb/packages/agenta-entities/tests/unit/environment-molecule.test.tsweb/packages/agenta-entities/tests/unit/loadable-store.test.tsweb/packages/agenta-entities/tests/unit/local-molecule.test.tsweb/packages/agenta-entities/tests/unit/molecule.test.tsweb/packages/agenta-entities/tests/unit/normalize.test.tsweb/packages/agenta-entities/tests/unit/port-helpers.test.tsweb/packages/agenta-entities/tests/unit/revision-table-state.test.tsweb/packages/agenta-entities/tests/unit/testcase-molecule.test.tsweb/packages/agenta-entities/tests/unit/testset-molecule.test.tsweb/packages/agenta-entities/tests/unit/trace-span-molecule.test.tsweb/packages/agenta-entities/vitest.config.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: af09aaae77
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -29,6 +29,7 @@ export const testsetsSearchTermAtom = atom<string>("") | |||
| export const testsetsExportFormatAtom = atomWithStorage<"csv" | "json">( | |||
| "agenta:testsets:export-format", | |||
| "csv", | |||
| stringStorage as Parameters<typeof atomWithStorage>[2], | |||
There was a problem hiding this comment.
Preserve JSON-encoded export preferences
When a browser already has agenta:testsets:export-format from the previous atomWithStorage implementation, the stored value is JSON-encoded (for example, "json"). Switching this atom to raw stringStorage returns that raw quoted string instead of json, so the persisted preference no longer matches the expected "csv" | "json" values and downstream export calls can send an invalid file_type until the user reselects a format. Please either migrate/parse existing JSON values here or keep the JSON storage for this key.
Useful? React with 👍 / 👎.
| "test": "pnpm run types:check && pnpm run lint" | ||
| "test": "vitest run", | ||
| "test:watch": "vitest", | ||
| "test:coverage": "vitest run --coverage", |
There was a problem hiding this comment.
Add Vitest's coverage provider dependency
test:coverage now invokes vitest run --coverage, and vitest.config.ts selects the v8 provider, but this package only adds vitest and not @vitest/coverage-v8. Vitest's coverage guide says the v8/istanbul support packages are optional and shows installing @vitest/coverage-v8 manually; in non-interactive CI this script will fail when the provider is missing instead of producing coverage.
Useful? React with 👍 / 👎.
Summary
Adds a complete Layer 1 (pure Jotai, no backend) unit test suite for the
@agenta/entitiespackage. All tests run in a Node environment via Vitest with a plaincreateStore()per test for full isolation.327 tests across 12 files, passing in < 6 s.
What's covered
molecule.test.tscreateMoleculefactory (draft, isDirty, lifecycle, cleanup)local-molecule.test.tscreateLocalMoleculefactory (inline entities, isNew)draft-state.test.tsnormalize.test.tsnormalizeValueForComparisonutilityloadable-store.test.tsloadableStoreatoms and actionsport-helpers.test.tsrevision-table-state.test.tstestset-molecule.test.tstestsetMolecule(filters, draft, null-safe selectors)testcase-molecule.test.tstestcaseMolecule(add/delete/create, selection draft)trace-span-molecule.test.tstraceSpanMolecule(local.set seeding, derived atoms, getAgDataPath)environment-molecule.test.tsenvironmentMolecule(deployments, revisionsList, lifecycle)__smoke__/entity-imports.test.tsInfrastructure added
vitest.config.ts— Node environment, JUnit reporter, v8 coveragetests/__mocks__/agenta-ui.ts— Lightweight stub that prevents the antd transform timeout (antd pulls in a large ESM tree that Vitest can't transform in time; this stub redirects@agenta/uiimports without touching the real package)web/packages/agenta-entities/.gitignore— Excludes generatedtest-results/andcoverage/from gitBug fix included
src/testset/state/paginatedStore.ts—testsetsExportFormatAtomusedatomWithStoragewithout a customstorageAdapter, which accessedlocalStorageat module scope and threw in Node. Fixed by passingstringStoragefrom@agenta/shared/stateas the third argument.Test plan
cd web/packages/agenta-entities && pnpm vitest run— all 327 tests passpnpm vitest run --coverage— coverage report generated undercoverage/test-results/andcoverage/are not committed (excluded by.gitignore)🤖 Generated with Claude Code