Skip to content

Commit 60fdc32

Browse files
committed
fix return full operation ids when comparing prefix groups
1 parent 1af80ce commit 60fdc32

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

src/components/compare/compare.utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,13 @@ export function createOperationChange(
268268
const impactedSummary = calculateImpactedSummary([changeSummary])
269269

270270
const currentOperationFields = current && {
271-
operationId: removeGroupPrefixFromOperationId(current.operationId, currentGroup ?? ''),
271+
operationId: current.operationId,
272272
apiKind: current.apiKind,
273273
metadata: getOperationMetadata(current),
274274
}
275275

276276
const previousOperationFields = previous && {
277-
previousOperationId: removeGroupPrefixFromOperationId(previous.operationId, previousGroup ?? ''),
277+
previousOperationId: previous.operationId,
278278
previousApiKind: previous.apiKind,
279279
previousMetadata: getOperationMetadata(previous),
280280
}

test/prefix-groups.test.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ import { ANNOTATION_CHANGE_TYPE, BREAKING_CHANGE_TYPE, BUILD_TYPE, NON_BREAKING_
2727
const pkg = LocalRegistry.openPackage('apihub')
2828

2929
describe('Prefix Groups test', () => {
30-
// this test uses too large sample (runs too long)
31-
// and checks only number of operations,
32-
// mostly useless
30+
31+
// this test uses too large sample (runs too long) and checks only number of operations, mostly useless
3332
// todo: remove this test
3433
test.skip('should compare prefix groups groups=v2,v3', async () => {
3534
// generate missing versions/apihub folder contents
@@ -120,13 +119,14 @@ describe('Prefix Groups test', () => {
120119
//check operation ids
121120
expect(result).toEqual(operationChangesMatcher([
122121
expect.objectContaining({
123-
previousOperationId: 'removed-get',
122+
previousOperationId: 'api-v1-removed-get',
124123
}),
125124
expect.objectContaining({
126-
operationId: 'added-get',
125+
operationId: 'api-v2-added-get',
127126
}),
128127
expect.objectContaining({
129-
operationId: 'changed1-get',
128+
operationId: 'api-v2-changed1-get',
129+
previousOperationId: 'api-v1-changed1-get',
130130
}),
131131
]))
132132
})
@@ -151,14 +151,14 @@ describe('Prefix Groups test', () => {
151151
//check operation ids
152152
expect(result).toEqual(operationChangesMatcher([
153153
expect.objectContaining({
154-
previousOperationId: 'removed-get',
154+
previousOperationId: 'api-v1-removed-get',
155155
}),
156156
expect.objectContaining({
157-
operationId: 'changed1-get',
158-
previousOperationId: 'changed1-get',
157+
operationId: 'api-v2-changed1-get',
158+
previousOperationId: 'api-v1-changed1-get',
159159
}),
160160
expect.objectContaining({
161-
operationId: 'added-get',
161+
operationId: 'api-v2-added-get',
162162
}),
163163
]))
164164
})
@@ -202,14 +202,14 @@ describe('Prefix Groups test', () => {
202202
//check operation ids
203203
expect(result).toEqual(operationChangesMatcher([
204204
expect.objectContaining({
205-
previousOperationId: 'added-get',
205+
previousOperationId: 'api-v1-removed-get',
206206
}),
207207
expect.objectContaining({
208-
operationId: 'changed1-get',
209-
previousOperationId: 'changed1-get',
208+
operationId: 'api-v2-changed1-get',
209+
previousOperationId: 'api-v1-changed1-get',
210210
}),
211211
expect.objectContaining({
212-
operationId: 'removed-get',
212+
operationId: 'api-v2-added-get',
213213
}),
214214
]))
215215
})
@@ -223,7 +223,7 @@ describe('Prefix Groups test', () => {
223223
//check operation ids
224224
expect(result).toEqual(operationChangesMatcher([
225225
expect.objectContaining({
226-
operationId: 'path1-post',
226+
operationId: 'api-v2-path1-post',
227227
}),
228228
]))
229229
})
@@ -237,7 +237,7 @@ describe('Prefix Groups test', () => {
237237
//check operation ids
238238
expect(result).toEqual(operationChangesMatcher([
239239
expect.objectContaining({
240-
previousOperationId: 'path1-post',
240+
previousOperationId: 'api-v1-path1-post',
241241
}),
242242
]))
243243
})
@@ -257,8 +257,8 @@ describe('Prefix Groups test', () => {
257257
//check operation ids
258258
expect(result).toEqual(operationChangesMatcher([
259259
expect.objectContaining({
260-
operationId: 'path1-get',
261-
previousOperationId: 'path1-get',
260+
operationId: 'api-v2-path1-get',
261+
previousOperationId: 'api-v1-path1-get',
262262
}),
263263
]))
264264
})
@@ -276,8 +276,8 @@ describe('Prefix Groups test', () => {
276276
//check operation ids
277277
expect(result).toEqual(operationChangesMatcher([
278278
expect.objectContaining({
279-
operationId: 'users-id-posts-get',
280-
previousOperationId: 'users-userid-posts-get',
279+
operationId: 'api-v2-users-id-posts-get',
280+
previousOperationId: 'api-v1-users-userid-posts-get',
281281
}),
282282
]))
283283
})
@@ -297,8 +297,8 @@ describe('Prefix Groups test', () => {
297297
//check operation ids
298298
expect(result).toEqual(operationChangesMatcher([
299299
expect.objectContaining({
300-
operationId: 'packages-get',
301-
previousOperationId: 'packages-get',
300+
operationId: 'api-v1000-packages-get',
301+
previousOperationId: 'api-v10-packages-get',
302302
}),
303303
]))
304304
})

test/projects/prefix-groups/mixed-cases-with-path-prefix-override/spec1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ info:
55
servers:
66
- url: https://example1.com/api/v4
77
paths:
8-
/added:
8+
/removed:
99
get:
1010
responses:
1111
'200':

test/projects/prefix-groups/mixed-cases-with-path-prefix-override/spec2.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ info:
55
servers:
66
- url: https://example1.com/api/v3
77
paths:
8-
/removed:
8+
/added:
99
get:
1010
responses:
1111
'200':

0 commit comments

Comments
 (0)