REFACTOR: Move test setup to a module

This is long overdue. We had a lot of (not linted) code to initialize
our test suite as part of the Ruby `test_helper.js` bundle.

This refactor moves that out to a `setup-tests` module, which imports
all the modules properly, rather than using `require`.

It also removes the global `server` variable which some tests were using
for pretender. Those tests are fixed, and in the case of widget tests,
support for a `pretend()` was added, which mimics our acceptance tests.

One problematic test was removed, which overwrites `/posts` - this could
break tons of other tests depending on order.
This commit is contained in:
Robin Ward
2020-10-07 17:08:19 -04:00
parent 5130b4d674
commit ef7d99b0a8
12 changed files with 563 additions and 566 deletions

View File

@ -1,10 +1,14 @@
import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
import { addPretenderCallback } from "discourse/tests/helpers/qunit-helpers";
export function moduleForWidget(name, options = {}) {
let fullName = `widget:${name}`;
addPretenderCallback(fullName, options.pretend);
moduleForComponent(
name,
`widget:${name}`,
fullName,
Object.assign(
{ integration: true },
{ beforeEach: options.beforeEach, afterEach: options.afterEach }