test: add auth system and attachment regression coverage
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import React from 'react';
|
||||
import '@testing-library/jest-dom';
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import { ConfirmProvider } from './confirm';
|
||||
import { PromptProvider } from './prompt';
|
||||
import Attachments from './components/Attachments';
|
||||
import { ToastProvider } from './toast';
|
||||
import { api } from './api';
|
||||
|
||||
jest.mock('./api', () => ({
|
||||
api: {
|
||||
get: jest.fn(),
|
||||
post: jest.fn(),
|
||||
patch: jest.fn(),
|
||||
delete: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
const mockedApi = api as jest.Mocked<typeof api>;
|
||||
|
||||
test('attachments empty state renders drag and drop guidance', async () => {
|
||||
mockedApi.get.mockResolvedValueOnce({ data: [] } as any);
|
||||
|
||||
render(
|
||||
<ToastProvider>
|
||||
<ConfirmProvider>
|
||||
<PromptProvider>
|
||||
<Attachments jobId={42} />
|
||||
</PromptProvider>
|
||||
</ConfirmProvider>
|
||||
</ToastProvider>,
|
||||
);
|
||||
|
||||
expect(await screen.findByText(/drag and drop files here/i)).toBeInTheDocument();
|
||||
expect(screen.getByText(/no attachments yet/i)).toBeInTheDocument();
|
||||
expect(screen.getByText(/max 10 mb each/i)).toBeInTheDocument();
|
||||
});
|
||||
Reference in New Issue
Block a user