Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

55 add unit tests for room creation #120

Merged
merged 14 commits into from
Aug 29, 2022

Conversation

odelcroi
Copy link
Member

@odelcroi odelcroi commented Jul 18, 2022

This PR adds unit tests for the TCHAP react component TchapCreateRoomDialog :

  • rendering tests to check that the switch button is shown when due
  • submit tests to check that the component invokes the room creation with the correct parameters.

It uses the framework Jest and Enzyme with Snapshots.

Static and Module mocking is widely use as there is no dependency injection :/

Side note : TchapCreateRoom has been mutated to a static class to ease mocking.. Maybe not necessary


This PR currently has none of the required changelog labels.

A reviewer can add one of: T-Deprecation, T-Enhancement, T-Defect, T-Task to indicate what type of change this is, or add Type: [enhancement/defect/task] to the description and I'll add them for you.

@odelcroi odelcroi linked an issue Jul 18, 2022 that may be closed by this pull request
@celiacheff
Copy link
Contributor

Je vais chipoter un peu mais pour moi les tests de components ne sont unitaires mais plutôt d'intégration (vu qu'il s'agit d'une dépendance externe au métier, que les tests sont plus lents et testent une collaboration). Après ça me choque pas plus que ça

@estellecomment
Copy link
Contributor

General note : we need to be easily able to tell what is our code and what is element's, for future rebases with element.
So far we have added ":TCHAP:" in comments everywhere.

@odelcroi
Copy link
Member Author

Key learnings :

  • The actual configuration does not work with jest 27 or jest 28. It is stuck to jest 26 with an error of typescript transcompilation I guess (babel..).

  • The configuration of enzyme is not taken from matrix-react-sdk for an unknown reason. It has been duplicated to a proper setupTests.js file. Though the rest of the configuration from matrix-react-sdk seems to be taken into account.

import Adapter from "@wojtekmaj/enzyme-adapter-react-17";
import { configure } from "enzyme";
configure({ adapter: new Adapter() });
  • only the unit tests are executed to alleviate pressure on computer ressources
"testMatch": [
      "<rootDir>/test/unit-tests/**/*-test.[tj]s?(x)"
    ]
  • the transformIgnorePatterns has been updated in order to work properly :
"transformIgnorePatterns": [
      "\/node_modules\/(?!matrix-js-sdk|matrix-react-sdk).+$"
    ]

@odelcroi odelcroi force-pushed the 55-add-unit-tests-for-room-creation branch from 54d1085 to 97fc0e3 Compare July 20, 2022 10:36
@estellecomment
Copy link
Contributor

CI fails :

  • build is failing because of timeout. It took too long.
  • static analysis : js-sdk is full of errors, react-sdk modules are not found (we could limit the check to our own code)
  • tests : /node_modules/matrix-react-sdk/test/setupTests.js in the setupFilesAfterEnv option was not found -> the yarn linking is probably not working ?
  • style lint : broken, needs yarn links ? Cannot find module 'matrix-react-sdk/.stylelintrc.js'

@estellecomment estellecomment merged commit 1c20baa into develop_tchap Aug 29, 2022
@odelcroi odelcroi deleted the 55-add-unit-tests-for-room-creation branch March 31, 2023 15:52
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.

Add unit tests for Room Creation
3 participants