Spaces:
Runtime error
Runtime error
Download tests/docs-knowledge.spec.ts from Powerman9x/HuggingClaw-MissionControl: direct link, hf CLI and curl.
- Browser
- Download file 2.05 kB
-
https://huggingface.co/spaces/Powerman9x/HuggingClaw-MissionControl/resolve/123e7c19b0ce60c8dc66ff876e0d2402eafbbbca/tests/docs-knowledge.spec.ts
- Command line
-
hf download hf://spaces/Powerman9x/HuggingClaw-MissionControl@123e7c19b0ce60c8dc66ff876e0d2402eafbbbca/tests/docs-knowledge.spec.ts
-
curl -L -o docs-knowledge.spec.ts https://huggingface.co/spaces/Powerman9x/HuggingClaw-MissionControl/resolve/123e7c19b0ce60c8dc66ff876e0d2402eafbbbca/tests/docs-knowledge.spec.ts
2.05 kB
| import { test, expect } from '@playwright/test' | |
| import { API_KEY_HEADER } from './helpers' | |
| test.describe('Docs Knowledge API', () => { | |
| test('tree/search/content flows for markdown knowledge docs', async ({ request }) => { | |
| const stamp = Date.now() | |
| const path = `knowledge-base/e2e-kb-${stamp}.md` | |
| const content = `# E2E Knowledge ${stamp}\n\nDeployment runbook token: kb-search-${stamp}` | |
| const create = await request.post('/api/memory', { | |
| headers: API_KEY_HEADER, | |
| data: { | |
| action: 'create', | |
| path, | |
| content, | |
| }, | |
| }) | |
| expect(create.status()).toBe(200) | |
| const tree = await request.get('/api/docs/tree', { headers: API_KEY_HEADER }) | |
| expect(tree.status()).toBe(200) | |
| const treeBody = await tree.json() | |
| expect(Array.isArray(treeBody.tree)).toBe(true) | |
| const search = await request.get(`/api/docs/search?q=${encodeURIComponent(`kb-search-${stamp}`)}`, { | |
| headers: API_KEY_HEADER, | |
| }) | |
| expect(search.status()).toBe(200) | |
| const searchBody = await search.json() | |
| const found = searchBody.results.find((r: any) => r.path === path) | |
| expect(found).toBeTruthy() | |
| const doc = await request.get(`/api/docs/content?path=${encodeURIComponent(path)}`, { | |
| headers: API_KEY_HEADER, | |
| }) | |
| expect(doc.status()).toBe(200) | |
| const docBody = await doc.json() | |
| expect(docBody.path).toBe(path) | |
| expect(docBody.content).toContain(`kb-search-${stamp}`) | |
| const cleanup = await request.delete('/api/memory', { | |
| headers: API_KEY_HEADER, | |
| data: { | |
| action: 'delete', | |
| path, | |
| }, | |
| }) | |
| expect(cleanup.status()).toBe(200) | |
| }) | |
| test('docs APIs require auth', async ({ request }) => { | |
| const tree = await request.get('/api/docs/tree') | |
| expect(tree.status()).toBe(401) | |
| const search = await request.get('/api/docs/search?q=deployment') | |
| expect(search.status()).toBe(401) | |
| const content = await request.get('/api/docs/content?path=knowledge-base/example.md') | |
| expect(content.status()).toBe(401) | |
| }) | |
| }) | |