Skip to content

Commit 10ceb8a

Browse files
committed
adjust e2e test helpers to reflect current naming scheme
1 parent b3df93c commit 10ceb8a

2 files changed

Lines changed: 25 additions & 25 deletions

File tree

dev-packages/test-utils/src/event-proxy-server.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import type {
66
SerializedMetric,
77
SerializedMetricContainer,
88
SerializedSession,
9-
SpanV2Envelope,
10-
SpanV2JSON,
9+
SerializedStreamedSpan,
10+
StreamedSpanEnvelope,
1111
} from '@sentry/core';
1212
import { parseEnvelope } from '@sentry/core';
1313
import * as fs from 'fs';
@@ -432,11 +432,11 @@ export function waitForMetric(
432432
/**
433433
* Check if an envelope item is a Span V2 container item.
434434
*/
435-
function isSpanV2EnvelopeItem(
435+
function isStreamedSpanEnvelopeItem(
436436
envelopeItem: EnvelopeItem,
437437
): envelopeItem is [
438438
{ type: 'span'; content_type: 'application/vnd.sentry.items.span.v2+json'; item_count: number },
439-
{ items: SpanV2JSON[] },
439+
{ items: SerializedStreamedSpan[] },
440440
] {
441441
const [header] = envelopeItem;
442442
return (
@@ -466,10 +466,10 @@ function isSpanV2EnvelopeItem(
466466
* });
467467
* ```
468468
*/
469-
export function waitForSpanV2Envelope(
469+
export function waitForStreamedSpanEnvelope(
470470
proxyServerName: string,
471-
callback?: (spanEnvelope: SpanV2Envelope) => Promise<boolean> | boolean,
472-
): Promise<SpanV2Envelope> {
471+
callback?: (spanEnvelope: StreamedSpanEnvelope) => Promise<boolean> | boolean,
472+
): Promise<StreamedSpanEnvelope> {
473473
const timestamp = getNanosecondTimestamp();
474474
return new Promise((resolve, reject) => {
475475
waitForRequest(
@@ -479,12 +479,12 @@ export function waitForSpanV2Envelope(
479479
const envelopeItems = envelope[1];
480480

481481
// Check if this is a Span V2 envelope by looking for a Span V2 item
482-
const hasSpanV2Item = envelopeItems.some(item => isSpanV2EnvelopeItem(item));
482+
const hasSpanV2Item = envelopeItems.some(item => isStreamedSpanEnvelopeItem(item));
483483
if (!hasSpanV2Item) {
484484
return false;
485485
}
486486

487-
const spanV2Envelope = envelope as SpanV2Envelope;
487+
const spanV2Envelope = envelope as StreamedSpanEnvelope;
488488

489489
if (callback) {
490490
return callback(spanV2Envelope);
@@ -494,7 +494,7 @@ export function waitForSpanV2Envelope(
494494
},
495495
timestamp,
496496
)
497-
.then(eventData => resolve(eventData.envelope as SpanV2Envelope))
497+
.then(eventData => resolve(eventData.envelope as StreamedSpanEnvelope))
498498
.catch(reject);
499499
});
500500
}
@@ -520,10 +520,10 @@ export function waitForSpanV2Envelope(
520520
* });
521521
* ```
522522
*/
523-
export function waitForSpanV2(
523+
export function waitForStreamedSpan(
524524
proxyServerName: string,
525-
callback: (span: SpanV2JSON) => Promise<boolean> | boolean,
526-
): Promise<SpanV2JSON> {
525+
callback: (span: SerializedStreamedSpan) => Promise<boolean> | boolean,
526+
): Promise<SerializedStreamedSpan> {
527527
const timestamp = getNanosecondTimestamp();
528528
return new Promise((resolve, reject) => {
529529
waitForRequest(
@@ -533,8 +533,8 @@ export function waitForSpanV2(
533533
const envelopeItems = envelope[1];
534534

535535
for (const envelopeItem of envelopeItems) {
536-
if (!isSpanV2EnvelopeItem(envelopeItem)) {
537-
return false
536+
if (!isStreamedSpanEnvelopeItem(envelopeItem)) {
537+
return false;
538538
}
539539

540540
const spans = envelopeItem[1].items;
@@ -574,10 +574,10 @@ export function waitForSpanV2(
574574
* expect(httpSpans.length).toBe(2);
575575
* ```
576576
*/
577-
export function waitForSpansV2(
577+
export function waitForStreamedSpans(
578578
proxyServerName: string,
579-
callback?: (span: SpanV2JSON) => Promise<boolean> | boolean,
580-
): Promise<SpanV2JSON[]> {
579+
callback?: (span: SerializedStreamedSpan) => Promise<boolean> | boolean,
580+
): Promise<SerializedStreamedSpan[]> {
581581
const timestamp = getNanosecondTimestamp();
582582
return new Promise((resolve, reject) => {
583583
waitForRequest(
@@ -587,10 +587,10 @@ export function waitForSpansV2(
587587
const envelopeItems = envelope[1];
588588

589589
for (const envelopeItem of envelopeItems) {
590-
if (isSpanV2EnvelopeItem(envelopeItem)) {
590+
if (isStreamedSpanEnvelopeItem(envelopeItem)) {
591591
const spans = envelopeItem[1].items;
592592
if (callback) {
593-
const matchingSpans: SpanV2JSON[] = [];
593+
const matchingSpans: SerializedStreamedSpan[] = [];
594594
for (const span of spans) {
595595
if (await callback(span)) {
596596
matchingSpans.push(span);
@@ -623,7 +623,7 @@ export function waitForSpansV2(
623623
* });
624624
* ```
625625
*/
626-
export function getSpanV2Op(span: SpanV2JSON): string | undefined {
626+
export function getSpanOp(span: SerializedStreamedSpan): string | undefined {
627627
return span.attributes?.['sentry.op']?.type === 'string' ? span.attributes['sentry.op'].value : undefined;
628628
}
629629

dev-packages/test-utils/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ export {
88
waitForSession,
99
waitForPlainRequest,
1010
waitForMetric,
11-
waitForSpanV2,
12-
waitForSpansV2,
13-
waitForSpanV2Envelope,
14-
getSpanV2Op,
11+
waitForStreamedSpan,
12+
waitForStreamedSpans,
13+
waitForStreamedSpanEnvelope,
14+
getSpanOp,
1515
} from './event-proxy-server';
1616

1717
export { getPlaywrightConfig } from './playwright-config';

0 commit comments

Comments
 (0)