hosted-write-eval-kn-b-e2e.test.mjs
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6
docs: record AIP-b SD-21 land (KN #308)
Human
9 days ago
| 1 | /** |
| 2 | * HOSTED-WRITE-EVAL-KN-b — Tier 3 e2e: Node Hub propose+approve applies note under reviewed/. |
| 3 | */ |
| 4 | import { describe, it, beforeEach, afterEach } from 'node:test'; |
| 5 | import assert from 'node:assert/strict'; |
| 6 | import fs from 'node:fs'; |
| 7 | import os from 'node:os'; |
| 8 | import path from 'node:path'; |
| 9 | import { createProposal, getProposal, updateProposalStatus, evaluationAllowsApprove } from '../hub/proposals-store.mjs'; |
| 10 | import { personalSelfApplyAllowsApprove, SCOOLING_REVIEW_TRAY_INTENT } from '../lib/hub-proposal-personal-self-apply.mjs'; |
| 11 | import { writeNote } from '../lib/write.mjs'; |
| 12 | import { readNote } from '../lib/vault.mjs'; |
| 13 | |
| 14 | describe('HOSTED-WRITE-EVAL-KN-b e2e — propose+approve apply', () => { |
| 15 | /** @type {string} */ |
| 16 | let dataDir; |
| 17 | /** @type {string} */ |
| 18 | let vaultPath; |
| 19 | |
| 20 | beforeEach(() => { |
| 21 | dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'kt-hwe-e2e-')); |
| 22 | vaultPath = path.join(dataDir, 'vault'); |
| 23 | fs.mkdirSync(vaultPath, { recursive: true }); |
| 24 | }); |
| 25 | |
| 26 | afterEach(() => { |
| 27 | fs.rmSync(dataDir, { recursive: true, force: true }); |
| 28 | }); |
| 29 | |
| 30 | it('member-class actor create+approve writes reviewed/*.md', async () => { |
| 31 | const actor = 'google:learner'; |
| 32 | const notePath = 'reviewed/e2e-self-apply.md'; |
| 33 | const body = '# Applied note\n\nhello'; |
| 34 | const proposal = createProposal(dataDir, { |
| 35 | path: notePath, |
| 36 | body, |
| 37 | intent: SCOOLING_REVIEW_TRAY_INTENT, |
| 38 | external_ref: 'scooling.review:e2e-self-apply', |
| 39 | evaluationRequired: true, |
| 40 | proposed_by: actor, |
| 41 | source: 'human', |
| 42 | }); |
| 43 | assert.equal(proposal.evaluation_status, 'passed'); |
| 44 | assert.equal(evaluationAllowsApprove(proposal), true); |
| 45 | assert.equal( |
| 46 | personalSelfApplyAllowsApprove({ |
| 47 | proposal, |
| 48 | hasVaultWrite: true, |
| 49 | partitionOwned: true, |
| 50 | role: 'member', |
| 51 | }), |
| 52 | true, |
| 53 | ); |
| 54 | |
| 55 | await writeNote(vaultPath, proposal.path, { |
| 56 | body: proposal.body, |
| 57 | frontmatter: proposal.frontmatter || {}, |
| 58 | }); |
| 59 | updateProposalStatus(dataDir, proposal.proposal_id, 'approved'); |
| 60 | |
| 61 | const onDisk = readNote(vaultPath, notePath); |
| 62 | assert.equal(onDisk.body.trimEnd(), body.trimEnd()); |
| 63 | assert.equal(getProposal(dataDir, proposal.proposal_id).status, 'approved'); |
| 64 | assert.match(notePath, /^reviewed\/.+\.md$/); |
| 65 | }); |
| 66 | }); |
File History
1 commit
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6
docs: record AIP-b SD-21 land (KN #308)
Human
9 days ago