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.
- Loading branch information
1 parent
046aebd
commit 7554939
Showing
27 changed files
with
521 additions
and
88 deletions.
There are no files selected for viewing
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
57 changes: 57 additions & 0 deletions
57
...y_solution/public/onboarding/components/onboarding_body/cards/alerts/alerts_card.test.tsx
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,57 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { AlertsCard } from './alerts_card'; | ||
import { TestProviders } from '../../../../../common/mock'; | ||
|
||
const props = { | ||
setComplete: jest.fn(), | ||
checkComplete: jest.fn(), | ||
isCardComplete: jest.fn(), | ||
setExpandedCardId: jest.fn(), | ||
}; | ||
|
||
describe('AlertsCard', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('description should be in the document', () => { | ||
const { getByTestId } = render( | ||
<TestProviders> | ||
<AlertsCard {...props} /> | ||
</TestProviders> | ||
); | ||
|
||
expect(getByTestId('alertsCardDescription')).toBeInTheDocument(); | ||
}); | ||
|
||
it('card callout should be rendered if integrations cards is not complete', () => { | ||
props.isCardComplete.mockReturnValueOnce(false); | ||
|
||
const { getByText } = render( | ||
<TestProviders> | ||
<AlertsCard {...props} /> | ||
</TestProviders> | ||
); | ||
|
||
expect(getByText('To view alerts add integrations first.')).toBeInTheDocument(); | ||
}); | ||
|
||
it('card button should be disabled if integrations cards is not complete', () => { | ||
props.isCardComplete.mockReturnValueOnce(false); | ||
|
||
const { getByTestId } = render( | ||
<TestProviders> | ||
<AlertsCard {...props} /> | ||
</TestProviders> | ||
); | ||
|
||
expect(getByTestId('alertsCardButton').querySelector('button')).toBeDisabled(); | ||
}); | ||
}); |
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
48 changes: 0 additions & 48 deletions
48
...nts/onboarding_body/cards/asistant/components/configure_connector/configure_connector.tsx
This file was deleted.
Oops, something went wrong.
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
56 changes: 56 additions & 0 deletions
56
.../public/onboarding/components/onboarding_body/cards/assistant/assistant_check_complete.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,56 @@ | ||
/* | ||
* 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 { loadAllActions as loadConnectors } from '@kbn/triggers-actions-ui-plugin/public/common/constants'; | ||
import type { AIConnector } from '@kbn/elastic-assistant/impl/connectorland/connector_selector'; | ||
import type { OpenAiProviderType } from '@kbn/stack-connectors-plugin/public/common'; | ||
import type { OnboardingCardCheckComplete } from '../../../../types'; | ||
|
||
const AllowedActionTypeIds = ['.bedrock', '.gen-ai', '.gemini']; | ||
const actionTypeKey = { | ||
bedrock: '.bedrock', | ||
openai: '.gen-ai', | ||
gemini: '.gemini', | ||
}; | ||
|
||
export const checkAssistantCardComplete: OnboardingCardCheckComplete = async ({ http }) => { | ||
const aiConnectorsResult = await loadConnectors({ http }); | ||
|
||
const reducedAiConnectorsResult = aiConnectorsResult.reduce( | ||
(acc: AIConnector[], connector) => [ | ||
...acc, | ||
...(!connector.isMissingSecrets && | ||
[actionTypeKey.bedrock, actionTypeKey.openai, actionTypeKey.gemini].includes( | ||
connector.actionTypeId | ||
) | ||
? [ | ||
{ | ||
...connector, | ||
apiProvider: | ||
!connector.isPreconfigured && | ||
!connector.isSystemAction && | ||
connector?.config?.apiProvider | ||
? (connector?.config?.apiProvider as OpenAiProviderType) | ||
: undefined, | ||
}, | ||
] | ||
: []), | ||
], | ||
[] | ||
); | ||
|
||
const filteredConnectors = reducedAiConnectorsResult.filter(({ actionTypeId }) => | ||
AllowedActionTypeIds.includes(actionTypeId) | ||
); | ||
|
||
return { | ||
isComplete: filteredConnectors.length > 0, | ||
metadata: { | ||
connectors: filteredConnectors, | ||
}, | ||
}; | ||
}; |
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
Oops, something went wrong.