11import { logger } from '@maz-ui/node'
22import { beforeEach , describe , expect , it , vi } from 'vitest'
33import { createMockConfig } from '../../../tests/mocks'
4- import { buildChangelogBody , collectContributorNames , executeHook , getPackagesOrBumpedPackages , getRootPackage , getSlackToken , getSlackWebhookUrl , getTwitterCredentials , isPrerelease , loadRelizyConfig , postReleaseToSlack , postReleaseToTwitter , resolveTags } from '../../core'
4+ import { collectContributorNames , executeHook , generateChangelog , getPackagesOrBumpedPackages , getRootPackage , getSlackToken , getSlackWebhookUrl , getTwitterCredentials , isPrerelease , loadRelizyConfig , postReleaseToSlack , postReleaseToTwitter , resolveTags } from '../../core'
55import { aiSafetyCheck , generateAISocialChangelog } from '../../core/ai'
66import { social , socialSafetyCheck } from '../social'
77
@@ -17,8 +17,9 @@ vi.mock('../../core', () => ({
1717 getPackagesOrBumpedPackages : vi . fn ( ) ,
1818 executeHook : vi . fn ( ) ,
1919 getRootPackage : vi . fn ( ) ,
20+ getPackageCommits : vi . fn ( ) . mockResolvedValue ( [ ] ) ,
21+ generateChangelog : vi . fn ( ) . mockResolvedValue ( '- Feature' ) ,
2022 resolveTags : vi . fn ( ) ,
21- buildChangelogBody : vi . fn ( ) ,
2223 isPrerelease : vi . fn ( ) ,
2324 getTwitterCredentials : vi . fn ( ) ,
2425 postReleaseToTwitter : vi . fn ( ) ,
@@ -208,7 +209,7 @@ describe('Given social command', () => {
208209 commits : [ ] ,
209210 } )
210211 vi . mocked ( resolveTags ) . mockResolvedValue ( { from : 'v0.9.0' , to : 'v1.0.0' } )
211- vi . mocked ( buildChangelogBody ) . mockReturnValue ( '- Feature' )
212+ vi . mocked ( generateChangelog ) . mockResolvedValue ( '- Feature' )
212213 vi . mocked ( isPrerelease ) . mockReturnValue ( false )
213214 vi . mocked ( getTwitterCredentials ) . mockReturnValue ( {
214215 apiKey : 'key' ,
@@ -466,7 +467,7 @@ describe('Given social command', () => {
466467 ai : { social : { twitter : { enabled : true } } } ,
467468 } )
468469 vi . mocked ( loadRelizyConfig ) . mockResolvedValue ( config )
469- vi . mocked ( buildChangelogBody ) . mockReturnValue ( '- Feature A\n- Feature B' )
470+ vi . mocked ( generateChangelog ) . mockResolvedValue ( '- Feature A\n- Feature B' )
470471 vi . mocked ( generateAISocialChangelog ) . mockResolvedValue ( 'AI rewritten tweet' )
471472
472473 await social ( { bumpResult : { bumped : true , bumpedPackages : [ ] } } )
@@ -499,7 +500,7 @@ describe('Given social command', () => {
499500 ai : { social : { slack : { enabled : true } } } ,
500501 } )
501502 vi . mocked ( loadRelizyConfig ) . mockResolvedValue ( config )
502- vi . mocked ( buildChangelogBody ) . mockReturnValue ( '- Feature A' )
503+ vi . mocked ( generateChangelog ) . mockResolvedValue ( '- Feature A' )
503504 vi . mocked ( generateAISocialChangelog ) . mockResolvedValue ( 'AI rewritten slack message' )
504505
505506 await social ( { bumpResult : { bumped : true , bumpedPackages : [ ] } } )
@@ -531,7 +532,7 @@ describe('Given social command', () => {
531532 ai : { social : { twitter : { enabled : true } , slack : { enabled : true } } } ,
532533 } )
533534 vi . mocked ( loadRelizyConfig ) . mockResolvedValue ( config )
534- vi . mocked ( buildChangelogBody ) . mockReturnValue ( '- Feature' )
535+ vi . mocked ( generateChangelog ) . mockResolvedValue ( '- Feature' )
535536 vi . mocked ( generateAISocialChangelog )
536537 . mockResolvedValueOnce ( 'AI tweet' )
537538 . mockResolvedValueOnce ( 'AI slack' )
@@ -562,7 +563,7 @@ describe('Given social command', () => {
562563 ai : { social : { twitter : { enabled : true } } } ,
563564 } )
564565 vi . mocked ( loadRelizyConfig ) . mockResolvedValue ( config )
565- vi . mocked ( buildChangelogBody ) . mockReturnValue ( '' )
566+ vi . mocked ( generateChangelog ) . mockResolvedValue ( '' )
566567
567568 await social ( { bumpResult : { bumped : true , bumpedPackages : [ ] } } )
568569
@@ -584,7 +585,7 @@ describe('Given social command', () => {
584585 ai : { social : { twitter : { enabled : true } } } ,
585586 } )
586587 vi . mocked ( loadRelizyConfig ) . mockResolvedValue ( config )
587- vi . mocked ( buildChangelogBody ) . mockReturnValue ( '- Feature A' )
588+ vi . mocked ( generateChangelog ) . mockResolvedValue ( '- Feature A' )
588589 vi . mocked ( isPrerelease ) . mockReturnValue ( true )
589590
590591 await social ( {
@@ -609,7 +610,7 @@ describe('Given social command', () => {
609610 ai : { social : { slack : { enabled : true } } } ,
610611 } )
611612 vi . mocked ( loadRelizyConfig ) . mockResolvedValue ( config )
612- vi . mocked ( buildChangelogBody ) . mockReturnValue ( '- Feature A' )
613+ vi . mocked ( generateChangelog ) . mockResolvedValue ( '- Feature A' )
613614 vi . mocked ( isPrerelease ) . mockReturnValue ( true )
614615
615616 await social ( {
@@ -636,7 +637,7 @@ describe('Given social command', () => {
636637 ai : { social : { twitter : { enabled : true } } } ,
637638 } )
638639 vi . mocked ( loadRelizyConfig ) . mockResolvedValue ( config )
639- vi . mocked ( buildChangelogBody ) . mockReturnValue ( '- Feature A' )
640+ vi . mocked ( generateChangelog ) . mockResolvedValue ( '- Feature A' )
640641 vi . mocked ( isPrerelease ) . mockReturnValue ( true )
641642 vi . mocked ( generateAISocialChangelog ) . mockResolvedValue ( 'AI tweet' )
642643
0 commit comments