hub-detail-read-actions-roles.test.mjs
sha256:c2dbf04d56308f3bbf2d06e6d2eb022b8948b1e827195fe525a44e5e18d5f9c0
feat(auth): Phase B Connect cloud agent (RFC 8628) + Hermes…
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
1 commit
sha256:93bcf8f9bd56d8c5b9339f4ec73b9ebd66571398d56262d38eedc2cfa9db9882
fix(test): align Band B landing assertion with desktop MCP …
Human
11 days ago