diff --git a/__tests__/main.spec.ts b/__tests__/main.spec.ts index a4fbdc13..d540b3e4 100644 --- a/__tests__/main.spec.ts +++ b/__tests__/main.spec.ts @@ -704,7 +704,6 @@ test('processing a stale PR will rotten it but not close it when days-before-pr- ...DefaultProcessorOptions, daysBeforeClose: 30, daysBeforeRotten: 0, - daysBeforePrClose: 30 }; const TestIssueList: Issue[] = [ @@ -1538,11 +1537,11 @@ test('when the option "labelsToRemoveWhenStale" is set, the labels should be rem expect(processor.removedLabelIssues).toHaveLength(1); }); -test('stale label should not be removed if a comment was added by the bot (and the issue should be rotten)', async () => { +test('stale label should not be removed if a comment was added by the bot, given that it does not get rotten', async () => { const opts = { ...DefaultProcessorOptions, removeStaleWhenUpdated: true, - daysBeforeRotten: 0 + daysBeforeRotten: -1 }; github.context.actor = 'abot'; const TestIssueList: Issue[] = [ @@ -1576,8 +1575,8 @@ test('stale label should not be removed if a comment was added by the bot (and t // process our fake issue list await processor.processIssues(1); - expect(processor.closedIssues).toHaveLength(0); - expect(processor.rottenIssues).toHaveLength(1); + expect(processor.closedIssues).toHaveLength(1); + expect(processor.rottenIssues).toHaveLength(0); expect(processor.staleIssues).toHaveLength(0); expect(processor.removedLabelIssues).toHaveLength(0); }); @@ -1651,7 +1650,7 @@ test('stale issues should not be closed until after the closed number of days', test('stale issues should be rotten if the rotten nubmer of days (additive) is also passed', async () => { const opts = {...DefaultProcessorOptions}; opts.daysBeforeStale = 5; // stale after 5 days - opts.daysBeforeRotten = 1; // closes after 6 days + opts.daysBeforeRotten = 1; // rotten after 6 days const lastUpdate = new Date(); lastUpdate.setDate(lastUpdate.getDate() - 7); const TestIssueList: Issue[] = [ @@ -1679,7 +1678,7 @@ test('stale issues should be rotten if the rotten nubmer of days (additive) is a expect(processor.closedIssues).toHaveLength(0); expect(processor.rottenIssues).toHaveLength(1); - expect(processor.removedLabelIssues).toHaveLength(0); + expect(processor.removedLabelIssues).toHaveLength(1); // the stale label should be removed on rotten label being added expect(processor.staleIssues).toHaveLength(0); }); @@ -2770,7 +2769,7 @@ test('processing an issue stale since less than the daysBeforeStale with a stale // process our fake issue list await processor.processIssues(1); - expect(processor.removedLabelIssues).toHaveLength(0); + expect(processor.removedLabelIssues).toHaveLength(1); // The stale label should be removed on adding the rotten label expect(processor.rottenIssues).toHaveLength(1); // Expected at 0 by the user expect(processor.deletedBranchIssues).toHaveLength(0); expect(processor.closedIssues).toHaveLength(0); diff --git a/src/classes/issues-processor.ts b/src/classes/issues-processor.ts index 05423aaf..b7f31bd9 100644 --- a/src/classes/issues-processor.ts +++ b/src/classes/issues-processor.ts @@ -908,6 +908,9 @@ export class IssuesProcessor { this._getDaysBeforeRottenUsedOptionName(issue) )} (${LoggerService.cyan(daysBeforeRotten)})` ); + // remove the stale label before marking the issue as rotten + await this._removeStaleLabel(issue, staleLabel); + await this._markRotten( issue, rottenMessage,