mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 20:26:23 +08:00
176aa0ac7d
* DEV: Remove server global test variable * Delete yarn-error.log * prettier and some eslint fixes * add global server variable back for plugins * rename imported server to pretender * prettier * support plugin server. usage * Export pretender as named * Prettier * change default pretender export * fix bad import * Use pretender() and original default export * export new Pretender as default * fix accidental change * WIP testing * add pretend handlers in correct location * move more stuff into the correct pretender * Consolidated more pretenders * comment out another bad test * fix user acceptance tests * commented out bad test * fixed another composer server stub * fix more tests * fixed tag test pretender * Fix admin email test * removed another draft handler * add back test * fix and uncomment another test * remove test that is not useful * remove commented out lines * reapply handlers between every test * no need to re-stub requests now :) * cleanup from review * more cleanup
109 lines
2.7 KiB
JavaScript
109 lines
2.7 KiB
JavaScript
import selectKit from "helpers/select-kit-helper";
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
import pretender from "helpers/create-pretender";
|
|
|
|
acceptance("Admin - User Index", {
|
|
loggedIn: true,
|
|
pretend(pretenderServer, helper) {
|
|
pretenderServer.get("/groups/search.json", () => {
|
|
return helper.response([
|
|
{
|
|
id: 42,
|
|
automatic: false,
|
|
name: "Macdonald",
|
|
user_count: 0,
|
|
alias_level: 99,
|
|
visible: true,
|
|
automatic_membership_email_domains: "",
|
|
automatic_membership_retroactive: false,
|
|
primary_group: false,
|
|
title: null,
|
|
grant_trust_level: null,
|
|
has_messages: false,
|
|
flair_url: null,
|
|
flair_bg_color: null,
|
|
flair_color: null,
|
|
bio_raw: null,
|
|
bio_cooked: null,
|
|
public_admission: false,
|
|
allow_membership_requests: true,
|
|
membership_request_template: "Please add me",
|
|
full_name: null
|
|
}
|
|
]);
|
|
});
|
|
}
|
|
});
|
|
|
|
QUnit.test("can edit username", async assert => {
|
|
pretender.put("/users/sam/preferences/username", () => [
|
|
200,
|
|
{ "Content-Type": "application/json" },
|
|
{ id: 2, username: "new-sam" }
|
|
]);
|
|
|
|
await visit("/admin/users/2/sam");
|
|
|
|
assert.equal(
|
|
find(".display-row.username .value")
|
|
.text()
|
|
.trim(),
|
|
"sam"
|
|
);
|
|
|
|
// Trying cancel.
|
|
await click(".display-row.username button");
|
|
await fillIn(".display-row.username .value input", "new-sam");
|
|
await click(".display-row.username a");
|
|
assert.equal(
|
|
find(".display-row.username .value")
|
|
.text()
|
|
.trim(),
|
|
"sam"
|
|
);
|
|
|
|
// Doing edit.
|
|
await click(".display-row.username button");
|
|
await fillIn(".display-row.username .value input", "new-sam");
|
|
await click(".display-row.username button");
|
|
assert.equal(
|
|
find(".display-row.username .value")
|
|
.text()
|
|
.trim(),
|
|
"new-sam"
|
|
);
|
|
});
|
|
|
|
QUnit.test("will clear unsaved groups when switching user", async assert => {
|
|
await visit("/admin/users/2/sam");
|
|
|
|
assert.equal(
|
|
find(".display-row.username .value")
|
|
.text()
|
|
.trim(),
|
|
"sam",
|
|
"the name should be correct"
|
|
);
|
|
|
|
const groupSelector = selectKit(".admin-group-selector");
|
|
await groupSelector.expand();
|
|
await groupSelector.selectRowByValue(42);
|
|
assert.equal(groupSelector.header().value(), 42, "group should be set");
|
|
|
|
await visit("/admin/users/1/eviltrout");
|
|
|
|
assert.equal(
|
|
find(".display-row.username .value")
|
|
.text()
|
|
.trim(),
|
|
"eviltrout",
|
|
"the name should be correct"
|
|
);
|
|
|
|
assert.equal(
|
|
find('.admin-group-selector span[title="Macdonald"]').length,
|
|
0,
|
|
"group should not be set"
|
|
);
|
|
});
|