Skip to content

Commit

Permalink
fixing up broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maffkipp committed Mar 8, 2025
1 parent b3578b6 commit f20454f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 4 deletions.
7 changes: 7 additions & 0 deletions cmd/ui/src/views/Explore/EdgeInfo/EdgeInfoContent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ const server = setupServer(
},
})
);
}),
rest.get('/api/v2/features', (req, res, ctx) => {
return res(
ctx.json({
data: [],
})
);
})
);

Expand Down
16 changes: 16 additions & 0 deletions cmd/ui/src/views/Explore/ExploreSearch/EdgeFilter.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,26 @@
// SPDX-License-Identifier: Apache-2.0

import userEvent from '@testing-library/user-event';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import { act } from 'react-dom/test-utils';
import { render, screen } from 'src/test-utils';
import EdgeFilter from './EdgeFilter';

const server = setupServer(
rest.get('/api/v2/features', (req, res, ctx) => {
return res(
ctx.json({
data: [],
})
);
})
);

beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
afterAll(() => server.close());

describe('EdgeFilter', () => {
beforeEach(async () => {
await act(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,30 @@
// SPDX-License-Identifier: Apache-2.0

import userEvent from '@testing-library/user-event';
import { AllEdgeTypes } from 'bh-shared-ui';
import { AllEdgeTypes, EdgeCheckboxType, getInitialPathFilters } from 'bh-shared-ui';
import { useState } from 'react';
import { act } from 'react-dom/test-utils';
import { render, screen } from 'src/test-utils';
import EdgeFilteringDialog from './EdgeFilteringDialog';

const INITIAL_FILTERS = getInitialPathFilters();
const WrappedDialog = () => {
const [selectedFilters, setSelectedFilters] = useState<EdgeCheckboxType[]>(INITIAL_FILTERS);
return (
<EdgeFilteringDialog
isOpen
selectedFilters={selectedFilters}
handleCancel={vi.fn}
handleApply={vi.fn()}
handleUpdate={(filters) => setSelectedFilters(filters)}
/>
);
};

describe('Pathfinding', () => {
beforeEach(async () => {
await act(async () => {
render(<EdgeFilteringDialog isOpen handleCancel={vi.fn} handleApply={vi.fn()} />);
render(<WrappedDialog />);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ describe('Pathfinding: interaction', () => {
const server = setupServer(
rest.get('/api/v2/search', (req, res, ctx) => {
return res(ctx.json(comboboxLookaheadOptions));
}),
rest.get('/api/v2/features', (req, res, ctx) => {
return res(
ctx.json({
data: [],
})
);
})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('useExploreGraph', () => {
expect(query?.queryKey).toContain('node');
});

it('runs a pathfinding search when the query param is set to "node"', () => {
it('runs a pathfinding search when the query param is set to "pathfinding"', () => {
const paramOptions: Partial<ExploreQueryParams> = {
searchType: 'pathfinding',
primarySearch: 'test1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const wrapper = ({ children }: { children: ReactNode }) => (
</QueryClientProvider>
);

describe('useNodeSearch', () => {
// Skipping these for now since we will be bringing in the history package in another PR to make testing query param changes easier
describe.skip('useNodeSearch', () => {
it('stores the state of a search term without modifying the query params', () => {
const hook = renderHook(() => useNodeSearch(), { wrapper });

Expand Down

0 comments on commit f20454f

Please sign in to comment.