mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-01-31 00:53:37 +00:00
Updated Tests and Caching
This commit is contained in:
parent
5ba9387411
commit
dbecdc0212
3 changed files with 36 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
# testing
|
# testing
|
||||||
/coverage
|
/coverage
|
||||||
|
junit.xml
|
||||||
|
|
||||||
# next.js
|
# next.js
|
||||||
/.next/
|
/.next/
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import '@testing-library/jest-dom';
|
import '@testing-library/jest-dom';
|
||||||
import { render, screen, fireEvent, act } from '@testing-library/react';
|
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
||||||
|
import { toast } from 'sonner';
|
||||||
|
|
||||||
import { BoardTitleForm } from '@/app/(platform)/(dashboard)/board/[boardId]/_components/board-title-form';
|
import { BoardTitleForm } from '@/app/(platform)/(dashboard)/board/[boardId]/_components/board-title-form';
|
||||||
import { Board } from '@prisma/client';
|
import { Board } from '@prisma/client';
|
||||||
|
@ -15,6 +16,16 @@ jest.mock('@/actions/update-board', () => ({
|
||||||
updateBoard: jest.fn(),
|
updateBoard: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
jest.mock('@/hooks/use-action', () => ({
|
||||||
|
useAction: jest.fn().mockImplementation(() => ({
|
||||||
|
execute: jest.fn().mockImplementation(({ title }) => {
|
||||||
|
Promise.resolve().then(() => {
|
||||||
|
toast.success(`Board "${title}" updated!`);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
})),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('BoardTitleForm', () => {
|
describe('BoardTitleForm', () => {
|
||||||
const mockBoard: Board = {
|
const mockBoard: Board = {
|
||||||
id: '1',
|
id: '1',
|
||||||
|
@ -46,4 +57,19 @@ describe('BoardTitleForm', () => {
|
||||||
const input = await screen.findByDisplayValue('Test Board');
|
const input = await screen.findByDisplayValue('Test Board');
|
||||||
expect(input).toBeInTheDocument();
|
expect(input).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should update board title when form is blurred', async () => {
|
||||||
|
render(<BoardTitleForm data={mockBoard} />);
|
||||||
|
|
||||||
|
const titleButton = screen.getByText('Test Board');
|
||||||
|
fireEvent.click(titleButton);
|
||||||
|
|
||||||
|
const input = await screen.findByDisplayValue('Test Board');
|
||||||
|
fireEvent.change(input, { target: { value: 'New Title' } });
|
||||||
|
fireEvent.blur(input);
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(toast.success).toHaveBeenCalledWith('Board "New Title" updated!');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -31,6 +31,14 @@ const nextConfig: NextConfig = {
|
||||||
key: 'Document-Policy',
|
key: 'Document-Policy',
|
||||||
value: 'js-profiling',
|
value: 'js-profiling',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'CDN-Cache-Control',
|
||||||
|
value: 'public, s-maxage=15',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'Vercel-CDN-Cache-Control',
|
||||||
|
value: 'public, s-maxage=30',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue