Skip to content

Commit f048fff

Browse files
committed
Update browser integration tests for captureFeedback
1 parent 7f6d9fa commit f048fff

File tree

6 files changed

+33
-30
lines changed

6 files changed

+33
-30
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Sentry.captureFeedback({
22
eventId: 'test_event_id',
33
email: 'test_email',
4-
comments: 'test_comments',
4+
message: 'test_comments',
55
name: 'test_name',
66
});
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import { expect } from '@playwright/test';
2-
import type { UserFeedback } from '@sentry/core';
2+
import type { FeedbackEvent } from '@sentry/core';
33

44
import { sentryTest } from '../../../../utils/fixtures';
55
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';
66

77
sentryTest('should capture simple user feedback', async ({ getLocalTestUrl, page }) => {
88
const url = await getLocalTestUrl({ testDir: __dirname });
99

10-
const eventData = await getFirstSentryEnvelopeRequest<UserFeedback>(page, url);
10+
const eventData = await getFirstSentryEnvelopeRequest<FeedbackEvent>(page, url);
1111

12-
expect(eventData).toMatchObject({
13-
eventId: 'test_event_id',
14-
email: 'test_email',
15-
comments: 'test_comments',
16-
name: 'test_name',
17-
});
12+
expect(eventData.contexts).toMatchObject(expect.objectContaining({
13+
feedback: {
14+
contact_email: 'test_email',
15+
message: 'test_comments',
16+
name: 'test_name',
17+
}
18+
}))
1819
});

dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureException/init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Sentry.init({
66
dsn: 'https://public@dsn.ingest.sentry.io/1337',
77
beforeSend(event) {
88
Sentry.captureFeedback({
9-
event_id: event.event_id,
9+
associatedEventId: event.event_id,
1010
name: 'John Doe',
1111
email: 'john@doe.com',
12-
comments: 'This feedback should be attached associated with the captured error',
12+
message: 'This feedback should be attached associated with the captured error',
1313
});
1414
return event;
1515
},
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
import { expect } from '@playwright/test';
2-
import type { Event, UserFeedback } from '@sentry/core';
2+
import type { Event, FeedbackEvent } from '@sentry/core';
33

44
import { sentryTest } from '../../../../utils/fixtures';
55
import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers';
66

77
sentryTest('capture user feedback when captureException is called', async ({ getLocalTestUrl, page }) => {
88
const url = await getLocalTestUrl({ testDir: __dirname });
99

10-
const data = (await getMultipleSentryEnvelopeRequests(page, 2, { url })) as (Event | UserFeedback)[];
10+
const data = (await getMultipleSentryEnvelopeRequests(page, 2, { url })) as (Event | FeedbackEvent)[];
1111

1212
expect(data).toHaveLength(2);
1313

1414
const errorEvent = ('exception' in data[0] ? data[0] : data[1]) as Event;
15-
const feedback = ('exception' in data[0] ? data[1] : data[0]) as UserFeedback;
15+
const feedback = ('exception' in data[0] ? data[1] : data[0]) as FeedbackEvent;
1616

17-
expect(feedback).toEqual({
18-
comments: 'This feedback should be attached associated with the captured error',
19-
email: 'john@doe.com',
20-
event_id: errorEvent.event_id,
21-
name: 'John Doe',
22-
});
17+
expect(feedback.contexts).toEqual(expect.objectContaining({
18+
feedback: {
19+
associated_event_id: errorEvent.event_id,
20+
message: 'This feedback should be attached associated with the captured error',
21+
contact_email: 'john@doe.com',
22+
name: 'John Doe',
23+
}
24+
}));
2325
});

dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureMessage/init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Sentry.init({
66
dsn: 'https://public@dsn.ingest.sentry.io/1337',
77
beforeSend(event) {
88
Sentry.captureFeedback({
9-
event_id: event.event_id,
9+
associatedEventId: event.event_id,
1010
name: 'John Doe',
1111
email: 'john@doe.com',
12-
comments: 'This feedback should be attached associated with the captured message',
12+
message: 'This feedback should be attached associated with the captured message',
1313
});
1414
return event;
1515
},
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import { expect } from '@playwright/test';
2-
import type { Event, UserFeedback } from '@sentry/core';
2+
import type { Event, FeedbackEvent } from '@sentry/core';
33

44
import { sentryTest } from '../../../../utils/fixtures';
55
import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers';
66

77
sentryTest('capture user feedback when captureMessage is called', async ({ getLocalTestUrl, page }) => {
88
const url = await getLocalTestUrl({ testDir: __dirname });
99

10-
const data = (await getMultipleSentryEnvelopeRequests(page, 2, { url })) as (Event | UserFeedback)[];
10+
const data = (await getMultipleSentryEnvelopeRequests(page, 2, { url })) as (Event | FeedbackEvent)[];
1111

1212
expect(data).toHaveLength(2);
1313

1414
const errorEvent = ('exception' in data[0] ? data[0] : data[1]) as Event;
15-
const feedback = ('exception' in data[0] ? data[1] : data[0]) as UserFeedback;
15+
const feedback = ('exception' in data[0] ? data[1] : data[0]) as FeedbackEvent;
1616

17-
expect(feedback).toEqual({
18-
comments: 'This feedback should be attached associated with the captured message',
19-
email: 'john@doe.com',
20-
event_id: errorEvent.event_id,
17+
expect(feedback.contexts).toEqual(expect.objectContaining({
18+
message: 'This feedback should be attached associated with the captured message',
19+
contact_email: 'john@doe.com',
20+
associated_event_id: errorEvent.event_id,
2121
name: 'John Doe',
22-
});
22+
}));
2323
});

0 commit comments

Comments
 (0)