hub-scope-filter.test.mjs
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠ breaking
11 days ago
| 1 | import { describe, it } from 'node:test'; |
| 2 | import assert from 'node:assert'; |
| 3 | import { |
| 4 | applyScopeFilterToNotes, |
| 5 | applyScopeFilterToProposals, |
| 6 | } from '../hub/lib/scope-filter.mjs'; |
| 7 | |
| 8 | describe('applyScopeFilterToProposals', () => { |
| 9 | it('returns all proposals when scope is empty', () => { |
| 10 | const ps = [{ path: 'inbox/a.md' }, { path: 'projects/foo/x.md' }]; |
| 11 | assert.deepStrictEqual(applyScopeFilterToProposals(ps, null), ps); |
| 12 | assert.deepStrictEqual(applyScopeFilterToProposals(ps, {}), ps); |
| 13 | }); |
| 14 | |
| 15 | it('filters by folder prefix like notes', () => { |
| 16 | const scope = { folders: ['inbox'] }; |
| 17 | const ps = [{ path: 'inbox/a.md' }, { path: 'other/b.md' }]; |
| 18 | assert.deepStrictEqual(applyScopeFilterToProposals(ps, scope), [{ path: 'inbox/a.md' }]); |
| 19 | }); |
| 20 | |
| 21 | it('filters by project from path projects/slug/', () => { |
| 22 | const scope = { projects: ['foo'] }; |
| 23 | const ps = [{ path: 'projects/foo/note.md' }, { path: 'projects/bar/note.md' }]; |
| 24 | assert.deepStrictEqual(applyScopeFilterToProposals(ps, scope), [{ path: 'projects/foo/note.md' }]); |
| 25 | }); |
| 26 | |
| 27 | it('filters by project from parsed frontmatter object', () => { |
| 28 | const scope = { projects: ['alpha'] }; |
| 29 | const ps = [ |
| 30 | { path: 'x.md', frontmatter: { project: 'alpha' } }, |
| 31 | { path: 'y.md', frontmatter: { project: 'beta' } }, |
| 32 | ]; |
| 33 | assert.deepStrictEqual(applyScopeFilterToProposals(ps, scope), [{ path: 'x.md', frontmatter: { project: 'alpha' } }]); |
| 34 | }); |
| 35 | |
| 36 | it('matches applyScopeFilterToNotes for same path set', () => { |
| 37 | const scope = { folders: ['inbox'], projects: ['p1'] }; |
| 38 | const notes = [ |
| 39 | { path: 'inbox/n.md', project: null }, |
| 40 | { path: 'deep/x.md', project: 'p1' }, |
| 41 | ]; |
| 42 | const proposals = [{ path: 'inbox/n.md' }, { path: 'deep/x.md', project: 'p1' }]; |
| 43 | const nf = applyScopeFilterToNotes(notes, scope).map((n) => n.path).sort(); |
| 44 | const pf = applyScopeFilterToProposals(proposals, scope).map((p) => p.path).sort(); |
| 45 | assert.deepStrictEqual(pf, nf); |
| 46 | }); |
| 47 | }); |
File History
4 commits
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠
11 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
⚠
50 days ago
sha256:6a102aafafdfe7e70a24f4e59740200f0ee713ce7915f1b53e9d4ba5ee8b4410
Initial Muse snapshot
Human
83 days ago