Skip to content

Conversation

@DaxServer
Copy link
Owner

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Aug 14, 2025

📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Switched runtime typeof checks to static type assertions, improving clarity and reliability of test expectations.
    • Enabled real store actions in testing (actions no longer stubbed) to verify actual state updates.
    • Refined test assertions and access patterns across store and composable tests for consistency.
    • No user-facing changes; application behavior and APIs remain unchanged.

Walkthrough

Test-only updates across backend and frontend: migrate runtime typeof checks to expectTypeOf assertions, adjust some non-null assertions in store tests, and change Pinia test setup to run actions by disabling stubbing. No production code or public API changes.

Changes

Cohort / File(s) Summary of Changes
Test type-assertion migration
backend/tests/db.test.ts, frontend/src/features/wikibase-schema/stores/__tests__/schema.store.test.ts, frontend/src/shared/composables/__tests__/useDragDropContext.test.ts
Import expectTypeOf and replace runtime typeof checks with type-level assertions; in schema.store tests also switch to non-null assertions for array access.
Pinia testing config
frontend/src/features/wikibase-schema/composables/__tests__/useSchemaApi.test.ts
Update createTestingPinia option: stubActions from true to false so actions execute during tests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch expectTypeOf

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
frontend/src/features/wikibase-schema/stores/__tests__/schema.store.test.ts (1)

16-31: Add missing imports: PropertyValueMap & ReferenceSchemaMapping

Both types are exported from backend/src/api/project/project.wikibase.ts but are not imported in the test file — add them to the existing import.

  • backend/src/api/project/project.wikibase.ts — exports PropertyValueMap (line ~80) and ReferenceSchemaMapping (line ~88)
  • frontend/src/features/wikibase-schema/stores/tests/schema.store.test.ts — top-level import missing these types

Apply this change in the test:

-import type {
-  ColumnMapping,
-  PropertyReference,
-  ValueMapping,
-} from '@backend/api/project/project.wikibase'
+import type {
+  ColumnMapping,
+  PropertyReference,
+  ValueMapping,
+  PropertyValueMap,
+  ReferenceSchemaMapping,
+} from '@backend/api/project/project.wikibase'
🧹 Nitpick comments (2)
frontend/src/shared/composables/__tests__/useDragDropContext.test.ts (2)

270-277: Great switch to type-level assertions for composable method presence; consider adding signature checks

You validated existence via toBeFunction(). Add return/parameter type checks to harden against signature regressions.

Apply the following additions near these assertions:

       expectTypeOf(context.startDrag).toBeFunction()
       expectTypeOf(context.endDrag).toBeFunction()
       expectTypeOf(context.enterDropZone).toBeFunction()
       expectTypeOf(context.leaveDropZone).toBeFunction()
       expectTypeOf(context.validateDrop).toBeFunction()
       expectTypeOf(context.performDrop).toBeFunction()
       expectTypeOf(context.createDropZoneConfig).toBeFunction()
+      // Optional: strengthen with signature checks
+      expectTypeOf(context.performDrop).returns.toEqualTypeOf<Promise<boolean>>()
+      expectTypeOf(context.createDropZoneConfig)
+        .parameters.toEqualTypeOf<[string, WikibaseDataType[], (column: ColumnInfo) => void]>()

292-292: Type-level assertion for getValidTargetsForColumn is good; consider adding return type check

Minor enhancement: add a compile-time return type check for clarity.

You can add:

   const store = useDragDropStore()
-  expectTypeOf(store.getValidTargetsForColumn).toBeFunction()
+  expectTypeOf(store.getValidTargetsForColumn).toBeFunction()
+  expectTypeOf(store.getValidTargetsForColumn)
+    .returns.toEqualTypeOf<DropTarget[]>()
+  expectTypeOf(store.getValidTargetsForColumn)
+    .parameters.toEqualTypeOf<[ColumnInfo]>()
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these settings in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5b5dbb9 and eff3049.

📒 Files selected for processing (4)
  • backend/tests/db.test.ts (4 hunks)
  • frontend/src/features/wikibase-schema/composables/__tests__/useSchemaApi.test.ts (1 hunks)
  • frontend/src/features/wikibase-schema/stores/__tests__/schema.store.test.ts (4 hunks)
  • frontend/src/shared/composables/__tests__/useDragDropContext.test.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

