Skip to content

test(browser): Add integration tests for setTags #4345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/integration-tests/suites/public-api/setTags/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as Sentry from '@sentry/browser';

window.Sentry = Sentry;

Sentry.init({
dsn: 'https://[email protected]/1337',
});
11 changes: 11 additions & 0 deletions packages/integration-tests/suites/public-api/setTags/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="{{htmlWebpackPlugin.options.initialization}}"></script>
</head>
<body>
<script src="{{htmlWebpackPlugin.options.subject}}"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Sentry.setTags({
tag_1: {},
tag_2: [],
tag_3: ['a', new Map()],
tag_4: () => {},
});

Sentry.captureMessage('non_primitives');
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';

sentryTest('should not accept non-primitive tags', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });

const eventData = await getSentryRequest(page, url);

expect(eventData.message).toBe('non_primitives');
expect(eventData.tags).toMatchObject({});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Sentry.setTags({
tag_1: 'foo',
tag_2: Math.PI,
tag_3: false,
tag_4: null,
tag_5: undefined,
tag_6: -1,
});

Sentry.captureMessage('primitive_tags');
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';

sentryTest('should set primitive tags', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });

const eventData = await getSentryRequest(page, url);

expect(eventData.message).toBe('primitive_tags');
expect(eventData.tags).toMatchObject({
tag_1: 'foo',
tag_2: 3.141592653589793,
tag_3: false,
tag_4: null,
tag_6: -1,
});
});