Using arrow functions changes `this` context, which is undesired in tests, e.g. it makes it impossible to setup things like pretender (`this.server`) in `beforeEach` hooks. Ember guides always use classic functions in examples (e.g. https://guides.emberjs.com/release/testing/test-types/), and that's what it uses in its own test suite, as do various addons and ember apps. It was also already used in Discourse where `this` was required. Moving forward, it will be needed in more places as we migrate toward ember-cli. (I might later add a custom rule to eslint-discourse-ember to enforce this)
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
|
|
import { exists } from "discourse/tests/helpers/qunit-helpers";
|
|
import { click, fillIn, visit } from "@ember/test-helpers";
|
|
import { test } from "qunit";
|
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
|
|
|
acceptance("Search - Mobile", function (needs) {
|
|
needs.mobileView();
|
|
|
|
test("search", async function (assert) {
|
|
await visit("/");
|
|
|
|
await click("#search-button");
|
|
|
|
assert.ok(
|
|
exists("input.full-page-search"),
|
|
"it shows the full page search form"
|
|
);
|
|
|
|
assert.ok(!exists(".search-results .fps-topic"), "no results by default");
|
|
|
|
await click(".search-advanced-title");
|
|
|
|
assert.ok(
|
|
queryAll(".search-advanced-filters").length === 1,
|
|
"it should expand advanced search filters"
|
|
);
|
|
|
|
await fillIn(".search-query", "posts");
|
|
await click(".search-cta");
|
|
|
|
assert.ok(queryAll(".fps-topic").length === 1, "has one post");
|
|
|
|
assert.ok(
|
|
queryAll(".search-advanced-filters").length === 0,
|
|
"it should collapse advanced search filters"
|
|
);
|
|
|
|
await click("#search-button");
|
|
|
|
assert.equal(
|
|
queryAll("input.full-page-search").val(),
|
|
"posts",
|
|
"it does not reset input when hitting search icon again"
|
|
);
|
|
});
|
|
});
|