@@ -11,6 +11,19 @@ const cli = {
1111 error ( ) { }
1212} ;
1313
14+ function assertExits ( fn ) {
15+ const originalExit = process . exit ;
16+ process . exit = ( ) => {
17+ throw new Error ( 'process.exit' ) ;
18+ } ;
19+
20+ try {
21+ assert . throws ( fn , / p r o c e s s \. e x i t / ) ;
22+ } finally {
23+ process . exit = originalExit ;
24+ }
25+ }
26+
1427function report ( id , rating , affectedVersions = [ '24.x' ] ) {
1528 return {
1629 id,
@@ -46,6 +59,16 @@ describe('security_release: severity announcement', () => {
4659 'The highest severity issue fixed in this release is MEDIUM.'
4760 ) ;
4861 } ) ;
62+
63+ it ( 'ignores invalid severity ratings' , ( ) => {
64+ const reports = [
65+ report ( 1 , 'low' ) ,
66+ report ( 2 , 'hypercritical' ) ,
67+ report ( 3 , 'medium' )
68+ ] ;
69+
70+ assert . strictEqual ( getHighestSeverity ( reports ) , 'MEDIUM' ) ;
71+ } ) ;
4972} ) ;
5073
5174describe ( 'security_blog: pre-release severity wording' , ( ) => {
@@ -59,7 +82,7 @@ describe('security_blog: pre-release severity wording', () => {
5982 } ;
6083
6184 assert . strictEqual (
62- blog . getVulnerabilities ( content ) ,
85+ blog . getPreReleaseVulnerabilities ( content ) ,
6386 'The highest severity issue fixed in this release is MEDIUM.'
6487 ) ;
6588 } ) ;
@@ -80,4 +103,94 @@ describe('security_blog: pre-release severity wording', () => {
80103 'The highest severity issue fixed in the 20.x release line is HIGH.'
81104 ) ;
82105 } ) ;
106+
107+ it ( 'replaces the pre-release template placeholder with the highest severity sentence' , ( ) => {
108+ const blog = new SecurityBlog ( cli ) ;
109+ const template = blog . getSecurityPreReleaseTemplate ( ) ;
110+ const preRelease = blog . buildPreRelease ( template , {
111+ annoucementDate : '2026-06-01T00:00:00.000Z' ,
112+ releaseDate : 'Tuesday, June 2, 2026' ,
113+ affectedVersions : '24.x, 22.x' ,
114+ vulnerabilities : blog . getPreReleaseVulnerabilities ( {
115+ reports : [
116+ report ( 1 , 'low' ) ,
117+ report ( 2 , 'high' )
118+ ]
119+ } ) ,
120+ slug : 'june-2026-security-releases' ,
121+ impact : 'The highest severity issue fixed in the 24.x release line is HIGH.'
122+ } ) ;
123+
124+ assert . match (
125+ preRelease ,
126+ / T h e h i g h e s t s e v e r i t y i s s u e f i x e d i n t h i s r e l e a s e i s H I G H \. /
127+ ) ;
128+ assert . doesNotMatch ( preRelease , / % V U L N E R A B I L I T I E S % / ) ;
129+ } ) ;
130+
131+ it ( 'exits when a report is missing a severity rating' , ( ) => {
132+ const errors = [ ] ;
133+ const blog = new SecurityBlog ( {
134+ error ( message ) {
135+ errors . push ( message ) ;
136+ }
137+ } ) ;
138+ const content = {
139+ reports : [
140+ {
141+ id : 1 ,
142+ severity : { } ,
143+ affectedVersions : [ '24.x' ]
144+ }
145+ ]
146+ } ;
147+
148+ assertExits ( ( ) => blog . getPreReleaseVulnerabilities ( content ) ) ;
149+ assertExits ( ( ) => blog . getImpact ( content ) ) ;
150+ assert . deepStrictEqual ( errors , [
151+ 'severity.rating not found for report 1.' ,
152+ 'severity.rating not found for report 1.'
153+ ] ) ;
154+ } ) ;
155+ } ) ;
156+
157+ describe ( 'security_blog: post-release severity wording' , ( ) => {
158+ it ( 'keeps the vulnerability count list' , ( ) => {
159+ const blog = new SecurityBlog ( cli ) ;
160+ const content = {
161+ reports : [
162+ report ( 1 , 'low' ) ,
163+ report ( 2 , 'medium' ) ,
164+ report ( 3 , 'medium' )
165+ ]
166+ } ;
167+
168+ assert . strictEqual (
169+ blog . getVulnerabilities ( content ) ,
170+ '- 1 low severity issues.\n- 2 medium severity issues.'
171+ ) ;
172+ } ) ;
173+
174+ it ( 'exits when a report is missing a severity rating' , ( ) => {
175+ const errors = [ ] ;
176+ const blog = new SecurityBlog ( {
177+ error ( message ) {
178+ errors . push ( message ) ;
179+ }
180+ } ) ;
181+ const content = {
182+ reports : [
183+ {
184+ id : 1 ,
185+ severity : { } ,
186+ affectedVersions : [ '24.x' ]
187+ }
188+ ]
189+ } ;
190+
191+ assertExits ( ( ) => blog . getVulnerabilities ( content ) ) ;
192+ assert . deepStrictEqual ( errors , [
193+ 'severity.rating not found for report 1.'
194+ ] ) ;
195+ } ) ;
83196} ) ;
0 commit comments