From 42b6492404c0701c60cfb2e3cb54abcb882bf0f5 Mon Sep 17 00:00:00 2001 From: Fini Date: Wed, 22 Apr 2026 10:35:00 +0800 Subject: [PATCH] chore(tests): fix tsc errors in earlier test files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two tsc errors surfaced by a later tsc run: 1. browser-image-search-fetcher.test.ts — imported `beforeEach` but never used; also `spy.mock.calls[0]` typed as empty tuple since vi.fn()'s signature isn't inferred. Cast via `unknown` + explicit tuple shape. 2. chart-builders-visual-smoke.test.ts — custom-dimensions case passed `width`/`height` to buildChartLine. The real shape is `point_spacing` + `chart_height`. Fixed the test to use the actual param names (test itself wasn't broken, just the type). --- .../ai/__tests__/browser-image-search-fetcher.test.ts | 8 ++++---- .../src/__tests__/chart-builders-visual-smoke.test.ts | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/web/src/services/ai/__tests__/browser-image-search-fetcher.test.ts b/apps/web/src/services/ai/__tests__/browser-image-search-fetcher.test.ts index 0546291b5..e4e02adfb 100644 --- a/apps/web/src/services/ai/__tests__/browser-image-search-fetcher.test.ts +++ b/apps/web/src/services/ai/__tests__/browser-image-search-fetcher.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; +import { describe, it, expect, afterEach, vi } from 'vitest'; import { makeBrowserImageSearchFetcher } from '../browser-image-search-fetcher'; /** @@ -28,9 +28,9 @@ describe('makeBrowserImageSearchFetcher', () => { expect(result).toBe('https://img.example/x.jpg'); expect(spy).toHaveBeenCalledOnce(); - const [url, init] = spy.mock.calls[0]; - expect(url).toBe('/api/ai/image-search'); - expect((init as RequestInit).method).toBe('POST'); + const firstCall = spy.mock.calls[0] as unknown as [string, RequestInit]; + expect(firstCall[0]).toBe('/api/ai/image-search'); + expect(firstCall[1].method).toBe('POST'); }); it('sends the query in the request body', async () => { diff --git a/packages/pen-core/src/__tests__/chart-builders-visual-smoke.test.ts b/packages/pen-core/src/__tests__/chart-builders-visual-smoke.test.ts index 72b82d5e2..44a154cce 100644 --- a/packages/pen-core/src/__tests__/chart-builders-visual-smoke.test.ts +++ b/packages/pen-core/src/__tests__/chart-builders-visual-smoke.test.ts @@ -133,7 +133,10 @@ describe('chart builders — visual smoke', () => { { name: 'two points only', args: { values: [1, 10] } }, { name: 'spike in middle', args: { values: [1, 1, 1, 100, 1, 1, 1] } }, { name: 'fractional values', args: { values: [0.5, 1.5, 2.25, 3.75] } }, - { name: 'custom dimensions', args: { values: [1, 2, 3], width: 400, height: 200 } }, + { + name: 'custom dimensions', + args: { values: [1, 2, 3], point_spacing: 50, chart_height: 200 }, + }, ]; for (const c of cases) {