-
-
Notifications
You must be signed in to change notification settings - Fork 720
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: playground custom properties are nested (#4686)
- Loading branch information
Showing
5 changed files
with
179 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
frontend/src/component/playground/Playground/playground.utils.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { | ||
normalizeCustomContextProperties, | ||
NormalizedContextProperties, | ||
} from './playground.utils'; | ||
|
||
test('should keep standard properties in their place', () => { | ||
const input: NormalizedContextProperties = { | ||
appName: 'testApp', | ||
environment: 'testEnv', | ||
userId: 'testUser', | ||
sessionId: 'testSession', | ||
remoteAddress: '127.0.0.1', | ||
currentTime: 'now', | ||
}; | ||
const output = normalizeCustomContextProperties(input); | ||
expect(output).toEqual(input); | ||
}); | ||
|
||
test('should move non-standard properties to nested properties field', () => { | ||
const input = { | ||
appName: 'testApp', | ||
customProp: 'customValue', | ||
anotherCustom: 'anotherValue', | ||
}; | ||
const output = normalizeCustomContextProperties(input); | ||
expect(output).toEqual({ | ||
appName: 'testApp', | ||
properties: { | ||
customProp: 'customValue', | ||
anotherCustom: 'anotherValue', | ||
}, | ||
}); | ||
}); | ||
|
||
test('should not have properties field if there are no non-standard properties', () => { | ||
const input = { | ||
appName: 'testApp', | ||
}; | ||
const output = normalizeCustomContextProperties(input); | ||
expect(output).toEqual(input); | ||
expect(output.properties).toBeUndefined(); | ||
}); | ||
|
||
test('should combine existing properties field with non-standard properties', () => { | ||
const input = { | ||
appName: 'testApp', | ||
properties: { | ||
existingProp: 'existingValue', | ||
}, | ||
customProp: 'customValue', | ||
}; | ||
const output = normalizeCustomContextProperties(input); | ||
expect(output).toEqual({ | ||
appName: 'testApp', | ||
properties: { | ||
existingProp: 'existingValue', | ||
customProp: 'customValue', | ||
}, | ||
}); | ||
}); | ||
|
||
test('should add multiple standard properties without breaking custom properties', () => { | ||
const input = { | ||
appName: 'testApp', | ||
properties: { | ||
existingProp: 'existingValue', | ||
}, | ||
currentTime: 'value', | ||
}; | ||
const output = normalizeCustomContextProperties(input); | ||
expect(output).toEqual({ | ||
appName: 'testApp', | ||
currentTime: 'value', | ||
properties: { | ||
existingProp: 'existingValue', | ||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters