-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Allow the page view feature to have access to an event buffer (#…
- Loading branch information
1 parent
8abf047
commit 64babe1
Showing
4 changed files
with
41 additions
and
9 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { setupAgent } from '../setup-agent' | ||
import { Instrument as PageViewEvent } from '../../../src/features/page_view_event/instrument' | ||
|
||
let mainAgent, pveAggregate | ||
|
||
beforeAll(async () => { | ||
mainAgent = setupAgent() | ||
mainAgent.info.errorBeacon = undefined // this prevents Harvester from actually running its `send` method | ||
}) | ||
beforeEach(async () => { | ||
const pveInstrument = new PageViewEvent(mainAgent) | ||
await new Promise(process.nextTick) | ||
pveAggregate = pveInstrument.featAggregate | ||
}) | ||
|
||
test('PageViewEvent does not throw on Harvester driven processes', () => { | ||
expect(pveAggregate.blocked).toEqual(false) | ||
expect(() => pveAggregate.makeHarvestPayload(true)).not.toThrow() | ||
|
||
// The following both don't send anything since PVE buffer is meant to stay empty, so they return false. | ||
expect(mainAgent.runtime.harvester.triggerHarvestFor(pveAggregate)).toEqual(false) // mimics what the harvester does on interval | ||
expect(mainAgent.runtime.harvester.triggerHarvestFor(pveAggregate, { isFinalHarvest: true })).toEqual(false) // mimics what the harvester does on EoL | ||
|
||
expect(mainAgent.runtime.harvester.triggerHarvestFor(pveAggregate, { | ||
directSend: { | ||
targetApp: 'someApp', | ||
payload: 'blah' | ||
}, | ||
needResponse: true, | ||
sendEmptyBody: true | ||
})).toEqual(true) // mimics the manual trigger in PVE `sendRum`; this should return true as it actually tries to "send" | ||
}) |
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