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

Account creation (issue #250) #293

Merged
merged 68 commits into from
Oct 3, 2018
Merged
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
174ddd0
create generic input component
JStein92 Sep 7, 2018
25dcc9d
ignore storybook-dist in eslint
JStein92 Sep 7, 2018
ac482dc
create login component, action and reducer catch
JStein92 Sep 10, 2018
3ef5bb1
Hook login form to utilize and store token
pcvonz Sep 10, 2018
2d9e7f7
Add navigation animation and user icon
pcvonz Sep 10, 2018
3561f71
add auth to REST requests
JStein92 Sep 10, 2018
9e3ab0c
Merge branch 'login' of https://github.com/bargreenellingson/pwa-stud…
JStein92 Sep 10, 2018
5673948
Add user icon
pcvonz Sep 10, 2018
614bd1d
Merge branch 'login' of https://github.com/bargreenellingson/pwa-stud…
JStein92 Sep 10, 2018
2b0d825
add auth header login_token to graphql queries
JStein92 Sep 10, 2018
455b7d3
Change animation, add user to store
pcvonz Sep 10, 2018
ece2eec
Move user logic into separate action/reducer
pcvonz Sep 10, 2018
9ad855d
Add token to auth headers when token is available (rest)
pcvonz Sep 10, 2018
ec87f4f
Style sign in form, fix user reducer
pcvonz Sep 11, 2018
03bea9b
Rename log in -> sign in. Wire up sign in form.
pcvonz Sep 11, 2018
491dfdc
Change login to signin
pcvonz Sep 11, 2018
f109d81
Add proptypes, clean up css
pcvonz Sep 11, 2018
293c523
Prettier pass
pcvonz Sep 11, 2018
fcfe28e
write test for signIn and input, small style and prop fixes
JStein92 Sep 12, 2018
aa88455
Merge branch 'master' into login
JStein92 Sep 12, 2018
4fc83b7
lint and prettier pass
JStein92 Sep 12, 2018
28a8e51
reword a c ouple tests
JStein92 Sep 13, 2018
240fc98
fix dependency issue and clean up navigation component
JStein92 Sep 13, 2018
710eb4d
Add redux actions to create account and transfer guest cart to user's…
pcvonz Sep 13, 2018
9d4e52e
add form, navheader and create account components, update styles
JStein92 Sep 14, 2018
2d0d31b
Refactor createAccount, handle transferring cart
pcvonz Sep 14, 2018
6835654
Merge
pcvonz Sep 14, 2018
6f2d9ae
add debounce email check
JStein92 Sep 14, 2018
5c70a74
merge branches
JStein92 Sep 14, 2018
35dd2be
add error display and checkbox components, wire up account creation w…
JStein92 Sep 17, 2018
1c3d710
make requested style changes on inputs
JStein92 Sep 18, 2018
443c37b
add automatic login
JStein92 Sep 18, 2018
2758c2d
Error display and createAccount adjustments
pcvonz Sep 18, 2018
cddc07e
let checkbox highlight on focus, add firstname and lastname required …
JStein92 Sep 18, 2018
65da408
refactor input to have a single help text line
JStein92 Sep 18, 2018
cfb44bb
Merge branch 'account_creation' of https://github.com/bargreenellings…
JStein92 Sep 18, 2018
358c4f4
Add tests for createAccount
pcvonz Sep 18, 2018
d6ad886
revert create account
pcvonz Sep 19, 2018
82680eb
Tests for createAccount form
pcvonz Sep 19, 2018
476a049
tests checkbox and fix other specs
JStein92 Sep 20, 2018
00744b4
enhance test coverage
JStein92 Sep 20, 2018
eae596b
prettier pass
JStein92 Sep 20, 2018
609f918
Merge branch 'master' into account_creation
JStein92 Sep 20, 2018
d493d39
revert to single helptext line
JStein92 Sep 20, 2018
186565d
update package-lock to please circleCI
JStein92 Sep 20, 2018
9c144fc
Merge branch 'master' into account_creation
JStein92 Sep 21, 2018
149098f
update package-lock and package.json
JStein92 Sep 21, 2018
b382769
Merge branch 'master' into account_creation
Sep 23, 2018
d859a10
use browser persistence instead of interacting directly with local st…
JStein92 Sep 28, 2018
63c6420
add TODO and fix indents
JStein92 Sep 28, 2018
8828635
Rename accountCreation variables
pcvonz Sep 28, 2018
8e1669d
add autocomplete to input
JStein92 Sep 28, 2018
1710e58
Remove mock account
pcvonz Sep 28, 2018
fcd4a25
set default username and replace Form component with Informed's Form
JStein92 Sep 28, 2018
9e1c58c
Merge branch 'account_creation' of https://github.com/bargreenellings…
JStein92 Sep 28, 2018
16a22e2
start switch to Text component from Informed
JStein92 Oct 1, 2018
6f65e6f
switch to dot lookup in navigation states
JStein92 Oct 1, 2018
b1d9b2d
Set initial value of CreateAccount (inform)
pcvonz Oct 1, 2018
b309e7e
prettier pass and some test fixes
JStein92 Oct 1, 2018
7586c42
Merge / Prettier / Lint
pcvonz Oct 1, 2018
81e92c0
Merge branch 'master' of https://github.com/magento-research/pwa-stud…
JStein92 Oct 1, 2018
c43b7c9
merge test fixes
JStein92 Oct 1, 2018
d28700d
start merge with 2.0 release
JStein92 Oct 2, 2018
83b9f45
remove debugger
JStein92 Oct 2, 2018
970f749
modify user actions/reducers to be in release 2.0 format
JStein92 Oct 2, 2018
a32f2e1
Resolve conflicts, prettier/lint
JStein92 Oct 2, 2018
0947576
get tests running for cart actions
JStein92 Oct 3, 2018
7b83f45
write tests for async User actions
JStein92 Oct 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests for createAccount
pcvonz committed Sep 19, 2018
commit 358c4f41eac89e54ef59770d097f2958896b615f
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { createElement } from 'react';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import CreateAccount from '../createAccount';

configure({ adapter: new Adapter() });

let blankState = {
firstName: '',
lastName: '',
email: '',
password: '',
passwordConfirm: '',
subscribe: false,
checkingEmail: false,
emailAvailable: false,
subscribe: true
};


let state = {
firstName: 'Test',
lastName: 'Test Test',
email: 'test@test.com',
password: 'test',
passwordConfirm: 'testa',
subscribe: false,
checkingEmail: false,
emailAvailable: false,
subscribe: true
};

jest.mock('@magento/peregrine', () => {
return {
RestApi: {
Magento2: {
request: () => {
return true;
}
}
}
};
});

jest.mock('underscore', () => {
return {
debounce: (cb) => {
return cb;
}
}
});

jest.useFakeTimers();

test('correctly checks if password and passwordConfirm match', () => {
const wrapper = shallow(
<CreateAccount />
).dive();
wrapper.setState(state);
expect(wrapper.instance().passwordConfirmError).toBe(true);
state.passwordConfirm = state.password;
wrapper.setState(state);
expect(wrapper.instance().passwordConfirmError).toBe(false);
});


test('account creation to be disabled if not all inputs are filled', () => {
const wrapper = shallow(
<CreateAccount />
).dive();
wrapper.setState(blankState);
expect(wrapper.instance().disableAccountCreation).toBe(true);
});

test('checks if email is available', () => {
const wrapper = shallow(
<CreateAccount />
).dive();
wrapper.setState(state);
wrapper.instance().checkEmail('test@test.com').then(() => {
const { emailAvailable } = wrapper.instance().state;
expect(emailAvailable).toBe(true);
}
);
});
Original file line number Diff line number Diff line change
@@ -7,19 +7,9 @@ configure({ adapter: new Adapter() });

const props = {
signIn: function() {},
signInError: { message: 'foo' }
};
signInError: { message: 'foo' } };

test('call `onSignIn` when form is submitted', () => {
const wrapper = shallow(
<SignIn signIn={props.signIn} signInError={props.signInError} />
).dive();

const onSignInSpy = jest.spyOn(wrapper.instance(), 'onSignIn');

wrapper.setProps({ signIn: function() {} });
wrapper.find('form').simulate('submit', { preventDefault() {} });
expect(onSignInSpy).toHaveBeenCalled();
});

test('set state `password` to new `password` on `updatePassword`', () => {