Skip to content

Commit 5816421

Browse files
cursoragentclaude
andcommitted
fix(browser-integration-tests): Replace deprecated envelope helpers in viewHierarchy test
Replace unreliable getMultipleSentryEnvelopeRequests and envelopeParser with waitForErrorRequest and properFullEnvelopeRequestParser for more reliable test execution. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 6649760 commit 5816421

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

  • dev-packages/browser-integration-tests/suites/integrations/viewHierarchy

dev-packages/browser-integration-tests/suites/integrations/viewHierarchy/test.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from '@playwright/test';
22
import type { ViewHierarchyData } from '@sentry/core';
33
import { sentryTest } from '../../../utils/fixtures';
4-
import { getMultipleSentryEnvelopeRequests, envelopeParser } from '../../../utils/helpers';
4+
import { properFullEnvelopeRequestParser, waitForErrorRequest } from '../../../utils/helpers';
55

66
sentryTest('Captures view hierarchy as attachment', async ({ getLocalTestUrl, page }) => {
77
const bundle = process.env.PW_BUNDLE;
@@ -11,18 +11,21 @@ sentryTest('Captures view hierarchy as attachment', async ({ getLocalTestUrl, pa
1111

1212
const url = await getLocalTestUrl({ testDir: __dirname });
1313

14-
const [, events] = await Promise.all([
15-
page.goto(url),
16-
getMultipleSentryEnvelopeRequests<ViewHierarchyData>(
17-
page,
18-
1,
19-
{},
20-
req => envelopeParser(req)?.[4] as ViewHierarchyData,
21-
),
22-
]);
23-
24-
expect(events).toHaveLength(1);
25-
const event: ViewHierarchyData = events[0];
14+
const req = await Promise.all([page.goto(url), waitForErrorRequest(page)]).then(([, req]) => req);
15+
16+
const envelope = properFullEnvelopeRequestParser(req);
17+
const items = envelope[1];
18+
19+
expect(items).toHaveLength(2);
20+
21+
const attachmentHeader = items[1][0];
22+
expect(attachmentHeader.type).toBe('attachment');
23+
expect(attachmentHeader.filename).toBe('view-hierarchy.json');
24+
25+
const attachmentData = items[1][1];
26+
const event: ViewHierarchyData = JSON.parse(
27+
typeof attachmentData === 'string' ? attachmentData : new TextDecoder().decode(attachmentData as Uint8Array),
28+
);
2629

2730
expect(event.rendering_system).toBe('DOM');
2831
expect(event.positioning).toBe('absolute');

0 commit comments

Comments
 (0)