hub-detail-read-actions-roles.test.mjs
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠ breaking
11 days ago
| 1 | /** |
| 2 | * Contract: note detail read-mode actions must not disappear for viewer/evaluator. |
| 3 | * Previously attachNoteDetailReadActions returned early when !hubUserCanWriteNotes(), |
| 4 | * leaving only the footer Close button. |
| 5 | */ |
| 6 | import { readFileSync } from 'node:fs'; |
| 7 | import { fileURLToPath } from 'node:url'; |
| 8 | import { dirname, join } from 'node:path'; |
| 9 | import test from 'node:test'; |
| 10 | import assert from 'node:assert/strict'; |
| 11 | |
| 12 | const root = join(dirname(fileURLToPath(import.meta.url)), '..'); |
| 13 | const hubJs = readFileSync(join(root, 'web', 'hub', 'hub.js'), 'utf8'); |
| 14 | |
| 15 | test('hub.js defines export + propose helpers separate from hubUserCanWriteNotes', () => { |
| 16 | assert.match(hubJs, /function hubUserMayProposeFromNote\(\)/); |
| 17 | assert.match(hubJs, /function hubUserCanExportNote\(\)/); |
| 18 | }); |
| 19 | |
| 20 | test('attachNoteDetailReadActions does not bail out only on !hubUserCanWriteNotes()', () => { |
| 21 | const fn = hubJs.match(/function attachNoteDetailReadActions\(actionsEl\)\s*\{[\s\S]{0,2200}?\n\s*\}/); |
| 22 | assert.ok(fn, 'expected attachNoteDetailReadActions block'); |
| 23 | assert.doesNotMatch( |
| 24 | fn[0], |
| 25 | /function attachNoteDetailReadActions\([\s\S]*?if\s*\(\s*!hubUserCanWriteNotes\(\)\s*\)\s*return/, |
| 26 | 'read actions must not return immediately when the user cannot write notes', |
| 27 | ); |
| 28 | }); |
| 29 | |
| 30 | test('self-hosted Hub export route allows viewer and evaluator', () => { |
| 31 | const serverPath = join(root, 'hub', 'server.mjs'); |
| 32 | const src = readFileSync(serverPath, 'utf8'); |
| 33 | assert.match( |
| 34 | src, |
| 35 | /app\.post\(\s*['"]\/api\/v1\/export['"][\s\S]*?requireRole\(\s*['"]viewer['"]\s*,\s*['"]editor['"]\s*,\s*['"]admin['"]\s*,\s*['"]evaluator['"]\s*\)/, |
| 36 | ); |
| 37 | }); |
File History
3 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