diff --git a/plugins/airbrake/package.json b/plugins/airbrake/package.json index d9b957803b..26e2d5fded 100644 --- a/plugins/airbrake/package.json +++ b/plugins/airbrake/package.json @@ -32,6 +32,7 @@ "react": "^16.13.1 || ^17.0.0" }, "devDependencies": { + "@backstage/app-defaults": "^0.1.2", "@backstage/cli": "^0.10.2", "@backstage/core-app-api": "^0.2.1", "@backstage/dev-utils": "^0.2.14", @@ -42,7 +43,8 @@ "@types/jest": "*", "@types/node": "*", "msw": "^0.35.0", - "cross-fetch": "^3.0.6" + "cross-fetch": "^3.0.6", + "react-router": "6.0.0-beta.0" }, "files": [ "dist" diff --git a/plugins/airbrake/src/plugin.test.ts b/plugins/airbrake/src/index.test.ts similarity index 73% rename from plugins/airbrake/src/plugin.test.ts rename to plugins/airbrake/src/index.test.ts index ab78fb2549..ce7d493983 100644 --- a/plugins/airbrake/src/plugin.test.ts +++ b/plugins/airbrake/src/index.test.ts @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { airbrakePlugin } from './plugin'; +import { AirbrakePage, airbrakePlugin } from './index'; -describe('airbrake', () => { - it('should export plugin', () => { - expect(airbrakePlugin).toBeDefined(); +describe('The demo index page', () => { + it('exports the plugin and page', async () => { + expect(AirbrakePage).toBeTruthy(); + expect(airbrakePlugin).toBeTruthy(); }); }); diff --git a/plugins/airbrake/src/plugin.test.tsx b/plugins/airbrake/src/plugin.test.tsx new file mode 100644 index 0000000000..36696e4aaa --- /dev/null +++ b/plugins/airbrake/src/plugin.test.tsx @@ -0,0 +1,57 @@ +/* + * Copyright 2021 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. + */ +import React from 'react'; +import { AirbrakePage, airbrakePlugin } from './plugin'; +import { renderWithEffects } from '@backstage/test-utils'; +import { createApp } from '@backstage/app-defaults'; +import { Route } from 'react-router'; + +describe('Airbrake', () => { + it('should export plugin', () => { + expect(airbrakePlugin).toBeDefined(); + }); + + it('should render page', async () => { + process.env = { + NODE_ENV: 'test', + APP_CONFIG: [ + { + data: { + app: { title: 'Test' }, + backend: { baseUrl: 'http://localhost:7000' }, + techdocs: { + storageUrl: 'http://localhost:7000/api/techdocs/static/docs', + }, + }, + context: 'test', + }, + ] as any, + }; + + const app = createApp(); + const AppProvider = app.getProvider(); + const AppRouter = app.getRouter(); + + const rendered = await renderWithEffects( + + + } /> + + , + ); + expect(rendered.baseElement).toBeInTheDocument(); + }); +});