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

49 lines
1.6 KiB
JavaScript

import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { click, render } from "@ember/test-helpers";
import { exists, query } from "discourse/tests/helpers/qunit-helpers";
import { hbs } from "ember-cli-htmlbars";
import pretender from "discourse/tests/helpers/create-pretender";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import User from "discourse/models/user";
module("Integration | Component | invite-panel", function (hooks) {
setupRenderingTest(hooks);
test("shows the invite link after it is generated", async function (assert) {
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",
},
];
});
this.currentUser.set("details", { can_invite_via_email: true });
this.set("panel", {
id: "invite",
model: { inviteModel: User.create(this.currentUser) },
});
await render(hbs`<InvitePanel @panel={{this.panel}} />`);
const input = selectKit(".invite-user-input");
await input.expand();
await input.fillInFilter("eviltrout@example.com");
await input.selectRowByValue("eviltrout@example.com");
assert.ok(!exists(".send-invite:disabled"));
await click(".generate-invite-link");
assert.strictEqual(
query(".invite-link-input").value,
"http://example.com/invites/92c297e886a0ca03089a109ccd6be155"
);
});
});