|
1 | 1 | import type { EmberRouterMain } from '@sentry/ember/addon/types'; |
2 | | -import { |
3 | | - _getLocationURL, |
4 | | - _getRouteUrlAttributes, |
5 | | -} from '@sentry/ember/utils/instrumentEmberAppInstanceForPerformance'; |
| 2 | +import { _getLocationURL, _getRouteUrlAttributes } from '@sentry/ember/utils/instrumentEmberAppInstanceForPerformance'; |
6 | 3 | import { setupTest } from 'ember-qunit'; |
7 | 4 | import { module, test } from 'qunit'; |
8 | 5 | import type { SentryTestContext } from '../helpers/setup-sentry'; |
@@ -124,4 +121,29 @@ module('Unit | Utility | instrument-router-location', function (hooks) { |
124 | 121 | assert.strictEqual(result['url.template'], '/tracing'); |
125 | 122 | assert.ok(result['url.full']?.includes('/tracing'), 'url.full includes the path'); |
126 | 123 | }); |
| 124 | + |
| 125 | + test('_getRouteUrlAttributes preserves query string in url.full', function (this: SentryTestContext, assert) { |
| 126 | + const result = _getRouteUrlAttributes('/tracing?foo=bar'); |
| 127 | + |
| 128 | + assert.strictEqual(result['url.path'], '/tracing'); |
| 129 | + assert.strictEqual(result['url.template'], '/tracing'); |
| 130 | + assert.ok(result['url.full']?.includes('?foo=bar'), 'url.full includes the query string'); |
| 131 | + assert.notOk(result['url.full']?.endsWith('/tracing'), 'url.full is not path-only'); |
| 132 | + }); |
| 133 | + |
| 134 | + test('_getRouteUrlAttributes preserves query string with route params', function (this: SentryTestContext, assert) { |
| 135 | + const result = _getRouteUrlAttributes('/users/123?page=2', { user_id: '123' }); |
| 136 | + |
| 137 | + assert.strictEqual(result['url.path'], '/users/123'); |
| 138 | + assert.strictEqual(result['url.template'], '/users/:user_id'); |
| 139 | + assert.ok(result['url.full']?.includes('/users/123?page=2'), 'url.full includes path and query string'); |
| 140 | + }); |
| 141 | + |
| 142 | + test('_getRouteUrlAttributes preserves query string for hash location', function (this: SentryTestContext, assert) { |
| 143 | + const result = _getRouteUrlAttributes('/#/tracing?foo=bar'); |
| 144 | + |
| 145 | + assert.strictEqual(result['url.path'], '/tracing'); |
| 146 | + assert.strictEqual(result['url.template'], '/tracing'); |
| 147 | + assert.ok(result['url.full']?.includes('?foo=bar'), 'url.full includes the query string'); |
| 148 | + }); |
127 | 149 | }); |
0 commit comments