ktx/packages/cli/test/progress-port-adapter.test.ts
Andrey Avtomonov 13774bfcef
feat(cli): stream plain ktx ingest progress to stderr (KLO-726) (#251)
* feat(cli): share public ingest progress adapter

* feat(cli): stream plain public ingest progress

* test(cli): update plain ingest progress assertions

* chore(cli): satisfy plain ingest progress checks

* fix(artifacts): expect plain ingest stderr progress in installed-CLI smoke

* ci(coverage): make Codecov upload non-fatal and fix repo slug

The Coverage job failed because the Codecov upload returned
'Repository not found' while fail_ci_if_error was true, turning a
Codecov-side issue into a hard CI failure even though all tests pass.

- Set fail_ci_if_error: false on both uploads so Codecov outages or an
  unlinked repo no longer break CI (upload stays best-effort).
- Correct the stale slug Kaelio/ktx -> Kaelio/ktx-ai-data-agents-context
  to match the actual GitHub repo (aligns with main).

* fix(cli): isolate query-history failure capture from scan output

The plain public-ingest progress path passes one captured IO as the
target-level `io`. With progress deps set, both the schema scan and the
query-history ingest resolved their capture to that same shared buffer,
so a non-actionable query-history failure surfaced leftover scan report
text (e.g. "Mode: enriched") as the skipped-facet detail instead of the
real query-history message.

Give the query-history ingest a phase-local capture while preserving the
flow-to-io branch the foreground context-build view relies on.

---------

Co-authored-by: Andrey Avtomonov <7889985+andreybavt@users.noreply.github.com>
2026-06-01 23:31:31 +02:00

35 lines
1.5 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { createAggregateProgressPort } from '../src/progress-port-adapter.js';
describe('createAggregateProgressPort', () => {
it('flattens nested weighted progress into absolute percent updates', async () => {
const updates: Array<{ percent: number; message: string; transient?: boolean }> = [];
const progress = createAggregateProgressPort((update) => updates.push(update));
await progress.update(0.1, 'Preparing scan');
const nested = progress.startPhase(0.5);
await nested.update(0.5, 'Generating descriptions 2/4 tables', { transient: true });
await progress.update(0.95, 'Writing schema artifacts');
expect(updates).toEqual([
{ percent: 10, message: 'Preparing scan' },
{ percent: 35, message: 'Generating descriptions 2/4 tables', transient: true },
{ percent: 95, message: 'Writing schema artifacts' },
]);
});
it('clamps updates and never moves the shared progress state backward', async () => {
const updates: Array<{ percent: number; message: string }> = [];
const progress = createAggregateProgressPort((update) => updates.push(update));
await progress.update(0.8, 'Building enriched schema context');
await progress.update(0.2, 'Older scan callback');
await progress.update(1.4, 'Scan completed');
expect(updates).toEqual([
{ percent: 80, message: 'Building enriched schema context' },
{ percent: 80, message: 'Older scan callback' },
{ percent: 100, message: 'Scan completed' },
]);
});
});