Chore/tests and ci - #2
Conversation
There was a problem hiding this comment.
Pull request overview
Introduces frontend unit testing infrastructure (Jest + React Testing Library), adds a dedicated test suite for the Pagination component, and adds a GitHub Actions CI workflow to run frontend/backend tests automatically.
Changes:
- Add Jest + React Testing Library setup (config, setup file, CSS module mocking).
- Add comprehensive
Paginationunit tests. - Add CI workflow to run backend and frontend test jobs on pushes/PRs.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
frontend/src/setupTests.ts | Loads @testing-library/jest-dom matchers for all Jest tests. |
frontend/src/components/Pagination.test.tsx | Adds Jest/RTL test coverage for pagination rendering, states, and callbacks. |
frontend/package.json | Updates test scripts and adds Jest/RTL dependencies. |
frontend/jest.config.cjs | Enables .tsx tests, adds CSS import mocking, and wires setupTests.ts. |
frontend/__mocks__/styleMock.cjs | Provides a stub for CSS/SCSS imports in Jest. |
.github/workflows/ci.yml | Adds CI jobs to run backend and frontend tests in GitHub Actions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| test('clicking Last on a small dataset goes to lastPage with filtered window', async () => { | ||
| const user = userEvent.setup(); | ||
| // totalCount=30 → lastPage=3; tail window = [lastPage-4..lastPage] but lastPage≤5 | ||
| // so getPageWindow(3, 3) → [1,2,3,4,5] filtered to ≤3 → [1,2,3] | ||
| const { onPageChange } = renderPagination(1, 30, 10); | ||
| await user.click(screen.getByRole('button', { name: 'Last' })); | ||
| expect(onPageChange).toHaveBeenCalledWith(3, [1, 2, 3, 4, 5]); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.
This pull request sets up and integrates unit testing for the frontend using Jest and React Testing Library, adds comprehensive tests for the
Paginationcomponent, and introduces a CI workflow to run both frontend and backend tests. The changes improve test coverage, developer experience, and ensure automated verification of code via GitHub Actions.Testing infrastructure and configuration:
.github/workflows/ci.ymlto run backend and frontend tests on push and pull request events, ensuring continuous integration for both codebases.frontend/jest.config.cjsto support.tsxtest files, added support for CSS module mocking, and included setup for React Testing Library.frontend/__mocks__/styleMock.cjsto prevent errors when importing CSS/SCSS in tests.@testing-library/jest-dominfrontend/src/setupTests.ts.Testing and dependencies:
frontend/package.json, including React Testing Library and related packages, and adjusted test scripts to run Jest for unit tests and Playwright for end-to-end tests. [1][2]Component test coverage:
Paginationcomponent infrontend/src/components/Pagination.test.tsx, covering rendering logic, button states, callback behavior, and edge cases.