diff --git a/plugins/api-docs/src/components/ApiExplorerPage/DefaultApiExplorerPage.test.tsx b/plugins/api-docs/src/components/ApiExplorerPage/DefaultApiExplorerPage.test.tsx
index fa698ded58..6d0b191d68 100644
--- a/plugins/api-docs/src/components/ApiExplorerPage/DefaultApiExplorerPage.test.tsx
+++ b/plugins/api-docs/src/components/ApiExplorerPage/DefaultApiExplorerPage.test.tsx
@@ -52,6 +52,10 @@ describe('DefaultApiExplorerPage', () => {
kind: 'API',
metadata: {
name: 'Entity1',
+ annotations: {
+ 'backstage.io/view-url': 'viewurl',
+ 'backstage.io/edit-url': 'editurl',
+ },
},
spec: { type: 'openapi' },
},
@@ -63,6 +67,11 @@ describe('DefaultApiExplorerPage', () => {
getEntityFacets: async () => ({
facets: { 'relations.ownedBy': [] },
}),
+ queryEntities: async () => ({
+ items: [],
+ pageInfo: {},
+ totalItems: 0,
+ }),
};
const configApi: ConfigApi = new ConfigReader({
@@ -152,37 +161,39 @@ describe('DefaultApiExplorerPage', () => {
it('should render the default actions of an item in the grid', async () => {
await renderWrapped();
- expect(await screen.findByText(/All apis \(1\)/)).toBeInTheDocument();
- expect(await screen.findByTitle(/View/)).toBeInTheDocument();
- expect(await screen.findByTitle(/View/)).toBeInTheDocument();
- expect(await screen.findByTitle(/Edit/)).toBeInTheDocument();
- expect(await screen.findByTitle(/Add to favorites/)).toBeInTheDocument();
+ await waitFor(() => {
+ expect(screen.getByText(/All apis \(1\)/)).toBeInTheDocument();
+ });
+
+ await waitFor(() => {
+ expect(screen.getByRole('button', { name: /view/i })).toBeInTheDocument();
+ });
+ expect(screen.getByRole('button', { name: /edit/i })).toBeInTheDocument();
+ expect(screen.getByTitle(/Add to favorites/)).toBeInTheDocument();
});
it('should render the custom actions of an item passed as prop', async () => {
const actions: TableProps['actions'] = [
- () => {
- return {
- icon: () => ,
- tooltip: 'Foo Action',
- disabled: false,
- onClick: () => jest.fn(),
- };
+ {
+ icon: () => ,
+ tooltip: 'Foo Action',
+ disabled: false,
+ onClick: jest.fn(),
},
- () => {
- return {
- icon: () => ,
- tooltip: 'Bar Action',
- disabled: true,
- onClick: () => jest.fn(),
- };
+ {
+ icon: () => ,
+ tooltip: 'Bar Action',
+ disabled: true,
+ onClick: jest.fn(),
},
];
await renderWrapped();
- expect(await screen.findByText(/All apis \(1\)/)).toBeInTheDocument();
- expect(await screen.findByTitle(/Foo Action/)).toBeInTheDocument();
- expect(await screen.findByTitle(/Bar Action/)).toBeInTheDocument();
- expect((await screen.findByTitle(/Bar Action/)).firstChild).toBeDisabled();
+ await waitFor(() => {
+ expect(screen.getByText(/All apis \(1\)/)).toBeInTheDocument();
+ });
+ expect(screen.getByTitle(/Foo Action/)).toBeInTheDocument();
+ expect(screen.getByTitle(/Bar Action/)).toBeInTheDocument();
+ expect(screen.getByTitle(/Bar Action/).firstChild).toBeDisabled();
});
});