@@ -12,6 +12,7 @@ vi.mock( '../../src/utils/constants.js', () => {
12
12
ISSUE_PATTERN : / ^ \d + $ / ,
13
13
ISSUE_SLUG_PATTERN : / ^ (?< owner > [ a - z 0 - 9 . - ] + ) \/ (?< repository > [ a - z 0 - 9 . - ] + ) # (?< number > \d + ) $ / ,
14
14
ISSUE_URL_PATTERN : / ^ (?< base > h t t p s : \/ \/ g i t h u b \. c o m ) \/ (?< owner > [ a - z 0 - 9 . - ] + ) \/ (?< repository > [ a - z 0 - 9 . - ] + ) \/ i s s u e s \/ (?< number > \d + ) $ / ,
15
+ NICK_NAME_PATTERN : / ^ @ [ a - z 0 - 9 - _ ] + $ / i,
15
16
TYPES : [
16
17
{ name : 'Feature' } ,
17
18
{ name : 'Other' } ,
@@ -317,30 +318,71 @@ describe( 'validateEntry()', () => {
317
318
} ) ;
318
319
} ) ;
319
320
321
+ describe ( 'communityCredits validation' , ( ) => {
322
+ it ( 'should add validation message but remain valid when community username is not valid GitHub username' , ( ) => {
323
+ const entry : ParsedFile = createEntry ( { type : 'Feature' , communityCredits : [ '@i n v a l i d n a m e' ] } ) ;
324
+
325
+ const { isValid, validatedEntry } = validateEntry ( entry , packageNames , false ) ;
326
+
327
+ expect ( isValid ) . toBeTruthy ( ) ;
328
+ expect ( validatedEntry . data . validations ) . toContain (
329
+ 'Community username "@i n v a l i d n a m e" is not valid GitHub username.'
330
+ ) ;
331
+ expect ( validatedEntry . data . communityCredits ) . toEqual ( [ ] ) ;
332
+ } ) ;
333
+
334
+ it ( 'should return valid when community username is valid GitHub username' , ( ) => {
335
+ const entry : ParsedFile = createEntry ( { type : 'Feature' , communityCredits : [ '@exampleName123' ] } ) ;
336
+
337
+ const { isValid, validatedEntry } = validateEntry ( entry , packageNames , false ) ;
338
+
339
+ expect ( isValid ) . toBeTruthy ( ) ;
340
+ expect ( validatedEntry . data . communityCredits ) . toEqual ( [ '@exampleName123' ] ) ;
341
+ } ) ;
342
+
343
+ it ( 'should filter out invalid community usernames while keeping valid ones' , ( ) => {
344
+ const entry : ParsedFile = createEntry ( {
345
+ type : 'Feature' ,
346
+ communityCredits : [ '@i n v a l i d n a m e' , '@exampleName123' ]
347
+ } ) ;
348
+
349
+ const { isValid, validatedEntry } = validateEntry ( entry , packageNames , false ) ;
350
+
351
+ expect ( isValid ) . toBeTruthy ( ) ;
352
+ expect ( validatedEntry . data . validations ) . toContain (
353
+ 'Community username "@i n v a l i d n a m e" is not valid GitHub username.'
354
+ ) ;
355
+ expect ( validatedEntry . data . communityCredits ) . toEqual ( [ '@exampleName123' ] ) ;
356
+ } ) ;
357
+ } ) ;
358
+
320
359
describe ( 'multiple validations' , ( ) => {
321
360
it ( 'should collect multiple validation errors but only mark as invalid for critical errors' , ( ) => {
322
361
const entry : ParsedFile = createEntry ( {
323
362
type : 'Unknown' ,
324
363
scope : [ 'unknown-package' ] ,
325
364
see : [ 'invalid-reference' ] ,
326
- closes : [ 'invalid-reference' ]
365
+ closes : [ 'invalid-reference' ] ,
366
+ communityCredits : [ '@i n v a l i d n a m e' ]
327
367
} ) ;
328
368
329
369
const { isValid, validatedEntry } = validateEntry ( entry , packageNames , false ) ;
330
370
331
371
expect ( isValid ) . toBeFalsy ( ) ;
332
- expect ( validatedEntry . data . validations ?. length ) . toBe ( 4 ) ;
372
+ expect ( validatedEntry . data . validations ?. length ) . toBe ( 5 ) ;
333
373
expect ( validatedEntry . data . scope ) . toEqual ( [ ] ) ;
334
374
expect ( validatedEntry . data . see ) . toEqual ( [ ] ) ;
335
375
expect ( validatedEntry . data . closes ) . toEqual ( [ ] ) ;
376
+ expect ( validatedEntry . data . communityCredits ) . toEqual ( [ ] ) ;
336
377
} ) ;
337
378
338
379
it ( 'should return valid for a completely valid entry' , ( ) => {
339
380
const entry : ParsedFile = createEntry ( {
340
381
type : 'Feature' ,
341
382
scope : [ 'ckeditor5-engine' ] ,
342
383
see : [ '1234' ] ,
343
- closes : [ 'ckeditor/ckeditor5#5678' ]
384
+ closes : [ 'ckeditor/ckeditor5#5678' ] ,
385
+ communityCredits : [ '@exampleName123' ]
344
386
} ) ;
345
387
346
388
const { isValid, validatedEntry } = validateEntry ( entry , packageNames , false ) ;
0 commit comments