fix(tracker): update tests for conditionsManager.test.ts

This commit is contained in:
nick-delirium 2024-01-22 16:43:44 +01:00
parent 5674f5b9b7
commit 932aa485df
2 changed files with 21 additions and 9 deletions

View file

@ -667,9 +667,9 @@ export default class App {
timezone: getTimezone(),
}),
})
// this token is needed to fetch conditions and flags,
// but it can't be used to record a session
const {
// this token is needed to fetch conditions and flags,
// but it can't be used to record a session
token,
userBrowser,
userCity,
@ -714,11 +714,9 @@ export default class App {
this.session.applySessionHash(startOpts.sessionHash)
}
if (startOpts.forceNew) {
// Reset session metadata only if requested directly
this.session.reset()
}
this.session.assign({
// MBTODO: maybe it would make sense to `forceNew` if the `userID` was changed
userID: startOpts.userID,
metadata: startOpts.metadata,
})
@ -764,11 +762,9 @@ export default class App {
this.session.applySessionHash(startOpts.sessionHash)
}
if (startOpts.forceNew) {
// Reset session metadata only if requested directly
this.session.reset()
}
this.session.assign({
// MBTODO: maybe it would make sense to `forceNew` if the `userID` was changed
userID: startOpts.userID,
metadata: startOpts.metadata,
})

View file

@ -150,8 +150,24 @@ describe('ConditionsManager', () => {
test('processMessage correctly processes a NetworkRequest message', () => {
const manager = new ConditionsManager(appMock, startOptionsMock)
manager.setConditions([
{ type: 'network_request', key: 'url', operator: 'is', value: ['https://api.example.com'] },
{ type: 'network_request', key: 'status', operator: 'greaterThan', value: 200 },
{
type: 'network_request',
subConditions: [
{ type: 'network_request', key: 'status', operator: 'greaterThan', value: 200 },
{
type: 'network_request',
key: 'url',
operator: 'is',
value: ['https://api.example.com'],
},
],
},
{
type: 'network_request',
subConditions: [
{ type: 'network_request', key: 'status', operator: 'greaterOrEqual', value: 400 },
],
},
])
const networkRequestMessage = [
Type.NetworkRequest,
@ -160,7 +176,7 @@ describe('ConditionsManager', () => {
'https://api.example.com',
'Request',
'Response',
200,
201,
Date.now(),
4000,
1024,