2018-03-27 04:45:21 -04:00
|
|
|
import { acceptance, logIn } from "helpers/qunit-helpers";
|
|
|
|
|
|
|
|
acceptance("New Group");
|
|
|
|
|
2018-07-19 06:11:18 -04:00
|
|
|
QUnit.test("As an anon user", async assert => {
|
2019-02-21 00:44:25 -05:00
|
|
|
await visit("/g");
|
2018-07-19 06:11:18 -04:00
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".groups-header-new").length,
|
|
|
|
0,
|
|
|
|
"it should not display the button to create a group"
|
|
|
|
);
|
2018-03-27 04:45:21 -04:00
|
|
|
});
|
|
|
|
|
2018-07-19 06:11:18 -04:00
|
|
|
QUnit.test("Creating a new group", async assert => {
|
2018-03-27 04:45:21 -04:00
|
|
|
logIn();
|
|
|
|
Discourse.reset();
|
|
|
|
|
2019-02-21 00:44:25 -05:00
|
|
|
await visit("/g");
|
2018-03-27 04:45:21 -04:00
|
|
|
|
2018-07-19 06:11:18 -04:00
|
|
|
await click(".groups-header-new");
|
2018-04-11 22:29:09 -04:00
|
|
|
|
2018-07-19 06:11:18 -04:00
|
|
|
assert.equal(
|
|
|
|
find(".group-form-save[disabled]").length,
|
|
|
|
1,
|
|
|
|
"save button should be disabled"
|
|
|
|
);
|
2018-04-11 22:29:09 -04:00
|
|
|
|
2018-07-19 06:11:18 -04:00
|
|
|
await fillIn("input[name='name']", "1");
|
2018-03-27 04:45:21 -04:00
|
|
|
|
2018-07-19 06:11:18 -04: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 04:45:21 -04:00
|
|
|
|
2018-07-19 06:11:18 -04:00
|
|
|
assert.ok(
|
|
|
|
find(".group-form-save:disabled").length === 1,
|
|
|
|
"it should disable the save button"
|
|
|
|
);
|
2018-03-27 04:45:21 -04:00
|
|
|
|
2018-07-19 06:11:18 -04:00
|
|
|
await fillIn(
|
2018-06-15 11:03:24 -04:00
|
|
|
"input[name='name']",
|
|
|
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
|
|
|
);
|
2018-03-27 04:45:21 -04:00
|
|
|
|
2018-07-19 06:11:18 -04: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 04:45:21 -04:00
|
|
|
});
|