DEV: migrate widgets tests to async/await

This commit is contained in:
Maja Komel
2018-07-24 17:49:42 +02:00
parent fe39cdc90a
commit 3a52c2fa64
6 changed files with 197 additions and 291 deletions

View File

@ -12,17 +12,15 @@ widgetTest("listing actions", {
] ]
}); });
}, },
test(assert) { async test(assert) {
assert.equal(this.$(".post-actions .post-action").length, 2); assert.equal(this.$(".post-actions .post-action").length, 2);
click(".post-action:eq(0) .action-link a"); await click(".post-action:eq(0) .action-link a");
andThen(() => { assert.equal(
assert.equal( this.$(".post-action:eq(0) img.avatar").length,
this.$(".post-action:eq(0) img.avatar").length, 1,
1, "clicking it shows the user"
"clicking it shows the user" );
);
});
} }
}); });
@ -38,13 +36,11 @@ widgetTest("undo", {
this.set("undoPostAction", () => (this.undid = true)); this.set("undoPostAction", () => (this.undid = true));
}, },
test(assert) { async test(assert) {
assert.equal(this.$(".post-actions .post-action").length, 1); assert.equal(this.$(".post-actions .post-action").length, 1);
click(".action-link.undo"); await click(".action-link.undo");
andThen(() => { assert.ok(this.undid, "it triggered the action");
assert.ok(this.undid, "it triggered the action");
});
} }
}); });
@ -65,13 +61,11 @@ widgetTest("deferFlags", {
this.on("deferPostActionFlags", () => (this.deferred = true)); this.on("deferPostActionFlags", () => (this.deferred = true));
}, },
test(assert) { async test(assert) {
assert.equal(this.$(".post-actions .post-action").length, 1); assert.equal(this.$(".post-actions .post-action").length, 1);
click(".action-link.defer-flags"); await click(".action-link.defer-flags");
andThen(() => { assert.ok(this.deferred, "it triggered the action");
assert.ok(this.deferred, "it triggered the action");
});
} }
}); });

View File

@ -21,19 +21,15 @@ widgetTest("sign up / login buttons", {
this.on("showLogin", () => (this.loginShown = true)); this.on("showLogin", () => (this.loginShown = true));
}, },
test(assert) { async test(assert) {
assert.ok(this.$("button.sign-up-button").length); assert.ok(this.$("button.sign-up-button").length);
assert.ok(this.$("button.login-button").length); assert.ok(this.$("button.login-button").length);
click("button.sign-up-button"); await click("button.sign-up-button");
andThen(() => { assert.ok(this.signupShown);
assert.ok(this.signupShown);
});
click("button.login-button"); await click("button.login-button");
andThen(() => { assert.ok(this.loginShown);
assert.ok(this.loginShown);
});
} }
}); });

View File

@ -46,11 +46,9 @@ widgetTest("collapsed links", {
] ]
}); });
}, },
test(assert) { async test(assert) {
assert.ok(this.$(".expand-links").length === 1, "collapsed by default"); assert.ok(this.$(".expand-links").length === 1, "collapsed by default");
click("a.expand-links"); await click("a.expand-links");
andThen(() => { assert.equal(this.$(".post-links a.track-link").length, 7);
assert.equal(this.$(".post-links a.track-link").length, 7);
});
} }
}); });

View File

