discourse/test/javascripts/acceptance/search-test.js.es6

75 lines
2.0 KiB
Plaintext
Raw Normal View History

import { acceptance } from "helpers/qunit-helpers";
acceptance("Search");
2017-06-15 01:57:58 +08:00
QUnit.test("search", (assert) => {
visit("/");
click('#search-button');
andThen(() => {
assert.ok(exists('#search-term'), 'it shows the search bar');
assert.ok(!exists('.search-menu .results ul li'), 'no results by default');
});
2015-08-11 03:31:10 +08:00
fillIn('#search-term', 'dev');
keyEvent('#search-term', 'keyup', 16);
2015-08-11 03:31:10 +08:00
andThen(() => {
assert.ok(exists('.search-menu .results ul li'), 'it shows results');
2015-08-11 03:31:10 +08:00
});
click('.show-help');
andThen(() => {
assert.equal(find('.full-page-search').val(), 'dev', 'it shows the search term');
assert.ok(exists('.search-advanced-options'), 'advanced search is expanded');
});
});
2017-06-15 01:57:58 +08:00
QUnit.test("search scope checkbox", assert => {
visit("/c/bug");
click('#search-button');
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.ok(exists('.search-context input:checked'), 'scope to category checkbox is checked');
});
click('#search-button');
visit("/t/internationalization-localization/280");
click('#search-button');
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.not(exists('.search-context input:checked'), 'scope to topic checkbox is not checked');
});
click('#search-button');
2017-03-29 02:27:54 +08:00
visit("/u/eviltrout");
click('#search-button');
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.ok(exists('.search-context input:checked'), 'scope to user checkbox is checked');
});
});
2017-06-15 01:57:58 +08:00
QUnit.test("Search with context", assert => {
visit("/t/internationalization-localization/280/1");
click('#search-button');
fillIn('#search-term', 'dev');
click(".search-context input[type='checkbox']");
keyEvent('#search-term', 'keyup', 16);
andThen(() => {
assert.ok(exists('.search-menu .results ul li'), 'it shows results');
});
visit("/");
click('#search-button');
andThen(() => {
assert.ok(!exists(".search-context input[type='checkbox']"));
});
visit("/t/internationalization-localization/280/1");
click('#search-button');
andThen(() => {
assert.ok(!$('.search-context input[type=checkbox]').is(":checked"));
});
2017-06-15 01:57:58 +08:00
});