mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Refactor and add tests for category editing
This commit is contained in:
@@ -2,7 +2,7 @@ import { acceptance } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Category Edit", { loggedIn: true });
|
||||
|
||||
test("Can edit a category", (assert) => {
|
||||
test("Can open the category modal", (assert) => {
|
||||
visit("/c/bug");
|
||||
|
||||
click('.edit-category');
|
||||
@@ -15,3 +15,15 @@ test("Can edit a category", (assert) => {
|
||||
assert.ok(!visible('#discourse-modal'), 'it closes the modal');
|
||||
});
|
||||
});
|
||||
|
||||
test("Change the category color", (assert) => {
|
||||
visit("/c/bug");
|
||||
|
||||
click('.edit-category');
|
||||
fillIn('#edit-text-color', '#ff0000');
|
||||
click('#save-category');
|
||||
andThen(() => {
|
||||
assert.ok(!visible('#discourse-modal'), 'it closes the modal');
|
||||
assert.equal(Discourse.URL.redirectedTo, '/c/bug', 'it does one of the rare full page redirects');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -119,6 +119,11 @@ export default function() {
|
||||
|
||||
this.get('/users/:username/staff-info.json', () => response({}));
|
||||
|
||||
this.put('/categories/:category_id', function(request) {
|
||||
const category = parsePostData(request.requestBody);
|
||||
return response({category});
|
||||
});
|
||||
|
||||
this.get('/draft.json', function() {
|
||||
return response({});
|
||||
});
|
||||
|
||||
@@ -90,6 +90,12 @@ QUnit.testStart(function(ctx) {
|
||||
Discourse.BaseUrl = "localhost";
|
||||
Discourse.User.resetCurrent();
|
||||
Discourse.Site.resetCurrent(Discourse.Site.create(fixtures['site.json'].site));
|
||||
|
||||
Discourse.URL.redirectedTo = null;
|
||||
Discourse.URL.redirectTo = function(url) {
|
||||
Discourse.URL.redirectedTo = url;
|
||||
};
|
||||
|
||||
PreloadStore.reset();
|
||||
|
||||
window.sandbox = sinon.sandbox.create();
|
||||
|
||||
Reference in New Issue
Block a user