Skip to content

Commit e48e59b

Browse files
authored
Merge branch 'main' into docs/fix/lifesim-app-guide-references
2 parents 0f44072 + 2f18c95 commit e48e59b

3 files changed

Lines changed: 28 additions & 128 deletions

File tree

‎planning/2026-09-09-activation-checklist.md‎

Lines changed: 0 additions & 126 deletions
This file was deleted.

‎scripts/review/documents.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ function readRegistry(source) {
2323
return entries(source).map((e) => e.values);
2424
}
2525
function validLocation(location) {
26-
if (!/^[a-zA-Z0-9][a-zA-Z0-9_./-]*$/.test(location) || location.split('/').some((p) => !p || p === '.' || p === '..'))
26+
if (
27+
typeof location !== 'string' ||
28+
!/^[a-zA-Z0-9][a-zA-Z0-9_./-]*$/.test(location) ||
29+
location.split('/').some((p) => !p || p === '.' || p === '..')
30+
)
2731
throw Error('Invalid document location');
2832
return location;
2933
}
@@ -40,6 +44,8 @@ const ASSET_ROOTS = ['figures', 'bibliographies', 'files', 'downloads'];
4044
function registryMap(source) {
4145
const result = new Map();
4246
for (const entry of readRegistry(source)) {
47+
// Download-only landing-page tiles have no MDX document identity.
48+
if (!Object.hasOwn(entry, 'doc_location') && typeof entry.downloadUrl === 'string' && entry.downloadUrl.trim()) continue;
4349
const location = validLocation(entry.doc_location);
4450
if (result.has(location)) throw Error(`Duplicate document location: ${location}`);
4551
result.set(location, entry);

‎tests/review-documents.test.js‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
11
const test = require('node:test');
22
const assert = require('node:assert/strict');
3-
const { readRegistry, flipDraft, documentScope, publicationChanges, registryChanges } = require('../scripts/review/documents');
3+
const { readRegistry, flipDraft, documentScope, publicationChanges, registryChanges, validLocation } = require('../scripts/review/documents');
44
const source = `const docs = [{doc_location:'a/manual', active:true, draft:true},{doc_location:'b/manual',active:true,draft:true}]; module.exports={docs};`;
5+
test('actual registry supports PDF-only tiles while detecting document changes', () => {
6+
const registry = require('node:fs').readFileSync(require('node:path').join(__dirname, '../src/docConfig.js'), 'utf8');
7+
assert.deepEqual(registryChanges(registry, registry), []);
8+
const changed = registry.replace('const docs = [', "const docs = [{doc_location:'regression/manual',active:true,draft:true},");
9+
assert.deepEqual(registryChanges(registry, changed), ['regression/manual']);
10+
});
11+
12+
test('PDF-only tiles need no document path but malformed document entries are rejected', () => {
13+
const pdf = `const docs=[{downloadUrl:'/report.pdf',doc_name:'Report'}];`;
14+
assert.deepEqual(registryChanges(pdf, pdf), []);
15+
for (const entry of ['{}', "{downloadUrl:''}", "{doc_location:null,downloadUrl:'/report.pdf'}"]) {
16+
assert.throws(() => registryChanges(`const docs=[${entry}];`, source), /Invalid document location/);
17+
}
18+
});
19+
20+
test('document locations reject non-string values with a validation error', () => {
21+
for (const value of [undefined, null, 123, true, {}, '']) {
22+
assert.throws(() => validLocation(value), /Invalid document location/);
23+
}
24+
});
525
test('only the explicitly selected registry flag changes', () => {
626
const result = flipDraft(source, 'a/manual');
727
assert.equal(readRegistry(result)[0].draft, false);

0 commit comments

Comments
 (0)