Skip to content

Commit d9fb002

Browse files
fix: Send correct payload for changing labels (#715)
* fix: issues labels * Update changelog.rst
1 parent 27dd124 commit d9fb002

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

__tests__/unit/actions/labels.test.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test('check that replace replaces existing labels', async () => {
1212

1313
await labels.afterValidate(context, settings)
1414
expect(context.octokit.issues.setLabels.mock.calls.length).toBe(1)
15-
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual({ labels: settings.replace })
15+
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual(settings.replace)
1616
})
1717

1818
test('check that add appends to existing labels', async () => {
@@ -25,7 +25,7 @@ test('check that add appends to existing labels', async () => {
2525

2626
await labels.afterValidate(context, settings)
2727
expect(context.octokit.issues.setLabels.mock.calls.length).toBe(1)
28-
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual({ labels: ['another label', 'test label', 'production', 'deploy'] })
28+
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual(['another label', 'test label', 'production', 'deploy'])
2929
})
3030

3131
test('check that delete removes from existing labels', async () => {
@@ -38,7 +38,7 @@ test('check that delete removes from existing labels', async () => {
3838

3939
await labels.afterValidate(context, settings)
4040
expect(context.octokit.issues.setLabels.mock.calls.length).toBe(1)
41-
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual({ labels: ['another label', 'test label'] })
41+
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual(['another label', 'test label'])
4242
})
4343

4444
test('check the order of replace, add, delete', async () => {
@@ -54,7 +54,7 @@ test('check the order of replace, add, delete', async () => {
5454

5555
await labels.afterValidate(context, settings)
5656
expect(context.octokit.issues.setLabels.mock.calls.length).toBe(1)
57-
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual({ labels: ['test present', 'addition'] })
57+
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual(['test present', 'addition'])
5858
})
5959

6060
test('check that settings can be a single value', async () => {
@@ -69,7 +69,7 @@ test('check that settings can be a single value', async () => {
6969

7070
await labels.afterValidate(context, settings)
7171
expect(context.octokit.issues.setLabels.mock.calls.length).toBe(1)
72-
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual({ labels: ['replace', 'addition'] })
72+
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual(['replace', 'addition'])
7373
})
7474

7575
test('check that unknown mode throw errors', async () => {
@@ -93,7 +93,7 @@ test('check that labels setting accepts an array', async () => {
9393

9494
await labels.afterValidate(context, settings)
9595
expect(context.octokit.issues.addLabels.mock.calls.length).toBe(1)
96-
expect(context.octokit.issues.addLabels.mock.calls[0][0].labels).toStrictEqual({ labels: ['testLabel', '2ndTestLabel'] })
96+
expect(context.octokit.issues.addLabels.mock.calls[0][0].labels).toStrictEqual(['testLabel', '2ndTestLabel'])
9797
})
9898

9999
test('check that labels setting defaults to add mode', async () => {
@@ -106,7 +106,7 @@ test('check that labels setting defaults to add mode', async () => {
106106

107107
await labels.afterValidate(context, settings)
108108
expect(context.octokit.issues.addLabels.mock.calls.length).toBe(1)
109-
expect(context.octokit.issues.addLabels.mock.calls[0][0].labels).toStrictEqual({ labels: ['testLabel', '2ndTestLabel'] })
109+
expect(context.octokit.issues.addLabels.mock.calls[0][0].labels).toStrictEqual(['testLabel', '2ndTestLabel'])
110110
})
111111

112112
test('check that set mode works', async () => {
@@ -120,7 +120,7 @@ test('check that set mode works', async () => {
120120

121121
await labels.afterValidate(context, settings)
122122
expect(context.octokit.issues.setLabels.mock.calls.length).toBe(1)
123-
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual({ labels: ['testLabel', '2ndTestLabel'] })
123+
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual(['testLabel', '2ndTestLabel'])
124124
})
125125

126126
test('check that delete mode works', async () => {
@@ -134,7 +134,7 @@ test('check that delete mode works', async () => {
134134

135135
await labels.afterValidate(context, settings)
136136
expect(context.octokit.issues.setLabels.mock.calls.length).toBe(1)
137-
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual({ labels: ['test2', 'label1'] })
137+
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual(['test2', 'label1'])
138138
})
139139

140140
test('check that issues from scheduler are labelled', async () => {
@@ -152,9 +152,9 @@ test('check that issues from scheduler are labelled', async () => {
152152
}]
153153
await labels.afterValidate(context, settings, '', schedulerResult)
154154
expect(context.octokit.issues.addLabels.mock.calls.length).toBe(3)
155-
expect(context.octokit.issues.addLabels.mock.calls[0][0].labels).toStrictEqual({ labels: ['testLabel', '2ndTestLabel'] })
156-
expect(context.octokit.issues.addLabels.mock.calls[1][0].labels).toStrictEqual({ labels: ['testLabel', '2ndTestLabel'] })
157-
expect(context.octokit.issues.addLabels.mock.calls[2][0].labels).toStrictEqual({ labels: ['testLabel', '2ndTestLabel'] })
155+
expect(context.octokit.issues.addLabels.mock.calls[0][0].labels).toStrictEqual(['testLabel', '2ndTestLabel'])
156+
expect(context.octokit.issues.addLabels.mock.calls[1][0].labels).toStrictEqual(['testLabel', '2ndTestLabel'])
157+
expect(context.octokit.issues.addLabels.mock.calls[2][0].labels).toStrictEqual(['testLabel', '2ndTestLabel'])
158158
})
159159

160160
test('check that labels from scheduler are deleted', async () => {
@@ -173,9 +173,9 @@ test('check that labels from scheduler are deleted', async () => {
173173
}]
174174
await labels.afterValidate(context, settings, '', schedulerResult)
175175
expect(context.octokit.issues.setLabels.mock.calls.length).toBe(3)
176-
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual({ labels: ['test2', 'label1'] })
177-
expect(context.octokit.issues.setLabels.mock.calls[1][0].labels).toStrictEqual({ labels: ['test2', 'label1'] })
178-
expect(context.octokit.issues.setLabels.mock.calls[2][0].labels).toStrictEqual({ labels: ['test2', 'label1'] })
176+
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual(['test2', 'label1'])
177+
expect(context.octokit.issues.setLabels.mock.calls[1][0].labels).toStrictEqual(['test2', 'label1'])
178+
expect(context.octokit.issues.setLabels.mock.calls[2][0].labels).toStrictEqual(['test2', 'label1'])
179179
})
180180

181181
test('check that labels from scheduler are set', async () => {
@@ -194,9 +194,9 @@ test('check that labels from scheduler are set', async () => {
194194
}]
195195
await labels.afterValidate(context, settings, '', schedulerResult)
196196
expect(context.octokit.issues.setLabels.mock.calls.length).toBe(3)
197-
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual({ labels: ['testLabel', '2ndTestLabel'] })
198-
expect(context.octokit.issues.setLabels.mock.calls[1][0].labels).toStrictEqual({ labels: ['testLabel', '2ndTestLabel'] })
199-
expect(context.octokit.issues.setLabels.mock.calls[2][0].labels).toStrictEqual({ labels: ['testLabel', '2ndTestLabel'] })
197+
expect(context.octokit.issues.setLabels.mock.calls[0][0].labels).toStrictEqual(['testLabel', '2ndTestLabel'])
198+
expect(context.octokit.issues.setLabels.mock.calls[1][0].labels).toStrictEqual(['testLabel', '2ndTestLabel'])
199+
expect(context.octokit.issues.setLabels.mock.calls[2][0].labels).toStrictEqual(['testLabel', '2ndTestLabel'])
200200
})
201201

202202
const createMockContext = (labels = [], eventName = undefined) => {

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CHANGELOG
22
=====================================
3+
| May 11, 2023: fix: Send correct payload for changing labels `#715 <https://github.com/mergeability/mergeable/pull/715>`_
34
| April 25, 2023: feat: Add author validator `#710 <https://github.com/mergeability/mergeable/pull/710>`_
45
| March 13, 2023: fix: Replace delete with remove in changeset validator `#705 <https://github.com/mergeability/mergeable/pull/705>`_
56
| March 7, 2023: fix: Extend checks supported events `#700 <https://github.com/mergeability/mergeable/pull/700>`_

lib/github/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class GithubAPI {
139139

140140
try {
141141
return await context.octokit.issues.addLabels(
142-
context.repo({ issue_number: issueNumber, labels: { labels: labels } })
142+
context.repo({ issue_number: issueNumber, labels: labels })
143143
)
144144
} catch (err) {
145145
return checkCommonError(err, context, callFn)
@@ -153,7 +153,7 @@ class GithubAPI {
153153

154154
try {
155155
return await context.octokit.issues.setLabels(
156-
context.repo({ issue_number: issueNumber, labels: { labels: labels } })
156+
context.repo({ issue_number: issueNumber, labels: labels })
157157
)
158158
} catch (err) {
159159
return checkCommonError(err, context, callFn)

0 commit comments

Comments
 (0)