Fixes by review

This commit is contained in:
ErickSkrauch 2020-08-04 13:48:16 +03:00
parent 00e74b1faf
commit 3b2fbb2cc4
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
4 changed files with 19 additions and 26 deletions

View File

@ -9,10 +9,8 @@ import DeleteAccount from './DeleteAccount';
storiesOf('Components/Profile', module).add('DeleteAccount', () => ( storiesOf('Components/Profile', module).add('DeleteAccount', () => (
<ProfileLayout> <ProfileLayout>
<DeleteAccount <DeleteAccount
onSubmit={() => { onSubmit={async () => {
action('onSubmit')(); action('onSubmit')();
return Promise.resolve();
}} }}
/> />
</ProfileLayout> </ProfileLayout>

View File

@ -11,23 +11,18 @@ const DeleteAccountPage: ComponentType = () => {
const context = useContext(ProfileContext); const context = useContext(ProfileContext);
const dispatch = useReduxDispatch(); const dispatch = useReduxDispatch();
const { current: form } = useRef(new FormModel()); const { current: form } = useRef(new FormModel());
const onSubmit = useCallback( const onSubmit = useCallback(async () => {
() => await context.onSubmit({
context form,
.onSubmit({ sendData: () => deleteAccount(context.userId, form.serialize()),
form, });
sendData: () => deleteAccount(context.userId, form.serialize()), dispatch(
}) updateUser({
.then(() => { isDeleted: true,
dispatch( }),
updateUser({ );
isDeleted: true, context.goToProfile();
}), }, [context]);
);
context.goToProfile();
}),
[context],
);
return <DeleteAccount onSubmit={onSubmit} />; return <DeleteAccount onSubmit={onSubmit} />;
}; };

View File

@ -125,7 +125,7 @@ describe('OAuth', () => {
it('should allow sign in during oauth (guest oauth)', () => { it('should allow sign in during oauth (guest oauth)', () => {
cy.visit(`/oauth2/v1/ely?${new URLSearchParams(defaults)}`); cy.visit(`/oauth2/v1/ely?${new URLSearchParams(defaults)}`);
cy.url().should('include', '/login'); cy.location('pathname').should('eq', '/login');
cy.get('[name=login]').type(`${account1.login}{enter}`); cy.get('[name=login]').type(`${account1.login}{enter}`);
@ -139,7 +139,7 @@ describe('OAuth', () => {
it('should allow sign in during oauth and not finish process if the account is deleted', () => { it('should allow sign in during oauth and not finish process if the account is deleted', () => {
cy.visit(`/oauth2/v1/ely?${new URLSearchParams(defaults)}`); cy.visit(`/oauth2/v1/ely?${new URLSearchParams(defaults)}`);
cy.url().should('include', '/login'); cy.location('pathname').should('eq', '/login');
cy.get('[name=login]').type(`${account1.login}{enter}`); cy.get('[name=login]').type(`${account1.login}{enter}`);
@ -296,7 +296,7 @@ describe('OAuth', () => {
cy.findByTestId('auth-controls').contains('another account').click(); cy.findByTestId('auth-controls').contains('another account').click();
cy.url().should('include', '/login'); cy.location('pathname').should('eq', '/login');
cy.get('[name=login]').type(`${account1.login}{enter}`); cy.get('[name=login]').type(`${account1.login}{enter}`);
@ -381,7 +381,7 @@ describe('OAuth', () => {
})}`, })}`,
); );
cy.url().should('include', '/login'); cy.location('pathname').should('eq', '/login');
cy.get('[name=login]').type(`${account1.login}{enter}`); cy.get('[name=login]').type(`${account1.login}{enter}`);

View File

@ -214,7 +214,7 @@ describe('Sign in / Log out', () => {
cy.location('pathname').should('eq', '/accept-rules'); cy.location('pathname').should('eq', '/accept-rules');
cy.findByTestId('auth-controls-secondary').contains('Decline and logout').click(); cy.findByText('Decline and logout').click();
cy.location('pathname').should('eq', '/login'); cy.location('pathname').should('eq', '/login');
cy.findByTestId('toolbar').should('contain', 'Join'); cy.findByTestId('toolbar').should('contain', 'Join');
@ -255,7 +255,7 @@ describe('Sign in / Log out', () => {
cy.location('pathname').should('eq', '/accept-rules'); cy.location('pathname').should('eq', '/accept-rules');
cy.findByTestId('auth-controls-secondary').contains('Delete account').click(); cy.findByText('Delete account').click();
cy.location('pathname').should('eq', '/profile/delete'); cy.location('pathname').should('eq', '/profile/delete');