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:
Robin Ward
2020-10-29 14:45:51 -04:00
parent c750a02f05
commit 435a9913a4
135 changed files with 1343 additions and 1025 deletions
@@ -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"
);
},