2019-06-14 20:54:20 +08:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
2018-03-27 16:45:21 +08:00
|
|
|
|
|
|
|
acceptance("New Group");
|
|
|
|
|
2018-07-19 18:11:18 +08:00
|
|
|
QUnit.test("As an anon user", async assert => {
|
2019-02-21 13:44:25 +08:00
|
|
|
await visit("/g");
|
2018-07-19 18:11:18 +08:00
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".groups-header-new").length,
|
|
|
|
0,
|
|
|
|
"it should not display the button to create a group"
|
|
|
|
);
|
2018-03-27 16:45:21 +08:00
|
|
|
});
|
|
|
|
|
2019-06-14 20:54:20 +08:00
|
|
|
acceptance("New Group", { loggedIn: true });
|
2018-03-27 16:45:21 +08:00
|
|
|
|
2019-06-14 20:54:20 +08:00
|
|
|
QUnit.test("Creating a new group", async assert => {
|
2019-02-21 13:44:25 +08:00
|
|
|
await visit("/g");
|
2018-07-19 18:11:18 +08:00
|
|
|
await click(".groups-header-new");
|
2018-04-12 10:29:09 +08:00
|
|
|
|
2018-07-19 18:11:18 +08:00
|
|
|
assert.equal(
|
|
|
|
find(".group-form-save[disabled]").length,
|
|
|
|
1,
|
|
|
|
"save button should be disabled"
|
|
|
|
);
|
2018-04-12 10:29:09 +08:00
|
|
|
|
2018-07-19 18:11:18 +08:00
|
|
|
await fillIn("input[name='name']", "1");
|
2018-03-27 16:45:21 +08:00
|
|
|
|
2018-07-19 18:11:18 +08:00
|
|
|
assert.equal(
|
|
|
|
find(".tip.bad")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
I18n.t("admin.groups.new.name.too_short"),
|
|
|
|
"it should show the right validation tooltip"
|
|
|
|
);
|
2018-03-27 16:45:21 +08:00
|
|
|
|
2018-07-19 18:11:18 +08:00
|
|
|
assert.ok(
|
|
|
|
find(".group-form-save:disabled").length === 1,
|
|
|
|
"it should disable the save button"
|
|
|
|
);
|
2018-03-27 16:45:21 +08:00
|
|
|
|
2018-07-19 18:11:18 +08:00
|
|
|
await fillIn(
|
2018-03-27 16:45:21 +08:00
|
|
|
"input[name='name']",
|
|
|
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
|
|
|
);
|
|
|
|
|
2018-07-19 18:11:18 +08:00
|
|
|
assert.equal(
|
|
|
|
find(".tip.bad")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
I18n.t("admin.groups.new.name.too_long"),
|
|
|
|
"it should show the right validation tooltip"
|
|
|
|
);
|
|
|
|
|
|
|
|
await fillIn("input[name='name']", "");
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".tip.bad")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
I18n.t("admin.groups.new.name.blank"),
|
|
|
|
"it should show the right validation tooltip"
|
|
|
|
);
|
|
|
|
|
|
|
|
await fillIn("input[name='name']", "goodusername");
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".tip.good")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
I18n.t("admin.groups.new.name.available"),
|
|
|
|
"it should show the right validation tooltip"
|
|
|
|
);
|
|
|
|
|
|
|
|
await click(".group-form-public-admission");
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find("groups-new-allow-membership-requests").length,
|
|
|
|
0,
|
|
|
|
"it should disable the membership requests checkbox"
|
|
|
|
);
|
2018-03-27 16:45:21 +08:00
|
|
|
});
|