Skip to content

Commit 1a0f182

Browse files
authored
[Observability] [Alert details page] Follow up to fix view in discover link is partial broken (elastic#226847)
## Summary This is a follow-up on #elastic#217993 and that fixes elastic#212133 by adding a missing check/case
1 parent 414216b commit 1a0f182

7 files changed

Lines changed: 43 additions & 7 deletions

File tree

x-pack/solutions/observability/plugins/observability/common/custom_threshold_rule/get_view_in_app_url.test.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ describe('getViewInAppUrl', () => {
302302
{ spaceId }
303303
);
304304
});
305-
it('should call getRedirectUrl with dataViewSpec', () => {
305+
it('should call getRedirectUrl with dataViewSpec of the AD-HOC data view', () => {
306306
const spaceId = 'mockedSpaceId';
307307
const dataViewSpec = {
308308
id: 'mockedDataViewId',
@@ -345,4 +345,39 @@ describe('getViewInAppUrl', () => {
345345
{ spaceId }
346346
);
347347
});
348+
it('should call getRedirectUrl with the id of the SAVED data view ', () => {
349+
const spaceId = 'mockedSpaceId';
350+
const mockedDataViewId = 'uuid-mocked-dataView-id';
351+
const args: GetViewInAppUrlArgs = {
352+
dataViewId: mockedDataViewId,
353+
searchConfiguration: {
354+
index: 'uuid-mockedDataViewId',
355+
query: {
356+
language: '',
357+
query: 'mockedFilter',
358+
},
359+
filter: [],
360+
},
361+
logsLocator,
362+
startedAt,
363+
endedAt,
364+
spaceId,
365+
};
366+
367+
expect(getViewInAppUrl(args)).toBe('mockedGetRedirectUrl');
368+
expect(logsLocator.getRedirectUrl).toHaveBeenCalledWith(
369+
{
370+
dataset: undefined,
371+
dataViewSpec: undefined,
372+
dataViewId: mockedDataViewId,
373+
timeRange: returnedTimeRange,
374+
filters: [],
375+
query: {
376+
query: 'mockedFilter',
377+
language: 'kuery',
378+
},
379+
},
380+
{ spaceId }
381+
);
382+
});
348383
});

x-pack/solutions/observability/plugins/observability/common/custom_threshold_rule/get_view_in_app_url.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,15 @@ export const getViewInAppUrl = ({
5858
query.query = searchConfigurationQuery;
5959
}
6060
let dataViewSpec;
61-
if (searchConfiguration?.index && !isEmpty(searchConfiguration?.index)) {
61+
62+
if (
63+
typeof searchConfiguration?.index === 'object' &&
64+
searchConfiguration.index !== null &&
65+
!isEmpty(searchConfiguration.index)
66+
) {
6267
dataViewSpec = searchConfiguration.index as DataViewSpec;
6368
}
69+
6470
return logsLocator.getRedirectUrl(
6571
{
6672
dataViewId,

x-pack/test/api_integration/deployment_agnostic/apis/observability/alerting/custom_threshold/avg_pct_fired.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
279279
expect(resp.hits.hits[0]._source?.viewInAppUrl).contain('DISCOVER_APP_LOCATOR');
280280
expect(omit(parsedViewInAppUrl.params, 'timeRange.from')).eql({
281281
dataViewId: DATA_VIEW_ID,
282-
dataViewSpec: DATA_VIEW_ID,
283282
timeRange: { to: 'now' },
284283
query: { query: '', language: 'kuery' },
285284
filters: [],

x-pack/test/api_integration/deployment_agnostic/apis/observability/alerting/custom_threshold/avg_pct_no_data.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
235235
expect(resp.hits.hits[0]._source?.viewInAppUrl).contain('DISCOVER_APP_LOCATOR');
236236
expect(omit(parsedViewInAppUrl.params, 'timeRange.from')).eql({
237237
dataViewId: DATA_VIEW_ID,
238-
dataViewSpec: DATA_VIEW_ID,
239238
timeRange: { to: 'now' },
240239
query: { query: '', language: 'kuery' },
241240
filters: [],

x-pack/test/api_integration/deployment_agnostic/apis/observability/alerting/custom_threshold/avg_ticks_fired.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
277277
expect(resp.hits.hits[0]._source?.viewInAppUrl).contain('DISCOVER_APP_LOCATOR');
278278
expect(omit(parsedViewInAppUrl.params, 'timeRange.from')).eql({
279279
dataViewId: DATA_VIEW_ID,
280-
dataViewSpec: DATA_VIEW_ID,
281280
timeRange: { to: 'now' },
282281
query: { query: '', language: 'kuery' },
283282
filters: [],

x-pack/test/api_integration/deployment_agnostic/apis/observability/alerting/custom_threshold/cardinality_runtime_field_fired.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
280280
expect(resp.hits.hits[0]._source?.viewInAppUrl).contain('DISCOVER_APP_LOCATOR');
281281
expect(omit(parsedViewInAppUrl.params, 'timeRange.from')).eql({
282282
dataViewId: DATA_VIEW_ID,
283-
dataViewSpec: DATA_VIEW_ID,
284283
timeRange: { to: 'now' },
285284
query: { query: '', language: 'kuery' },
286285
filters: [],

x-pack/test/api_integration/deployment_agnostic/apis/observability/alerting/custom_threshold/documents_count_fired.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
266266
expect(resp.hits.hits[0]._source?.viewInAppUrl).contain('DISCOVER_APP_LOCATOR');
267267
expect(omit(parsedViewInAppUrl.params, 'timeRange.from')).eql({
268268
dataViewId: DATA_VIEW_ID,
269-
dataViewSpec: DATA_VIEW_ID,
270269
timeRange: { to: 'now' },
271270
query: { query: 'host.name:* and container.id:*', language: 'kuery' },
272271
filters: [],

0 commit comments

Comments
 (0)