@@ -226,7 +226,7 @@ describe('Azure DevOps Commit Validator', () => {
226226 await run ( ) ;
227227
228228 expect ( mockSetFailed ) . toHaveBeenCalledWith (
229- 'Azure DevOps organization is required when link-commits-to-pull-request is true '
229+ 'The following input is required when link-commits-to-pull-request is enabled: azure-devops-organization '
230230 ) ;
231231 } ) ;
232232
@@ -249,11 +249,11 @@ describe('Azure DevOps Commit Validator', () => {
249249 await run ( ) ;
250250
251251 expect ( mockSetFailed ) . toHaveBeenCalledWith (
252- 'Azure DevOps token is required when link-commits-to-pull-request is true '
252+ 'The following input is required when link-commits-to-pull-request is enabled: azure-devops-token '
253253 ) ;
254254 } ) ;
255255
256- it ( 'should pass when link-commits-to-pull-request is false even if azure-devops config is missing' , async ( ) => {
256+ it ( 'should pass when link-commits-to-pull-request is false and validate-work-item-exists is false even if azure-devops config is missing' , async ( ) => {
257257 mockGetInput . mockImplementation ( name => {
258258 const defaults = {
259259 'check-pull-request' : 'false' ,
@@ -264,7 +264,7 @@ describe('Azure DevOps Commit Validator', () => {
264264 'azure-devops-organization' : '' ,
265265 'github-token' : 'github-token' ,
266266 'comment-on-failure' : 'true' ,
267- 'validate-work-item-exists' : 'false'
267+ 'validate-work-item-exists' : 'false' // Validation disabled
268268 } ;
269269 return defaults [ name ] || '' ;
270270 } ) ;
@@ -278,9 +278,55 @@ describe('Azure DevOps Commit Validator', () => {
278278
279279 await run ( ) ;
280280
281- // Should not call setFailed for missing Azure DevOps config since linking is disabled
281+ // Should not call setFailed for missing Azure DevOps config since both features are disabled
282282 expect ( mockSetFailed ) . not . toHaveBeenCalled ( ) ;
283283 } ) ;
284+
285+ it ( 'should fail when validate-work-item-exists is true but azure-devops credentials are missing' , async ( ) => {
286+ mockGetInput . mockImplementation ( name => {
287+ const defaults = {
288+ 'check-pull-request' : 'false' ,
289+ 'check-commits' : 'true' ,
290+ 'fail-if-missing-workitem-commit-link' : 'true' ,
291+ 'link-commits-to-pull-request' : 'false' , // Linking disabled
292+ 'azure-devops-token' : '' ,
293+ 'azure-devops-organization' : '' ,
294+ 'github-token' : 'github-token' ,
295+ 'comment-on-failure' : 'true' ,
296+ 'validate-work-item-exists' : 'true' // Validation enabled but no credentials
297+ } ;
298+ return defaults [ name ] || '' ;
299+ } ) ;
300+
301+ await run ( ) ;
302+
303+ expect ( mockSetFailed ) . toHaveBeenCalledWith (
304+ 'The following inputs are required when validate-work-item-exists is enabled: azure-devops-organization, azure-devops-token'
305+ ) ;
306+ } ) ;
307+
308+ it ( 'should fail when both link-commits-to-pull-request and validate-work-item-exists are true but credentials are missing' , async ( ) => {
309+ mockGetInput . mockImplementation ( name => {
310+ const defaults = {
311+ 'check-pull-request' : 'false' ,
312+ 'check-commits' : 'true' ,
313+ 'fail-if-missing-workitem-commit-link' : 'true' ,
314+ 'link-commits-to-pull-request' : 'true' , // Linking enabled
315+ 'azure-devops-token' : '' ,
316+ 'azure-devops-organization' : '' ,
317+ 'github-token' : 'github-token' ,
318+ 'comment-on-failure' : 'true' ,
319+ 'validate-work-item-exists' : 'true' // Validation also enabled
320+ } ;
321+ return defaults [ name ] || '' ;
322+ } ) ;
323+
324+ await run ( ) ;
325+
326+ expect ( mockSetFailed ) . toHaveBeenCalledWith (
327+ 'The following inputs are required when link-commits-to-pull-request or validate-work-item-exists are enabled: azure-devops-organization, azure-devops-token'
328+ ) ;
329+ } ) ;
284330 } ) ;
285331
286332 describe ( 'Commit validation' , ( ) => {
@@ -1277,9 +1323,9 @@ describe('Azure DevOps Commit Validator', () => {
12771323
12781324 await run ( ) ;
12791325
1280- // Should fail due to missing Azure DevOps organization
1326+ // Should fail due to missing Azure DevOps organization and token
12811327 expect ( mockSetFailed ) . toHaveBeenCalledWith (
1282- 'Azure DevOps organization is required when link-commits-to-pull-request is true '
1328+ 'The following inputs are required when link-commits-to-pull-request is enabled: azure-devops-organization, azure-devops-token '
12831329 ) ;
12841330 // Should not call linkWorkItem since validation failed
12851331 expect ( mockLinkWorkItem ) . not . toHaveBeenCalled ( ) ;
0 commit comments