discourse/test/javascripts/acceptance/account-created-test.js.es6

100 lines
2.6 KiB
Plaintext
Raw Normal View History

import { acceptance } from "helpers/qunit-helpers";
2018-06-15 11:03:24 -04:00
import PreloadStore from "preload-store";
acceptance("Account Created");
2017-06-14 13:57:58 -04:00
QUnit.test("account created - message", assert => {
2018-06-15 11:03:24 -04:00
PreloadStore.store("accountCreated", {
message: "Hello World"
});
visit("/u/account-created");
andThen(() => {
2018-06-15 11:03:24 -04:00
assert.ok(exists(".account-created"));
assert.equal(
2018-06-15 11:03:24 -04:00
find(".account-created .ac-message")
.text()
.trim(),
"Hello World",
"it displays the message"
);
2018-06-15 11:03:24 -04:00
assert.notOk(exists(".activation-controls"));
});
});
2017-06-14 13:57:58 -04:00
QUnit.test("account created - resend email", assert => {
2018-06-15 11:03:24 -04:00
PreloadStore.store("accountCreated", {
message: "Hello World",
2018-06-15 11:03:24 -04:00
username: "eviltrout",
email: "eviltrout@example.com",
2017-05-25 15:56:11 -04:00
show_controls: true
});
visit("/u/account-created");
andThen(() => {
2018-06-15 11:03:24 -04:00
assert.ok(exists(".account-created"));
assert.equal(
2018-06-15 11:03:24 -04:00
find(".account-created .ac-message")
.text()
.trim(),
"Hello World",
"it displays the message"
);
});
2018-06-15 11:03:24 -04:00
click(".activation-controls .resend");
andThen(() => {
assert.equal(currentPath(), "account-created.resent");
2018-06-15 11:03:24 -04:00
const email = find(".account-created .ac-message b").text();
assert.equal(email, "eviltrout@example.com");
});
});
2017-06-14 13:57:58 -04:00
QUnit.test("account created - update email - cancel", assert => {
2018-06-15 11:03:24 -04:00
PreloadStore.store("accountCreated", {
message: "Hello World",
2018-06-15 11:03:24 -04:00
username: "eviltrout",
email: "eviltrout@example.com",
2017-05-25 15:56:11 -04:00
show_controls: true
});
visit("/u/account-created");
2018-06-15 11:03:24 -04:00
click(".activation-controls .edit-email");
andThen(() => {
assert.equal(currentPath(), "account-created.edit-email");
2018-06-15 11:03:24 -04:00
assert.ok(find(".activation-controls .btn-primary:disabled").length);
});
2018-06-15 11:03:24 -04:00
click(".activation-controls .edit-cancel");
andThen(() => {
assert.equal(currentPath(), "account-created.index");
});
});
2017-06-14 13:57:58 -04:00
QUnit.test("account created - update email - submit", assert => {
2018-06-15 11:03:24 -04:00
PreloadStore.store("accountCreated", {
message: "Hello World",
2018-06-15 11:03:24 -04:00
username: "eviltrout",
email: "eviltrout@example.com",
2017-05-25 15:56:11 -04:00
show_controls: true
});
visit("/u/account-created");
2018-06-15 11:03:24 -04:00
click(".activation-controls .edit-email");
andThen(() => {
2018-06-15 11:03:24 -04:00
assert.ok(find(".activation-controls .btn-primary:disabled").length);
});
2018-06-15 11:03:24 -04:00
fillIn(".activate-new-email", "newemail@example.com");
andThen(() => {
2018-06-15 11:03:24 -04:00
assert.notOk(find(".activation-controls .btn-primary:disabled").length);
});
2018-06-15 11:03:24 -04:00
click(".activation-controls .btn-primary");
andThen(() => {
assert.equal(currentPath(), "account-created.resent");
2018-06-15 11:03:24 -04:00
const email = find(".account-created .ac-message b").text();
assert.equal(email, "newemail@example.com");
});
2018-06-15 11:03:24 -04:00
});