Skip to content

Commit e5dde48

Browse files
authored
test: add smoke test for INP (#658)
1 parent 41347d3 commit e5dde48

File tree

2 files changed

+88
-2
lines changed

2 files changed

+88
-2
lines changed

src/__smoke-test-npm__/ingestion-integ.spec.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
PAGE_VIEW_EVENT_TYPE,
1212
SESSION_START_EVENT_TYPE,
1313
DOM_EVENT_TYPE,
14-
XRAY_TRACE_EVENT_TYPE
14+
XRAY_TRACE_EVENT_TYPE,
15+
INP_EVENT_TYPE
1516
} from '../plugins/utils/constant';
1617
import {
1718
getEventIds,
@@ -327,3 +328,45 @@ test('when xray event is sent then the event is ingested', async ({ page }) => {
327328
);
328329
expect(isIngestionCompleted).toEqual(true);
329330
});
331+
332+
test('when INP event is sent then event is ingested', async ({ page }) => {
333+
const timestamp = Date.now() - 30000;
334+
335+
// Open page
336+
await page.goto(TEST_URL);
337+
const dummyButton = page.locator('[id=dummyButton]');
338+
339+
// trigger a slow interaction
340+
await Promise.all(
341+
new Array(30).fill(null).map(async () => {
342+
return await dummyButton.click();
343+
})
344+
);
345+
346+
// trigger visibility change event
347+
const cls = page.locator('[id=dispatchCLS]');
348+
await cls.click();
349+
350+
// Test will timeout if no successful dataplane request is found
351+
const response = await page.waitForResponse(async (response) =>
352+
isDataPlaneRequest(response, TARGET_URL)
353+
);
354+
355+
// Parse payload to verify event count
356+
const requestBody = JSON.parse(response.request().postData());
357+
358+
const inp = getEventsByType(requestBody, INP_EVENT_TYPE);
359+
const eventIds = getEventIds(inp);
360+
361+
expect(eventIds.length).not.toEqual(0);
362+
363+
// Expect INP to be INgested
364+
const isIngestionCompleted = await verifyIngestionWithRetry(
365+
rumClient,
366+
eventIds,
367+
timestamp,
368+
MONITOR_NAME,
369+
5
370+
);
371+
expect(isIngestionCompleted).toEqual(true);
372+
});

src/__smoke-test__/ingestion-integ.spec.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
PAGE_VIEW_EVENT_TYPE,
1212
SESSION_START_EVENT_TYPE,
1313
DOM_EVENT_TYPE,
14-
XRAY_TRACE_EVENT_TYPE
14+
XRAY_TRACE_EVENT_TYPE,
15+
INP_EVENT_TYPE
1516
} from '../plugins/utils/constant';
1617
import {
1718
getEventIds,
@@ -447,3 +448,45 @@ test('when event with custom attributes is sent then the event is ingested', asy
447448
);
448449
expect(isIngestionCompleted).toEqual(true);
449450
});
451+
452+
test('when INP event is sent then event is ingested', async ({ page }) => {
453+
const timestamp = Date.now() - 30000;
454+
455+
// Open page
456+
await page.goto(TEST_URL);
457+
const dummyButton = page.locator('[id=dummyButton]');
458+
459+
// trigger a slow interaction
460+
await Promise.all(
461+
new Array(30).fill(null).map(async () => {
462+
return await dummyButton.click();
463+
})
464+
);
465+
466+
// trigger visibility change event
467+
const cls = page.locator('[id=dispatchCLS]');
468+
await cls.click();
469+
470+
// Test will timeout if no successful dataplane request is found
471+
const response = await page.waitForResponse(async (response) =>
472+
isDataPlaneRequest(response, TARGET_URL)
473+
);
474+
475+
// Parse payload to verify event count
476+
const requestBody = JSON.parse(response.request().postData());
477+
478+
const inp = getEventsByType(requestBody, INP_EVENT_TYPE);
479+
const eventIds = getEventIds(inp);
480+
481+
expect(eventIds.length).not.toEqual(0);
482+
483+
// Expect INP to be INgested
484+
const isIngestionCompleted = await verifyIngestionWithRetry(
485+
rumClient,
486+
eventIds,
487+
timestamp,
488+
MONITOR_NAME,
489+
5
490+
);
491+
expect(isIngestionCompleted).toEqual(true);
492+
});

0 commit comments

Comments
 (0)