mirror of
https://github.com/discourse/discourse.git
synced 2026-08-10 04:58:31 -05:00
REFACTOR: Replace global find with queryAll
In newer Embers jQuery is removed. There is a `find` but it only returns one element and not a jQuery selector. This patch migrates our code to a new helper `queryAll` which allows us to remove the global.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { moduleForComponent } from "ember-qunit";
|
||||
import { componentTest } from "wizard/test/helpers/component-test";
|
||||
|
||||
moduleForComponent("invite-list", { integration: true });
|
||||
|
||||
componentTest("can add users", {
|
||||
@@ -11,10 +12,13 @@ componentTest("can add users", {
|
||||
|
||||
async test(assert) {
|
||||
assert.ok(
|
||||
find(".users-list .invite-list-user").length === 0,
|
||||
document.querySelectorAll(".users-list .invite-list-user").length === 0,
|
||||
"no users at first"
|
||||
);
|
||||
assert.ok(find(".new-user .invalid").length === 0, "not invalid at first");
|
||||
assert.ok(
|
||||
document.querySelectorAll(".new-user .invalid").length === 0,
|
||||
"not invalid at first"
|
||||
);
|
||||
|
||||
const firstVal = JSON.parse(this.get("field.value"));
|
||||
assert.equal(firstVal.length, 0, "empty JSON at first");
|
||||
@@ -26,19 +30,19 @@ componentTest("can add users", {
|
||||
|
||||
await click(".add-user");
|
||||
assert.ok(
|
||||
find(".users-list .invite-list-user").length === 0,
|
||||
document.querySelectorAll(".users-list .invite-list-user").length === 0,
|
||||
"doesn't add a blank user"
|
||||
);
|
||||
assert.ok(find(".new-user .invalid").length === 1);
|
||||
assert.ok(document.querySelectorAll(".new-user .invalid").length === 1);
|
||||
|
||||
await fillIn(".invite-email", "eviltrout@example.com");
|
||||
await click(".add-user");
|
||||
|
||||
assert.ok(
|
||||
find(".users-list .invite-list-user").length === 1,
|
||||
document.querySelectorAll(".users-list .invite-list-user").length === 1,
|
||||
"adds the user"
|
||||
);
|
||||
assert.ok(find(".new-user .invalid").length === 0);
|
||||
assert.ok(document.querySelectorAll(".new-user .invalid").length === 0);
|
||||
|
||||
const val = JSON.parse(this.get("field.value"));
|
||||
assert.equal(val.length, 1);
|
||||
@@ -54,23 +58,23 @@ componentTest("can add users", {
|
||||
await click(".add-user");
|
||||
|
||||
assert.ok(
|
||||
find(".users-list .invite-list-user").length === 1,
|
||||
document.querySelectorAll(".users-list .invite-list-user").length === 1,
|
||||
"can't add the same user twice"
|
||||
);
|
||||
assert.ok(find(".new-user .invalid").length === 1);
|
||||
assert.ok(document.querySelectorAll(".new-user .invalid").length === 1);
|
||||
|
||||
await fillIn(".invite-email", "not-an-email");
|
||||
await click(".add-user");
|
||||
|
||||
assert.ok(
|
||||
find(".users-list .invite-list-user").length === 1,
|
||||
document.querySelectorAll(".users-list .invite-list-user").length === 1,
|
||||
"won't add an invalid email"
|
||||
);
|
||||
assert.ok(find(".new-user .invalid").length === 1);
|
||||
assert.ok(document.querySelectorAll(".new-user .invalid").length === 1);
|
||||
|
||||
await click(".invite-list .invite-list-user:eq(0) .remove-user");
|
||||
assert.ok(
|
||||
find(".users-list .invite-list-user").length === 0,
|
||||
document.querySelectorAll(".users-list .invite-list-user").length === 0,
|
||||
"removed the user"
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user