Skip to content

Commit

Permalink
Update integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan committed Aug 3, 2022
1 parent 019d791 commit f62e2c3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/remix/test/integration/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import type { MetaFunction } from '@remix-run/node';
import { Links, LiveReload, Meta, Outlet, Scripts, ScrollRestoration } from '@remix-run/react';
import { withSentry } from '@sentry/remix';

export const meta: MetaFunction = () => ({
export const meta: MetaFunction = ({ data }) => ({
charset: 'utf-8',
title: 'New Remix App',
viewport: 'width=device-width,initial-scale=1',
'sentry-trace': data.sentryTrace,
baggage: data.sentryBaggage,
});

function App() {
Expand Down
34 changes: 34 additions & 0 deletions packages/remix/test/integration/test/client/meta-tags.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { test, expect } from '@playwright/test';
import { getFirstSentryEnvelopeRequest } from './utils/helpers';
import { Event } from '@sentry/types';

test('should inject `sentry-trace` and `baggage` meta tags inside the root page.', async ({ page }) => {
await page.goto('/');
Expand Down Expand Up @@ -27,3 +29,35 @@ test('should inject `sentry-trace` and `baggage` meta tags inside a parameterize

expect(sentryBaggageContent).toEqual(expect.any(String));
});

test('should send transactions with corresponding `sentry-trace` and `baggage` inside root page', async ({ page }) => {
const envelope = await getFirstSentryEnvelopeRequest<Event>(page, '/');

const sentryTraceTag = await page.$('meta[name="sentry-trace"]');
const sentryTraceContent = await sentryTraceTag?.getAttribute('content');
const sentryBaggageTag = await page.$('meta[name="baggage"]');
const sentryBaggageContent = await sentryBaggageTag?.getAttribute('content');

expect(sentryTraceContent).toContain(
`${envelope.contexts?.trace.trace_id}-${envelope.contexts?.trace.parent_span_id}-`,
);

expect(sentryBaggageContent).toContain(envelope.contexts?.trace.trace_id);
});

test('should send transactions with corresponding `sentry-trace` and `baggage` inside a parameterized route', async ({
page,
}) => {
const envelope = await getFirstSentryEnvelopeRequest<Event>(page, '/loader-json-response/0');

const sentryTraceTag = await page.$('meta[name="sentry-trace"]');
const sentryTraceContent = await sentryTraceTag?.getAttribute('content');
const sentryBaggageTag = await page.$('meta[name="baggage"]');
const sentryBaggageContent = await sentryBaggageTag?.getAttribute('content');

expect(sentryTraceContent).toContain(
`${envelope.contexts?.trace.trace_id}-${envelope.contexts?.trace.parent_span_id}-`,
);

expect(sentryBaggageContent).toContain(envelope.contexts?.trace.trace_id);
});

0 comments on commit f62e2c3

Please sign in to comment.