@@ -10,6 +10,19 @@ const cli = {
1010 error ( ) { }
1111} ;
1212
13+ function assertExits ( fn ) {
14+ const originalExit = process . exit ;
15+ process . exit = ( ) => {
16+ throw new Error ( 'process.exit' ) ;
17+ } ;
18+
19+ try {
20+ assert . throws ( fn , / p r o c e s s \. e x i t / ) ;
21+ } finally {
22+ process . exit = originalExit ;
23+ }
24+ }
25+
1326function report ( id , rating , affectedVersions = [ '24.x' ] ) {
1427 return {
1528 id,
@@ -80,6 +93,19 @@ describe('security_release: severity announcement', () => {
8093 'The highest severity issue fixed in this release is MEDIUM.'
8194 ) ;
8295 } ) ;
96+
97+ it ( 'ignores invalid severity ratings' , ( ) => {
98+ const reports = [
99+ report ( 1 , 'low' ) ,
100+ report ( 2 , 'hypercritical' ) ,
101+ report ( 3 , 'medium' )
102+ ] ;
103+
104+ assert . strictEqual (
105+ getHighestSeverityAnnouncement ( reports ) ,
106+ 'The highest severity issue fixed in this release is MEDIUM.'
107+ ) ;
108+ } ) ;
83109} ) ;
84110
85111describe ( 'security_blog: pre-release severity wording' , ( ) => {
@@ -93,9 +119,13 @@ describe('security_blog: pre-release severity wording', () => {
93119 } ;
94120
95121 assert . strictEqual (
96- blog . getVulnerabilities ( content ) ,
122+ blog . getPreReleaseVulnerabilities ( content ) ,
97123 'The highest severity issue fixed in this release is MEDIUM.'
98124 ) ;
125+ assert . strictEqual (
126+ blog . getVulnerabilities ( content ) ,
127+ '- 1 low severity issues.\n- 1 medium severity issues.'
128+ ) ;
99129 } ) ;
100130
101131 it ( 'uses the highest severity per release line in impact text' , ( ) => {
@@ -114,4 +144,94 @@ describe('security_blog: pre-release severity wording', () => {
114144 'The highest severity issue fixed in the 20.x release line is HIGH.'
115145 ) ;
116146 } ) ;
147+
148+ it ( 'replaces the pre-release template placeholder with the highest severity sentence' , ( ) => {
149+ const blog = new SecurityBlog ( cli ) ;
150+ const template = blog . getSecurityPreReleaseTemplate ( ) ;
151+ const preRelease = blog . buildPreRelease ( template , {
152+ annoucementDate : '2026-06-01T00:00:00.000Z' ,
153+ releaseDate : 'Tuesday, June 2, 2026' ,
154+ affectedVersions : '24.x, 22.x' ,
155+ vulnerabilities : blog . getPreReleaseVulnerabilities ( {
156+ reports : [
157+ report ( 1 , 'low' ) ,
158+ report ( 2 , 'high' )
159+ ]
160+ } ) ,
161+ slug : 'june-2026-security-releases' ,
162+ impact : 'The highest severity issue fixed in the 24.x release line is HIGH.'
163+ } ) ;
164+
165+ assert . match (
166+ preRelease ,
167+ / 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 \. /
168+ ) ;
169+ assert . doesNotMatch ( preRelease , / % V U L N E R A B I L I T I E S % / ) ;
170+ } ) ;
171+
172+ it ( 'exits when a report is missing a severity rating' , ( ) => {
173+ const errors = [ ] ;
174+ const blog = new SecurityBlog ( {
175+ error ( message ) {
176+ errors . push ( message ) ;
177+ }
178+ } ) ;
179+ const content = {
180+ reports : [
181+ {
182+ id : 1 ,
183+ severity : { } ,
184+ affectedVersions : [ '24.x' ]
185+ }
186+ ]
187+ } ;
188+
189+ assertExits ( ( ) => blog . getPreReleaseVulnerabilities ( content ) ) ;
190+ assertExits ( ( ) => blog . getImpact ( content ) ) ;
191+ assert . deepStrictEqual ( errors , [
192+ 'severity.rating not found for report 1.' ,
193+ 'severity.rating not found for report 1.'
194+ ] ) ;
195+ } ) ;
196+ } ) ;
197+
198+ describe ( 'security_blog: post-release severity wording' , ( ) => {
199+ it ( 'keeps the vulnerability count list' , ( ) => {
200+ const blog = new SecurityBlog ( cli ) ;
201+ const content = {
202+ reports : [
203+ report ( 1 , 'low' ) ,
204+ report ( 2 , 'medium' ) ,
205+ report ( 3 , 'medium' )
206+ ]
207+ } ;
208+
209+ assert . strictEqual (
210+ blog . getVulnerabilities ( content ) ,
211+ '- 1 low severity issues.\n- 2 medium severity issues.'
212+ ) ;
213+ } ) ;
214+
215+ it ( 'exits when a report is missing a severity rating' , ( ) => {
216+ const errors = [ ] ;
217+ const blog = new SecurityBlog ( {
218+ error ( message ) {
219+ errors . push ( message ) ;
220+ }
221+ } ) ;
222+ const content = {
223+ reports : [
224+ {
225+ id : 1 ,
226+ severity : { } ,
227+ affectedVersions : [ '24.x' ]
228+ }
229+ ]
230+ } ;
231+
232+ assertExits ( ( ) => blog . getVulnerabilities ( content ) ) ;
233+ assert . deepStrictEqual ( errors , [
234+ 'severity.rating not found for report 1.'
235+ ] ) ;
236+ } ) ;
117237} ) ;
0 commit comments