From a2ee1d73d1f5ba2da31f7d4eb3d4b98c253a2537 Mon Sep 17 00:00:00 2001 From: Kamil Wolny Date: Tue, 9 Aug 2022 23:27:46 +0100 Subject: [PATCH] feat: generate test issue + new dependencies Signed-off-by: Kamil Wolny --- plugins/github-issues/package.json | 4 +- .../src/utils/generateTestIssue.ts | 53 +++++++++++++++++++ plugins/github-issues/src/utils/index.ts | 16 ++++++ yarn.lock | 7 ++- 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 plugins/github-issues/src/utils/generateTestIssue.ts create mode 100644 plugins/github-issues/src/utils/index.ts diff --git a/plugins/github-issues/package.json b/plugins/github-issues/package.json index 2ddb8481c4..98434ce748 100644 --- a/plugins/github-issues/package.json +++ b/plugins/github-issues/package.json @@ -25,15 +25,17 @@ "@backstage/catalog-model": "^1.0.3", "@backstage/core-components": "^0.11.0-next.2", "@backstage/core-plugin-api": "^1.0.5-next.0", + "@backstage/errors": "^1.1.0", "@backstage/integration": "^1.3.0-next.0", "@backstage/plugin-catalog-react": "^1.1.3-next.2", "@backstage/theme": "^0.2.15", + "@faker-js/faker": "^7.4.0", "@material-ui/core": "^4.12.4", "@material-ui/icons": "^4.9.1", "@material-ui/lab": "^4.0.0-alpha.61", "luxon": "^2.4.0", "octokit": "^2.0.4", - "react-use": "^17.2.4" + "react-use": "^17.4.0" }, "peerDependencies": { "react": "^16.13.1 || ^17.0.0" diff --git a/plugins/github-issues/src/utils/generateTestIssue.ts b/plugins/github-issues/src/utils/generateTestIssue.ts new file mode 100644 index 0000000000..a07c8dfc57 --- /dev/null +++ b/plugins/github-issues/src/utils/generateTestIssue.ts @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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 { faker } from '@faker-js/faker'; +import { Issue } from '../api'; + +export const generateTestIssue = ( + overwrites: Partial = {}, +): { node: Issue } => ({ + node: { + ...{ + assignees: { + edges: [ + { + node: { + avatarUrl: faker.internet.avatar(), + login: `${faker.word.adjective()}-${faker.animal.type()}`, + }, + }, + ], + }, + author: { + login: `${faker.word.adjective()}-${faker.animal.type()}`, + }, + repository: { + nameWithOwner: `${faker.animal.type()}/${faker.animal.type()}`, + }, + title: faker.lorem.words(3), + url: faker.internet.url(), + participants: { + totalCount: +faker.random.numeric(), + }, + updatedAt: faker.date.past().toISOString(), + createdAt: faker.date.past().toISOString(), + comments: { + totalCount: +faker.random.numeric(), + }, + }, + ...overwrites, + }, +}); diff --git a/plugins/github-issues/src/utils/index.ts b/plugins/github-issues/src/utils/index.ts new file mode 100644 index 0000000000..16740dac94 --- /dev/null +++ b/plugins/github-issues/src/utils/index.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2022 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 * from './generateTestIssue'; diff --git a/yarn.lock b/yarn.lock index f8d31be28f..4bebec76e1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2673,6 +2673,11 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" +"@faker-js/faker@^7.4.0": + version "7.4.0" + resolved "https://registry.npmjs.org/@faker-js/faker/-/faker-7.4.0.tgz#cac720d860a89d487b47e55e66a4fd114f1d3fe5" + integrity sha512-xDd3Tvkt2jgkx1LkuwwxpNBy/Oe+LkZBTwkgEFTiWpVSZgQ5sc/LenbHKRHbFl0dq/KFeeq/szyyPtpJRKY0fg== + "@fmvilas/pseudo-yaml-ast@^0.3.1": version "0.3.1" resolved "https://registry.npmjs.org/@fmvilas/pseudo-yaml-ast/-/pseudo-yaml-ast-0.3.1.tgz#66c5df2c2d76ba8571dc5bd98fda4d7dce6121de" @@ -22465,7 +22470,7 @@ react-universal-interface@^0.6.2: resolved "https://registry.npmjs.org/react-universal-interface/-/react-universal-interface-0.6.2.tgz#5e8d438a01729a4dbbcbeeceb0b86be146fe2b3b" integrity sha512-dg8yXdcQmvgR13RIlZbTRQOoUrDciFVoSBZILwjE2LFISxZZ8loVJKAkuzswl5js8BHda79bIb2b84ehU8IjXw== -react-use@^17.2.4, react-use@^17.3.1, react-use@^17.3.2: +react-use@^17.2.4, react-use@^17.3.1, react-use@^17.3.2, react-use@^17.4.0: version "17.4.0" resolved "https://registry.npmjs.org/react-use/-/react-use-17.4.0.tgz#cefef258b0a6c534a5c8021c2528ac6e1a4cdc6d" integrity sha512-TgbNTCA33Wl7xzIJegn1HndB4qTS9u03QUwyNycUnXaweZkE4Kq2SB+Yoxx8qbshkZGYBDvUXbXWRUmQDcZZ/Q==