From 1473dd9eb69cbe0f60b23beddc7de3b0fc5d4afa Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Tue, 7 Mar 2023 09:22:22 +0100 Subject: [PATCH] add initial test for search plugin Signed-off-by: Emma Indal --- plugins/search-backend/package.json | 1 + plugins/search-backend/src/alpha.test.ts | 31 ++++++++++++++++++++++++ yarn.lock | 1 + 3 files changed, 33 insertions(+) create mode 100644 plugins/search-backend/src/alpha.test.ts diff --git a/plugins/search-backend/package.json b/plugins/search-backend/package.json index 6e971ba646..50a28d3ac5 100644 --- a/plugins/search-backend/package.json +++ b/plugins/search-backend/package.json @@ -57,6 +57,7 @@ "zod": "~3.18.0" }, "devDependencies": { + "@backstage/backend-test-utils": "workspace:^", "@backstage/cli": "workspace:^", "@types/supertest": "^2.0.8", "supertest": "^6.1.3" diff --git a/plugins/search-backend/src/alpha.test.ts b/plugins/search-backend/src/alpha.test.ts new file mode 100644 index 0000000000..527f099236 --- /dev/null +++ b/plugins/search-backend/src/alpha.test.ts @@ -0,0 +1,31 @@ +/* + * 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. + */ + +import { startTestBackend } from '@backstage/backend-test-utils'; +import request from 'supertest'; +import { searchPlugin } from './alpha'; + +describe('searchPlugin', () => { + it('should serve search results on query endpoint', async () => { + const { server } = await startTestBackend({ + features: [searchPlugin()], + }); + + const response = await request(server).get('/api/search/query'); + expect(response.status).toBe(200); + expect(response.body).toEqual({ numberOfResults: 0, results: [] }); + }); +}); diff --git a/yarn.lock b/yarn.lock index c2c60036fb..b5203fbe29 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7837,6 +7837,7 @@ __metadata: dependencies: "@backstage/backend-common": "workspace:^" "@backstage/backend-plugin-api": "workspace:^" + "@backstage/backend-test-utils": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" "@backstage/errors": "workspace:^"