import-url-importer.test.mjs
43 lines 1.4 KB
Raw
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor ⚠ breaking 10 days ago
1 /**
2 * URL importer integration (network: example.com).
3 * Skips when example.com is not resolvable (offline/sandbox) so `npm test` is reliable without network.
4 * CI and normal dev (with DNS) run the test.
5 */
6 import { describe, it } from 'node:test';
7 import assert from 'node:assert/strict';
8 import fs from 'fs';
9 import os from 'os';
10 import path from 'path';
11 import dns from 'node:dns/promises';
12 import { importUrl } from '../lib/importers/url.mjs';
13
14 let importUrlNetworkSkipReason;
15 try {
16 await dns.lookup('example.com');
17 importUrlNetworkSkipReason = false;
18 } catch (e) {
19 const msg = e && e.message ? String(e.message) : String(e);
20 importUrlNetworkSkipReason =
21 'example.com DNS not available (' + msg + '); set network access or use CI to run this integration test.';
22 }
23
24 describe('importUrl', () => {
25 it('dryRun fetches https://example.com with auto mode', { skip: importUrlNetworkSkipReason }, async () => {
26 const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'kn-url-dry-'));
27 try {
28 const result = await importUrl('https://example.com/', {
29 vaultPath: dir,
30 outputBase: 'inbox',
31 project: null,
32 tags: [],
33 dryRun: true,
34 urlMode: 'auto',
35 });
36 assert.equal(result.count, 1);
37 assert.ok(result.imported[0].path.includes('imports/url/'));
38 assert.ok(result.imported[0].source_id);
39 } finally {
40 fs.rmSync(dir, { recursive: true, force: true });
41 }
42 });
43 });
File History 4 commits
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor 10 days ago
sha256:d8c648b20a4d53b2673c5c082ee7edfa7b2fc9b11080832da1f38807b6bf940b fix(7C-L1b): route hosted delegation proposals through cani… Human minor 30 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91 fix: repair endpoint now sets has_active_subscription when … Human minor 49 days ago