-
Notifications
You must be signed in to change notification settings - Fork 0
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
React Testing Library (RTL) and Version Status Component #135
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…require ActionKeys
…additional Metafile fields
…red it (i.e. Diff card)
nelsonni
added
bug
Bug reports or bug fixes
feature
Feature requests or improvements
help wanted
question
dependencies
Issues or updates to dependency files
labels
Sep 2, 2020
This was
linked to
issues
Sep 2, 2020
Closed
…o use the new reduxStoreMock.ts implementation
…t mocked Redux store access
…ter is a directory
After e743c32, the test coverage is:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Bug reports or bug fixes
dependencies
Issues or updates to dependency files
feature
Feature requests or improvements
help wanted
question
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Testing React function components for UI interactions with Enzyme is cumbersome and brittle (i.e. prone to false negatives when tests needed to fire off a series of click/selection events). Therefore, React Testing Library is being added to provide testing infrastructure for user-centric actions (such as clicks and visual tests). Instead of testing implementation details, the updated tests now operate in ways similar to how a user would locate and interact with the React component UIs.
Additionally, several new and upcoming features required a re-architecture of the
Metafile
andCard
type definitions. The introduction of React Testing Library also found several asynchronous bugs in the acquisition and loading functions for metafiles, cards, and repositories. This PR closes #98.Includes:
metafiles.getMetafiles()
refactored to be a Thunk Action Creator that retrieves Metafile objects based on one of three different parameters:{ id: UUID }
for obtaining existing Metafile objects from the Redux store.{ filepath: PathLike }
for obtaining new (or existing) Metafile objects associated with the specific file path and Git branch (if under version control).{ virtual: { name: string, handler: CardType, ... } }
for obtaining new (or existing) Metafile objects that are not associated with a specific file path, but can be represented by a Metafile within the Redux store. All fields of theMetafile
type can be included and set in this virtual parameter (except forid
,modified
,name
, andhandler
).NarrowType
andRemoveType
have been simplified to useExtract<Type, Union>
andExclude<Type, ExcludedUnion>
Utility Types instead of discriminated type narrowing (which required bothAction
andActionKeys
to be added at each invocation); now only the appropriateActionKeys
must be provided.mockStore
.FileExplorer
has been renamed toExplorer
to align with the other card components (e.g.Editor
,Browser
,Diff
).useDirectory
React Hook updated with tests and a bugfix for a synchronization bug when initializing the hook data using theinitialRoot
parameter. Because calls tosetState()
on ReactuseState
hooks enqueue the subsequent updates to occur after the next component re-render, theuseDirectory
hook was providing stale data that didn't include theroot
metafile (and throwing subsequent errors when attempting to poll for directories and files).useDirectory
hook switched from default export to explicit exporting, which was needed to allow the hook to be mocked for testing using@testing-library/react-hooks
.extractFieldArray()
andExtractFieldMap()
added to allow typed extraction of mocked Redux store fields that would normally be returned withDeepPartial<T> | undefined
types onstore.getState().field<T>
calls.Metafile
type definitions expanded to include atargets
field forDiff
cards to have UUIDs for linked cards (including being able to get live diff updates based on content changes in those cards).Card
type definitions updated to include the UUID of only one related metafile (i.e. the metafile containing the content displayed in that card). Previously, theCard
type allowed multiple linked metafiles in order to allow theDiff
card to directly manage linked cards, but since theDiff
card must maintain the diff'ed content in another metafile it made sense to migrate this information into theMetafile
type definitions.handlers.loadCard()
refactored to be a Thunk Action Creator that retrieves and adds Card objects based on one of two different parameters:{ metafile: Metafile }
for loading a new Card based on an existing Metafile from the Redux store.{ filepath: PathLike }
for obtaining a new (or existing) Metafile object associated with the specific file path and Git branch (if under version control).ErrorDialog
updated to correctly display error messages within the dialog. Previous attempts used@material-ui/core/TextField
components inside of@material-ui/core/Dialog
components, which are incompatible and result in null ops for rendering any text within the dialog.git.getStatus
parameter is a directory, sinceisomorphic-git.status()
does not resolve the git status of directories (per git status for directories isomorphic-git/isomorphic-git#13), and instead suggests the use ofisomorphic-git.statusMatrix()
for descending into directories and gathering the git status of all contained files instead..simulate()
method in theEnzyme
library (per Deprecating Enzyme's .simulate() function and replacing event handler invokers #98), and instead rely on thefireEvent
commands in theReact Testing Library (RTL)
.hidefile
v3.0.0 added@testing-library/jest-dom
v5.11.4 added@testing-library/react
v10.4.9 added@testing-library/react-hooks
v3.4.1 addedeslint-plugin-jest-dom
v3.1.7 addedeslint-plugin-testing-library
v3.8.0 addedreact-select-event
v5.0.0 addedisomorphic-git
updated from v1.5.0 to v1.7.6jest
updated from v26.0.1 to v26.4.0