Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions __tests__/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ test('stale issues should not be closed if days is set to -1', async () => {
expect(processor.removedLabelIssues).toHaveLength(0);
});

test('stale label should be removed if a comment was added to a stale issue', async () => {
test('stale label should be removed if a user comment was added to a stale issue', async () => {
const opts = {...DefaultProcessorOptions, removeStaleWhenUpdated: true};
const TestIssueList: Issue[] = [
generateIssue(
Expand Down Expand Up @@ -1247,6 +1247,44 @@ test('stale label should be removed if a comment was added to a stale issue', as
expect(processor.removedLabelIssues).toHaveLength(1);
});

test('stale label should not be removed if a bot comment was added to a stale issue', async () => {
const opts = {...DefaultProcessorOptions, removeStaleWhenUpdated: true};
const TestIssueList: Issue[] = [
generateIssue(
opts,
1,
'An issue that should un-stale',
'2020-01-01T17:00:00Z',
'2020-01-01T17:00:00Z',
false,
false,
['Stale']
)
];
const processor = new IssuesProcessorMock(
opts,
alwaysFalseStateMock,
async p => (p === 1 ? TestIssueList : []),
async () => [
{
user: {
login: 'notme',
type: 'Bot'
},
body: 'Body'
}
], // return a fake comment to indicate there was an update
async () => new Date().toDateString()
);

// process our fake issue list
await processor.processIssues(1);

expect(processor.closedIssues).toHaveLength(1);
expect(processor.staleIssues).toHaveLength(0);
expect(processor.removedLabelIssues).toHaveLength(0);
});

test('when the option "labelsToAddWhenUnstale" is set, the labels should be added when unstale', async () => {
expect.assertions(4);
const opts = {
Expand Down Expand Up @@ -1360,7 +1398,7 @@ test('stale label should not be removed if a comment was added by the bot (and t
{
user: {
login: 'abot',
type: 'User'
type: 'Bot'
},
body: 'This issue is stale'
}
Expand Down
Loading
Loading