GitNexus/gitnexus/test/unit/api-query-readonly-wiring.test.ts
azizur100389 f8036ac349
feat(analyze): add explicit FTS opt-out (#3205)
* feat(analyze): add explicit FTS opt-out

* chore(autofix): apply prettier + eslint fixes via /autofix command

* fix(analyze): treat flag and env FTS opt-out as one mode

Avoid a same-commit rebuild when only the skipReason discriminator
changes, and advertise disablement on dirty meta before leftover
indexes are wiped.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-11 14:05:28 +00:00

35 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import fs from 'node:fs/promises';
import path from 'node:path';
describe('api query read-only wiring', () => {
it('uses withLbugDb readOnly mode inside handleQueryRequest', async () => {
const source = await fs.readFile(
path.join(__dirname, '..', '..', 'src', 'server', 'api.ts'),
'utf-8',
);
// The open now routes through readOnlyFtsOptions(skipFts) so the persisted
// FTS mode rides along; api-readonly-wiring.test.ts pins that the helper
// always sets `readOnly: true`.
expect(source).toMatch(
/handleQueryRequest[\s\S]*withLbugDb\([\s\S]*(?:readOnly:\s*true|readOnlyFtsOptions\()/,
);
});
it('routes /api/query through handleQueryRequest', async () => {
const source = await fs.readFile(
path.join(__dirname, '..', '..', 'src', 'server', 'api.ts'),
'utf-8',
);
expect(source).toContain("app.post('/api/query', async (req, res) => {");
expect(source).toContain('await handleQueryRequest(req, res, resolveRepo);');
});
it('opens Ladybug connection with readOnly option when requested', async () => {
const source = await fs.readFile(
path.join(__dirname, '..', '..', 'src', 'core', 'lbug', 'lbug-adapter.ts'),
'utf-8',
);
expect(source).toMatch(/openLbugConnection\(lbug,\s*dbPath,\s*\{\s*readOnly:\s*true\s*\}\)/);
});
});