diff --git a/.changeset/flat-beans-kiss.md b/.changeset/flat-beans-kiss.md new file mode 100644 index 0000000000..4dfe06afdd --- /dev/null +++ b/.changeset/flat-beans-kiss.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-pagerduty': patch +--- + +Minor internal tweaks to improve tests diff --git a/packages/repo-tools/src/commands/api-reports/api-reports.test.ts b/packages/repo-tools/src/commands/api-reports/api-reports.test.ts index ccb6981baa..0ffd8c5342 100644 --- a/packages/repo-tools/src/commands/api-reports/api-reports.test.ts +++ b/packages/repo-tools/src/commands/api-reports/api-reports.test.ts @@ -113,6 +113,8 @@ describe('buildApiReports', () => { jest.clearAllMocks(); }); + jest.spyOn(console, 'log').mockImplementation(() => {}); + it('should run without any options', async () => { const opts = {}; const paths: string[] = []; diff --git a/plugins/pagerduty/src/components/PagerDutyCard/index.test.tsx b/plugins/pagerduty/src/components/PagerDutyCard/PagerDutyCard.test.tsx similarity index 99% rename from plugins/pagerduty/src/components/PagerDutyCard/index.test.tsx rename to plugins/pagerduty/src/components/PagerDutyCard/PagerDutyCard.test.tsx index bc00d7d6e6..b1f525bcfa 100644 --- a/plugins/pagerduty/src/components/PagerDutyCard/index.test.tsx +++ b/plugins/pagerduty/src/components/PagerDutyCard/PagerDutyCard.test.tsx @@ -16,7 +16,7 @@ import React from 'react'; import { screen, waitFor, fireEvent, act } from '@testing-library/react'; -import { PagerDutyCard } from '../PagerDutyCard'; +import { PagerDutyCard } from './PagerDutyCard'; import { NotFoundError } from '@backstage/errors'; import { TestApiRegistry, renderInTestApp } from '@backstage/test-utils'; import { pagerDutyApiRef, UnauthorizedError, PagerDutyClient } from '../../api'; diff --git a/plugins/pagerduty/src/components/PagerDutyCard/index.tsx b/plugins/pagerduty/src/components/PagerDutyCard/PagerDutyCard.tsx similarity index 89% rename from plugins/pagerduty/src/components/PagerDutyCard/index.tsx rename to plugins/pagerduty/src/components/PagerDutyCard/PagerDutyCard.tsx index 332d823f1f..8be87e0f15 100644 --- a/plugins/pagerduty/src/components/PagerDutyCard/index.tsx +++ b/plugins/pagerduty/src/components/PagerDutyCard/PagerDutyCard.tsx @@ -13,8 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import React, { ReactNode, useState, useCallback } from 'react'; -import { Card, CardHeader, Divider, CardContent } from '@material-ui/core'; +import { + Card, + CardHeader, + Divider, + CardContent, + TabProps, +} from '@material-ui/core'; import { Incidents } from '../Incident'; import { EscalationPolicy } from '../Escalation'; import useAsync from 'react-use/lib/useAsync'; @@ -146,6 +153,23 @@ export const PagerDutyCard = (props: PagerDutyCardProps) => { icon: , }; + const tabs: React.ReactElement[] = [ + + + , + ]; + + if (disableChangeEvents !== true) { + tabs.push( + + + , + ); + } + return ( <> @@ -163,24 +187,7 @@ export const PagerDutyCard = (props: PagerDutyCardProps) => { /> - - - - - <> - {disableChangeEvents !== true && ( - - - - )} - - + {...tabs} diff --git a/plugins/pagerduty/src/components/PagerDutyCard/index.ts b/plugins/pagerduty/src/components/PagerDutyCard/index.ts new file mode 100644 index 0000000000..4944a9a13d --- /dev/null +++ b/plugins/pagerduty/src/components/PagerDutyCard/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { PagerDutyCard, type PagerDutyCardProps } from './PagerDutyCard'; diff --git a/plugins/pagerduty/src/components/TriggerDialog/TriggerDialog.tsx b/plugins/pagerduty/src/components/TriggerDialog/TriggerDialog.tsx index a1e88b8fa6..7e273b8d25 100644 --- a/plugins/pagerduty/src/components/TriggerDialog/TriggerDialog.tsx +++ b/plugins/pagerduty/src/components/TriggerDialog/TriggerDialog.tsx @@ -131,7 +131,7 @@ export const TriggerDialog = ({ id="description" multiline fullWidth - rows="4" + minRows={4} margin="normal" label="Problem description" variant="outlined"