@ -23,14 +23,12 @@ widgetTest("wiki", {
this.set("args", { wiki: true, version: 2, canViewEditHistory: true }); this.set("args", { wiki: true, version: 2, canViewEditHistory: true });
this.on("showHistory", () => (this.historyShown = true)); this.on("showHistory", () => (this.historyShown = true));
}, },
test(assert) { async test(assert) {
click(".post-info .wiki"); await click(".post-info .wiki");
andThen(() => { assert.ok(
assert.ok( this.historyShown,
this.historyShown, "clicking the wiki icon displays the post history"
"clicking the wiki icon displays the post history" );
);
});
} }
}); });
@ -40,11 +38,9 @@ widgetTest("wiki without revision", {
this.set("args", { wiki: true, version: 1, canViewEditHistory: true }); this.set("args", { wiki: true, version: 1, canViewEditHistory: true });
this.on("editPost", () => (this.editPostCalled = true)); this.on("editPost", () => (this.editPostCalled = true));
}, },
test(assert) { async test(assert) {
click(".post-info .wiki"); await click(".post-info .wiki");
andThen(() => { assert.ok(this.editPostCalled, "clicking wiki icon edits the post");
assert.ok(this.editPostCalled, "clicking wiki icon edits the post");
});
} }
}); });
@ -55,14 +51,9 @@ widgetTest("via-email", {
this.set("args", { via_email: true, canViewRawEmail: true }); this.set("args", { via_email: true, canViewRawEmail: true });
this.on("showRawEmail", () => (this.rawEmailShown = true)); this.on("showRawEmail", () => (this.rawEmailShown = true));
}, },
test(assert) { async test(assert) {
click(".post-info.via-email"); await click(".post-info.via-email");
andThen(() => { assert.ok(this.rawEmailShown, "clicking the enveloppe shows the raw email");
assert.ok(
this.rawEmailShown,
"clicking the enveloppe shows the raw email"
);
});
} }
}); });
@ -73,14 +64,12 @@ widgetTest("via-email without permission", {
this.set("args", { via_email: true, canViewRawEmail: false }); this.set("args", { via_email: true, canViewRawEmail: false });
this.on("showRawEmail", () => (this.rawEmailShown = true)); this.on("showRawEmail", () => (this.rawEmailShown = true));
}, },
test(assert) { async test(assert) {
click(".post-info.via-email"); await click(".post-info.via-email");
andThen(() => { assert.ok(
assert.ok( !this.rawEmailShown,
!this.rawEmailShown, `clicking the enveloppe doesn't show the raw email`
`clicking the enveloppe doesn't show the raw email` );
);
});
} }
}); });
@ -91,11 +80,9 @@ widgetTest("history", {
this.set("args", { version: 3, canViewEditHistory: true }); this.set("args", { version: 3, canViewEditHistory: true });
this.on("showHistory", () => (this.historyShown = true)); this.on("showHistory", () => (this.historyShown = true));
}, },
test(assert) { async test(assert) {
click(".post-info.edits"); await click(".post-info.edits");
andThen(() => { assert.ok(this.historyShown, "clicking the pencil shows the history");
assert.ok(this.historyShown, "clicking the pencil shows the history");
});
} }
}); });
@ -106,14 +93,12 @@ widgetTest("history without view permission", {
this.set("args", { version: 3, canViewEditHistory: false }); this.set("args", { version: 3, canViewEditHistory: false });
this.on("showHistory", () => (this.historyShown = true)); this.on("showHistory", () => (this.historyShown = true));
}, },
test(assert) { async test(assert) {
click(".post-info.edits"); await click(".post-info.edits");
andThen(() => { assert.ok(
assert.ok( !this.historyShown,
!this.historyShown, `clicking the pencil doesn't show the history`
`clicking the pencil doesn't show the history` );
);
});
} }
}); });
@ -142,23 +127,19 @@ widgetTest("like count button", {
this.set("post", post); this.set("post", post);
this.set("args", { likeCount: 1 }); this.set("args", { likeCount: 1 });
}, },
test(assert) { async test(assert) {
assert.ok(this.$("button.like-count").length === 1); assert.ok(this.$("button.like-count").length === 1);
assert.ok(this.$(".who-liked").length === 0); assert.ok(this.$(".who-liked").length === 0);
// toggle it on // toggle it on
click("button.like-count"); await click("button.like-count");
andThen(() => { assert.ok(this.$(".who-liked").length === 1);
assert.ok(this.$(".who-liked").length === 1); assert.ok(this.$(".who-liked a.trigger-user-card").length === 1);
assert.ok(this.$(".who-liked a.trigger-user-card").length === 1);
});
// toggle it off // toggle it off
click("button.like-count"); await click("button.like-count");
andThen(() => { assert.ok(this.$(".who-liked").length === 0);
assert.ok(this.$(".who-liked").length === 0); assert.ok(this.$(".who-liked a.trigger-user-card").length === 0);
assert.ok(this.$(".who-liked a.trigger-user-card").length === 0);
});
} }
}); });
@ -196,23 +177,19 @@ widgetTest("liking", {
args.likeCount = args.liked ? 1 : 0; args.likeCount = args.liked ? 1 : 0;
}); });
}, },
test(assert) { async test(assert) {
assert.ok(!!this.$(".actions button.like").length); assert.ok(!!this.$(".actions button.like").length);
assert.ok(this.$(".actions button.like-count").length === 0); assert.ok(this.$(".actions button.like-count").length === 0);
click(".actions button.like"); await click(".actions button.like");
andThen(() => { assert.ok(!this.$(".actions button.like").length);
assert.ok(!this.$(".actions button.like").length); assert.ok(!!this.$(".actions button.has-like").length);
assert.ok(!!this.$(".actions button.has-like").length); assert.ok(this.$(".actions button.like-count").length === 1);
assert.ok(this.$(".actions button.like-count").length === 1);
});
click(".actions button.has-like"); await click(".actions button.has-like");
andThen(() => { assert.ok(!!this.$(".actions button.like").length);
assert.ok(!!this.$(".actions button.like").length); assert.ok(!this.$(".actions button.has-like").length);
assert.ok(!this.$(".actions button.has-like").length); assert.ok(this.$(".actions button.like-count").length === 0);
assert.ok(this.$(".actions button.like-count").length === 0);
});
} }
}); });
@ -225,14 +202,12 @@ widgetTest("anon liking", {
this.set("args", args); this.set("args", args);
this.on("showLogin", () => (this.loginShown = true)); this.on("showLogin", () => (this.loginShown = true));
}, },
test(assert) { async test(assert) {
assert.ok(!!this.$(".actions button.like").length); assert.ok(!!this.$(".actions button.like").length);
assert.ok(this.$(".actions button.like-count").length === 0); assert.ok(this.$(".actions button.like-count").length === 0);
click(".actions button.like"); await click(".actions button.like");
andThen(() => { assert.ok(this.loginShown);
assert.ok(this.loginShown);
});
} }
}); });
@ -242,11 +217,9 @@ widgetTest("edit button", {
this.set("args", { canEdit: true }); this.set("args", { canEdit: true });
this.on("editPost", () => (this.editPostCalled = true)); this.on("editPost", () => (this.editPostCalled = true));
}, },
test(assert) { async test(assert) {
click("button.edit"); await click("button.edit");
andThen(() => { assert.ok(this.editPostCalled, "it triggered the edit action");
assert.ok(this.editPostCalled, "it triggered the edit action");
});
} }
}); });
@ -266,11 +239,9 @@ widgetTest("recover button", {
this.set("args", { canDelete: true }); this.set("args", { canDelete: true });
this.on("deletePost", () => (this.deletePostCalled = true)); this.on("deletePost", () => (this.deletePostCalled = true));
}, },
test(assert) { async test(assert) {
click("button.delete"); await click("button.delete");
andThen(() => { assert.ok(this.deletePostCalled, "it triggered the delete action");
assert.ok(this.deletePostCalled, "it triggered the delete action");
});
} }
}); });
@ -280,11 +251,9 @@ widgetTest("delete topic button", {
this.set("args", { canDeleteTopic: true }); this.set("args", { canDeleteTopic: true });
this.on("deletePost", () => (this.deletePostCalled = true)); this.on("deletePost", () => (this.deletePostCalled = true));
}, },
test(assert) { async test(assert) {
click("button.delete"); await click("button.delete");
andThen(() => { assert.ok(this.deletePostCalled, "it triggered the delete action");
assert.ok(this.deletePostCalled, "it triggered the delete action");
});
} }
}); });
@ -329,9 +298,9 @@ widgetTest("recover topic button", {
this.set("args", { canRecoverTopic: true }); this.set("args", { canRecoverTopic: true });
this.on("recoverPost", () => (this.recovered = true)); this.on("recoverPost", () => (this.recovered = true));
}, },
test(assert) { async test(assert) {
click("button.recover"); await click("button.recover");
andThen(() => assert.ok(this.recovered)); assert.ok(this.recovered);
} }
}); });
@ -351,11 +320,9 @@ widgetTest("delete post button", {
this.set("args", { canDelete: true }); this.set("args", { canDelete: true });
this.on("deletePost", () => (this.deletePostCalled = true)); this.on("deletePost", () => (this.deletePostCalled = true));
}, },
test(assert) { async test(assert) {
click("button.delete"); await click("button.delete");
andThen(() => { assert.ok(this.deletePostCalled, "it triggered the delete action");
assert.ok(this.deletePostCalled, "it triggered the delete action");
});
} }
}); });
@ -376,9 +343,9 @@ widgetTest("recover post button", {
this.set("args", { canRecover: true }); this.set("args", { canRecover: true });
this.on("recoverPost", () => (this.recovered = true)); this.on("recoverPost", () => (this.recovered = true));
}, },
test(assert) { async test(assert) {
click("button.recover"); await click("button.recover");
andThen(() => assert.ok(this.recovered)); assert.ok(this.recovered);
} }
}); });
@ -398,13 +365,11 @@ widgetTest(`flagging`, {
this.set("args", { canFlag: true }); this.set("args", { canFlag: true });
this.on("showFlags", () => (this.flagsShown = true)); this.on("showFlags", () => (this.flagsShown = true));
}, },
test(assert) { async test(assert) {
assert.ok(this.$("button.create-flag").length === 1); assert.ok(this.$("button.create-flag").length === 1);
click("button.create-flag"); await click("button.create-flag");
andThen(() => { assert.ok(this.flagsShown, "it triggered the action");
assert.ok(this.flagsShown, "it triggered the action");
});
} }
}); });
@ -482,13 +447,11 @@ widgetTest("reply directly above", {
}); });
this.siteSettings.suppress_reply_directly_above = false; this.siteSettings.suppress_reply_directly_above = false;
}, },
test(assert) { async test(assert) {
assert.equal(this.$(".avoid-tab").length, 1, "has the avoid tab class"); assert.equal(this.$(".avoid-tab").length, 1, "has the avoid tab class");
click("a.reply-to-tab"); await click("a.reply-to-tab");
andThen(() => { assert.equal(this.$("section.embedded-posts.top .cooked").length, 1);
assert.equal(this.$("section.embedded-posts.top .cooked").length, 1); assert.equal(this.$("section.embedded-posts .d-icon-arrow-up").length, 1);
assert.equal(this.$("section.embedded-posts .d-icon-arrow-up").length, 1);
});
} }
}); });
@ -499,11 +462,9 @@ widgetTest("cooked content hidden", {
this.set("args", { cooked_hidden: true }); this.set("args", { cooked_hidden: true });
this.on("expandHidden", () => (this.unhidden = true)); this.on("expandHidden", () => (this.unhidden = true));
}, },
test(assert) { async test(assert) {
click(".topic-body .expand-hidden"); await click(".topic-body .expand-hidden");
andThen(() => { assert.ok(this.unhidden, "triggers the action");
assert.ok(this.unhidden, "triggers the action");
});
} }
}); });
@ -513,11 +474,9 @@ widgetTest("expand first post", {
this.set("args", { expandablePost: true }); this.set("args", { expandablePost: true });
this.set("post", store.createRecord("post", { id: 1234 })); this.set("post", store.createRecord("post", { id: 1234 }));
}, },
test(assert) { async test(assert) {
click(".topic-body .expand-post"); await click(".topic-body .expand-post");
andThen(() => { assert.equal(this.$(".expand-post").length, 0, "button is gone");
assert.equal(this.$(".expand-post").length, 0, "button is gone");
});
} }
}); });
@ -541,14 +500,12 @@ widgetTest("bookmark", {
this.set("args", args); this.set("args", args);
this.on("toggleBookmark", () => (args.bookmarked = true)); this.on("toggleBookmark", () => (args.bookmarked = true));
}, },
test(assert) { async test(assert) {
assert.equal(this.$(".post-menu-area .bookmark").length, 1); assert.equal(this.$(".post-menu-area .bookmark").length, 1);
assert.equal(this.$("button.bookmarked").length, 0); assert.equal(this.$("button.bookmarked").length, 0);
click("button.bookmark"); await click("button.bookmark");
andThen(() => { assert.equal(this.$("button.bookmarked").length, 1);
assert.equal(this.$("button.bookmarked").length, 1);
});
} }
}); });
@ -567,20 +524,16 @@ widgetTest("show admin menu", {
beforeEach() { beforeEach() {
this.set("args", { canManage: true }); this.set("args", { canManage: true });
}, },
test(assert) { async test(assert) {
assert.equal(this.$(".post-admin-menu").length, 0); assert.equal(this.$(".post-admin-menu").length, 0);
click(".post-menu-area .show-post-admin-menu"); await click(".post-menu-area .show-post-admin-menu");
andThen(() => { assert.equal(this.$(".post-admin-menu").length, 1, "it shows the popup");
assert.equal(this.$(".post-admin-menu").length, 1, "it shows the popup"); await click(".post-menu-area");
}); assert.equal(
click(".post-menu-area"); this.$(".post-admin-menu").length,
andThen(() => { 0,
assert.equal( "clicking outside clears the popup"
this.$(".post-admin-menu").length, );
0,
"clicking outside clears the popup"
);
});
} }
}); });
@ -591,13 +544,11 @@ widgetTest("toggle moderator post", {
this.set("args", { canManage: true }); this.set("args", { canManage: true });
this.on("togglePostType", () => (this.toggled = true)); this.on("togglePostType", () => (this.toggled = true));
}, },
test(assert) { async test(assert) {
click(".post-menu-area .show-post-admin-menu"); await click(".post-menu-area .show-post-admin-menu");
click(".post-admin-menu .toggle-post-type"); await click(".post-admin-menu .toggle-post-type");
andThen(() => { assert.ok(this.toggled);
assert.ok(this.toggled); assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
});
} }
}); });
widgetTest("toggle moderator post", { widgetTest("toggle moderator post", {
@ -607,13 +558,11 @@ widgetTest("toggle moderator post", {
this.set("args", { canManage: true }); this.set("args", { canManage: true });
this.on("togglePostType", () => (this.toggled = true)); this.on("togglePostType", () => (this.toggled = true));
}, },
test(assert) { async test(assert) {
click(".post-menu-area .show-post-admin-menu"); await click(".post-menu-area .show-post-admin-menu");
click(".post-admin-menu .toggle-post-type"); await click(".post-admin-menu .toggle-post-type");
andThen(() => { assert.ok(this.toggled);
assert.ok(this.toggled); assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
});
} }
}); });
@ -623,13 +572,11 @@ widgetTest("rebake post", {
this.set("args", { canManage: true }); this.set("args", { canManage: true });
this.on("rebakePost", () => (this.baked = true)); this.on("rebakePost", () => (this.baked = true));
}, },
test(assert) { async test(assert) {
click(".post-menu-area .show-post-admin-menu"); await click(".post-menu-area .show-post-admin-menu");
click(".post-admin-menu .rebuild-html"); await click(".post-admin-menu .rebuild-html");
andThen(() => { assert.ok(this.baked);
assert.ok(this.baked); assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
});
} }
}); });
@ -639,13 +586,11 @@ widgetTest("unhide post", {
this.set("args", { canManage: true, hidden: true }); this.set("args", { canManage: true, hidden: true });
this.on("unhidePost", () => (this.unhidden = true)); this.on("unhidePost", () => (this.unhidden = true));
}, },
test(assert) { async test(assert) {
click(".post-menu-area .show-post-admin-menu"); await click(".post-menu-area .show-post-admin-menu");
click(".post-admin-menu .unhide-post"); await click(".post-admin-menu .unhide-post");
andThen(() => { assert.ok(this.unhidden);
assert.ok(this.unhidden); assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
});
} }
}); });
@ -657,13 +602,11 @@ widgetTest("change owner", {
this.set("args", { canManage: true }); this.set("args", { canManage: true });
this.on("changePostOwner", () => (this.owned = true)); this.on("changePostOwner", () => (this.owned = true));
}, },
test(assert) { async test(assert) {
click(".post-menu-area .show-post-admin-menu"); await click(".post-menu-area .show-post-admin-menu");
click(".post-admin-menu .change-owner"); await click(".post-admin-menu .change-owner");
andThen(() => { assert.ok(this.owned);
assert.ok(this.owned); assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
});
} }
}); });
@ -674,11 +617,9 @@ widgetTest("reply", {
this.set("args", { canCreatePost: true }); this.set("args", { canCreatePost: true });
this.on("replyToPost", () => (this.replied = true)); this.on("replyToPost", () => (this.replied = true));
}, },
test(assert) { async test(assert) {
click(".post-controls .create"); await click(".post-controls .create");
andThen(() => { assert.ok(this.replied);
assert.ok(this.replied);
});
} }
}); });
@ -730,15 +671,10 @@ widgetTest("replies - one below, not suppressed", {
this.siteSettings.suppress_reply_directly_below = false; this.siteSettings.suppress_reply_directly_below = false;
this.set("args", { id: 6654, replyCount: 1, replyDirectlyBelow: true }); this.set("args", { id: 6654, replyCount: 1, replyDirectlyBelow: true });
}, },
test(assert) { async test(assert) {
click("button.show-replies"); await click("button.show-replies");
andThen(() => { assert.equal(this.$("section.embedded-posts.bottom .cooked").length, 1);
assert.equal(this.$("section.embedded-posts.bottom .cooked").length, 1); assert.equal(this.$("section.embedded-posts .d-icon-arrow-down").length, 1);
assert.equal(
this.$("section.embedded-posts .d-icon-arrow-down").length,
1
);
});
} }
}); });
@ -761,21 +697,19 @@ widgetTest("topic map - few posts", {
participants: [{ username: "eviltrout" }, { username: "codinghorror" }] participants: [{ username: "eviltrout" }, { username: "codinghorror" }]
}); });
}, },
test(assert) { async test(assert) {
assert.equal( assert.equal(
this.$("li.avatars a.poster").length, this.$("li.avatars a.poster").length,
0, 0,
"shows no participants when collapsed" "shows no participants when collapsed"
); );
click("nav.buttons button"); await click("nav.buttons button");
andThen(() => { assert.equal(
assert.equal( this.$(".topic-map-expanded a.poster").length,
this.$(".topic-map-expanded a.poster").length, 2,
2, "shows all when expanded"
"shows all when expanded" );
);
});
} }
}); });
@ -794,23 +728,21 @@ widgetTest("topic map - participants", {
userFilters: ["sam", "codinghorror"] userFilters: ["sam", "codinghorror"]
}); });
}, },
test(assert) { async test(assert) {
assert.equal( assert.equal(
this.$("li.avatars a.poster").length, this.$("li.avatars a.poster").length,
3, 3,
"limits to three participants" "limits to three participants"
); );
click("nav.buttons button"); await click("nav.buttons button");
andThen(() => { assert.equal(this.$("li.avatars a.poster").length, 0);
assert.equal(this.$("li.avatars a.poster").length, 0); assert.equal(
assert.equal( this.$(".topic-map-expanded a.poster").length,
this.$(".topic-map-expanded a.poster").length, 4,
4, "shows all when expanded"
"shows all when expanded" );
); assert.equal(this.$("a.poster.toggled").length, 2, "two are toggled");
assert.equal(this.$("a.poster.toggled").length, 2, "two are toggled");
});
} }
}); });
@ -829,31 +761,27 @@ widgetTest("topic map - links", {
] ]
}); });
}, },
test(assert) { async test(assert) {
assert.equal(this.$(".topic-map").length, 1); assert.equal(this.$(".topic-map").length, 1);
assert.equal(this.$(".map.map-collapsed").length, 1); assert.equal(this.$(".map.map-collapsed").length, 1);
assert.equal(this.$(".topic-map-expanded").length, 0); assert.equal(this.$(".topic-map-expanded").length, 0);
click("nav.buttons button"); await click("nav.buttons button");
andThen(() => { assert.equal(this.$(".map.map-collapsed").length, 0);
assert.equal(this.$(".map.map-collapsed").length, 0); assert.equal(this.$(".topic-map .d-icon-chevron-up").length, 1);
assert.equal(this.$(".topic-map .d-icon-chevron-up").length, 1); assert.equal(this.$(".topic-map-expanded").length, 1);
assert.equal(this.$(".topic-map-expanded").length, 1); assert.equal(
assert.equal( this.$(".topic-map-expanded .topic-link").length,
this.$(".topic-map-expanded .topic-link").length, 5,
5, "it limits the links displayed"
"it limits the links displayed" );
);
});
click(".link-summary button"); await click(".link-summary button");
andThen(() => { assert.equal(
assert.equal( this.$(".topic-map-expanded .topic-link").length,
this.$(".topic-map-expanded .topic-link").length, 6,
6, "all links now shown"
"all links now shown" );
);
});
} }
}); });
@ -874,11 +802,11 @@ widgetTest("topic map - has summary", {
this.set("args", { showTopicMap: true, hasTopicSummary: true }); this.set("args", { showTopicMap: true, hasTopicSummary: true });
this.on("toggleSummary", () => (this.summaryToggled = true)); this.on("toggleSummary", () => (this.summaryToggled = true));
}, },
test(assert) { async test(assert) {
assert.equal(this.$(".toggle-summary").length, 1); assert.equal(this.$(".toggle-summary").length, 1);
click(".toggle-summary button"); await click(".toggle-summary button");
andThen(() => assert.ok(this.summaryToggled)); assert.ok(this.summaryToggled);
} }
}); });