**/*.{ts,tsx,js,jsx}: Use bun <file> instead of node <file> or ts-node <file> for running TypeScript or JavaScript files
Do not use dotenv; Bun automatically loads .env files
Use Bun.serve() for HTTP servers and WebSockets instead of express
Use bun:sqlite for SQLite instead of better-sqlite3
Use Bun.redis for Redis instead of ioredis
Use Bun.sql for Postgres instead of pg or postgres.js
Use built-in WebSocket instead of ws
Prefer Bun.file over node:fs's readFile/writeFile
Use Bun.$ (e.g., Bun.$ls``) instead of execa for running shell commands

Files:

  • frontend/src/features/wikibase-schema/composables/__tests__/useSchemaApi.test.ts
  • frontend/src/features/wikibase-schema/stores/__tests__/schema.store.test.ts
  • frontend/src/shared/composables/__tests__/useDragDropContext.test.ts
  • backend/tests/db.test.ts
**/*.test.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Use bun test instead of jest for running tests

Files:

  • frontend/src/features/wikibase-schema/composables/__tests__/useSchemaApi.test.ts
  • frontend/src/features/wikibase-schema/stores/__tests__/schema.store.test.ts
  • frontend/src/shared/composables/__tests__/useDragDropContext.test.ts
  • backend/tests/db.test.ts
**/*.{html,ts,tsx,css}

📄 CodeRabbit Inference Engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Use bun build <file.html|file.ts|file.css> instead of webpack or esbuild for building HTML, TypeScript, or CSS files

Files:

  • frontend/src/features/wikibase-schema/composables/__tests__/useSchemaApi.test.ts
  • frontend/src/features/wikibase-schema/stores/__tests__/schema.store.test.ts
  • frontend/src/shared/composables/__tests__/useDragDropContext.test.ts
  • backend/tests/db.test.ts
🧠 Learnings (3)
📚 Learning: 2025-07-20T14:13:24.706Z
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/composables/**/*.ts : Do not proxy or export Pinia store state/actions from composables

Applied to files:

  • frontend/src/features/wikibase-schema/composables/__tests__/useSchemaApi.test.ts
📚 Learning: 2025-07-20T14:13:40.153Z
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-07-20T14:13:40.153Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use `bun test` instead of `jest` for running tests

Applied to files:

  • frontend/src/features/wikibase-schema/stores/__tests__/schema.store.test.ts
  • frontend/src/shared/composables/__tests__/useDragDropContext.test.ts
  • backend/tests/db.test.ts
📚 Learning: 2025-07-20T14:13:40.153Z
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-07-20T14:13:40.153Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `bun:sqlite` for SQLite instead of `better-sqlite3`

Applied to files:

  • backend/tests/db.test.ts
🔇 Additional comments (9)
frontend/src/features/wikibase-schema/composables/__tests__/useSchemaApi.test.ts (1)

95-99: Enabling real Pinia actions in tests is appropriate here

Switching stubActions to false makes the tests verify actual state transitions, which matches the assertions below (e.g., schemaId, projectId updates). The createSpy: mock still spies on actions, so call assertions remain valid. Good alignment with the PR’s intent.

frontend/src/shared/composables/__tests__/useDragDropContext.test.ts (2)

1-1: Adopting expectTypeOf for type-level assertions is consistent with the PR objective

Importing expectTypeOf from bun:test prepares this test to assert API surface types without runtime checks. Good move.


281-281: Type-level assertion for setAvailableTargets looks good

Matches the store API described in drag-drop.store. No concerns.

backend/tests/db.test.ts (1)

1-1: Type-level checks for db.run are aligned with PR; LGTM

Using expectTypeOf(db.run).toBeFunction() removes unnecessary runtime typeof checks while preserving intent. No further issues spotted.

Also applies to: 13-13, 25-25, 68-68

frontend/src/features/wikibase-schema/stores/__tests__/schema.store.test.ts (5)

1-1: Adopting expectTypeOf import is on point

Consistent with the broader migration to type-level assertions.


56-61: Running real store actions in tests is appropriate

stubActions: false ensures state changes are exercised, which your tests rely on. With createSpy: mock, action calls remain observable. Well set.


637-638: Type-level assertion for statement id is a good replacement

Clearer than runtime checks; helps catch regressions at compile-time.


655-656: Type-level assertion for property object looks good

Keeps the test focused on structure without runtime coupling.


673-674: Type-level assertion for value object looks good

Matches the intended shape of the statement value mapping.

@DaxServer DaxServer merged commit a58ebee into main Aug 14, 2025
5 of 6 checks passed
@DaxServer DaxServer deleted the expectTypeOf branch August 14, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant