mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 17:40:43 +08:00
DEV: migrate acceptance tests to async await - admin, about, account created (#6111)
This commit is contained in:

committed by
Guo Xiang Tan

parent
4bee7fb458
commit
6aa2eb19d4
@ -3,97 +3,90 @@ import PreloadStore from "preload-store";
|
||||
|
||||
acceptance("Account Created");
|
||||
|
||||
QUnit.test("account created - message", assert => {
|
||||
QUnit.test("account created - message", async assert => {
|
||||
PreloadStore.store("accountCreated", {
|
||||
message: "Hello World"
|
||||
});
|
||||
visit("/u/account-created");
|
||||
await visit("/u/account-created");
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists(".account-created"));
|
||||
assert.equal(
|
||||
find(".account-created .ac-message")
|
||||
.text()
|
||||
.trim(),
|
||||
"Hello World",
|
||||
"it displays the message"
|
||||
);
|
||||
assert.notOk(exists(".activation-controls"));
|
||||
});
|
||||
assert.ok(exists(".account-created"));
|
||||
assert.equal(
|
||||
find(".account-created .ac-message")
|
||||
.text()
|
||||
.trim(),
|
||||
"Hello World",
|
||||
"it displays the message"
|
||||
);
|
||||
assert.notOk(exists(".activation-controls"));
|
||||
});
|
||||
|
||||
QUnit.test("account created - resend email", assert => {
|
||||
QUnit.test("account created - resend email", async assert => {
|
||||
PreloadStore.store("accountCreated", {
|
||||
message: "Hello World",
|
||||
username: "eviltrout",
|
||||
email: "eviltrout@example.com",
|
||||
show_controls: true
|
||||
});
|
||||
visit("/u/account-created");
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists(".account-created"));
|
||||
assert.equal(
|
||||
find(".account-created .ac-message")
|
||||
.text()
|
||||
.trim(),
|
||||
"Hello World",
|
||||
"it displays the message"
|
||||
);
|
||||
});
|
||||
await visit("/u/account-created");
|
||||
|
||||
click(".activation-controls .resend");
|
||||
andThen(() => {
|
||||
assert.equal(currentPath(), "account-created.resent");
|
||||
const email = find(".account-created .ac-message b").text();
|
||||
assert.equal(email, "eviltrout@example.com");
|
||||
});
|
||||
assert.ok(exists(".account-created"));
|
||||
assert.equal(
|
||||
find(".account-created .ac-message")
|
||||
.text()
|
||||
.trim(),
|
||||
"Hello World",
|
||||
"it displays the message"
|
||||
);
|
||||
|
||||
await click(".activation-controls .resend");
|
||||
|
||||
assert.equal(currentPath(), "account-created.resent");
|
||||
const email = find(".account-created .ac-message b").text();
|
||||
assert.equal(email, "eviltrout@example.com");
|
||||
});
|
||||
|
||||
QUnit.test("account created - update email - cancel", assert => {
|
||||
QUnit.test("account created - update email - cancel", async assert => {
|
||||
PreloadStore.store("accountCreated", {
|
||||
message: "Hello World",
|
||||
username: "eviltrout",
|
||||
email: "eviltrout@example.com",
|
||||
show_controls: true
|
||||
});
|
||||
visit("/u/account-created");
|
||||
|
||||
click(".activation-controls .edit-email");
|
||||
andThen(() => {
|
||||
assert.equal(currentPath(), "account-created.edit-email");
|
||||
assert.ok(find(".activation-controls .btn-primary:disabled").length);
|
||||
});
|
||||
await visit("/u/account-created");
|
||||
|
||||
click(".activation-controls .edit-cancel");
|
||||
andThen(() => {
|
||||
assert.equal(currentPath(), "account-created.index");
|
||||
});
|
||||
await click(".activation-controls .edit-email");
|
||||
|
||||
assert.equal(currentPath(), "account-created.edit-email");
|
||||
assert.ok(find(".activation-controls .btn-primary:disabled").length);
|
||||
|
||||
await click(".activation-controls .edit-cancel");
|
||||
|
||||
assert.equal(currentPath(), "account-created.index");
|
||||
});
|
||||
|
||||
QUnit.test("account created - update email - submit", assert => {
|
||||
QUnit.test("account created - update email - submit", async assert => {
|
||||
PreloadStore.store("accountCreated", {
|
||||
message: "Hello World",
|
||||
username: "eviltrout",
|
||||
email: "eviltrout@example.com",
|
||||
show_controls: true
|
||||
});
|
||||
visit("/u/account-created");
|
||||
|
||||
click(".activation-controls .edit-email");
|
||||
andThen(() => {
|
||||
assert.ok(find(".activation-controls .btn-primary:disabled").length);
|
||||
});
|
||||
await visit("/u/account-created");
|
||||
|
||||
fillIn(".activate-new-email", "newemail@example.com");
|
||||
andThen(() => {
|
||||
assert.notOk(find(".activation-controls .btn-primary:disabled").length);
|
||||
});
|
||||
await click(".activation-controls .edit-email");
|
||||
|
||||
click(".activation-controls .btn-primary");
|
||||
andThen(() => {
|
||||
assert.equal(currentPath(), "account-created.resent");
|
||||
const email = find(".account-created .ac-message b").text();
|
||||
assert.equal(email, "newemail@example.com");
|
||||
});
|
||||
assert.ok(find(".activation-controls .btn-primary:disabled").length);
|
||||
|
||||
await fillIn(".activate-new-email", "newemail@example.com");
|
||||
|
||||
assert.notOk(find(".activation-controls .btn-primary:disabled").length);
|
||||
|
||||
await click(".activation-controls .btn-primary");
|
||||
|
||||
assert.equal(currentPath(), "account-created.resent");
|
||||
const email = find(".account-created .ac-message b").text();
|
||||
assert.equal(email, "newemail@example.com");
|
||||
});
|
||||
|
Reference in New Issue
Block a user