View File

@ -22,13 +22,11 @@ widgetTest("log out", {
this.on("logout", () => (this.loggedOut = true)); this.on("logout", () => (this.loggedOut = true));
}, },
test(assert) { async test(assert) {
assert.ok(this.$(".logout").length); assert.ok(this.$(".logout").length);
click(".logout"); await click(".logout");
andThen(() => { assert.ok(this.loggedOut);
assert.ok(this.loggedOut);
});
} }
}); });
@ -66,12 +64,10 @@ widgetTest("anonymous", {
this.on("toggleAnonymous", () => (this.anonymous = true)); this.on("toggleAnonymous", () => (this.anonymous = true));
}, },
test(assert) { async test(assert) {
assert.ok(this.$(".enable-anonymous").length); assert.ok(this.$(".enable-anonymous").length);
click(".enable-anonymous"); await click(".enable-anonymous");
andThen(() => { assert.ok(this.anonymous);
assert.ok(this.anonymous);
});
} }
}); });
@ -98,11 +94,9 @@ widgetTest("anonymous - switch back", {
this.on("toggleAnonymous", () => (this.anonymous = true)); this.on("toggleAnonymous", () => (this.anonymous = true));
}, },
test(assert) { async test(assert) {
assert.ok(this.$(".disable-anonymous").length); assert.ok(this.$(".disable-anonymous").length);
click(".disable-anonymous"); await click(".disable-anonymous");
andThen(() => { assert.ok(this.anonymous);
assert.ok(this.anonymous);
});
} }
}); });

View File

@ -136,14 +136,12 @@ widgetTest("widget state", {
}); });
}, },
test(assert) { async test(assert) {
assert.ok(this.$("button.test").length, "it renders the button"); assert.ok(this.$("button.test").length, "it renders the button");
assert.equal(this.$("button.test").text(), "0 clicks"); assert.equal(this.$("button.test").text(), "0 clicks");
click(this.$("button")); await click(this.$("button"));
andThen(() => { assert.equal(this.$("button.test").text(), "1 clicks");
assert.equal(this.$("button.test").text(), "1 clicks");
});
} }
}); });
@ -173,7 +171,7 @@ widgetTest("widget update with promise", {
}); });
}, },
test(assert) { async test(assert) {
assert.equal( assert.equal(
this.$("button.test") this.$("button.test")
.text() .text()
@ -181,15 +179,13 @@ widgetTest("widget update with promise", {
"No name" "No name"
); );
click(this.$("button")); await click(this.$("button"));
andThen(() => { assert.equal(
assert.equal( this.$("button.test")
this.$("button.test") .text()
.text() .trim(),
.trim(), "Robin"
"Robin" );
);
});
} }
}); });