Skip to content

Commit

Permalink
chore: add intetgration test for attribution
Browse files Browse the repository at this point in the history
  • Loading branch information
williazz committed Sep 11, 2023
1 parent 133521c commit fbeb308
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/plugins/event-plugins/__integ__/WebVitalsPlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import {
RESPONSE_STATUS
} from '../../../test-utils/integ-test-utils';
import { Selector } from 'testcafe';
import { CLS_EVENT_TYPE, LCP_EVENT_TYPE } from '../../utils/constant';
import {
CLS_EVENT_TYPE,
FID_EVENT_TYPE,
LCP_EVENT_TYPE
} from '../../utils/constant';

const testButton: Selector = Selector(`#testButton`);
const makePageHidden: Selector = Selector(`#makePageHidden`);
Expand All @@ -17,14 +21,15 @@ fixture('WebVitalEvent Plugin').page(
// "FID is not reported if the user never interacts with the page."
// It doesn't seem like TestCafe actions are registered as user interactions, so cannot test FID

test('WebVitalEvent records lcp and cls events', async (t: TestController) => {
test('WebVitalEvent records lcp and cls events on chrome', async (t: TestController) => {
// If we click too soon, the client/event collector plugin will not be loaded and will not record the click.
// This could be a symptom of an issue with RUM web client load speed, or prioritization of script execution.
const browser = t.browser.name;
if (browser === 'Safari' || browser === 'Firefox') {
return 'Test is skipped';
}
await t.wait(300);
document.getElementById('#testButton')?.click();

await t
// Interact with page to trigger lcp event
Expand All @@ -51,5 +56,9 @@ test('WebVitalEvent records lcp and cls events', async (t: TestController) => {
.expect(lcpEventDetails.value)
.typeOf('number')
.expect(clsEventDetails.value)
.typeOf('number');
.typeOf('number')
.expect(lcpEventDetails.attribution)
.typeOf('object')
.expect(clsEventDetails.attribution)
.typeOf('object');
});

0 comments on commit fbeb308

Please sign in to comment.