Feature/client test experiment#10069
Conversation
|
🖥️ App preview is ready! 🔗 Preview URL: https://pr-10069.trilium-app.pages.dev ✅ All checks passed This preview will be updated automatically with new commits. |
Bundle ReportChanges will decrease total bundle size by 25.95kB (-0.03%) ⬇️. This is within the configured threshold ✅ Detailed changes
ℹ️ *Bundle size includes cached data from a previous commit Affected Assets, Files, and Routes:view changes for bundle: client-esmAssets Changed:
view changes for bundle: standalone-esmAssets Changed:
|
There was a problem hiding this comment.
Code Review
This pull request introduces comprehensive unit tests (*.spec.tsx) for various Preact widgets, collections, and dialogs in the client application, along with updated documentation and shared test helpers (mocks.ts, render.tsx, setup.ts) to streamline test writing. The feedback recommends importing createContext from from "preact" at the top level of column.spec.tsx and using it directly inside the hoisted vi.mock factory instead of require("preact") to prevent potential Preact instance mismatch and context resolution failures.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| import { act } from "preact/test-utils"; | ||
| import { beforeEach, describe, expect, it, vi } from "vitest"; |
There was a problem hiding this comment.
To support using createContext directly in the hoisted vi.mock factory (and avoid potential context mismatch issues from require("preact")), import createContext from "preact" at the top level.
| import { act } from "preact/test-utils"; | |
| import { beforeEach, describe, expect, it, vi } from "vitest"; | |
| import { createContext } from "preact"; | |
| import { act } from "preact/test-utils"; | |
| import { beforeEach, describe, expect, it, vi } from "vitest"; |
| vi.mock(".", () => { | ||
| const { createContext: cc } = require("preact"); | ||
| const BoardViewContext = cc(undefined); |
There was a problem hiding this comment.
Using require("preact") inside a hoisted vi.mock factory can lead to multiple instances of Preact being loaded or mismatched context objects, causing useContext(BoardViewContext) to silently fail (returning undefined instead of the provided value). To ensure context resolution works reliably and consistently with other test files (like card.spec.tsx), use the top-level imported createContext directly.
| vi.mock(".", () => { | |
| const { createContext: cc } = require("preact"); | |
| const BoardViewContext = cc(undefined); | |
| vi.mock(".", () => { | |
| const BoardViewContext = createContext(undefined); |
❌ 31 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
No description provided.