mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 15:49:55 +08:00
61 lines
2.0 KiB
JavaScript
61 lines
2.0 KiB
JavaScript
import { acceptance } from "helpers/qunit-helpers";
|
|
import PreloadStore from 'preload-store';
|
|
import { parsePostData } from "helpers/create-pretender";
|
|
|
|
acceptance("Password Reset", {
|
|
beforeEach() {
|
|
const response = (object) => {
|
|
return [
|
|
200,
|
|
{"Content-Type": "application/json"},
|
|
object
|
|
];
|
|
};
|
|
|
|
server.get('/u/confirm-email-token/myvalidtoken.json', () => { //eslint-disable-line
|
|
return response({success: "OK"});
|
|
});
|
|
|
|
server.put('/u/password-reset/myvalidtoken.json', request => { //eslint-disable-line
|
|
const body = parsePostData(request.requestBody);
|
|
if (body.password === "jonesyAlienSlayer") {
|
|
return response({success: false, errors: {password: ["is the name of your cat"]}});
|
|
} else {
|
|
return response({success: "OK", message: I18n.t('password_reset.success')});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
QUnit.test("Password Reset Page", assert => {
|
|
PreloadStore.store('password_reset', {is_developer: false});
|
|
|
|
visit("/u/password-reset/myvalidtoken");
|
|
andThen(() => {
|
|
assert.ok(exists(".password-reset input"), "shows the input");
|
|
});
|
|
|
|
fillIn('.password-reset input', 'perf3ctly5ecur3');
|
|
andThen(() => {
|
|
assert.ok(exists(".password-reset .tip.good"), "input looks good");
|
|
});
|
|
|
|
fillIn('.password-reset input', '123');
|
|
andThen(() => {
|
|
assert.ok(exists(".password-reset .tip.bad"), "input is not valid");
|
|
assert.ok(find(".password-reset .tip.bad").html().indexOf(I18n.t('user.password.too_short')) > -1, "password too short");
|
|
});
|
|
|
|
fillIn('.password-reset input', 'jonesyAlienSlayer');
|
|
click('.password-reset form button');
|
|
andThen(() => {
|
|
assert.ok(exists(".password-reset .tip.bad"), "input is not valid");
|
|
assert.ok(find(".password-reset .tip.bad").html().indexOf("is the name of your cat") > -1, "server validation error message shows");
|
|
});
|
|
|
|
fillIn('.password-reset input', 'perf3ctly5ecur3');
|
|
click('.password-reset form button');
|
|
andThen(() => {
|
|
assert.ok(!exists(".password-reset form"), "form is gone");
|
|
});
|
|
}); |