Versie 0.2.0
This commit is contained in:
commit
e77d8fd373
495 files changed
+81026
No files matched your search
@@ -0,0 +1,86 @@
|
||||
// Generated, do not edit. sha256:19a3bb75110abcec8d0ce1494adf6296cb48fd73fb9943873caae31596ad520e
|
||||
import { describe, it, before, beforeEach, mock } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import { mkdtemp } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { createDbHarness } from '../helpers/db-node.mjs';
|
||||
|
||||
process.env.ASSETAPP_DATA_DIR = await mkdtemp(join(tmpdir(), 'assetapp-dienstdiagnose-'));
|
||||
|
||||
const harness = createDbHarness({ seedPreferences: true });
|
||||
mock.module('../../server/db.js', { namedExports: harness.exports });
|
||||
|
||||
let DEKKING = { status: 'off' };
|
||||
mock.module('../../server/data/market.js', { namedExports: { serviceCoverage: async () => DEKKING } });
|
||||
|
||||
const { READ_TOOLS } = await import('../../server/mcp/read-tools.mjs');
|
||||
const { PRICE_TOOLS } = await import('../../server/mcp/price-tool.mjs');
|
||||
const { _resetVertalers } = await import('../../server/mcp/session.mjs');
|
||||
const { setPref } = await import('../../server/data/preferences.js');
|
||||
|
||||
const gezondheid = READ_TOOLS.find(t => t.name === 'integration_health');
|
||||
const koersen = PRICE_TOOLS.find(t => t.name === 'price_data');
|
||||
const ctx = { session: { id: 'dienst' } };
|
||||
const { run, lastId } = harness.exports;
|
||||
let btc;
|
||||
|
||||
before(() => {
|
||||
harness.recreate();
|
||||
run(`INSERT INTO Asset (symbol, name, searchName, kind, unit, subunit, decimals, displayUnit)
|
||||
VALUES ('BTC','Bitcoin','bitcoin','crypto','BTC','sat',8,'unit')`);
|
||||
btc = lastId();
|
||||
run(`INSERT INTO Provider (key, name, searchName, baseUrl, authenticationKind, authenticationRequired,
|
||||
isActive, isSeed, isSystem, createdAt)
|
||||
VALUES ('bitvavo','Bitvavo','bitvavo','https://x','none',0,0,1,0,'2026-10-16T00:00:00Z')`);
|
||||
const p = lastId();
|
||||
run(`INSERT INTO ProviderCoverage (providerId, symbol) VALUES (?, 'BTC')`, [p]);
|
||||
run(`INSERT INTO ProviderEndpoint (providerId, capability, method, pathTemplate) VALUES (?, 'daily_history', 'GET', '/c')`, [p]);
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
_resetVertalers();
|
||||
DEKKING = { status: 'off' };
|
||||
await setPref('app', 'market_spot', 'off');
|
||||
});
|
||||
|
||||
const bronkeuzeRegel = text => text.split('\n').find(r => r.startsWith('- BTC (crypto):')) || '';
|
||||
|
||||
describe('integration_health: de bronkeuze met de dienst', () => {
|
||||
it('met de stand aan en BTC gedekt: geen melding, wel dat de dienst de historie levert', async () => {
|
||||
await setPref('app', 'market_spot', 'first');
|
||||
DEKKING = { status: 'ok', assetIds: [btc] };
|
||||
const r = bronkeuzeRegel((await gezondheid.run({}, ctx)).text);
|
||||
assert.doesNotMatch(r, /staan uit/);
|
||||
assert.match(r, /historie uit Atreides Services/);
|
||||
});
|
||||
|
||||
it('met de stand uit, of zonder dekking, blijft de melding', async () => {
|
||||
DEKKING = { status: 'ok', assetIds: [btc] };
|
||||
assert.match(bronkeuzeRegel((await gezondheid.run({}, ctx)).text), /de dekkende bronnen staan uit \(Bitvavo\)/, 'stand uit');
|
||||
await setPref('app', 'market_spot', 'first');
|
||||
DEKKING = { status: 'ok', assetIds: [] };
|
||||
const r = bronkeuzeRegel((await gezondheid.run({}, ctx)).text);
|
||||
assert.match(r, /staan uit/, 'niet gedekt');
|
||||
assert.doesNotMatch(r, /Atreides Services/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('price_data sources: de diagnose met de dienst', () => {
|
||||
it('met de stand aan en BTC gedekt: in orde, en de dienst genoemd', async () => {
|
||||
await setPref('app', 'market_spot', 'fallback');
|
||||
DEKKING = { status: 'ok', assetIds: [btc] };
|
||||
const uit = (await koersen.run({ asset: 'BTC', view: 'sources' }, ctx)).text;
|
||||
assert.match(uit, /Diagnose van de bronkeuze:\n- in orde/);
|
||||
assert.match(uit, /historie uit Atreides Services/);
|
||||
});
|
||||
|
||||
it('met een onbereikbare dienst blijft de melding', async () => {
|
||||
await setPref('app', 'market_spot', 'first');
|
||||
DEKKING = { status: 'unavailable' };
|
||||
const uit = (await koersen.run({ asset: 'BTC', view: 'sources' }, ctx)).text;
|
||||
assert.match(uit, /- allInactive \(Bitvavo\)/);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user