This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/integration/components/invite-panel-test.js
Jarek Radosz 21e8a33177
DEV: Clean up QUnit tests (#13328)
* DEV: Use `query` helper instead of `queryAll()[0]`
* DEV: Replace `queryAll().length` w/ `exists()`/`count()`
* DEV: Use `exists()` instead of `count() > 0`, `count() === 0`
* DEV: Use `count()`/`exists()` instead of `find().length`
2021-06-08 17:54:12 +02:00

54 lines
1.8 KiB
JavaScript

import { set } from "@ember/object";
import { click, fillIn } from "@ember/test-helpers";
import User from "discourse/models/user";
import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import pretender from "discourse/tests/helpers/create-pretender";
import { discourseModule, exists } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import hbs from "htmlbars-inline-precompile";
discourseModule("Integration | Component | invite-panel", function (hooks) {
setupRenderingTest(hooks);
componentTest("shows the invite link after it is generated", {
template: hbs`{{invite-panel panel=panel}}`,
beforeEach() {
pretender.get("/u/search/users", () => {
return [200, { "Content-Type": "application/json" }, { users: [] }];
});
pretender.post("/invites", () => {
return [
200,
{ "Content-Type": "application/json" },
{
link: "http://example.com/invites/92c297e886a0ca03089a109ccd6be155",
},
];
});
set(this.currentUser, "details", { can_invite_via_email: true });
this.set("panel", {
id: "invite",
model: { inviteModel: User.create(this.currentUser) },
});
},
async test(assert) {
const input = selectKit(".invite-user-input");
await input.expand();
await fillIn(".invite-user-input .filter-input", "eviltrout@example.com");
await input.selectRowByValue("eviltrout@example.com");
assert.ok(!exists(".send-invite:disabled"));
await click(".generate-invite-link");
assert.equal(
find(".invite-link-input")[0].value,
"http://example.com/invites/92c297e886a0ca03089a109ccd6be155"
);
},
});
});