@@ -65,6 +65,134 @@ test.serial('Publish a release', async (t) => {
6565 t . true ( github . isDone ( ) ) ;
6666} ) ;
6767
68+ test . serial ( 'Publish a release removing the title from the release notes by default' , async ( t ) => {
69+ const owner = 'test_user' ;
70+ const repo = 'test_repo' ;
71+ const env = { GITHUB_TOKEN : 'github_token' } ;
72+ const pluginConfig = { } ;
73+ const expectedBody = 'Test release note body' ;
74+ const nextRelease = {
75+ version : '1.0.1' ,
76+ gitTag : 'v1.0.1' ,
77+ name : 'v1.0.1' ,
78+ notes : `### [1.0.1](https://github.com/${ owner } /${ repo } /compare/v1.0.0...v1.0.1) (2020-12-12)\n\n${ expectedBody } ` ,
79+ } ;
80+ const options = { repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
81+ const releaseUrl = `https://github.com/${ owner } /${ repo } /releases/${ nextRelease . version } ` ;
82+ const releaseId = 1 ;
83+ const uploadUri = `/api/uploads/repos/${ owner } /${ repo } /releases/${ releaseId } /assets` ;
84+ const uploadUrl = `https://github.com${ uploadUri } {?name,label}` ;
85+ const branch = 'test_branch' ;
86+
87+ const github = authenticate ( env )
88+ . post ( `/repos/${ owner } /${ repo } /releases` , {
89+ tag_name : nextRelease . gitTag ,
90+ target_commitish : branch ,
91+ name : nextRelease . name ,
92+ body : expectedBody ,
93+ prerelease : false ,
94+ } )
95+ . reply ( 200 , { upload_url : uploadUrl , html_url : releaseUrl } ) ;
96+
97+ const result = await publish ( pluginConfig , {
98+ cwd,
99+ env,
100+ options,
101+ branch : { name : branch , type : 'release' , main : true } ,
102+ nextRelease,
103+ logger : t . context . logger ,
104+ } ) ;
105+
106+ t . is ( result . url , releaseUrl ) ;
107+ t . deepEqual ( t . context . log . args [ 0 ] , [ 'Published GitHub release: %s' , releaseUrl ] ) ;
108+ t . true ( github . isDone ( ) ) ;
109+ } ) ;
110+
111+ test . serial ( 'Publish a release removing the title from the release notes' , async ( t ) => {
112+ const owner = 'test_user' ;
113+ const repo = 'test_repo' ;
114+ const env = { GITHUB_TOKEN : 'github_token' } ;
115+ const pluginConfig = { removeTitleFromReleaseNotes : true } ;
116+ const expectedBody = 'Test release note body' ;
117+ const nextRelease = {
118+ version : '1.0.1' ,
119+ gitTag : 'v1.0.1' ,
120+ name : 'v1.0.1' ,
121+ notes : `### [1.0.1](https://github.com/${ owner } /${ repo } /compare/v1.0.0...v1.0.1) (2020-12-12)\n\n${ expectedBody } ` ,
122+ } ;
123+ const options = { repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
124+ const releaseUrl = `https://github.com/${ owner } /${ repo } /releases/${ nextRelease . version } ` ;
125+ const releaseId = 1 ;
126+ const uploadUri = `/api/uploads/repos/${ owner } /${ repo } /releases/${ releaseId } /assets` ;
127+ const uploadUrl = `https://github.com${ uploadUri } {?name,label}` ;
128+ const branch = 'test_branch' ;
129+
130+ const github = authenticate ( env )
131+ . post ( `/repos/${ owner } /${ repo } /releases` , {
132+ tag_name : nextRelease . gitTag ,
133+ target_commitish : branch ,
134+ name : nextRelease . name ,
135+ body : expectedBody ,
136+ prerelease : false ,
137+ } )
138+ . reply ( 200 , { upload_url : uploadUrl , html_url : releaseUrl } ) ;
139+
140+ const result = await publish ( pluginConfig , {
141+ cwd,
142+ env,
143+ options,
144+ branch : { name : branch , type : 'release' , main : true } ,
145+ nextRelease,
146+ logger : t . context . logger ,
147+ } ) ;
148+
149+ t . is ( result . url , releaseUrl ) ;
150+ t . deepEqual ( t . context . log . args [ 0 ] , [ 'Published GitHub release: %s' , releaseUrl ] ) ;
151+ t . true ( github . isDone ( ) ) ;
152+ } ) ;
153+
154+ test . serial ( 'Publish a release without removing the title from the release notes' , async ( t ) => {
155+ const owner = 'test_user' ;
156+ const repo = 'test_repo' ;
157+ const env = { GITHUB_TOKEN : 'github_token' } ;
158+ const pluginConfig = { removeTitleFromReleaseNotes : false } ;
159+ const nextRelease = {
160+ version : '1.0.1' ,
161+ gitTag : 'v1.0.1' ,
162+ name : 'v1.0.1' ,
163+ notes : `### [1.0.1](https://github.com/${ owner } /${ repo } /compare/v1.0.0...v1.0.1) (2020-12-12)\n\nTest release note body` ,
164+ } ;
165+ const options = { repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
166+ const releaseUrl = `https://github.com/${ owner } /${ repo } /releases/${ nextRelease . version } ` ;
167+ const releaseId = 1 ;
168+ const uploadUri = `/api/uploads/repos/${ owner } /${ repo } /releases/${ releaseId } /assets` ;
169+ const uploadUrl = `https://github.com${ uploadUri } {?name,label}` ;
170+ const branch = 'test_branch' ;
171+
172+ const github = authenticate ( env )
173+ . post ( `/repos/${ owner } /${ repo } /releases` , {
174+ tag_name : nextRelease . gitTag ,
175+ target_commitish : branch ,
176+ name : nextRelease . name ,
177+ body : nextRelease . notes ,
178+ prerelease : false ,
179+ } )
180+ . reply ( 200 , { upload_url : uploadUrl , html_url : releaseUrl } ) ;
181+
182+ const result = await publish ( pluginConfig , {
183+ cwd,
184+ env,
185+ options,
186+ branch : { name : branch , type : 'release' , main : true } ,
187+ nextRelease,
188+ logger : t . context . logger ,
189+ } ) ;
190+
191+ t . is ( result . url , releaseUrl ) ;
192+ t . deepEqual ( t . context . log . args [ 0 ] , [ 'Published GitHub release: %s' , releaseUrl ] ) ;
193+ t . true ( github . isDone ( ) ) ;
194+ } ) ;
195+
68196test . serial ( 'Publish a release on a channel' , async ( t ) => {
69197 const owner = 'test_user' ;
70198 const repo = 'test_repo' ;
0 commit comments