Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Test CreateNewProjectWizard components #361

Merged
merged 8 commits into from
Mar 26, 2019

Conversation

AWolf81
Copy link
Collaborator

@AWolf81 AWolf81 commented Feb 5, 2019

Related Issue:
#309

Summary:
This is a larger PR and adds the tests for the following components from src\components\CreateNewProjectWizard

  • MainPane
  • ProjectName (just scramble method is untested)
  • ProjectPath
  • SummaryPane
  • ImportExisting
  • SubmitButton

Todos
Write tests for these components

  • CreateNewProjectWizard
  • BuildPane
  • BuildStepProgress

Discussion

  • How to test each updateProject... method in MainPane.js? The tests are easy to understand but if there would be a refactor of the component it's some work to rename/modify these tests. Is there a better way of testing prop methods?
  • Should we add a __tests__ folder here? I think the test files are adding some noise around the components in CreateNewProjectWizard folder. There are around 10 components and 10 test files. I think it's OK to keep both in the same folder if there are just one or two components. But it's probably also OK to keep all in the same folder. If we'd change to tests folder just imports need to be modified by one additional relative path ../.

Notes

  • Package.json update of enzyme for renderProp support (see MainPane.test.js)
  • Disabled liniting of test files so /* eslint-disable flowtype/require-valid-file-annotation */ is not needed anymore. It was annoying to copy that line to each new test file. Please let me know if it's OK to add the override to .eslintrc.js file.

@codecov
Copy link

codecov bot commented Feb 5, 2019

Codecov Report

Merging #361 into master will increase coverage by 12.11%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #361       +/-   ##
===========================================
+ Coverage   37.54%   49.65%   +12.11%     
===========================================
  Files         158      158               
  Lines        3540     3351      -189     
  Branches      449      458        +9     
===========================================
+ Hits         1329     1664      +335     
+ Misses       1928     1446      -482     
+ Partials      283      241       -42
Impacted Files Coverage Δ
src/components/Sidebar/Sidebar.js 100% <ø> (ø) ⬆️
src/components/CreateNewProjectWizard/BuildPane.js 97.67% <100%> (+97.67%) ⬆️
...s/CreateNewProjectWizard/CreateNewProjectWizard.js 100% <100%> (+100%) ⬆️
...c/components/CreateNewProjectWizard/ProjectPath.js 100% <100%> (+100%) ⬆️
...omponents/CreateNewProjectWizard/ImportExisting.js 100% <100%> (+100%) ⬆️
...c/components/CreateNewProjectWizard/ProjectName.js 84.9% <100%> (+84.9%) ⬆️
.../components/CreateNewProjectWizard/SubmitButton.js 100% <100%> (+100%) ⬆️
src/components/Planet/PlanetGlow.js 0% <0%> (ø) ⬆️
src/components/Debounced/Debounced.js 0% <0%> (ø) ⬆️
src/components/Earth/Earth.js 0% <0%> (ø) ⬆️
... and 29 more

@AWolf81 AWolf81 changed the title [WIP] Test CreateNewProjectWizard components Test CreateNewProjectWizard components Feb 7, 2019
expect(instance.verifyProjectNameUniqueness).not.toHaveBeenCalled();
});

it('should set foucs', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo: focus


beforeEach(() => {
wrapper = shallowRenderBuildPane(newProject);
instance = wrapper.instance();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
instance = wrapper.instance();
instance = wrapper.instance();
// mock console errors so they don't output while running the test
jest.spyOn(console, 'error')
console.error.mockImplementation(() => {})
})
afterEach(() => {
console.error.mockRestore()
})

This prevents the error from being output while running the missing project prop test (which is confusing output IMO). From jestjs/jest#5267 (comment).

Screenshot of the error being logged:

Screen Shot 2019-03-25 at 7 56 34 PM

Copy link
Collaborator

@melanieseltzer melanieseltzer left a comment

Choose a reason for hiding this comment

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

Seems very comprehensive and LGTM 👍 Just had the suggestion for no console error output.

I'm all for __tests__ folder if it improves organization. Since it's ultimately grouped under CreateNewProjectWizard I think it's fine.

I wouldn't be able to answer your other question but I think we could gather these questions and file an issue to see if the community knows a better way.

@melanieseltzer melanieseltzer merged commit a62509c into master Mar 26, 2019
@melanieseltzer melanieseltzer deleted the test-create-new-project-wiz branch March 26, 2019 20:09
Haroenv pushed a commit that referenced this pull request Mar 27, 2019
* WIP: Added tests

* WIP: ProjectType undefined not throwing in test

* fixed flow

* added tests

* reverted to children render props

* Merge branch 'master' into test-create-new-project-wiz

* Fixed linting & replaced snapshot with simple smoke tests

* addressed review comments
Haroenv added a commit that referenced this pull request Mar 27, 2019
* add analytics tags

* Update AddDependencySearchProvider.js

* #352 Disable actions that require an internet connection (#368)

* Online check component added

* add reducer & action for online check component.

also included in App.js

* removed sidebar functionality when offline

* removed depedency functionality when offline

* removed functionality from create new project wizard when offline

* fixed tests to align with disabled pattern

* add infoBanner to Z-indexes for future usage.

* removed random {' '}, changed IS_ONLINE_CHECK to SET_ONLINE_STATUS

* pull request requested changes

missed one file.

* updated infobar to be fixed header.

* flow fix

* remove random whitespace

* Pull request changes

remove state type, move styled components to before redux part, change background color of infobar to be transparent.

* enable menu items based on isOnline

* Setup ESlint rules for Jest (#366)

* WIP: Added eslint-jest & fixed issues (except snapshots)

* reduced snapshot size to meet max 100 lines

* fixed snapshot

* changed comment to a note about noPadding prop

* updated snapshot

* Test ProjectConfigurationModal component (#360)

* WIP: Added render test

* WIP: Added tests

* fixed flow

* added focus test

* Merge branch 'master' into test-project-configuration-modal

* fixed linting warnings

* removed typing as no flow used in test files

* Test CreateNewProjectWizard components (#361)

* WIP: Added tests

* WIP: ProjectType undefined not throwing in test

* fixed flow

* added tests

* reverted to children render props

* Merge branch 'master' into test-create-new-project-wiz

* Fixed linting & replaced snapshot with simple smoke tests

* addressed review comments

* Test DependencyManagementPane component (#363)

* moved related components to DependencyManagementPane

* added tests

* fixed flow

* added a constant instead of Date.now()

* updated snapshot

* removed white-spaces

* removed verbose

* fixed linting & mocked AlgoliaLogo

* move related component files & moved tests to __tests__ folder

* Add script for test:dev

* Fix spaces and update lint-staged (#369)

* Switch to advanced config to silence validation warning

* Fix spacing issues

* chore: fix merge changes
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants