Skip to content

Commit dbe7417

Browse files
committed
revert: Revert "fix: mergeKey participates in diffEntry value, but not in its cache key (#40)"
This reverts commit 99b6df0.
1 parent 99b6df0 commit dbe7417

File tree

4 files changed

+2
-168
lines changed

4 files changed

+2
-168
lines changed

src/core/compare.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ const cleanUpRecursive = (ctx: NodeContext): NodeContext => {
156156
}
157157

158158
export const getOrCreateChildDiffAdd = (diffUniquenessCache: EvaluationCacheService, childCtx: CompareContext) => {
159-
return diffUniquenessCache.cacheEvaluationResultByFootprint<[unknown, string, CompareScope, typeof DiffAction.add, PropertyKey], DiffEntry<DiffAdd>>([childCtx.after.value, buildPathsIdentifier(childCtx.after.declarativePaths), childCtx.scope, DiffAction.add, childCtx.mergeKey], () => {
159+
return diffUniquenessCache.cacheEvaluationResultByFootprint<[unknown, string, CompareScope, typeof DiffAction.add], DiffEntry<DiffAdd>>([childCtx.after.value, buildPathsIdentifier(childCtx.after.declarativePaths), childCtx.scope, DiffAction.add], () => {
160160
return diffFactory.added(childCtx)
161161
}, {} as DiffEntry<DiffAdd>, (result, guard) => {
162162
Object.assign(guard, result)

test/bugs.test.ts

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { annotation, apiDiff, breaking, ClassifierType, CompareOptions, DiffAction, nonBreaking, unclassified } from '../src'
1+
import { annotation, apiDiff, ClassifierType, CompareOptions, DiffAction, nonBreaking, unclassified } from '../src'
22
import offeringQualificationBefore from './helper/resources/api-v2-offeringqualification-qualification-post/before.json'
33
import offeringQualificationAfter from './helper/resources/api-v2-offeringqualification-qualification-post/after.json'
44
import readDefaultValueOfRequiredBefore from './helper/resources/read-default-value-of-required-field/before.json'
@@ -30,9 +30,6 @@ import spearedParamsAfter from './helper/resources/speared-parameters/after.json
3030
import wildcardContentSchemaMediaTypeCombinedWithSpecificMediaTypeBefore from './helper/resources/wildcard-content-schema-media-type-combined-with-specific-media-type/before.json'
3131
import wildcardContentSchemaMediaTypeCombinedWithSpecificMediaTypeAfter from './helper/resources/wildcard-content-schema-media-type-combined-with-specific-media-type/after.json'
3232

33-
import shouldNotMissRemoveDiffForEnumEntryInOneOfBefore from './helper/resources/should-not-miss-remove-diff-for-enum-entry-in-oneOf/before.json'
34-
import shouldNotMissRemoveDiffForEnumEntryInOneOfAfter from './helper/resources/should-not-miss-remove-diff-for-enum-entry-in-oneOf/after.json'
35-
3633
import { diffsMatcher } from './helper/matchers'
3734
import { TEST_DIFF_FLAG, TEST_ORIGINS_FLAG } from './helper'
3835
import { JSON_SCHEMA_NODE_SYNTHETIC_TYPE_NOTHING } from '@netcracker/qubership-apihub-api-unifier'
@@ -230,35 +227,4 @@ describe('Real Data', () => {
230227
}),
231228
]))
232229
})
233-
234-
it('should not miss remove diff for enum entry in oneOf', () => {
235-
const before: any = shouldNotMissRemoveDiffForEnumEntryInOneOfBefore
236-
const after: any = shouldNotMissRemoveDiffForEnumEntryInOneOfAfter
237-
const { merged } = apiDiff(before, after, OPTIONS)
238-
239-
expect(
240-
Object.values((merged as any).paths['/path1'].post.requestBody.content['application/json'].schema.oneOf[1].properties.scope.items.enum[TEST_DIFF_FLAG])
241-
).toEqual(diffsMatcher([
242-
expect.objectContaining({
243-
beforeValue: 'query',
244-
action: DiffAction.remove,
245-
type: breaking,
246-
}),
247-
expect.objectContaining({
248-
beforeValue: 'subscription',
249-
action: DiffAction.remove,
250-
type: breaking,
251-
}),
252-
expect.objectContaining({
253-
afterValue: 'argument',
254-
action: DiffAction.add,
255-
type: nonBreaking,
256-
}),
257-
expect.objectContaining({
258-
afterValue: 'annotation',
259-
action: DiffAction.add,
260-
type: nonBreaking,
261-
}),
262-
]))
263-
})
264230
})

test/helper/resources/should-not-miss-remove-diff-for-enum-entry-in-oneOf/after.json

Lines changed: 0 additions & 66 deletions
This file was deleted.

test/helper/resources/should-not-miss-remove-diff-for-enum-entry-in-oneOf/before.json

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)