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

CIF-1328: Refactor the Create Account process #274

Merged
merged 10 commits into from
May 27, 2020
Merged

Conversation

laurentiumagureanu
Copy link
Collaborator

Description

  1. The shopper fills in the required data and clicks the "Create account" button.
  2. The account is created and then the shopper is presented with a message Your account was successfully created. You will receive a link at {{email}}. Access that link to confirm your email address. and a Sign in button.
  3. The shopper logs in.

Related Issue

CIF-1328

Motivation and Context

In our current implementation, the Create Account process automatically logs in the user after the account is created. This goes against the good practices in the industry because usually Create Account and Sign in are two separate user actions.

How Has This Been Tested?

  • unit tests
  • manual functional testing

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes and the overall coverage did not decrease.
  • All unit tests pass on CircleCi.
  • I ran all tests locally and they pass.

</MockedProvider>
);

expect(getByText('Sign in')).not.toBeUndefined();
Copy link
Member

Choose a reason for hiding this comment

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

expect(getByText('Sign in')) should be sufficient, since the getBy* query throws an error if an element cannot be found. See https://testing-library.com/docs/dom-testing-library/api-queries#getby.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True but expect is rarely used without a matcher.
It also fails linting.

expect(getByText('Sign in')).not.toBeUndefined();

fireEvent.click(getByText('Sign in'));
const result = await waitForElement(() => getByTestId('sign_in'));
Copy link
Member

Choose a reason for hiding this comment

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

Same here. You could write:

await waitForElement(() => getByTestId('sign_in')); // fails if element cannot be found after timeout
expect(result.textContent).toEqual('Sign in page');

@codecov
Copy link

codecov bot commented May 19, 2020

Codecov Report

Merging #274 into master will increase coverage by 0.43%.
The diff coverage is 94.68%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #274      +/-   ##
============================================
+ Coverage     63.15%   63.58%   +0.43%     
  Complexity      757      757              
============================================
  Files           173      175       +2     
  Lines          5368     5440      +72     
  Branches        843      853      +10     
============================================
+ Hits           3390     3459      +69     
- Misses         1861     1864       +3     
  Partials        117      117              
Flag Coverage Δ Complexity Δ
#jest 42.13% <94.68%> (+1.39%) 0.00 <0.00> (ø)
#karma 94.88% <ø> (ø) 0.00 <ø> (ø)
#unittests 85.16% <ø> (ø) 757.00 <ø> (ø)
Impacted Files Coverage Δ Complexity Δ
react-components/src/context/UserContext.js 90.00% <0.00%> (+0.34%) 0.00 <0.00> (ø)
react-components/src/context/NavigationContext.js 93.18% <93.18%> (ø) 0.00 <0.00> (?)
react-components/src/actions/navigation/actions.js 100.00% <100.00%> (ø) 0.00 <0.00> (?)
...s/src/components/CreateAccount/useCreateAccount.js 100.00% <100.00%> (ø) 0.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac2d42a...6531426. Read the comment docs.

@dplaton dplaton merged commit e8d1e54 into master May 27, 2020
@dplaton dplaton deleted the issues/CIF-1328 branch May 27, 2020 14:13
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.

3 participants