Dev (#46)
* 🚀 refactor: simplify deployment process in workflow file * 🚀 chore: add IMAGE_NAME to GITHUB_ENV for deployment workflow * ✨ chore: simplify deployment logging in workflow file * 🚀 fix: correct container name in deployment script logic * 🚀 refactor: rename job and streamline deployment steps * Update README.md * ✨ fix: prevent multiple form submissions in Contact component * ✨ feat: honeypot and timestamp checks to form submission * ✨ refactor: simplify contact form and improve UI elements * ✨ feat: add responsive masonry layout for projects display * ✨ style: Update project title size and improve layout visibility * ✨ fix: remove unnecessary test assertions and improve act usage
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
||||
import { render, screen, fireEvent, waitFor, act } from '@testing-library/react';
|
||||
import Contact from '@/app/components/Contact';
|
||||
import '@testing-library/jest-dom';
|
||||
|
||||
@@ -28,16 +28,29 @@ describe('Contact', () => {
|
||||
|
||||
it('submits the form', async () => {
|
||||
render(<Contact />);
|
||||
// Wrap timer advancement in act
|
||||
await act(async () => {
|
||||
jest.advanceTimersByTime(3000);
|
||||
});
|
||||
|
||||
// Fast forward time to ensure the timestamp check passes
|
||||
jest.advanceTimersByTime(3000);
|
||||
// Fire events inside act if needed
|
||||
act(() => {
|
||||
fireEvent.change(screen.getByPlaceholderText('Your Name'), {
|
||||
target: { value: 'John Doe' },
|
||||
});
|
||||
fireEvent.change(screen.getByPlaceholderText('you@example.com'), {
|
||||
target: { value: 'john@example.com' },
|
||||
});
|
||||
fireEvent.change(screen.getByPlaceholderText('Your Message...'), {
|
||||
target: { value: 'Hello!' },
|
||||
});
|
||||
fireEvent.click(screen.getByLabelText('I accept the privacy policy.'));
|
||||
fireEvent.click(screen.getByText('Send Message'));
|
||||
});
|
||||
|
||||
fireEvent.change(screen.getByPlaceholderText('Your Name'), { target: { value: 'John Doe' } });
|
||||
fireEvent.change(screen.getByPlaceholderText('you@example.com'), { target: { value: 'john@example.com' } });
|
||||
fireEvent.change(screen.getByPlaceholderText('Your Message...'), { target: { value: 'Hello!' } });
|
||||
fireEvent.click(screen.getByLabelText('I accept the privacy policy.'));
|
||||
fireEvent.click(screen.getByText('Send Message'));
|
||||
|
||||
await waitFor(() => expect(screen.getByText('Email sent')).toBeInTheDocument());
|
||||
// Wait for the result
|
||||
await waitFor(() =>
|
||||
expect(screen.getByText('Email sent')).toBeInTheDocument()
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -38,7 +38,6 @@ describe('Projects', () => {
|
||||
expect(screen.getByText('Hello bla bla bla bla')).toBeInTheDocument();
|
||||
expect(screen.getByText('Blockchain Based Voting System')).toBeInTheDocument();
|
||||
expect(screen.getByText('This project aims to revolutionize voting systems by leveraging blockchain to ensure security, transparency, and immutability.')).toBeInTheDocument();
|
||||
expect(screen.getByText('More to come')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user