diff --git a/plugins/splunk-on-call/src/components/Errors/MissingTokenError.tsx b/plugins/splunk-on-call/src/components/Errors/MissingApiKeyOrApiIdError.tsx similarity index 80% rename from plugins/splunk-on-call/src/components/Errors/MissingTokenError.tsx rename to plugins/splunk-on-call/src/components/Errors/MissingApiKeyOrApiIdError.tsx index 221ab780e7..ea72b6ca51 100644 --- a/plugins/splunk-on-call/src/components/Errors/MissingTokenError.tsx +++ b/plugins/splunk-on-call/src/components/Errors/MissingApiKeyOrApiIdError.tsx @@ -17,11 +17,11 @@ import React from 'react'; import { EmptyState } from '@backstage/core'; import { Button } from '@material-ui/core'; -export const MissingTokenError = () => ( +export const MissingApiKeyOrApiIdError = () => ( { }), ).toBeInTheDocument(); expect(getByText('test-incident')).toBeInTheDocument(); - expect(getByTitle('ACKED')).toBeInTheDocument(); + expect(getByTitle('Acknowledged')).toBeInTheDocument(); expect(getByLabelText('Status warning')).toBeInTheDocument(); // assert links, mailto and hrefs, date calculation diff --git a/plugins/splunk-on-call/src/components/SplunkOnCallCard.test.tsx b/plugins/splunk-on-call/src/components/SplunkOnCallCard.test.tsx index 018c18f37d..8a4f2464cb 100644 --- a/plugins/splunk-on-call/src/components/SplunkOnCallCard.test.tsx +++ b/plugins/splunk-on-call/src/components/SplunkOnCallCard.test.tsx @@ -22,6 +22,9 @@ import { alertApiRef, ApiProvider, ApiRegistry, + ConfigApi, + configApiRef, + ConfigReader, createApiRef, } from '@backstage/core'; import { @@ -43,8 +46,15 @@ const mockSplunkOnCallApi: Partial = { getTeams: async () => [MOCK_TEAM], }; +const configApi: ConfigApi = new ConfigReader({ + splunkOnCall: { + username: MOCKED_USER.username, + }, +}); + const apis = ApiRegistry.from([ [splunkOnCallApiRef, mockSplunkOnCallApi], + [configApiRef, configApi], [ alertApiRef, createApiRef({ @@ -64,7 +74,7 @@ const entity: Entity = { }, }; -describe('PageDutyCard', () => { +describe('SplunkOnCallCard', () => { it('Render splunkoncall', async () => { mockSplunkOnCallApi.getUsers = jest .fn() @@ -97,7 +107,7 @@ describe('PageDutyCard', () => { ); await waitFor(() => !queryByTestId('progress')); expect( - getByText('Missing or invalid SplunkOnCall Token'), + getByText('Missing or invalid Splunk On-Call API key and/or API id'), ).toBeInTheDocument(); }); diff --git a/plugins/splunk-on-call/src/components/SplunkOnCallCard.tsx b/plugins/splunk-on-call/src/components/SplunkOnCallCard.tsx index 63776b6844..6d6d1c71e4 100644 --- a/plugins/splunk-on-call/src/components/SplunkOnCallCard.tsx +++ b/plugins/splunk-on-call/src/components/SplunkOnCallCard.tsx @@ -39,7 +39,7 @@ import { Alert } from '@material-ui/lab'; import { splunkOnCallApiRef, UnauthorizedError } from '../api'; import AlarmAddIcon from '@material-ui/icons/AlarmAdd'; import { TriggerDialog } from './TriggerDialog'; -import { MissingTokenError } from './Errors/MissingTokenError'; +import { MissingApiKeyOrApiIdError } from './Errors/MissingApiKeyOrApiIdError'; import { User } from './types'; const useStyles = makeStyles({ @@ -69,7 +69,7 @@ export const MissingUsername = () => ( ); @@ -117,7 +117,7 @@ export const SplunkOnCallCard = ({ entity }: Props) => { username && users?.userList.find(user => user.username === username); if (error instanceof UnauthorizedError) { - return ; + return ; } if (error) { @@ -136,7 +136,7 @@ export const SplunkOnCallCard = ({ entity }: Props) => { if (!team) { return ; } - if (!username) { + if (!username || !incidentCreator) { return ; } diff --git a/plugins/splunk-on-call/src/components/TriggerDialog/TriggerDialog.test.tsx b/plugins/splunk-on-call/src/components/TriggerDialog/TriggerDialog.test.tsx index 16fbe815d0..c5176efefd 100644 --- a/plugins/splunk-on-call/src/components/TriggerDialog/TriggerDialog.test.tsx +++ b/plugins/splunk-on-call/src/components/TriggerDialog/TriggerDialog.test.tsx @@ -66,6 +66,7 @@ describe('TriggerDialog', () => { {}} users={[MOCKED_USER]} onIncidentCreated={() => {}} diff --git a/plugins/splunk-on-call/src/plugin.test.ts b/plugins/splunk-on-call/src/plugin.test.ts index e55229cab8..a64e5474a1 100644 --- a/plugins/splunk-on-call/src/plugin.test.ts +++ b/plugins/splunk-on-call/src/plugin.test.ts @@ -15,7 +15,7 @@ */ import { plugin } from './plugin'; -describe('splunkoncall', () => { +describe('splunk-on-call', () => { it('should export plugin', () => { expect(plugin).toBeDefined(); });