mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-08 19:28:57 +08:00
feat: add unit test
This commit is contained in:
parent
b35b975798
commit
b499b10333
@ -521,6 +521,7 @@ function DashboardsList(): JSX.Element {
|
||||
</div>
|
||||
|
||||
{action && (
|
||||
<div data-testid="dashboard-action-popover">
|
||||
<Popover
|
||||
trigger="click"
|
||||
content={
|
||||
@ -578,6 +579,7 @@ function DashboardsList(): JSX.Element {
|
||||
}}
|
||||
/>
|
||||
</Popover>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="dashboard-details">
|
||||
|
@ -1,7 +1,10 @@
|
||||
/* eslint-disable sonarjs/no-duplicate-string */
|
||||
import ROUTES from 'constants/routes';
|
||||
import DashboardsList from 'container/ListOfDashboard';
|
||||
import { dashboardEmptyState } from 'mocks-server/__mockdata__/dashboards';
|
||||
import {
|
||||
dashboardEmptyState,
|
||||
dashboardSuccessResponse,
|
||||
} from 'mocks-server/__mockdata__/dashboards';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { DashboardProvider } from 'providers/Dashboard/Dashboard';
|
||||
@ -204,4 +207,24 @@ describe('dashboard list page', () => {
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it('ensure that the popover actions on each list item renders list of options', async () => {
|
||||
const { getByText, getAllByTestId } = render(
|
||||
<MemoryRouter initialEntries={['/dashbords']}>
|
||||
<DashboardProvider>
|
||||
<DashboardsList />
|
||||
</DashboardProvider>
|
||||
</MemoryRouter>,
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
const popovers = getAllByTestId('dashboard-action-popover');
|
||||
expect(popovers).toHaveLength(dashboardSuccessResponse.data.length);
|
||||
fireEvent.click([...popovers[0].children][0]);
|
||||
});
|
||||
|
||||
expect(getByText('View')).toBeInTheDocument();
|
||||
expect(getByText('Copy Link')).toBeInTheDocument();
|
||||
expect(getByText('Export JSON')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user