-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
72 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ describe('captcha on signup', function () { | |
}); | ||
|
||
it('should not show the captcha input', function () { | ||
console.log('banana penguin', this.lock); | ||
expect(h.qInput(this.lock, 'captcha', false)).to.not.be.ok(); | ||
}); | ||
|
||
|
@@ -124,75 +125,75 @@ describe('captcha on signup', function () { | |
}); | ||
}); | ||
|
||
describe('recaptcha', () => { | ||
describe('when the api returns a new challenge', function () { | ||
beforeEach(function (done) { | ||
this.stub = h.stubGetSignupChallenge([recaptchav2Response]); | ||
this.lock = h.displayLock('', lockOpts, done); | ||
}); | ||
|
||
afterEach(function () { | ||
this.lock.hide(); | ||
}); | ||
|
||
it('should load the captcha script and input', function (done) { | ||
h.waitUntilExists(this.lock, '.auth0-lock-recaptchav2', () => { | ||
expect(h.q(this.lock, '.auth0-lock-recaptchav2')).to.be.ok(); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should not submit the form if the captcha is not provided', function (done) { | ||
h.waitForEmailAndPasswordInput(this.lock, () => { | ||
h.signUpWithEmailAndPassword(this.lock, () => { | ||
h.waitUntilErrorExists(this.lock, () => { | ||
expect(h.wasSignUpAttemptedWith({})).not.to.be.ok(); | ||
expect(h.hasErrorMessage(this.lock, en.error.login.invalid_recaptcha)).to.be.ok(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('when the challenge api returns required: false', function () { | ||
let notRequiredStub; | ||
beforeEach(function (done) { | ||
notRequiredStub = h.stubGetSignupChallenge({ | ||
required: false | ||
}); | ||
this.lock = h.displayLock('', lockOpts, done); | ||
}); | ||
|
||
afterEach(function () { | ||
this.lock.hide(); | ||
}); | ||
|
||
it('should not show the captcha input', function () { | ||
expect(h.q(this.lock, '.auth0-lock-recaptchav2')).to.not.be.ok(); | ||
}); | ||
|
||
describe('when the form submission fails and the transaction starts requiring a challenge', function () { | ||
let challengeStub; | ||
beforeEach(function (done) { | ||
h.assertSignUp((lockID, options, cb) => { | ||
cb(new Error('bad request')); | ||
// We wait 250ms to display errors | ||
setTimeout(done, 260); | ||
}); | ||
|
||
challengeStub = h.stubGetSignupChallenge(recaptchav2Response); | ||
h.fillEmailInput(this.lock, '[email protected]'); | ||
h.fillComplexPassword(this.lock); | ||
h.submitForm(this.lock); | ||
}); | ||
|
||
it('should call the challenge api again and show the input', function () { | ||
expect(notRequiredStub.calledOnce).to.be.true; | ||
expect(challengeStub.calledOnce).to.be.true; | ||
expect(h.q(this.lock, '.auth0-lock-recaptchav2')).to.be.ok(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
// describe('recaptcha', () => { | ||
// describe('when the api returns a new challenge', function () { | ||
// beforeEach(function (done) { | ||
// this.stub = h.stubGetSignupChallenge([recaptchav2Response]); | ||
// this.lock = h.displayLock('', lockOpts, done); | ||
// }); | ||
// | ||
// afterEach(function () { | ||
// this.lock.hide(); | ||
// }); | ||
// | ||
// it('should load the captcha script and input', function (done) { | ||
// h.waitUntilExists(this.lock, '.auth0-lock-recaptchav2', () => { | ||
// expect(h.q(this.lock, '.auth0-lock-recaptchav2')).to.be.ok(); | ||
// done(); | ||
// }); | ||
// }); | ||
// | ||
// it('should not submit the form if the captcha is not provided', function (done) { | ||
// h.waitForEmailAndPasswordInput(this.lock, () => { | ||
// h.signUpWithEmailAndPassword(this.lock, () => { | ||
// h.waitUntilErrorExists(this.lock, () => { | ||
// expect(h.wasSignUpAttemptedWith({})).not.to.be.ok(); | ||
// expect(h.hasErrorMessage(this.lock, en.error.login.invalid_recaptcha)).to.be.ok(); | ||
// done(); | ||
// }); | ||
// }); | ||
// }); | ||
// }); | ||
// }); | ||
// | ||
// describe('when the challenge api returns required: false', function () { | ||
// let notRequiredStub; | ||
// beforeEach(function (done) { | ||
// notRequiredStub = h.stubGetSignupChallenge({ | ||
// required: false | ||
// }); | ||
// this.lock = h.displayLock('', lockOpts, done); | ||
// }); | ||
// | ||
// afterEach(function () { | ||
// this.lock.hide(); | ||
// }); | ||
// | ||
// it('should not show the captcha input', function () { | ||
// expect(h.q(this.lock, '.auth0-lock-recaptchav2')).to.not.be.ok(); | ||
// }); | ||
// | ||
// describe('when the form submission fails and the transaction starts requiring a challenge', function () { | ||
// let challengeStub; | ||
// beforeEach(function (done) { | ||
// h.assertSignUp((lockID, options, cb) => { | ||
// cb(new Error('bad request')); | ||
// // We wait 250ms to display errors | ||
// setTimeout(done, 260); | ||
// }); | ||
// | ||
// challengeStub = h.stubGetSignupChallenge(recaptchav2Response); | ||
// h.fillEmailInput(this.lock, '[email protected]'); | ||
// h.fillComplexPassword(this.lock); | ||
// h.submitForm(this.lock); | ||
// }); | ||
// | ||
// it('should call the challenge api again and show the input', function () { | ||
// expect(notRequiredStub.calledOnce).to.be.true; | ||
// expect(challengeStub.calledOnce).to.be.true; | ||
// expect(h.q(this.lock, '.auth0-lock-recaptchav2')).to.be.ok(); | ||
// }); | ||
// }); | ||
// }); | ||
// }); | ||
}); |