Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
- name: Run Biome Check
run: npx @biomejs/biome ci .

- name: Run TypeScript Typecheck
run: npm run typecheck

- name: Run Tests
run: npm test

Expand Down
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Run the ones for the areas you touched. CI runs the check column; use the fix co
|---|---|---|
| Biome lint & format | `npm run check` | `npm run check:fix` |
| Pre-dev auto-format | — | `npm run predev` |
| TypeScript typecheck | `npm run typecheck` | — |
| Unit tests | `npm run test` | — |
| Web production build | `npm run build` | — |
| Electron development | `npm run electron-dev` | — |
Expand Down Expand Up @@ -73,4 +74,4 @@ Contribution workflow
Definition of done
## Definition of done

A change is not finished until the relevant checks pass locally. At minimum, run `npm run check` and `npm run test`. If you changed the web application or production build configuration, also run `npm run build`. If you touched input drivers, gestures, or WebRTC signaling, test end-to-end via QR code scan on a mobile device or VM.
A change is not finished until the relevant checks pass locally. At minimum, run `npm run check`, `npm run typecheck` and `npm run test`. If you changed the web application or production build configuration, also run `npm run build`. If you touched input drivers, gestures, or WebRTC signaling, test end-to-end via QR code scan on a mobile device or VM.
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ We use Vitest for testing and Biome for formatting/linting:
# Run tests
npm run test

# Type-check (tsc --noEmit)
npm run typecheck

# Format & Lint code
npm run check

Expand Down Expand Up @@ -178,6 +181,7 @@ git push origin feature/your-feature-name
### Before Submitting

- [ ] Your code follows the project's style guidelines (`npm run check`)
- [ ] Your code type-checks (`npm run typecheck`)
- [ ] You've tested your changes thoroughly (`npm run test`)
- [ ] You've updated relevant documentation
- [ ] Your commits are clean and well-organized
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"preview": "vite preview",
"test": "vitest run",
"check": "biome check .",
"check:fix": "biome check . --write"
"check:fix": "biome check . --write",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@imxade/inject": "^0.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/server/signalling/handlers/sessionStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe("sessionStore lifecycle and SSE delivery", () => {
const response = new FakeResponse()
client.sessionSseRes = response as unknown as ServerResponse
const onTimeout = vi.fn()
client.disconnectTimer = setTimeout(onTimeout, 1000)
client.disconnectTimer = setTimeout(() => onTimeout(), 1000)
const clients = new Map([["session-1", client]])

cleanupSession(clients, "session-1")
Expand Down
28 changes: 13 additions & 15 deletions tests/server/clipboard.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { EventEmitter } from "node:events"
import { spawn } from "node:child_process"
import { ChildProcess, spawn } from "node:child_process"
import os from "node:os"
import { PassThrough } from "node:stream"
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
import { getSystemClipboard, setSystemClipboard } from "@/server/clipboard.ts"

vi.mock("node:child_process", () => ({
vi.mock("node:child_process", async (importOriginal) => ({
...(await importOriginal<typeof import("node:child_process")>()),
spawn: vi.fn(),
}))

Expand All @@ -14,12 +15,13 @@ vi.mock("node:os", () => ({
},
}))

interface MockChildProcess extends EventEmitter {
stdout: EventEmitter
stdin: {
on: ReturnType<typeof vi.fn>
end: ReturnType<typeof vi.fn>
}
/**
* A real ChildProcess (so every member is typed by Node's own declarations)
* with the streams clipboard.ts uses replaced by non-null PassThrough streams.
*/
class MockChildProcess extends ChildProcess {
override stdout = new PassThrough()
override stdin = new PassThrough()
}

function createMockProcess(options: {
Expand All @@ -28,12 +30,8 @@ function createMockProcess(options: {
failError?: Error | null
}) {
const { stdoutData = "", exitCode = 0, failError = null } = options
const proc = new EventEmitter() as unknown as MockChildProcess
proc.stdout = new EventEmitter()
proc.stdin = {
on: vi.fn(),
end: vi.fn(),
}
const proc = new MockChildProcess()
vi.spyOn(proc.stdin, "end")

setTimeout(() => {
if (failError) {
Expand Down
Loading