add frontend tests for dinopark sign up
This commit is contained in:
Родитель
2794a9f5b6
Коммит
2866751f37
|
@ -25,6 +25,10 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
redirect(url) {
|
||||||
|
window.location = url
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
normalSignup() {
|
normalSignup() {
|
||||||
const options = this.get("options")
|
const options = this.get("options")
|
||||||
|
@ -57,7 +61,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
var destination_url = this.get("options.destination_url")
|
var destination_url = this.get("options.destination_url")
|
||||||
window.location = destination_url ? destination_url : "/"
|
this.redirect(destination_url ? destination_url : "/")
|
||||||
} else {
|
} else {
|
||||||
this.set("submitted", false)
|
this.set("submitted", false)
|
||||||
this.flash(result.message || I18n.t("create_account.failed"), "error")
|
this.flash(result.message || I18n.t("create_account.failed"), "error")
|
||||||
|
|
|
@ -9,22 +9,22 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div class="dinopark-fields">
|
<div class="dinopark-fields">
|
||||||
<div>{{i18n 'dinopark.fields.username'}}:</div>
|
<div>{{i18n 'dinopark.fields.username'}}:</div>
|
||||||
<div class="value">{{values.username}}</div>
|
<div class="value value-username">{{values.username}}</div>
|
||||||
|
|
||||||
<div>{{i18n 'dinopark.fields.full_name'}}:</div>
|
<div>{{i18n 'dinopark.fields.full_name'}}:</div>
|
||||||
<div class="value">{{values.full_name}}</div>
|
<div class="value value-name">{{values.full_name}}</div>
|
||||||
|
|
||||||
<div>{{i18n 'dinopark.fields.pronouns'}}:</div>
|
<div>{{i18n 'dinopark.fields.pronouns'}}:</div>
|
||||||
<div class="value">{{values.pronouns}}</div>
|
<div class="value value-pronouns">{{values.pronouns}}</div>
|
||||||
|
|
||||||
<div>{{i18n 'dinopark.fields.fun_title'}}:</div>
|
<div>{{i18n 'dinopark.fields.fun_title'}}:</div>
|
||||||
<div class="value">{{values.fun_title}}</div>
|
<div class="value value-title">{{values.fun_title}}</div>
|
||||||
|
|
||||||
<div>{{i18n 'dinopark.fields.location'}}:</div>
|
<div>{{i18n 'dinopark.fields.location'}}:</div>
|
||||||
<div class="value">{{values.location}}</div>
|
<div class="value value-location">{{values.location}}</div>
|
||||||
|
|
||||||
<div>{{i18n 'dinopark.fields.description'}}:</div>
|
<div>{{i18n 'dinopark.fields.description'}}:</div>
|
||||||
<div class="value bio">{{cook-text values.description}}</div>
|
<div class="value value-bio">{{cook-text values.description}}</div>
|
||||||
</div>
|
</div>
|
||||||
{{input type="checkbox" id="tos-checkbox" checked=tosChecked}}
|
{{input type="checkbox" id="tos-checkbox" checked=tosChecked}}
|
||||||
<label for="tos-checkbox">{{{i18n 'dinopark.sign_up.tos' tos_url=siteSettings.tos_url privacy_url=siteSettings.privacy_policy_url}}}</label>
|
<label for="tos-checkbox">{{{i18n 'dinopark.sign_up.tos' tos_url=siteSettings.tos_url privacy_url=siteSettings.privacy_policy_url}}}</label>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
min-height: 1.4em;
|
min-height: 1.4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bio {
|
.value-bio {
|
||||||
p:first-child {
|
p:first-child {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,16 +7,18 @@ describe UsersController do
|
||||||
describe '#create' do
|
describe '#create' do
|
||||||
before do
|
before do
|
||||||
User.any_instance.stubs(:active?).returns(true)
|
User.any_instance.stubs(:active?).returns(true)
|
||||||
UsersController.any_instance.stubs(:honeypot_value).returns(nil)
|
|
||||||
UsersController.any_instance.stubs(:challenge_value).returns(nil)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:create_params) do
|
let(:create_params) do
|
||||||
|
get '/u/hp.json'
|
||||||
|
json = JSON.parse(response.body)
|
||||||
{
|
{
|
||||||
name: "Jill Bloggs",
|
name: "Jill Bloggs",
|
||||||
username: "jillbloggs",
|
username: "jillbloggs",
|
||||||
password: "supersecret",
|
password: "supersecret",
|
||||||
email: "jill@example.com"
|
email: "jill@example.com",
|
||||||
|
password_confirmation: json["value"],
|
||||||
|
challenge: json["challenge"].reverse
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,162 @@
|
||||||
|
import { acceptance } from "helpers/qunit-helpers"
|
||||||
|
import user_fixtures from "fixtures/user_fixtures"
|
||||||
|
import SignUpController from "discourse/plugins/mozilla-iam/discourse/controllers/dinopark-sign-up"
|
||||||
|
|
||||||
|
acceptance("Mozilla IAM - Sign Up")
|
||||||
|
|
||||||
|
// prevent redirecting out of tests
|
||||||
|
SignUpController.reopen({
|
||||||
|
redirect(url) {}
|
||||||
|
})
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
auth_provider: "auth0",
|
||||||
|
destination_url: "/",
|
||||||
|
email: "eviltrout@mozilla.com",
|
||||||
|
email_valid: true,
|
||||||
|
name: "Eviltrout",
|
||||||
|
omit_username: false,
|
||||||
|
username: "eviltrout"
|
||||||
|
}
|
||||||
|
|
||||||
|
const dinopark_data = Object.assign(
|
||||||
|
{
|
||||||
|
dinopark_profile: {
|
||||||
|
description: "A rather nasty [fish](example.com)",
|
||||||
|
full_name: "Evil Trout",
|
||||||
|
fun_title: "Ember Supremo",
|
||||||
|
location: "The Ocean",
|
||||||
|
pronouns: "fi/sh",
|
||||||
|
username: "evil_trout"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data
|
||||||
|
)
|
||||||
|
|
||||||
|
const assertNormalModal = assert => {
|
||||||
|
assert.ok(
|
||||||
|
exists(".modal .create-account"),
|
||||||
|
"opens normal create account modal"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find("#new-account-email").val(),
|
||||||
|
"eviltrout@mozilla.com",
|
||||||
|
"email is filled in correctly"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find("#new-account-username").val(),
|
||||||
|
"eviltrout",
|
||||||
|
"username is filled in correctly"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find("#new-account-name").val(),
|
||||||
|
"Eviltrout",
|
||||||
|
"name is filled in correctly"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
QUnit.test("sign up without dinopark enabled", async assert => {
|
||||||
|
await visit("/");
|
||||||
|
|
||||||
|
Discourse.authenticationComplete(data)
|
||||||
|
await new Promise(r => setTimeout(r, 0))
|
||||||
|
|
||||||
|
assertNormalModal(assert)
|
||||||
|
})
|
||||||
|
|
||||||
|
QUnit.test("sign up with dinopark enabled, clicking not right now", async assert => {
|
||||||
|
await visit("/");
|
||||||
|
|
||||||
|
Discourse.authenticationComplete(dinopark_data)
|
||||||
|
await new Promise(r => setTimeout(r, 0))
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
exists(".modal .dinopark-sign-up"),
|
||||||
|
"opens normal create account modal"
|
||||||
|
)
|
||||||
|
|
||||||
|
await click(".modal-footer .btn:not(.btn-primary)")
|
||||||
|
|
||||||
|
assertNormalModal(assert)
|
||||||
|
})
|
||||||
|
|
||||||
|
QUnit.test("sign up with dinopark enabled", async assert => {
|
||||||
|
await visit("/");
|
||||||
|
|
||||||
|
Discourse.authenticationComplete(dinopark_data)
|
||||||
|
await new Promise(r => setTimeout(r, 0))
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
exists(".modal .dinopark-sign-up"),
|
||||||
|
"opens normal create account modal"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
exists(".modal-footer .btn-primary:disabled"),
|
||||||
|
"continue button is disabled"
|
||||||
|
)
|
||||||
|
|
||||||
|
await click("#tos-checkbox")
|
||||||
|
|
||||||
|
await click(".modal-footer .btn-primary")
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find(".dinopark-fields .value-username").text(),
|
||||||
|
"evil_trout",
|
||||||
|
"dinopark username is filled in"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find(".dinopark-fields .value-name").text(),
|
||||||
|
"Evil Trout",
|
||||||
|
"dinopark name is filled in"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find(".dinopark-fields .value-pronouns").text(),
|
||||||
|
"fi/sh",
|
||||||
|
"dinopark pronouns is filled in"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find(".dinopark-fields .value-title").text(),
|
||||||
|
"Ember Supremo",
|
||||||
|
"dinopark title is filled in"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find(".dinopark-fields .value-location").text(),
|
||||||
|
"The Ocean",
|
||||||
|
"dinopark location is filled in"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find(".dinopark-fields .value-bio").text().trim(),
|
||||||
|
"A rather nasty fish",
|
||||||
|
"dinopark bio is filled in"
|
||||||
|
)
|
||||||
|
|
||||||
|
await click("#tos-checkbox")
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
exists(".modal-footer .btn-primary:disabled"),
|
||||||
|
"confirm button is disabled"
|
||||||
|
)
|
||||||
|
|
||||||
|
await click("#tos-checkbox")
|
||||||
|
|
||||||
|
await click(".modal-footer .btn-primary")
|
||||||
|
|
||||||
|
assert.notOk(
|
||||||
|
exists(".modal-footer .btn"),
|
||||||
|
"buttons are hidden"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
exists(".modal-footer .spinner"),
|
||||||
|
"spinner is shown"
|
||||||
|
)
|
||||||
|
})
|
Загрузка…
Ссылка в новой задаче