Skip to content

Conversation

@Alex-Delaveau
Copy link
Contributor

Describe your changes

image

  • Testing framework switch: Replaced Vitest with Jest (jest.config.ts, updated scripts/dependencies).
  • Test utilities: Added module mocks and a renderWithProviders helper.
  • New unit tests: Covering the FolderModal component, ModalProvider, and the isEnterPressed utility.
  • Build script update: Extended build.sh with a testFormulaireReact target to run React tests.
  • Minor tweaks: Simplified DialogTitle in FolderModal and enabled esModuleInterop/allowSyntheticDefaultImports in tsconfig.app.json.

Checklist tests

Issue ticket number and link

Checklist before requesting a review (magic string, indentation, comment/documentation...)

  • I have detailed the tests to do in my feature/fix in order to prevent consequents regressions (must specify in Checklist tests)
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (API Doc etc...) - (must specify in Description for target version)
  • If it is a consequent feature, I have added thorough tests.
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been added to this project (must specify in Description)

@Alex-Delaveau Alex-Delaveau requested a review from Copilot April 23, 2025 09:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Jest and Testing Library support for React, replacing Vitest and introducing new tests for key components and utilities.

  • Switched testing framework from Vitest to Jest and updated related scripts and configuration.
  • Added test utilities (renderWithProviders) and new unit tests for FolderModal, ModalProvider, and isEnterPressed utility.
  • Updated build scripts and minor UI tweaks in FolderModal.

Reviewed Changes

Copilot reviewed 11 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
formulaire/frontend/src/tests/testUtils.tsx Added a custom renderWithProviders for wrapping tests with app context.
formulaire/frontend/src/tests/mocks/uiMocks.tsx Created module mocks for UI components from @cgi-learning-hub/ui.
formulaire/frontend/src/tests/mocks/edificeReact.tsx Provided no-op mocks for EdificeClientProvider / EdificeThemeProvider.
formulaire/frontend/src/tests/mocks/cgiTheme.tsx Added a simplified ThemeProvider mock for tests.
formulaire/frontend/src/tests/jestSetup.tsx Configured jest setup and i18n mock.
formulaire/frontend/src/providers/ModalProvider/tests/ModalProvider.spec.tsx Added tests to validate modal context behavior and error handling.
formulaire/frontend/src/core/tests/utils.spec.ts Tested the isEnterPressed utility.
formulaire/frontend/src/containers/FolderModal/index.tsx Simplified DialogTitle usage in FolderModal.
formulaire/frontend/src/containers/FolderModal/tests/FolderModal.spec.tsx Added tests for FolderModal actions in both CREATE and RENAME modes.
formulaire/frontend/jest.config.ts Updated Jest configuration for transforms, coverage, and module mappings.
Files not reviewed (3)
  • build.sh: Language not supported
  • formulaire/frontend/package.json: Language not supported
  • formulaire/frontend/tsconfig.app.json: Language not supported
Comments suppressed due to low confidence (1)

formulaire/frontend/src/containers/FolderModal/index.tsx:79

  • Ensure that the DialogTitle component accepts the 'fontWeight' prop directly; if not, consider using the sx prop (e.g., <DialogTitle sx={{ fontWeight: 'bold' }}>...) to apply the styling.
<DialogTitle fontWeight="bold">{t(currentConfig.i18nTitle)}</DialogTitle>

@niko-amosse niko-amosse requested a review from Copilot April 23, 2025 09:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces Vitest with Jest as the testing framework and improves the test infrastructure by adding mocks, a custom render helper, and new unit tests for several components and utilities.

  • Replaced Vitest with Jest and updated configuration/scripts
  • Introduced a custom render helper (renderWithProviders) and added relevant test mocks
  • Added new tests for FolderModal, ModalProvider, and the isEnterPressed utility

Reviewed Changes

Copilot reviewed 12 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/tests/testUtils.tsx Added renderWithProviders helper with app providers for Jest tests
src/tests/mocks/uiMocks.tsx Provided mocks for UI components from MUI
src/tests/mocks/edificeReact.tsx Provided no‑op implementations for Edifice providers
src/tests/mocks/cgiTheme.tsx Provided a no‑op ThemeProvider for testing
src/tests/jestSetup.tsx Set up Jest-related test configuration and mocks
providers/ModalProvider/tests/ModalProvider.spec.tsx Added tests to verify proper functioning of ModalProvider
src/core/tests/utils.spec.ts Added tests covering the isEnterPressed utility function
containers/FolderModal/index.tsx Simplified the DialogTitle structure in FolderModal
containers/FolderModal/tests/FolderModal.spec.tsx Added tests for FolderModal behaviors in both CREATE and RENAME modes
jest.config.ts Introduced a Jest configuration file for overall test setup
Files not reviewed (3)
  • build.sh: Language not supported
  • formulaire/frontend/package.json: Language not supported
  • formulaire/frontend/tsconfig.app.json: Language not supported

