Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
b2e7a0c9
Commit
b2e7a0c9
authored
Nov 05, 2019
by
Ben Wheeler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revised join flow and registration error tests
parent
0305fff6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
115 deletions
+63
-115
test/unit/components/join-flow.test.jsx
test/unit/components/join-flow.test.jsx
+51
-115
test/unit/components/registration-error-step.test.jsx
test/unit/components/registration-error-step.test.jsx
+12
-0
No files found.
test/unit/components/join-flow.test.jsx
View file @
b2e7a0c9
...
@@ -57,117 +57,6 @@ describe('JoinFlow', () => {
...
@@ -57,117 +57,6 @@ describe('JoinFlow', () => {
.
dive
();
// unwrap injectIntl(JoinFlow)
.
dive
();
// unwrap injectIntl(JoinFlow)
};
};
test
(
'
handleRegistrationResponse with successful response
'
,
()
=>
{
const
props
=
{
refreshSession
:
jest
.
fn
()
};
const
joinFlowInstance
=
getJoinFlowWrapper
(
props
).
instance
();
const
responseErr
=
null
;
const
responseBody
=
[
{
success
:
true
}
];
const
responseObj
=
{
statusCode
:
200
};
joinFlowInstance
.
handleRegistrationResponse
(
responseErr
,
responseBody
,
responseObj
);
expect
(
joinFlowInstance
.
props
.
refreshSession
).
toHaveBeenCalled
();
expect
(
joinFlowInstance
.
state
.
registrationError
).
toBe
(
null
);
});
test
(
'
handleRegistrationResponse with healthy response, indicating failure
'
,
()
=>
{
const
props
=
{
refreshSession
:
jest
.
fn
()
};
const
joinFlowInstance
=
getJoinFlowWrapper
(
props
).
instance
();
const
responseErr
=
null
;
const
responseBody
=
[
{
msg
:
'
This field is required.
'
,
errors
:
{
username
:
[
'
This field is required.
'
]
},
success
:
false
}
];
const
responseObj
=
{
statusCode
:
200
};
joinFlowInstance
.
handleRegistrationResponse
(
responseErr
,
responseBody
,
responseObj
);
expect
(
joinFlowInstance
.
props
.
refreshSession
).
not
.
toHaveBeenCalled
();
expect
(
joinFlowInstance
.
state
.
registrationError
).
toEqual
({
errorAllowsTryAgain
:
false
,
errorMsg
:
'
registration.problemsAre: "username: This field is required."
'
});
});
test
(
'
handleRegistrationResponse with failure response, with error fields missing
'
,
()
=>
{
const
props
=
{
refreshSession
:
jest
.
fn
()
};
const
joinFlowInstance
=
getJoinFlowWrapper
(
props
).
instance
();
const
responseErr
=
null
;
const
responseBody
=
[
{
msg
:
'
This field is required.
'
,
success
:
false
}
];
const
responseObj
=
{
statusCode
:
200
};
joinFlowInstance
.
handleRegistrationResponse
(
responseErr
,
responseBody
,
responseObj
);
expect
(
joinFlowInstance
.
props
.
refreshSession
).
not
.
toHaveBeenCalled
();
expect
(
joinFlowInstance
.
state
.
registrationError
).
toEqual
({
errorAllowsTryAgain
:
false
,
errorMsg
:
null
});
});
test
(
'
handleRegistrationResponse with failure response, with no text explanation
'
,
()
=>
{
const
props
=
{
refreshSession
:
jest
.
fn
()
};
const
joinFlowInstance
=
getJoinFlowWrapper
(
props
).
instance
();
const
responseErr
=
null
;
const
responseBody
=
[
{
success
:
false
}
];
const
responseObj
=
{
statusCode
:
200
};
joinFlowInstance
.
handleRegistrationResponse
(
responseErr
,
responseBody
,
responseObj
);
expect
(
joinFlowInstance
.
props
.
refreshSession
).
not
.
toHaveBeenCalled
();
expect
(
joinFlowInstance
.
state
.
registrationError
).
toEqual
({
errorAllowsTryAgain
:
false
,
errorMsg
:
null
});
});
test
(
'
handleRegistrationResponse with failure status code
'
,
()
=>
{
const
props
=
{
refreshSession
:
jest
.
fn
()
};
const
joinFlowInstance
=
getJoinFlowWrapper
(
props
).
instance
();
const
responseErr
=
null
;
const
responseBody
=
[
{
success
:
false
}
];
const
responseObj
=
{
statusCode
:
400
};
joinFlowInstance
.
handleRegistrationResponse
(
responseErr
,
responseBody
,
responseObj
);
expect
(
joinFlowInstance
.
props
.
refreshSession
).
not
.
toHaveBeenCalled
();
expect
(
joinFlowInstance
.
state
.
registrationError
).
toEqual
({
errorAllowsTryAgain
:
true
});
});
test
(
'
handleCaptchaError gives state with captcha message
'
,
()
=>
{
test
(
'
handleCaptchaError gives state with captcha message
'
,
()
=>
{
const
joinFlowInstance
=
getJoinFlowWrapper
().
instance
();
const
joinFlowInstance
=
getJoinFlowWrapper
().
instance
();
joinFlowInstance
.
setState
({});
joinFlowInstance
.
setState
({});
...
@@ -388,6 +277,7 @@ describe('JoinFlow', () => {
...
@@ -388,6 +277,7 @@ describe('JoinFlow', () => {
const
joinFlowInstance
=
getJoinFlowWrapper
(
props
).
instance
();
const
joinFlowInstance
=
getJoinFlowWrapper
(
props
).
instance
();
joinFlowInstance
.
handleRegistrationResponse
(
null
,
responseBodySuccess
,
{
statusCode
:
200
});
joinFlowInstance
.
handleRegistrationResponse
(
null
,
responseBodySuccess
,
{
statusCode
:
200
});
expect
(
joinFlowInstance
.
state
.
registrationError
).
toEqual
(
null
);
expect
(
joinFlowInstance
.
state
.
registrationError
).
toEqual
(
null
);
expect
(
joinFlowInstance
.
props
.
refreshSession
).
toHaveBeenCalled
();
expect
(
joinFlowInstance
.
state
.
step
).
toEqual
(
1
);
expect
(
joinFlowInstance
.
state
.
step
).
toEqual
(
1
);
expect
(
joinFlowInstance
.
state
.
waiting
).
toBeFalsy
();
expect
(
joinFlowInstance
.
state
.
waiting
).
toBeFalsy
();
});
});
...
@@ -401,6 +291,29 @@ describe('JoinFlow', () => {
...
@@ -401,6 +291,29 @@ describe('JoinFlow', () => {
});
});
});
});
test
(
'
handleRegistrationResponse with failure response, with error fields missing
'
,
()
=>
{
const
props
=
{
refreshSession
:
jest
.
fn
()
};
const
joinFlowInstance
=
getJoinFlowWrapper
(
props
).
instance
();
const
responseErr
=
null
;
const
responseBody
=
[
{
msg
:
'
This field is required.
'
,
success
:
false
}
];
const
responseObj
=
{
statusCode
:
200
};
joinFlowInstance
.
handleRegistrationResponse
(
responseErr
,
responseBody
,
responseObj
);
expect
(
joinFlowInstance
.
props
.
refreshSession
).
not
.
toHaveBeenCalled
();
expect
(
joinFlowInstance
.
state
.
registrationError
).
toEqual
({
errorAllowsTryAgain
:
false
,
errorMsg
:
null
});
});
test
(
'
handleRegistrationResponse when passed body with unfamiliar server error
'
,
()
=>
{
test
(
'
handleRegistrationResponse when passed body with unfamiliar server error
'
,
()
=>
{
const
joinFlowInstance
=
getJoinFlowWrapper
().
instance
();
const
joinFlowInstance
=
getJoinFlowWrapper
().
instance
();
joinFlowInstance
.
handleRegistrationResponse
(
null
,
responseBodyMultipleErrs
,
{
statusCode
:
200
});
joinFlowInstance
.
handleRegistrationResponse
(
null
,
responseBodyMultipleErrs
,
{
statusCode
:
200
});
...
@@ -411,6 +324,28 @@ describe('JoinFlow', () => {
...
@@ -411,6 +324,28 @@ describe('JoinFlow', () => {
});
});
});
});
test
(
'
handleRegistrationResponse with failure response, with no text explanation
'
,
()
=>
{
const
props
=
{
refreshSession
:
jest
.
fn
()
};
const
joinFlowInstance
=
getJoinFlowWrapper
(
props
).
instance
();
const
responseErr
=
null
;
const
responseBody
=
[
{
success
:
false
}
];
const
responseObj
=
{
statusCode
:
200
};
joinFlowInstance
.
handleRegistrationResponse
(
responseErr
,
responseBody
,
responseObj
);
expect
(
joinFlowInstance
.
props
.
refreshSession
).
not
.
toHaveBeenCalled
();
expect
(
joinFlowInstance
.
state
.
registrationError
).
toEqual
({
errorAllowsTryAgain
:
false
,
errorMsg
:
null
});
});
test
(
'
handleRegistrationResponse when passed non null outgoing request error
'
,
()
=>
{
test
(
'
handleRegistrationResponse when passed non null outgoing request error
'
,
()
=>
{
const
joinFlowInstance
=
getJoinFlowWrapper
().
instance
();
const
joinFlowInstance
=
getJoinFlowWrapper
().
instance
();
joinFlowInstance
.
handleRegistrationResponse
({},
responseBodyMultipleErrs
,
{
statusCode
:
200
});
joinFlowInstance
.
handleRegistrationResponse
({},
responseBodyMultipleErrs
,
{
statusCode
:
200
});
...
@@ -420,8 +355,12 @@ describe('JoinFlow', () => {
...
@@ -420,8 +355,12 @@ describe('JoinFlow', () => {
});
});
test
(
'
handleRegistrationResponse when passed status 400
'
,
()
=>
{
test
(
'
handleRegistrationResponse when passed status 400
'
,
()
=>
{
const
joinFlowInstance
=
getJoinFlowWrapper
().
instance
();
const
props
=
{
refreshSession
:
jest
.
fn
()
};
const
joinFlowInstance
=
getJoinFlowWrapper
(
props
).
instance
();
joinFlowInstance
.
handleRegistrationResponse
({},
responseBodyMultipleErrs
,
{
statusCode
:
400
});
joinFlowInstance
.
handleRegistrationResponse
({},
responseBodyMultipleErrs
,
{
statusCode
:
400
});
expect
(
joinFlowInstance
.
props
.
refreshSession
).
not
.
toHaveBeenCalled
();
expect
(
joinFlowInstance
.
state
.
registrationError
).
toEqual
({
expect
(
joinFlowInstance
.
state
.
registrationError
).
toEqual
({
errorAllowsTryAgain
:
true
errorAllowsTryAgain
:
true
});
});
...
@@ -434,7 +373,4 @@ describe('JoinFlow', () => {
...
@@ -434,7 +373,4 @@ describe('JoinFlow', () => {
errorAllowsTryAgain
:
true
errorAllowsTryAgain
:
true
});
});
});
});
test
(
'
handleErrorNext
'
,
()
=>
{
});
});
});
test/unit/components/registration-error-step.test.jsx
View file @
b2e7a0c9
...
@@ -38,6 +38,18 @@ describe('RegistrationErrorStep', () => {
...
@@ -38,6 +38,18 @@ describe('RegistrationErrorStep', () => {
expect
(
errMsgElement
.
text
()).
toEqual
(
'
halp there is a errors!!
'
);
expect
(
errMsgElement
.
text
()).
toEqual
(
'
halp there is a errors!!
'
);
});
});
test
(
'
when errorMsg is null, registrationError does not show it
'
,
()
=>
{
const
props
=
{
canTryAgain
:
true
,
errorMsg
:
null
,
onSubmit
:
onSubmit
};
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
(
props
).
find
(
JoinFlowStep
);
const
joinFlowStepInstance
=
joinFlowStepWrapper
.
dive
();
const
errMsgElement
=
joinFlowStepInstance
.
find
(
'
.registration-error-msg
'
);
expect
(
errMsgElement
).
toHaveLength
(
0
);
});
test
(
'
when no errorMsg provided, registrationError does not show it
'
,
()
=>
{
test
(
'
when no errorMsg provided, registrationError does not show it
'
,
()
=>
{
const
props
=
{
const
props
=
{
canTryAgain
:
true
,
canTryAgain
:
true
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment