discourse/test/javascripts/acceptance/admin-site-settings-test.js.es6

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

106 lines
2.9 KiB
Plaintext
Raw Normal View History

import { acceptance } from "helpers/qunit-helpers";
import siteSettingFixture from "fixtures/site_settings";
FEATURE: Automatically generate optimized site metadata icons (#7372) This change automatically resizes icons for various purposes. Admins can now upload `logo` and `logo_small`, and everything else will be auto-generated. Specific icons can still be uploaded separately if required. ## Core - Adds an SiteIconManager module which manages automatic resizing and fallback - Icons are looked up in the OptimizedImage table at runtime, and then cached in Redis. If the resized version is missing for some reason, then most icons will fall back to the original files. Some icons (e.g. PWA Manifest) will return `nil` (because an incorrectly sized icon is worse than a missing icon). - `SiteSetting.site_large_icon_url` will return the optimized version, including any fallback. `SiteSetting.large_icon` continues to return the upload object. This means that (almost) no changes are required in core/plugins to support this new system. - Icons are resized whenever a relevant site setting is changed, and during post-deploy migrations ## Wizard - Allows `requiresRefresh` wizard steps to reload data via AJAX instead of a full page reload - Add placeholders to the **icons** step of the wizard, which automatically update from the "Square Logo" - Various copy updates to support the changes - Remove the "upload-time" resizing for `large_icon`. This is no longer required. ## Site Settings UX - Move logo/icon settings under a new "Branding" tab - Various copy changes to support the changes - Adds placeholder support to the `image-uploader` component - Automatically reloads site settings after saving. This allows setting placeholders to change based on changes to other settings - Upload site settings will be assigned a placeholder if SiteIconManager `responds_to?` an icon of the same name ## Dashboard Warnings - Remove PWA icon and PWA title warnings. Both are now handled automatically. ## Bonus - Updated the sketch logos to use @awesomerobot's new high-res designs
2019-05-01 21:44:45 +08:00
var titleOverride = undefined;
acceptance("Admin - Site Settings", {
loggedIn: true,
FEATURE: Automatically generate optimized site metadata icons (#7372) This change automatically resizes icons for various purposes. Admins can now upload `logo` and `logo_small`, and everything else will be auto-generated. Specific icons can still be uploaded separately if required. ## Core - Adds an SiteIconManager module which manages automatic resizing and fallback - Icons are looked up in the OptimizedImage table at runtime, and then cached in Redis. If the resized version is missing for some reason, then most icons will fall back to the original files. Some icons (e.g. PWA Manifest) will return `nil` (because an incorrectly sized icon is worse than a missing icon). - `SiteSetting.site_large_icon_url` will return the optimized version, including any fallback. `SiteSetting.large_icon` continues to return the upload object. This means that (almost) no changes are required in core/plugins to support this new system. - Icons are resized whenever a relevant site setting is changed, and during post-deploy migrations ## Wizard - Allows `requiresRefresh` wizard steps to reload data via AJAX instead of a full page reload - Add placeholders to the **icons** step of the wizard, which automatically update from the "Square Logo" - Various copy updates to support the changes - Remove the "upload-time" resizing for `large_icon`. This is no longer required. ## Site Settings UX - Move logo/icon settings under a new "Branding" tab - Various copy changes to support the changes - Adds placeholder support to the `image-uploader` component - Automatically reloads site settings after saving. This allows setting placeholders to change based on changes to other settings - Upload site settings will be assigned a placeholder if SiteIconManager `responds_to?` an icon of the same name ## Dashboard Warnings - Remove PWA icon and PWA title warnings. Both are now handled automatically. ## Bonus - Updated the sketch logos to use @awesomerobot's new high-res designs
2019-05-01 21:44:45 +08:00
beforeEach() {
titleOverride = undefined;
},
pretend(server, helper) {
FEATURE: Automatically generate optimized site metadata icons (#7372) This change automatically resizes icons for various purposes. Admins can now upload `logo` and `logo_small`, and everything else will be auto-generated. Specific icons can still be uploaded separately if required. ## Core - Adds an SiteIconManager module which manages automatic resizing and fallback - Icons are looked up in the OptimizedImage table at runtime, and then cached in Redis. If the resized version is missing for some reason, then most icons will fall back to the original files. Some icons (e.g. PWA Manifest) will return `nil` (because an incorrectly sized icon is worse than a missing icon). - `SiteSetting.site_large_icon_url` will return the optimized version, including any fallback. `SiteSetting.large_icon` continues to return the upload object. This means that (almost) no changes are required in core/plugins to support this new system. - Icons are resized whenever a relevant site setting is changed, and during post-deploy migrations ## Wizard - Allows `requiresRefresh` wizard steps to reload data via AJAX instead of a full page reload - Add placeholders to the **icons** step of the wizard, which automatically update from the "Square Logo" - Various copy updates to support the changes - Remove the "upload-time" resizing for `large_icon`. This is no longer required. ## Site Settings UX - Move logo/icon settings under a new "Branding" tab - Various copy changes to support the changes - Adds placeholder support to the `image-uploader` component - Automatically reloads site settings after saving. This allows setting placeholders to change based on changes to other settings - Upload site settings will be assigned a placeholder if SiteIconManager `responds_to?` an icon of the same name ## Dashboard Warnings - Remove PWA icon and PWA title warnings. Both are now handled automatically. ## Bonus - Updated the sketch logos to use @awesomerobot's new high-res designs
2019-05-01 21:44:45 +08:00
server.put("/admin/site_settings/title", body => {
titleOverride = body.requestBody.split("=")[1];
return helper.response({ success: "OK" });
});
server.get("/admin/site_settings", () => {
const fixtures = siteSettingFixture["/admin/site_settings"].site_settings;
const titleSetting = Object.assign({}, fixtures[0]);
if (titleOverride) {
titleSetting.value = titleOverride;
}
const response = {
site_settings: [titleSetting, ...fixtures.slice(1)]
};
return helper.response(response);
});
}
});
2018-11-14 15:03:02 +08:00
QUnit.test("upload site setting", async assert => {
await visit("/admin/site_settings");
assert.ok(
exists(".row.setting.upload .image-uploader"),
"image uploader is present"
);
assert.ok(exists(".row.setting.upload .undo"), "undo button is present");
});
QUnit.test("changing value updates dirty state", async assert => {
await visit("/admin/site_settings");
await fillIn("#setting-filter", " title ");
assert.equal(count(".row.setting"), 1, "filter returns 1 site setting");
assert.ok(!exists(".row.setting.overridden"), "setting isn't overriden");
await fillIn(".input-setting-string", "Test");
await click("button.cancel");
assert.ok(
!exists(".row.setting.overridden"),
"canceling doesn't mark setting as overriden"
);
await fillIn(".input-setting-string", "Test");
await click("button.ok");
assert.ok(
exists(".row.setting.overridden"),
"saving marks setting as overriden"
);
await click("button.undo");
assert.ok(
!exists(".row.setting.overridden"),
"setting isn't marked as overriden after undo"
);
await click("button.cancel");
assert.ok(
exists(".row.setting.overridden"),
"setting is marked as overriden after cancel"
);
await click("button.undo");
await click("button.ok");
assert.ok(
!exists(".row.setting.overridden"),
"setting isn't marked as overriden after undo"
);
await fillIn(".input-setting-string", "Test");
await keyEvent(".input-setting-string", "keydown", 13); // enter
assert.ok(
exists(".row.setting.overridden"),
"saving via Enter key marks setting as overriden"
);
});
QUnit.test(
"always shows filtered site settings if a filter is set",
async assert => {
await visit("/admin/site_settings");
await fillIn("#setting-filter", "title");
assert.equal(count(".row.setting"), 1);
// navigate away to the "Dashboard" page
await click(".nav.nav-pills li:nth-child(1) a");
assert.equal(count(".row.setting"), 0);
// navigate back to the "Settings" page
await click(".nav.nav-pills li:nth-child(2) a");
assert.equal(count(".row.setting"), 1);
}
);