@Alex-Delaveau Alex-Delaveau force-pushed the test-env branch 3 times, most recently from 3c41394 to 62e480b Compare April 28, 2025 12:03
@Alex-Delaveau Alex-Delaveau requested a review from Copilot April 28, 2025 13:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR transitions the testing framework from Vitest to Jest, adds extensive unit tests for various components and utilities, and includes several minor tweaks to UI components and build configurations.

  • Introduces Jest configuration and polyfills.
  • Adds new unit tests for ModalProvider, FolderModal, FormPropModal, and various utility functions.
  • Implements minor refactors such as simplified DialogTitle usage and updates to ESLint and workflow files.

Reviewed Changes

Copilot reviewed 26 out of 28 changed files in this pull request and generated no comments.

Show a summary per file
File Description
formulaire/frontend/src/tests/jest/jest.polyfills.js Adds polyfills to support Jest in the frontend tests.
formulaire/frontend/src/providers/ModalProvider/tests/ModalProvider.spec.tsx Provides tests for modal provider behavior and error boundaries.
formulaire/frontend/src/core/models/form/utils.ts Updates utility functions, including changes to distribution functions and form status logic.
formulaire/frontend/src/core/models/form/tests/IForm.spec.ts Adds unit tests covering form-related utilities.
formulaire/frontend/src/core/models/distribution/utils.ts Adds getLatestResponsedDistribution and refactors getLatestDistribution and getFirstDistribution.
formulaire/frontend/src/core/models/distribution/tests/IDistribution.spec.ts Introduces tests verifying distribution utility functions.
formulaire/frontend/src/core/constants.ts Updates the DEFAULT_PAGINATION_LIMIT value.
formulaire/frontend/src/core/tests/utils.spec.ts Includes tests for the isEnterPressed utility function.
formulaire/frontend/src/containers/HomeMainFormsTable/index.tsx Wraps table content with an explicit Table component and updates pagination conditions.
formulaire/frontend/src/containers/HomeMainFormsTable/tests/HomeMainFormsTable.spec.tsx Adds tests for table rendering, pagination behavior, and checkbox selection.
formulaire/frontend/src/containers/FormPropModal/index.tsx Refactors DialogTitle usage using Fragment for keying and simplifies markup.
formulaire/frontend/src/containers/FormPropModal/tests/FormPropModal.spec.tsx Provides tests for form modal interactions in both CREATE and UPDATE modes.
formulaire/frontend/src/containers/FolderModal/index.tsx Simplifies the DialogTitle component for the folder modal.
formulaire/frontend/src/containers/FolderModal/tests/FolderModal.spec.tsx Includes tests for folder creation and renaming functionality.
formulaire/frontend/src/components/RgpdInfoBox/test/RgpdInfoBox.spec.tsx Adds tests for rendering RGPD information with interpolated values.
formulaire/frontend/jest.config.ts Establishes Jest configuration with coverage settings and module mappings.
formulaire/frontend/eslint.config.js Updates the ignore list to include additional test polyfill files.
.github/workflows/dev-check-repository.yml Refines workflow step names for running tests across different frameworks.
Files not reviewed (2)
  • build.sh: Language not supported
  • formulaire/frontend/package.json: Language not supported
Comments suppressed due to low confidence (2)

formulaire/frontend/src/core/models/form/utils.ts:77

  • In isFormFilled, getNbFinishedDistrib is applied to the full distributions array rather than the filtered formDistributions. It should likely use formDistributions to correctly reflect the form's response status.
return getNbFinishedDistrib(distributions) > 0;

formulaire/frontend/src/core/constants.ts:40

  • Changing DEFAULT_PAGINATION_LIMIT from 10 to 1 may impact UI pagination behavior. Please confirm if this change is intentional.
export const DEFAULT_PAGINATION_LIMIT = 1;

qperie and others added 17 commits May 5, 2025 13:34
)

* chore(): [#FOR-868] change architecture to prepare React migration

* chore(pipeline): [#FOR-868] fix git workflow
* chore(react): [#FOR-868] add React

* chore(react): [#FOR-868] update git worflow

* chore(react): [#FOR-868] add React and improve build.sh files

* chore(angular): [#FOR-868] fix build.sh

* chore(react): [#FOR-868] link react to the app

* chore(lint): [#FOR-868] fix pipeline git

* fix(JekinsFile): [#FOR-868] fix JenkinsFile for future delivery
* feat: add HomeView component and folder API service

* refactor: simplify Folder interface and clean up folderApi endpoints
* feat(): [#FOR-869] add Header

* feat(header): [#FOR-869] retours PR

* lint
* feat: implement HomeTabs component and update folder modal functionality

* feat(sidebar) : mainlayout+sidebarlayout+treeview-impl+tab

* fix: update Box import source in HomeMainLayout

* fix(form): fix review
* feat(FormPropModal): add modal component with create/update functionality and localization

* feat(FormPropModal): enhance modal with image upload, date selection, and improved localization

* wip

* feat(FormPropModal): refactor date handling and improve checkbox state management

* feat(Form): refactor form model and API integration; update folder imports and improve state management

* feat(RgpdInfoBox, FormPropModal): fix review
* feat(toaster): implement toaster component with button actions and state management

* refactor(toaster): simplify button actions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants