Spike: eHoldings - Investigate areas that need refactoring for Jest + RTL testing

UIEH-980 - Getting issue details... STATUS

Goal: provide clarity of what parts of ui-eholdings module need to be refactored for an easier migration to Jest+RTL + suggest order in which components will be tested

Results of Владислав Велицкий review of ui-eholdings code in scope of UIEH-980 - Getting issue details... STATUS

Overview

During replacement proposed to create new test branch where team would write tests on jest library. After completing bigtest test would be removed.

Module has a lot of components, utils, hooks, redux support files which needed to be tested. It needs to create complex stories. There are list of all components below which must be tested. Complexity means that 1 is easy to use component and 3 is hard and need more time to test it.

Tests for actions, epic, reducers would be replaced quickly because libraries had same flow. Just need to move, for example: to.be.equal() => .toEqual()

Components from other libraries should be written in __mock__ folder. There are some of them presented here.

Information about Usage Consolidation feature was not included to this PR because this feature isn't available on master branch and all tests for it could be made in a scope of one task after merging

Components which should be refactored

ComponentDescriptionСomplexityTest statusPreliminary component test estimationEstimation grouped
AccessTypeDisplay-1

✔️



AccessTypeEditSection-1-1
AccessTypeSelect-1-1
CustomLabelEditSection-1-1
CustomLabelShowSection-1-1
AccordionListHeadersuggestions:
- move it so separate folder
- move constants to constants folder
- check propTypes
1-1





3
DetailsViewSection-1-1
ApiLimitExceededErrorScreen-1-1
FailedBackendErrorScreen-1-1
InvalidBackendErrorScreen-1-1
NoBackendErrorScreen-1-1
UserNotAssignedToKbErrorScreen-1-1
ExternalLink-1-1
HiddenLabel-1-1
KeyValueColumns-1-1
List-1-1
NoResultMessage-1-1
PackageContentTypeField-1-1
PackageNameField-1-1





3
PackageEdit-1-1
ProxySelectField-1-1
QueryNotFound-1-1
CustomUrlFieldsThere are two same components - in resource and in title pages. Can remove code duplication1-1
SearchBadge-1-1





3
SearchPackageListItem-1-1
RootProxySelectField-1-1
TagsLabel-1-1
AddTitleToPackage-1-1





3
CustomUrlFields-1-1
DescriptionField-1-1
EditionField-1-1
TitleNameField-1-1
PackageSelectField-1-1





3
PeerReviewedField-1-1
PublicationTypeField-1-1
PublisherNameField-1-1
TitleListItem-1-1
Toast-1-1





3
Toaster-1-1
ToggleSwitchthe component has not been used, it is necessary to check whether it can be removed1-1
TokenField-1-1
ContributorsList-1-1
IdentifiersList-1-1





3
InternalLink-1-1
ProxyDisplay-1-1
shouldFocus-1-1
TokenDisplay-1-1
EHoldingsmove from index.js to separate file and import it to index.js, it could help to keep project structure (one component consist of js file with code, index.js and test file)2-1





3

AgreementsList

-2-22
CoverageDateListcomponent has containsNonEmptyObjectsWithStringValues
function which is better to refactor
1-22
NavigationModal-1-22
PackageCoverageFieldscould be splitted to smallest ones2-22
SelectionStatushave a lot of functions which is better to remove to separate file2-22
ProviderListItem-2-22
QueryList-1-22
CoverageStatementFields-1-2
VisibilityField-1-2





3
SearchPaneset-2-22
SettingsForm-2-22
TagsAccrodion-1-22
ContributorField-2-22
IdentifiersFields-1-22
TitleCreatealready refactored, could be used as an example2-22
TitleEditalready refactored, could be used as an example2-22
PackageSearchList

identical to TitleSearchList, ProviderSearchList

1-2
ProviderSearchListidentical to PackageSearchList, TitleSearchList1-2
TitleSearchListidentical to PackageSearchList, ProviderSearchList1-2





3
AgreementsAccordion-2-33
PackageCreate-2-33
ResourceCoverageFields-2-33
CustomEmbargoFieldscould be splitted2-33
SearchFilters-2-33
CustomLabelField-2-33
SettingsCustomLabels-3-33
SettingsRootProxy-2-33
Settings-3-33
Tags-2-33
PackageFilterModal-2-33
DetailsViewit is better to split the component into several smaller ones3-55
ProviderEdit-2-55
ResourceEditit is better to split the component into several smaller ones, at least each accordion could make component more readable and easier to testing3-55
ScrollView-2-55
SearchFormit is better to split the component into several smaller ones, at least each accordion could make component more readable and easier to testing3-55
SearchModal-2-55
SettingsAccessStatusTypes-3-55
SettingsKnowledgeBasesuggestions:
- check constants
3-55
SettingsAssignedUsers-3-55
ManagedPackageEditit is better to split the component into several smaller ones, at least each accordion could make component more readable and easier to testing3-8?8
CustomPackageEditit is better to split the component into several smaller ones, at least each accordion could make component more readable and easier to testing3-8?8
ProviderShowit is better to split the component into several smaller ones, at least each accordion could make component more readable and easier to testing3-8?8
PackageShowit is better to split the component into several smaller ones, at least each accordion could make component more readable and easier to testing3-8?8
ResourceEditCustomTitleit is better to split the component into several smaller ones, at least each accordion could make component more readable and easier to testing3-8?8
ResourceEditManagedTitleit is better to split the component into several smaller ones, at least each accordion could make component more readable and easier to testing3-8?8
ResourceShowit is better to split the component into several smaller ones, at least each accordion could make component more readable and easier to testing3-8?8
TitleShowit is better to split the component into several smaller ones, at least each accordion could make component more readable and easier to testing3-88
InlineFormthe component has not been used, it is necessary to check whether it can be removed1-0
ResultPanethe component has not been used, it is necessary to check whether it can be removed1-0
SearchPanethe component has not been used, it is necessary to check whether it can be removed1-0
PackageSearchFilters-1-0
ProviderSearchFilters-1-0
TitleSearchFiltersidentical to PackageSearchList, ProviderSearchList1-0
PaneHeaderButtonthe component has not been used, it is necessary to check whether it can be removed1-0
Route-1-0
SearchLabel-1-




Total:227200

Learning

  • "no-redeclare" eslint rule was temporary excluded, because two libraries overlap, which is why more errors are thrown out. This rule could be move out after full replacement.


eHoldings components dependency diagram


On the diagram above you can see that the topmost components, that are composed of smaller components are located on the left side of the image. And the smaller components are located on the right side.
I'd suggest to move from right to left  as it will allow us to gradually test and/or refactor components that are simpler.