feat(splunk-on-call-plugin): update tests
This commit is contained in:
+3
-3
@@ -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 = () => (
|
||||
<EmptyState
|
||||
missing="info"
|
||||
title="Missing or invalid SplunkOnCall Token"
|
||||
description="The request to fetch data needs a valid token. See README for more details."
|
||||
title="Missing or invalid Splunk On-Call API key and/or API id"
|
||||
description="The request to fetch data needs a valid api id and a valid api key. See README for more details."
|
||||
action={
|
||||
<Button
|
||||
color="primary"
|
||||
@@ -14,4 +14,4 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export { MissingTokenError } from './MissingTokenError';
|
||||
export { MissingApiKeyOrApiIdError } from './MissingApiKeyOrApiIdError';
|
||||
|
||||
@@ -93,7 +93,7 @@ describe('Incidents', () => {
|
||||
}),
|
||||
).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
|
||||
|
||||
@@ -22,6 +22,9 @@ import {
|
||||
alertApiRef,
|
||||
ApiProvider,
|
||||
ApiRegistry,
|
||||
ConfigApi,
|
||||
configApiRef,
|
||||
ConfigReader,
|
||||
createApiRef,
|
||||
} from '@backstage/core';
|
||||
import {
|
||||
@@ -43,8 +46,15 @@ const mockSplunkOnCallApi: Partial<SplunkOnCallClient> = {
|
||||
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();
|
||||
});
|
||||
|
||||
|
||||
@@ -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 = () => (
|
||||
<EmptyState
|
||||
title="No Splunk On-Call user available."
|
||||
missing="info"
|
||||
description="You need to add a username to your 'app.config.yml' if you want to enable Splunk On-Call."
|
||||
description="You need to add a valid username to your 'app.config.yml' if you want to enable Splunk On-Call."
|
||||
/>
|
||||
</CardContent>
|
||||
);
|
||||
@@ -117,7 +117,7 @@ export const SplunkOnCallCard = ({ entity }: Props) => {
|
||||
username && users?.userList.find(user => user.username === username);
|
||||
|
||||
if (error instanceof UnauthorizedError) {
|
||||
return <MissingTokenError />;
|
||||
return <MissingApiKeyOrApiIdError />;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
@@ -136,7 +136,7 @@ export const SplunkOnCallCard = ({ entity }: Props) => {
|
||||
if (!team) {
|
||||
return <MissingTeamAnnotation />;
|
||||
}
|
||||
if (!username) {
|
||||
if (!username || !incidentCreator) {
|
||||
return <MissingUsername />;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ describe('TriggerDialog', () => {
|
||||
<ApiProvider apis={apis}>
|
||||
<TriggerDialog
|
||||
showDialog
|
||||
incidentCreator={MOCKED_USER}
|
||||
handleDialog={() => {}}
|
||||
users={[MOCKED_USER]}
|
||||
onIncidentCreated={() => {}}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
import { plugin } from './plugin';
|
||||
|
||||
describe('splunkoncall', () => {
|
||||
describe('splunk-on-call', () => {
|
||||
it('should export plugin', () => {
|
||||
expect(plugin).toBeDefined();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user