mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 18:02:45 +08:00
![Martin Brennan](/assets/img/avatar_default.png)
Our method of loading a subset of client settings into tests via tests/helpers/site-settings.js can be improved upon. Currently we have a hardcoded subset of the client settings, which may get out of date and not have the correct defaults. As well as this plugins do not get their settings into the tests, so whenever you need a setting from a plugin, even if it has a default, you have to do needs.setting({ ... }) which is inconvenient. This commit introduces an ember CLI build step to take the site_settings.yml and all the plugin settings.yml files, pull out the client settings, and dump them into a variable in a single JS file we can load in our tests, so we have the correct selection of settings and default values in our JS tests. It also fixes many, many tests that were operating under incorrect assumptions or old settings. Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
|
|
import { test } from "qunit";
|
|
import { click, currentURL, settled, visit } from "@ember/test-helpers";
|
|
|
|
acceptance("Bootstrap Mode Notice", function (needs) {
|
|
needs.user({ admin: true });
|
|
needs.site({ wizard_required: true });
|
|
needs.settings({
|
|
bootstrap_mode_enabled: true,
|
|
bootstrap_mode_min_users: 50,
|
|
});
|
|
|
|
test("Navigation", async function (assert) {
|
|
await visit("/");
|
|
assert.ok(
|
|
exists(".bootstrap-mode-notice"),
|
|
"has the bootstrap mode notice"
|
|
);
|
|
assert.ok(
|
|
exists(".bootstrap-invite-button"),
|
|
"bootstrap notice has invite button"
|
|
);
|
|
assert.ok(
|
|
exists(".bootstrap-wizard-link"),
|
|
"bootstrap notice has wizard link"
|
|
);
|
|
|
|
await click(".bootstrap-invite-button");
|
|
assert.ok(exists(".create-invite-modal"), "opens create invite modal");
|
|
|
|
await click(".bootstrap-wizard-link");
|
|
assert.strictEqual(
|
|
currentURL(),
|
|
"/wizard/steps/hello-world",
|
|
"it transitions to the wizard page"
|
|
);
|
|
|
|
this.siteSettings.bootstrap_mode_enabled = false;
|
|
await visit("/");
|
|
await settled();
|
|
assert.ok(
|
|
!exists(".bootstrap-mode-notice"),
|
|
"removes the notice when bootstrap mode is disabled"
|
|
);
|
|
});
|
|
});
|