-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating to node v20 and fixing tests #186
base: main
Are you sure you want to change the base?
Changes from all commits
c6a0c74
62bff99
72d6399
da005fa
07b773a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,12 +104,13 @@ describe('Check auto demotion', () => { | |
replyGithubGetResponse('/repos/test/test/issues/1', null, issueOpenedMock) | ||
replyGithubPatchResponse('/repos/test/test/issues/1', (_, req) => { | ||
expect(req.state).toBe('closed') | ||
expect.assertions(1) | ||
return { ...issueOpenedMock, status: 'closed' } | ||
}) | ||
const action = new CheckAutoDemotionAction(apis, mockParams) | ||
const result = await action.execute() | ||
expect(result.status).toBe('success') | ||
expect.assertions(2) | ||
expect.assertions(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stebje I don't know if I did this correctly, but the number of expected assertions seemed to fail when the first one was in a closure above? I wonder if something changed with scoping. I reduced the number expected here and then added a new expectation in the block above, but let me know what you think. |
||
}) | ||
|
||
test('execute() - Issue is not closed if the duration is smaller than the current time passed', async () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -241,9 +241,10 @@ describe('Demotion report', () => { | |
try { | ||
fs.unlinkSync(path.join(__dirname, '/fixtures/1_droidpl.json')) | ||
} catch (e) { | ||
// No mater if this the file doesn't exist always | ||
// No matter if this the file doesn't exist always | ||
} | ||
}) | ||
|
||
test('execute() - Check report generated with empty audit log entries', async () => { | ||
const apis = mockApis() | ||
const mockParams = { | ||
|
@@ -253,15 +254,16 @@ describe('Demotion report', () => { | |
issueNumber: 1, | ||
duration: 1, | ||
ticket: '1234', | ||
demotionDate: new Date(Date.parse('2021-02-08T10:20:00Z')), | ||
promotionDate: new Date(Date.parse('2021-02-07T10:20:00Z')), | ||
demotionDate: '2021-02-08T10:20:00Z', | ||
promotionDate: '2021-02-07T10:20:00Z', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stebje I changed these dates back to the ISO-8601 form since the previous version was creating a more human-readable date string that seemed to break the test. Could this be related to the shift from |
||
targetOrg: 'test', | ||
reportPath: 'tests/fixtures' | ||
} | ||
|
||
replyGithubGetResponse('/orgs/test/audit-log', { | ||
include: 'all', | ||
per_page: 100, | ||
phrase: `created:>=${mockParams.promotionDate} created:<=${mockParams.demotionDate} ` | ||
phrase: `created:${mockParams.promotionDate}..${mockParams.demotionDate}` | ||
}, []) | ||
const action = new DemotionReportAction(apis, mockParams) | ||
const result = await action.execute() | ||
|
@@ -272,17 +274,17 @@ describe('Demotion report', () => { | |
issueNumber: 1, | ||
duration: 1, | ||
ticket: '1234', | ||
demotionDate: '2021-02-08T10:20:00.000Z', | ||
promotionDate: '2021-02-07T10:20:00.000Z', | ||
demotionDate: '2021-02-08T10:20:00Z', | ||
promotionDate: '2021-02-07T10:20:00Z', | ||
targetOrg: 'test', | ||
auditLogTrail: [] | ||
}) | ||
expect(file.auditLogTrail).toEqual(expect.arrayContaining([])) | ||
expect(result.status).toBe('success') | ||
expect.assertions(3) | ||
}) | ||
|
||
test('execute() - Check report generated with audit log entries', async () => { | ||
const mockCallback = jest.fn() | ||
const apis = mockApis() | ||
const mockParams = { | ||
username: 'droidpl', | ||
|
@@ -291,19 +293,16 @@ describe('Demotion report', () => { | |
issueNumber: 1, | ||
duration: 1, | ||
ticket: '1234', | ||
demotionDate: new Date(Date.parse('2021-03-19T11:05:50Z')), | ||
promotionDate: new Date(Date.parse('2021-03-19T11:08:03Z')), | ||
demotionDate: '2021-03-19T11:05:50Z', | ||
promotionDate: '2021-03-19T11:08:03Z', | ||
targetOrg: 'test', | ||
reportPath: 'tests/fixtures' | ||
} | ||
replyGithubGetResponse('/orgs/test/audit-log', { | ||
include: 'all', | ||
per_page: 100, | ||
phrase: `created:>=${mockParams.promotionDate} created:<=${mockParams.demotionDate} ` | ||
}, () => { | ||
mockCallback() | ||
return demotionAuditLog | ||
}) | ||
phrase: `created:${mockParams.promotionDate}..${mockParams.demotionDate}` | ||
}, demotionAuditLog) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stebje This was throwing a Javascript error that I didn't quite understand, and Copilot recommended this change. I'm thinking this might be related to the calling convention of |
||
const action = new DemotionReportAction(apis, mockParams) | ||
const result = await action.execute() | ||
const file = JSON.parse(fs.readFileSync(path.join(__dirname, '/fixtures/1_droidpl.json'))) | ||
|
@@ -313,13 +312,13 @@ describe('Demotion report', () => { | |
issueNumber: 1, | ||
duration: 1, | ||
ticket: '1234', | ||
demotionDate: '2021-03-19T11:05:50.000Z', | ||
promotionDate: '2021-03-19T11:08:03.000Z', | ||
demotionDate: '2021-03-19T11:05:50Z', | ||
promotionDate: '2021-03-19T11:08:03Z', | ||
targetOrg: 'test' | ||
}) | ||
expect(file.auditLogTrail).toEqual(expect.arrayContaining(demotionAuditLog)) | ||
expect(mockCallback).toBeCalled() | ||
expect(result.status).toBe('success') | ||
expect.assertions(3) | ||
}) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stebje I changed the search query here based on the documentation https://docs.github.com/en/enterprise-cloud@latest/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/searching-the-audit-log-for-your-enterprise#search-based-on-time-of-action