Files
stack/packages/organization/tests/project-repo.test.mjs
jason.woltje a8d9eecf65 organization: move packages/business to packages/organization (rename r2 stage B1)
git mv packages/business -> packages/organization (@mosaic/organization). The
old package stays as one-line re-export shims of each moved module, with
src/business.mjs re-exporting src/organization-config.mjs and src/cli.mjs
forwarding to the moved executable. BusinessError is OrganizationConfigError
(one constructor, name kept BusinessError); OrganizationError stays distinct.
The bus adapter gains organization-context.mjs (busOrganization), with
business.mjs (busBusiness) as the same function.

Import consumers, manifests, the lockfile, scripts/mosaic, stack-copy.sh
COPY_PATHS (both roots), seat sandbox RUNNER_FILES and the copy closure
walker (organization-imports.mjs, both roots required) move to the new path.
v1 serialization, v1 writers and the stage A fixtures are unchanged; the stage
A contract tests stay where they were and pass as before.
2026-11-09 11:47:48 -06:00

30 lines
1.7 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { join } from 'node:path';
import { businessDoc, REPO_ROLES, tmp } from './helpers.mjs';
import { validateBusinessDocument } from '../src/organization-config.mjs';
import { projectRepo } from '../../project/src/index.mjs';
test('optional project repo is preserved and must be a normalized absolute path', () => {
const root = tmp(), doc = businessDoc(root), file = join(root, 'businesses/acme.json');
const check = () => validateBusinessDocument(doc, file, { rolesDir: REPO_ROLES });
assert.ok(!Object.hasOwn(check().projects.stack, 'repo'));
doc.projects.stack.repo = join(root, 'records');
assert.equal(check().projects.stack.repo, join(root, 'records'));
for (const value of ['relative', '/records/../outside', '/records\0bad', 1, null, {}]) {
doc.projects.stack.repo = value;
assert.throws(check, /repo.*normalized absolute path/);
}
});
test('loaded business project repo cannot be nested in any declared code checkout', () => {
const root = tmp(), doc = businessDoc(root), file = join(root, 'businesses/acme.json');
doc.projects.other = { root: join(root, 'other-code') };
doc.projects.stack.repo = join(doc.projects.other.root, 'records');
const business = validateBusinessDocument(doc, file, { rolesDir: REPO_ROLES });
const context = { business, project: 'stack', dataRoot: join(root, 'data') };
assert.throws(() => projectRepo(context), { code: 'project-path' });
doc.projects.stack.repo = join(root, 'safe-records');
const safe = validateBusinessDocument(doc, file, { rolesDir: REPO_ROLES });
assert.equal(projectRepo({ ...context, business: safe }), doc.projects.stack.repo);
});