Skip to content

Commit 4250db3

Browse files
committed
fix background tab test
1 parent 68c3f57 commit 4250db3

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/backgroundtab-custom/test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ sentryTest('should finish a custom transaction when the page goes background', a
2323
const transactionHandle = await page.evaluateHandle('window.transaction');
2424

2525
const id_before = await getPropertyValue(transactionHandle, 'span_id');
26-
const name_before = await getPropertyValue(transactionHandle, 'name');
26+
const nameBefore = JSON.parse(await transactionHandle.evaluate((t: any) => JSON.stringify(t))).description;
2727
const status_before = await getPropertyValue(transactionHandle, 'status');
2828
const tags_before = await getPropertyValue(transactionHandle, 'tags');
2929

30-
expect(name_before).toBe('test-transaction');
30+
expect(nameBefore).toBe('test-transaction');
3131
expect(status_before).toBeUndefined();
3232
expect(tags_before).toStrictEqual({});
3333

3434
await page.locator('#go-background').click();
3535

3636
const id_after = await getPropertyValue(transactionHandle, 'span_id');
37-
const name_after = await getPropertyValue(transactionHandle, 'name');
37+
const nameAfter = JSON.parse(await transactionHandle.evaluate((t: any) => JSON.stringify(t))).description;
3838
const status_after = await getPropertyValue(transactionHandle, 'status');
3939
const tags_after = await getPropertyValue(transactionHandle, 'tags');
4040

4141
expect(id_before).toBe(id_after);
42-
expect(name_after).toBe(name_before);
42+
expect(nameAfter).toBe('test-transaction');
4343
expect(status_after).toBe('cancelled');
4444
expect(tags_after).toStrictEqual({ visibilitychange: 'document.hidden' });
4545
});

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/pageloadWithHeartbeatTimeout/test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect } from '@playwright/test';
2+
import { spanToJSON } from '@sentry/core';
23
import type { Event } from '@sentry/types';
34

45
import { sentryTest } from '../../../../utils/fixtures';
@@ -20,8 +21,10 @@ sentryTest(
2021

2122
expect(eventData.contexts?.trace?.op).toBe('pageload');
2223
expect(
23-
// eslint-disable-next-line deprecation/deprecation
24-
eventData.spans?.find(span => span.description === 'pageload-child-span' && span.status === 'cancelled'),
24+
eventData.spans?.find(
25+
// eslint-disable-next-line deprecation/deprecation
26+
span => spanToJSON(span).description === 'pageload-child-span' && span.status === 'cancelled',
27+
),
2528
).toBeDefined();
2629
},
2730
);

dev-packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-custom/test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ sentryTest('should finish a custom transaction when the page goes background', a
2323
const transactionHandle = await page.evaluateHandle('window.transaction');
2424

2525
const id_before = await getPropertyValue(transactionHandle, 'span_id');
26-
const name_before = await getPropertyValue(transactionHandle, 'name');
26+
const nameBefore = JSON.parse(await transactionHandle.evaluate((t: any) => JSON.stringify(t))).description;
2727
const status_before = await getPropertyValue(transactionHandle, 'status');
2828
const tags_before = await getPropertyValue(transactionHandle, 'tags');
2929

30-
expect(name_before).toBe('test-transaction');
30+
expect(nameBefore).toBe('test-transaction');
3131
expect(status_before).toBeUndefined();
3232
expect(tags_before).toStrictEqual({});
3333

3434
await page.locator('#go-background').click();
3535

3636
const id_after = await getPropertyValue(transactionHandle, 'span_id');
37-
const name_after = await getPropertyValue(transactionHandle, 'name');
37+
const nameAfter = JSON.parse(await transactionHandle.evaluate((t: any) => JSON.stringify(t))).description;
3838
const status_after = await getPropertyValue(transactionHandle, 'status');
3939
const tags_after = await getPropertyValue(transactionHandle, 'tags');
4040

4141
expect(id_before).toBe(id_after);
42-
expect(name_after).toBe(name_before);
42+
expect(nameAfter).toBe('test-transaction');
4343
expect(status_after).toBe('cancelled');
4444
expect(tags_after).toStrictEqual({ visibilitychange: 'document.hidden' });
4545
});

dev-packages/browser-integration-tests/suites/tracing/browsertracing/pageloadWithHeartbeatTimeout/test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect } from '@playwright/test';
2+
import { spanToJSON } from '@sentry/core';
23
import type { Event } from '@sentry/types';
34

45
import { sentryTest } from '../../../../utils/fixtures';
@@ -20,8 +21,10 @@ sentryTest(
2021

2122
expect(eventData.contexts?.trace?.op).toBe('pageload');
2223
expect(
23-
// eslint-disable-next-line deprecation/deprecation
24-
eventData.spans?.find(span => span.description === 'pageload-child-span' && span.status === 'cancelled'),
24+
eventData.spans?.find(
25+
// eslint-disable-next-line deprecation/deprecation
26+
span => spanToJSON(span).description === 'pageload-child-span' && span.status === 'cancelled',
27+
),
2528
).toBeDefined();
2629
},
2730
);

packages/core/test/lib/tracing/trace.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ describe('startSpan', () => {
105105
}
106106
expect(ref).toBeDefined();
107107

108-
expect(ref.name).toEqual('GET users/[id]');
108+
expect(spanToJSON(ref).description).toEqual('GET users/[id]');
109109
expect(ref.status).toEqual(isError ? 'internal_error' : undefined);
110110
});
111111

@@ -192,7 +192,7 @@ describe('startSpan', () => {
192192
}
193193

194194
expect(ref.spanRecorder.spans).toHaveLength(2);
195-
expect(ref.spanRecorder.spans[1].description).toEqual('SELECT * from users');
195+
expect(spanToJSON(ref.spanRecorder.spans[1]).description).toEqual('SELECT * from users');
196196
expect(ref.spanRecorder.spans[1].parentSpanId).toEqual(ref.spanId);
197197
expect(ref.spanRecorder.spans[1].status).toEqual(isError ? 'internal_error' : undefined);
198198
});

packages/core/test/lib/tracing/transaction.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ describe('transaction', () => {
1818
const transaction = new Transaction({ name: 'span name' });
1919
transaction.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');
2020
expect(spanToJSON(transaction).description).toEqual('span name');
21+
expect(spanToJSON(transaction).data?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]).toEqual('route');
2122

2223
transaction.updateName('new name');
2324

2425
expect(spanToJSON(transaction).description).toEqual('new name');
25-
expect(transaction.metadata.source).toEqual('route');
26+
expect(spanToJSON(transaction).data?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]).toEqual('custom');
2627
});
2728
/* eslint-enable deprecation/deprecation */
2829
});

0 commit comments

Comments
 (0)