chore(lint): fix eslint violations in worker config and e2e tests

This commit is contained in:
Richard R 2026-05-21 21:44:58 -06:00
parent 057d2a4e32
commit 7a49ff9896
6 changed files with 28 additions and 15 deletions

View file

@ -20,7 +20,7 @@ import {
type JetStreamManager,
type JsMsg,
} from '@nats-io/jetstream';
import { Kvm, type KV } from '@nats-io/kv';
import { Kvm } from '@nats-io/kv';
import {
ensureComputeModels,
runPdfLayoutFromPdfBuffer,
@ -437,7 +437,7 @@ async function main(): Promise<void> {
Math.max(30 * 60_000, Math.max(whisperTimeoutMs, pdfTimeoutMs) * 4),
);
const connectOpts: any = { servers: natsUrl };
const connectOpts: Parameters<typeof connect>[0] = { servers: natsUrl };
const natsCreds = process.env.NATS_CREDS?.trim();
const natsCredsFile = process.env.NATS_CREDS_FILE?.trim();

View file

@ -1 +1,3 @@
export default {};
const emptyModule = {};
export default emptyModule;

View file

@ -1,5 +1,6 @@
import type { NextConfig } from "next";
import path from "node:path";
import { DefinePlugin } from "webpack";
const securityHeaders = [
{ key: 'X-Content-Type-Options', value: 'nosniff' },
@ -78,8 +79,6 @@ const nextConfig: NextConfig = {
},
webpack: (config, { isServer }) => {
if (isServer) {
// Use runtime require to avoid adding an explicit webpack TS dependency.
const { DefinePlugin } = require('webpack') as { DefinePlugin: new (defs: Record<string, string>) => unknown };
config.plugins = config.plugins || [];
config.plugins.push(
new DefinePlugin({

View file

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/test';
import { test, expect, type Page } from '@playwright/test';
import { setupTest, uploadFiles, ensureDocumentsListed, waitForDocumentListHintPersist, dispatchHtml5DragAndDrop } from './helpers';
test.describe('Document folders and hint persistence', () => {
@ -7,7 +7,7 @@ test.describe('Document folders and hint persistence', () => {
});
// Utility to get the draggable row for a given filename (by link)
const rowFor = (page: any, fileName: string) => {
const rowFor = (page: Page, fileName: string) => {
const link = page.getByRole('link', { name: new RegExp(fileName, 'i') }).first();
// The draggable attribute lives on the row container ancestor
return link.locator('xpath=ancestor::*[@draggable="true"][1]');

View file

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/test';
import { test, expect, type Page } from '@playwright/test';
import {
setupTest,
uploadFiles,
@ -11,7 +11,7 @@ import {
} from './helpers';
// Single-spec helpers kept local to avoid cluttering shared helpers:
async function navigateToPdfPageViaNavigator(page: any, targetPage: number) {
async function navigateToPdfPageViaNavigator(page: Page, targetPage: number) {
// Navigator popover shows "X / Y"
const navTrigger = page.getByRole('button', { name: /\d+\s*\/\s*\d+/ });
await expect(navTrigger).toBeVisible({ timeout: 10000 });
@ -23,11 +23,11 @@ async function navigateToPdfPageViaNavigator(page: any, targetPage: number) {
await input.press('Enter');
}
async function countRenderedPdfPages(page: any): Promise<number> {
async function countRenderedPdfPages(page: Page): Promise<number> {
return await page.locator('.react-pdf__Page').count();
}
async function triggerViewportResize(page: any, width: number, height: number) {
async function triggerViewportResize(page: Page, width: number, height: number) {
await page.setViewportSize({ width, height });
}

View file

@ -1,6 +1,15 @@
import { test, expect } from '@playwright/test';
import { uploadFile, uploadAndDisplay, setupTest, expectDocumentListed, uploadFiles, ensureDocumentsListed, clickDocumentLink, expectViewerForFile } from './helpers';
interface HtmlDocumentRow {
id?: string;
data?: string;
}
type HashCheckResult =
| { ok: true; storedId: string; computedId: string }
| { ok: false; reason: 'Missing stored html document' };
test.describe('Document Upload Tests', () => {
test.beforeEach(async ({ page }, testInfo) => {
await setupTest(page, testInfo);
@ -25,7 +34,7 @@ test.describe('Document Upload Tests', () => {
await uploadFile(page, 'sample.txt');
await expectDocumentListed(page, 'sample.txt');
const result = await page.evaluate(async () => {
const result = await page.evaluate<HashCheckResult>(async () => {
const idb = await new Promise<IDBDatabase>((resolve, reject) => {
const request = indexedDB.open('openreader-db');
request.onerror = () => reject(request.error);
@ -33,12 +42,12 @@ test.describe('Document Upload Tests', () => {
});
try {
const docs = await new Promise<any[]>((resolve, reject) => {
const docs = await new Promise<HtmlDocumentRow[]>((resolve, reject) => {
const tx = idb.transaction('html-documents', 'readonly');
const store = tx.objectStore('html-documents');
const request = store.getAll();
request.onerror = () => reject(request.error);
request.onsuccess = () => resolve(request.result as any[]);
request.onsuccess = () => resolve(request.result as HtmlDocumentRow[]);
});
if (!docs[0]?.data || !docs[0]?.id) {
@ -57,7 +66,10 @@ test.describe('Document Upload Tests', () => {
}
});
expect(result.ok, `Expected storedId=${(result as any).storedId} computedId=${(result as any).computedId}`).toBeTruthy();
const detail = result.ok
? `Expected storedId=${result.storedId} computedId=${result.computedId}`
: `Expected valid stored html document but got reason=${result.reason}`;
expect(result.ok, detail).toBeTruthy();
});
test('uploads and converts a DOCX document', async ({ page }) => {