forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ALERTING][APM] Fix service names with spaces are not being URL encod…
…ed properly for {{context.viewInAppUrl}} (elastic#202890) ## Summary It fixes elastic#184381 by encoding correctly the service name and adding tests
- Loading branch information
1 parent
d6da75f
commit ecb125b
Showing
2 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
x-pack/plugins/observability_solution/apm/common/utils/formatters/alert_url.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { getAlertUrlErrorCount, getAlertUrlTransaction } from './alert_url'; | ||
describe('alert_url', () => { | ||
describe('getAlertUrlErrorCount', () => { | ||
it('return the URL where the service name is camelcase', () => { | ||
const url = getAlertUrlErrorCount('serviceName', 'serviceEnv'); | ||
expect(url).toBe('/app/apm/services/serviceName/errors?environment=serviceEnv'); | ||
}); | ||
it('return the URL where the service name is sneak case', () => { | ||
const url = getAlertUrlErrorCount('service_name', 'serviceEnv'); | ||
expect(url).toBe('/app/apm/services/service_name/errors?environment=serviceEnv'); | ||
}); | ||
it('return the URL encoded correctly where the service name has spaces', () => { | ||
const url = getAlertUrlErrorCount('service name', 'serviceEnv'); | ||
expect(url).toBe('/app/apm/services/service%20name/errors?environment=serviceEnv'); | ||
}); | ||
}); | ||
describe('getAlertUrlTransaction', () => { | ||
it('return the URL where the service name is camelcase', () => { | ||
const url = getAlertUrlTransaction('serviceName', 'serviceEnv', 'transactionType'); | ||
expect(url).toBe( | ||
'/app/apm/services/serviceName?transactionType=transactionType&environment=serviceEnv' | ||
); | ||
}); | ||
it('return the URL where the service name is sneak case', () => { | ||
const url = getAlertUrlTransaction('service_name', 'serviceEnv', 'transactionType'); | ||
expect(url).toBe( | ||
'/app/apm/services/service_name?transactionType=transactionType&environment=serviceEnv' | ||
); | ||
}); | ||
it('return the URL encoded correctly where the service name has spaces', () => { | ||
const url = getAlertUrlTransaction('service name', 'serviceEnv', 'transactionType'); | ||
expect(url).toBe( | ||
'/app/apm/services/service%20name?transactionType=transactionType&environment=serviceEnv' | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters