mirror of
https://github.com/discourse/discourse.git
synced 2025-04-14 01:00:49 +08:00

This PR refactors the following: * leaving all the CSS applied to the old `modal-body` classes in their respective files * made new clean styling for `.d-modal` and refactored the template to use the new BEM classes * `inner-`, `middle-`, `outer-` container classes are gone and replaced with simplified `wrapper` and `container` classes * use standardised max-sizes with modifiers `-large` and `-max` * lighter backdrop, * min-width to prevent puny modals * other styling changes regarding padding, close button,… * pulled out all modal overrides into a general `modal-overrides` file + cleanup of outdated CSS * pulled out login and create account modal styling into their own file, cause it's such a big override * removed old general login.scss file for mobile & desktop * only kept some remainders I don't want to touch in `app/assets/stylesheets/common/base/login.scss`
87 lines
3.1 KiB
JavaScript
87 lines
3.1 KiB
JavaScript
import { click, visit } from "@ember/test-helpers";
|
|
import { test } from "qunit";
|
|
import topicFixtures from "discourse/tests/fixtures/topic";
|
|
import {
|
|
acceptance,
|
|
exists,
|
|
query,
|
|
updateCurrentUser,
|
|
} from "discourse/tests/helpers/qunit-helpers";
|
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
|
import { cloneJSON } from "discourse-common/lib/object";
|
|
import I18n from "discourse-i18n";
|
|
|
|
acceptance("Topic - Slow Mode - enabled", function (needs) {
|
|
needs.user();
|
|
needs.pretender((server, helper) => {
|
|
server.get("/t/1.json", () => {
|
|
const json = cloneJSON(topicFixtures["/t/130.json"]);
|
|
json.slow_mode_seconds = 600;
|
|
json.slow_mode_enabled_until = "2040-01-01T04:00:00.000Z";
|
|
|
|
return helper.response(json);
|
|
});
|
|
server.get("/t/2.json", () => {
|
|
const json = cloneJSON(topicFixtures["/t/130.json"]);
|
|
json.slow_mode_seconds = 0;
|
|
json.slow_mode_enabled_until = null;
|
|
|
|
return helper.response(json);
|
|
});
|
|
});
|
|
|
|
needs.hooks.beforeEach(() => {
|
|
updateCurrentUser({ moderator: true });
|
|
});
|
|
|
|
test("the slow mode dialog loads settings of currently enabled slow mode ", async function (assert) {
|
|
await visit("/t/a-topic-with-enabled-slow-mode/1");
|
|
await click(".toggle-admin-menu");
|
|
await click(".topic-admin-slow-mode button");
|
|
|
|
const slowModeType = selectKit(".slow-mode-type");
|
|
assert.strictEqual(
|
|
slowModeType.header().name(),
|
|
I18n.t("topic.slow_mode_update.durations.10_minutes"),
|
|
"slow mode interval is rendered"
|
|
);
|
|
|
|
// unfortunately we can't check exact date and time
|
|
// but at least we can make sure that components for choosing date and time are rendered
|
|
// (in case of inactive slow mode it would be only a combo box with text "Select a timeframe",
|
|
// and date picker and time picker wouldn't be rendered)
|
|
assert.strictEqual(
|
|
query("div.enabled-until span.name").innerText,
|
|
I18n.t("time_shortcut.custom"),
|
|
"enabled until combobox is switched to the option Pick Date and Time"
|
|
);
|
|
|
|
assert.ok(exists("input.date-picker"), "date picker is rendered");
|
|
assert.ok(exists("input.time-input"), "time picker is rendered");
|
|
});
|
|
|
|
test("'Enable' button changes to 'Update' button when slow mode is enabled", async function (assert) {
|
|
await visit("/t/a-topic-with-disabled-slow-mode/2");
|
|
await click(".toggle-admin-menu");
|
|
await click(".topic-admin-slow-mode button");
|
|
await click(".future-date-input-selector-header");
|
|
|
|
assert.strictEqual(
|
|
query("div.d-modal__footer button.btn-primary span").innerText,
|
|
I18n.t("topic.slow_mode_update.enable"),
|
|
"shows 'Enable' button when slow mode is disabled"
|
|
);
|
|
|
|
await visit("/t/a-topic-with-enabled-slow-mode/1");
|
|
await click(".toggle-admin-menu");
|
|
await click(".topic-admin-slow-mode button");
|
|
await click(".future-date-input-selector-header");
|
|
|
|
assert.strictEqual(
|
|
query("div.d-modal__footer button.btn-primary span").innerText,
|
|
I18n.t("topic.slow_mode_update.update"),
|
|
"shows 'Update' button when slow mode is enabled"
|
|
);
|
|
});
|
|
});
|