// Unit tests for the PURE (private) helper methods of DocmostClient plus the // transformPage vm sandbox. The constructor only calls axios.create (no // network), so a real instance can be built and its private methods exercised // via an `(client as any)` cast. Private methods are pure (no I/O) except for // transformPage, whose network calls (ensureAuthenticated / listComments / // getPageRaw) we stub on the instance so the dryRun path runs offline. import { describe, it, expect } from 'vitest'; import { DocmostClient } from '../packages/docmost-client/src/client.js'; // Build a fresh client per test. The given URL ends with /api so appUrl tests // have something to strip; other tests do not depend on the suffix. function makeClient(apiUrl = 'https://docmost.example/api'): any { return new DocmostClient(apiUrl, 'a@b.c', 'pw') as any; } describe('DocmostClient.isSafeUrl (SECURITY)', () => { // --- dangerous schemes must be rejected in both contexts --- const dangerousLink = ['javascript:alert(1)', 'vbscript:msgbox(1)', 'data:text/html,