From ad5f1a0022ee55596bdc4fcd45380ad350adcf04 Mon Sep 17 00:00:00 2001 From: Karan Shah Date: Thu, 30 Dec 2021 11:50:53 +0000 Subject: [PATCH] Change example data to json Signed-off-by: Karan Shah --- plugins/airbrake/package.json | 2 +- .../AirbrakeWidget/AirbrakeWidget.test.tsx | 4 +- .../AirbrakeWidget/AirbrakeWidget.tsx | 2 +- .../components/AirbrakeWidget/ExampleData.ts | 100 ------------------ .../AirbrakeWidget/example-data.json | 85 +++++++++++++++ 5 files changed, 89 insertions(+), 104 deletions(-) delete mode 100644 plugins/airbrake/src/components/AirbrakeWidget/ExampleData.ts create mode 100644 plugins/airbrake/src/components/AirbrakeWidget/example-data.json diff --git a/plugins/airbrake/package.json b/plugins/airbrake/package.json index 1e12bdd182..d9c983b1dc 100644 --- a/plugins/airbrake/package.json +++ b/plugins/airbrake/package.json @@ -13,7 +13,7 @@ "build": "backstage-cli plugin:build", "start": "backstage-cli plugin:serve", "lint": "backstage-cli lint", - "test": "backstage-cli test --coverage", + "test": "backstage-cli test", "diff": "backstage-cli plugin:diff", "prepack": "backstage-cli prepack", "postpack": "backstage-cli postpack", diff --git a/plugins/airbrake/src/components/AirbrakeWidget/AirbrakeWidget.test.tsx b/plugins/airbrake/src/components/AirbrakeWidget/AirbrakeWidget.test.tsx index 470064ed10..e9e09bd6fc 100644 --- a/plugins/airbrake/src/components/AirbrakeWidget/AirbrakeWidget.test.tsx +++ b/plugins/airbrake/src/components/AirbrakeWidget/AirbrakeWidget.test.tsx @@ -19,10 +19,10 @@ import { render } from '@testing-library/react'; import { ThemeProvider } from '@material-ui/core'; import { lightTheme } from '@backstage/theme'; import { AirbrakeWidget } from './AirbrakeWidget'; -import exampleData from './ExampleData'; +import exampleData from './example-data.json'; describe('AirbrakeWidget', () => { - it('should render all messages sent from a payload', async () => { + it('renders all errors sent from Airbrake', async () => { const table = await render( diff --git a/plugins/airbrake/src/components/AirbrakeWidget/AirbrakeWidget.tsx b/plugins/airbrake/src/components/AirbrakeWidget/AirbrakeWidget.tsx index 1bceb9c7e1..d0a97e76f6 100644 --- a/plugins/airbrake/src/components/AirbrakeWidget/AirbrakeWidget.tsx +++ b/plugins/airbrake/src/components/AirbrakeWidget/AirbrakeWidget.tsx @@ -16,7 +16,7 @@ import React from 'react'; import { Grid, Typography } from '@material-ui/core'; import { InfoCard } from '@backstage/core-components'; -import exampleData from './ExampleData'; +import exampleData from './example-data.json'; import hash from 'object-hash'; import { makeStyles } from '@material-ui/core/styles'; import { BackstageTheme } from '@backstage/theme'; diff --git a/plugins/airbrake/src/components/AirbrakeWidget/ExampleData.ts b/plugins/airbrake/src/components/AirbrakeWidget/ExampleData.ts deleted file mode 100644 index 3d4793c011..0000000000 --- a/plugins/airbrake/src/components/AirbrakeWidget/ExampleData.ts +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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. - */ -export default { - count: 2, - end: '', - groups: [ - { - id: '1', - projectId: 123, - resolved: false, - muted: false, - mutedBy: 0, - mutedAt: null, - errors: [ - { - type: 'Error', - message: 'useSearch must be used within a SearchContextProvider', - backtrace: [ - { - file: 'webpack-internal:///../../node_modules/@backstage/plugin-search/dist/esm/index-893ec2f5.esm.js', - function: 'useSearch', - line: 303, - column: 11, - code: null, - }, - ], - }, - ], - attributes: null, - context: { - action: '', - component: '', - environment: 'local', - severity: 'error', - }, - lastDeployId: '0', - lastDeployAt: null, - lastNoticeId: '234', - lastNoticeAt: '2021-12-19T09:59:00.124Z', - noticeCount: 5, - noticeTotalCount: 5, - commentCount: 0, - createdAt: '2021-12-19T09:44:30.067447Z', - }, - { - id: '2', - projectId: 123, - resolved: true, - muted: false, - mutedBy: 0, - mutedAt: null, - errors: [ - { - type: 'ChunkLoadError', - message: 'Loading chunk 7764 failed.', - backtrace: [ - { - file: '/PROJECT_ROOT/static/runtime.069c874d.js', - function: 'Object._.f.j', - line: 1, - column: 19465, - code: null, - }, - ], - }, - ], - attributes: null, - context: { - action: '', - component: '', - environment: 'local', - severity: 'error', - }, - lastDeployId: '0', - lastDeployAt: null, - lastNoticeId: '345', - lastNoticeAt: '2021-12-15T17:16:38.419Z', - noticeCount: 1, - noticeTotalCount: 1, - commentCount: 0, - createdAt: '2021-12-15T17:16:38.41983Z', - }, - ], - page: 1, - resolvedCount: 1, - unresolvedCount: 1, -}; diff --git a/plugins/airbrake/src/components/AirbrakeWidget/example-data.json b/plugins/airbrake/src/components/AirbrakeWidget/example-data.json new file mode 100644 index 0000000000..fa654ec50b --- /dev/null +++ b/plugins/airbrake/src/components/AirbrakeWidget/example-data.json @@ -0,0 +1,85 @@ +{ + "count": 2, + "end": "", + "groups": [ + { + "id": "1", + "projectId": 123, + "resolved": false, + "muted": false, + "mutedBy": 0, + "mutedAt": null, + "errors": [ + { + "type": "Error", + "message": "useSearch must be used within a SearchContextProvider", + "backtrace": [ + { + "file": "webpack-internal:///../../node_modules/@backstage/plugin-search/dist/esm/index-893ec2f5.esm.js", + "function": "useSearch", + "line": 303, + "column": 11, + "code": null + } + ] + } + ], + "attributes": null, + "context": { + "action": "", + "component": "", + "environment": "local", + "severity": "error" + }, + "lastDeployId": "0", + "lastDeployAt": null, + "lastNoticeId": "234", + "lastNoticeAt": "2021-12-19T09:59:00.124Z", + "noticeCount": 5, + "noticeTotalCount": 5, + "commentCount": 0, + "createdAt": "2021-12-19T09:44:30.067447Z" + }, + { + "id": "2", + "projectId": 123, + "resolved": true, + "muted": false, + "mutedBy": 0, + "mutedAt": null, + "errors": [ + { + "type": "ChunkLoadError", + "message": "Loading chunk 7764 failed.", + "backtrace": [ + { + "file": "/PROJECT_ROOT/static/runtime.069c874d.js", + "function": "Object._.f.j", + "line": 1, + "column": 19465, + "code": null + } + ] + } + ], + "attributes": null, + "context": { + "action": "", + "component": "", + "environment": "local", + "severity": "error" + }, + "lastDeployId": "0", + "lastDeployAt": null, + "lastNoticeId": "345", + "lastNoticeAt": "2021-12-15T17:16:38.419Z", + "noticeCount": 1, + "noticeTotalCount": 1, + "commentCount": 0, + "createdAt": "2021-12-15T17:16:38.41983Z" + } + ], + "page": 1, + "resolvedCount": 1, + "unresolvedCount": 1 +}