Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/create-docs-pr.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ async function getFrontMatter(tagName, frontMatterFile) {
}

return {
security: JSON.stringify(frontmatter.changes.security),
bugfixes: JSON.stringify(frontmatter.changes.bugfixes),
features: JSON.stringify(frontmatter.changes.features)
security: JSON.stringify(frontmatter.changes.security || []),
bugfixes: JSON.stringify(frontmatter.changes.bugfixes || []),
features: JSON.stringify(frontmatter.changes.features || [])
}
}

Expand Down
24 changes: 24 additions & 0 deletions bin/test/create-docs-pr.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ tap.test('Create Docs PR script', (testHarness) => {
t.test('should throw an error if there is no frontmatter', async (t) => {
mockFs.readFile.yields(null, JSON.stringify({ entries: [{ version: '1.2.3', changes: [] }] }))

// eslint-disable-next-line sonarjs/no-duplicate-string
const func = () => script.getFrontMatter('v2.0.0', 'changelog.json')
t.rejects(func, 'Unable to find 2.0.0 entry in changelog.json')

Expand Down Expand Up @@ -106,6 +107,29 @@ tap.test('Create Docs PR script', (testHarness) => {
})
t.end()
})

t.test('should return empty arrays if missing changes', async (t) => {
mockFs.readFile.yields(
null,
JSON.stringify({
entries: [
{
version: '2.0.0',
changes: {}
}
]
})
)

const result = await script.getFrontMatter('v2.0.0', 'changelog.json')

t.same(result, {
security: '[]',
bugfixes: '[]',
features: '[]'
})
t.end()
})
})

testHarness.test('formatReleaseNotes', (t) => {
Expand Down
3 changes: 2 additions & 1 deletion changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"version": "11.23.0",
"changes": {
"security": [],
"bugfixes": [],
"features": [
"Added support for account level governance of AI Monitoring"
]
Expand Down Expand Up @@ -514,4 +515,4 @@
}
}
]
}
}