Skip to content

Commit 431603f

Browse files
committed
Add another integration test for input breadcrumbs
1 parent cac7d82 commit 431603f

File tree

3 files changed

+73
-26
lines changed

3 files changed

+73
-26
lines changed

packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/click/test.ts

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -58,34 +58,37 @@ sentryTest('captures Breadcrumb for clicks & debounces them for a second', async
5858
]);
5959
});
6060

61-
sentryTest('prioritizes the annotated component nam', async ({ getLocalTestUrl, page }) => {
62-
const url = await getLocalTestUrl({ testDir: __dirname });
63-
64-
await page.route('**/foo', route => {
65-
return route.fulfill({
66-
status: 200,
67-
body: JSON.stringify({
68-
userNames: ['John', 'Jane'],
69-
}),
70-
headers: {
71-
'Content-Type': 'application/json',
72-
},
61+
sentryTest(
62+
'prioritizes the annotated component name within the breadcrumb message',
63+
async ({ getLocalTestUrl, page }) => {
64+
const url = await getLocalTestUrl({ testDir: __dirname });
65+
66+
await page.route('**/foo', route => {
67+
return route.fulfill({
68+
status: 200,
69+
body: JSON.stringify({
70+
userNames: ['John', 'Jane'],
71+
}),
72+
headers: {
73+
'Content-Type': 'application/json',
74+
},
75+
});
7376
});
74-
});
7577

76-
const promise = getFirstSentryEnvelopeRequest<Event>(page);
78+
const promise = getFirstSentryEnvelopeRequest<Event>(page);
7779

78-
await page.goto(url);
79-
await page.click('#annotated-button');
80-
await page.evaluate('Sentry.captureException("test exception")');
80+
await page.goto(url);
81+
await page.click('#annotated-button');
82+
await page.evaluate('Sentry.captureException("test exception")');
8183

82-
const eventData = await promise;
84+
const eventData = await promise;
8385

84-
expect(eventData.breadcrumbs).toEqual([
85-
{
86-
timestamp: expect.any(Number),
87-
category: 'ui.click',
88-
message: 'AnnotatedButton',
89-
},
90-
]);
91-
});
86+
expect(eventData.breadcrumbs).toEqual([
87+
{
88+
timestamp: expect.any(Number),
89+
category: 'ui.click',
90+
message: 'AnnotatedButton',
91+
},
92+
]);
93+
},
94+
);

packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/textInput/template.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
<body>
88
<input id="input1" type="text" />
99
<input id="input2" type="text" />
10+
<input id="annotated-input" data-component="AnnotatedInput" type="text" />
1011
</body>
1112
</html>

packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/textInput/test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,46 @@ sentryTest('captures Breadcrumb for events on inputs & debounced them', async ({
6464
},
6565
]);
6666
});
67+
68+
sentryTest(
69+
'prioritizes the annotated component name within the breadcrumb message',
70+
async ({ getLocalTestUrl, page }) => {
71+
const url = await getLocalTestUrl({ testDir: __dirname });
72+
73+
await page.route('**/foo', route => {
74+
return route.fulfill({
75+
status: 200,
76+
body: JSON.stringify({
77+
userNames: ['John', 'Jane'],
78+
}),
79+
headers: {
80+
'Content-Type': 'application/json',
81+
},
82+
});
83+
});
84+
85+
const promise = getFirstSentryEnvelopeRequest<Event>(page);
86+
87+
await page.goto(url);
88+
89+
await page.click('#annotated-input');
90+
await page.type('#annotated-input', 'John', { delay: 1 });
91+
92+
await page.evaluate('Sentry.captureException("test exception")');
93+
const eventData = await promise;
94+
expect(eventData.exception?.values).toHaveLength(1);
95+
96+
expect(eventData.breadcrumbs).toEqual([
97+
{
98+
timestamp: expect.any(Number),
99+
category: 'ui.click',
100+
message: 'AnnotatedInput',
101+
},
102+
{
103+
timestamp: expect.any(Number),
104+
category: 'ui.input',
105+
message: 'AnnotatedInput',
106+
},
107+
]);
108+
},
109+
);

0 commit comments

Comments
 (0)