fix(catalog): tests

This commit is contained in:
Nikita Nek Dudnik
2020-06-17 17:00:10 +02:00
parent 739882c144
commit 29a88c3e9c
7 changed files with 5 additions and 53 deletions
-4
View File
@@ -32,8 +32,6 @@ import {
githubAuthApiRef,
storageApiRef,
WebStorage,
identityApiRef,
MockIdentity,
} from '@backstage/core';
import {
@@ -54,8 +52,6 @@ export const apis = (config: ConfigApi) => {
const builder = ApiRegistry.builder();
builder.add(identityApiRef, new MockIdentity());
const alertApi = builder.add(alertApiRef, new AlertApiForwarder());
const errorApi = builder.add(
errorApiRef,
@@ -1,25 +0,0 @@
/*
* Copyright 2020 Spotify AB
*
* 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 { IdentityApi } from '../..';
export class MockIdentity implements IdentityApi {
getUserId(): string {
return '';
}
getIdToken(): string | undefined {
throw new Error('Method not implemented.');
}
}
@@ -1,16 +0,0 @@
/*
* Copyright 2020 Spotify AB
*
* 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 './Identity';
@@ -26,4 +26,3 @@ export * from './ConfigApi';
export * from './ErrorApi';
export * from './OAuthRequestApi';
export * from './StorageApi';
export * from './IdentityApi';
-1
View File
@@ -13,7 +13,6 @@ import {
GoogleAuth,
GithubAuth,
identityApiRef,
MockIdentity,
} from '@backstage/core';
const builder = ApiRegistry.builder();
@@ -44,6 +44,7 @@ describe('CatalogPage', () => {
kind: 'Component',
spec: {
owner: 'tools@example.com',
type: 'service',
},
},
{
@@ -54,6 +55,7 @@ describe('CatalogPage', () => {
kind: 'Component',
spec: {
owner: 'not-tools@example.com',
type: 'service',
},
},
] as Entity[]),
@@ -83,7 +85,6 @@ describe('CatalogPage', () => {
),
);
await waitFor(() => screen.getByText(/All Services \(2\)/));
expect(screen.getByText(/All Services \(2\)/)).toBeInTheDocument();
});
it('should filter by owner', async () => {
render(
@@ -102,6 +103,5 @@ describe('CatalogPage', () => {
);
fireEvent.click(screen.getByText(/Owned/));
await waitFor(() => screen.getByText(/Owned \(1\)/));
expect(screen.getByText(/Owned \(1\)/)).toBeInTheDocument();
});
});
@@ -61,11 +61,10 @@ export const CatalogPage: FC<{}> = () => {
error,
loading,
selectedFilter,
setSelectedFilter,
toggleStarredEntity,
isStarredEntity,
setSelectedFilter,
selectedTypeFilter: selectedTab,
selectTypeFilter: setSelectedTab,
selectTypeFilter,
} = useEntities();
const filteredEntities = entitiesByFilter[selectedFilter ?? EntityGroup.ALL];
@@ -123,7 +122,7 @@ export const CatalogPage: FC<{}> = () => {
<HeaderTabs
tabs={labeledEntityTypes}
onChange={(index: Number) => {
setSelectedTab(labeledEntityTypes[index as number].id);
selectTypeFilter(labeledEntityTypes[index as number].id);
}}
/>
<Content>