Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion __tests__/hooks/useQueryBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
*/
import { renderHook, act } from "@testing-library/react-native";

/* ---- Types ---- */
interface SerializedFilter {
logic: string;
filters: Array<{
field: string;
operator: string;
value: string;
}>;
}
Comment on lines +7 to +15
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

The new SerializedFilter interface suggests the real ObjectQL serialization format is an object with logic/filters, but the production serializeFilterTree() returns an array-based AST (unknown | null). To avoid confusion, consider renaming this to something test/mock-specific (e.g., MockSerializedFilter) or switching the expectation to structural matching without introducing a misleading type name.

Copilot uses AI. Check for mistakes.

/* ---- Mock query-builder helpers ---- */
let mockNextId = 0;
jest.mock("~/lib/query-builder", () => ({
Expand Down Expand Up @@ -186,7 +196,7 @@ describe("useQueryBuilder", () => {

const serialized = result.current.serialize();
expect(serialized).toBeDefined();
expect(serialized.logic).toBe("AND");
expect((serialized as SerializedFilter).logic).toBe("AND");
Comment on lines 197 to +199
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

expect(serialized).toBeDefined() doesn’t exclude null (null is “defined”), so if serialize() ever returns null this test will throw when accessing .logic rather than failing with a clear assertion. Prefer asserting non-null (e.g., not.toBeNull() / not.toBeNull() + type guard) or use an objectContaining({ logic: "AND" }) matcher to avoid unsafe property access on unknown.

Copilot uses AI. Check for mistakes.
});

it("manages selected fields and projection", () => {
Expand Down
Loading