2017-08-08 04:08:07 -04:00
|
|
|
import { acceptance, logIn } from "helpers/qunit-helpers";
|
2015-06-22 14:05:35 -04:00
|
|
|
acceptance("Search");
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("search", (assert) => {
|
2015-06-22 14:05:35 -04:00
|
|
|
visit("/");
|
|
|
|
|
|
|
|
click('#search-button');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(exists('#search-term'), 'it shows the search bar');
|
2015-08-26 16:55:01 -04:00
|
|
|
assert.ok(!exists('.search-menu .results ul li'), 'no results by default');
|
2015-06-22 14:05:35 -04:00
|
|
|
});
|
|
|
|
|
2015-08-10 15:31:10 -04:00
|
|
|
fillIn('#search-term', 'dev');
|
2016-04-14 15:23:05 -04:00
|
|
|
keyEvent('#search-term', 'keyup', 16);
|
2015-08-10 15:31:10 -04:00
|
|
|
andThen(() => {
|
2015-08-26 16:55:01 -04:00
|
|
|
assert.ok(exists('.search-menu .results ul li'), 'it shows results');
|
2015-08-10 15:31:10 -04:00
|
|
|
});
|
2016-10-24 23:46:50 -04: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');
|
|
|
|
});
|
2015-06-22 14:05:35 -04:00
|
|
|
});
|
2017-02-20 17:02:02 -05:00
|
|
|
|
2017-08-25 11:52:18 -04:00
|
|
|
QUnit.test("search for a tag", (assert) => {
|
|
|
|
visit("/");
|
|
|
|
|
|
|
|
click('#search-button');
|
|
|
|
|
|
|
|
fillIn('#search-term', 'evil');
|
|
|
|
keyEvent('#search-term', 'keyup', 16);
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(exists('.search-menu .results ul li'), 'it shows results');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("search scope checkbox", assert => {
|
2017-02-20 17:02:02 -05:00
|
|
|
visit("/c/bug");
|
|
|
|
click('#search-button');
|
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(exists('.search-context input:checked'), 'scope to category checkbox is checked');
|
2017-02-20 17:02:02 -05:00
|
|
|
});
|
|
|
|
click('#search-button');
|
|
|
|
|
|
|
|
visit("/t/internationalization-localization/280");
|
|
|
|
click('#search-button');
|
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.not(exists('.search-context input:checked'), 'scope to topic checkbox is not checked');
|
2017-02-20 17:02:02 -05:00
|
|
|
});
|
|
|
|
click('#search-button');
|
|
|
|
|
2017-03-28 14:27:54 -04:00
|
|
|
visit("/u/eviltrout");
|
2017-02-20 17:02:02 -05:00
|
|
|
click('#search-button');
|
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(exists('.search-context input:checked'), 'scope to user checkbox is checked');
|
2017-02-20 17:02:02 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("Search with context", assert => {
|
2017-02-02 22:28:54 -05:00
|
|
|
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-07-17 15:42:32 -04:00
|
|
|
});
|
2017-08-08 04:08:07 -04:00
|
|
|
|
2017-08-09 04:42:50 -04:00
|
|
|
QUnit.test("Right filters are shown to anonymous users", assert => {
|
2017-08-08 04:08:07 -04:00
|
|
|
visit("/search?expanded=true");
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-08-09 04:42:50 -04:00
|
|
|
assert.ok(exists('select#in option[value=first]'));
|
|
|
|
assert.ok(exists('select#in option[value=pinned]'));
|
|
|
|
assert.ok(exists('select#in option[value=unpinned]'));
|
|
|
|
assert.ok(exists('select#in option[value=wiki]'));
|
|
|
|
assert.ok(exists('select#in option[value=images]'));
|
2017-08-08 04:08:07 -04:00
|
|
|
|
|
|
|
assert.notOk(exists('select#in option[value=unseen]'));
|
|
|
|
assert.notOk(exists('select#in option[value=posted]'));
|
|
|
|
assert.notOk(exists('select#in option[value=watching]'));
|
|
|
|
assert.notOk(exists('select#in option[value=tracking]'));
|
|
|
|
assert.notOk(exists('select#in option[value=bookmarks]'));
|
2017-08-09 04:42:50 -04:00
|
|
|
|
|
|
|
assert.notOk(exists('.search-advanced-options .in-likes'));
|
|
|
|
assert.notOk(exists('.search-advanced-options .in-private'));
|
|
|
|
assert.notOk(exists('.search-advanced-options .in-seen'));
|
2017-08-08 04:08:07 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-08-09 04:42:50 -04:00
|
|
|
QUnit.test("Right filters are shown to logged-in users", assert => {
|
2017-08-08 04:08:07 -04:00
|
|
|
logIn();
|
|
|
|
Discourse.reset();
|
|
|
|
visit("/search?expanded=true");
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-08-09 04:42:50 -04:00
|
|
|
assert.ok(exists('select#in option[value=first]'));
|
|
|
|
assert.ok(exists('select#in option[value=pinned]'));
|
|
|
|
assert.ok(exists('select#in option[value=unpinned]'));
|
|
|
|
assert.ok(exists('select#in option[value=wiki]'));
|
|
|
|
assert.ok(exists('select#in option[value=images]'));
|
|
|
|
|
2017-08-08 04:08:07 -04:00
|
|
|
assert.ok(exists('select#in option[value=unseen]'));
|
|
|
|
assert.ok(exists('select#in option[value=posted]'));
|
|
|
|
assert.ok(exists('select#in option[value=watching]'));
|
|
|
|
assert.ok(exists('select#in option[value=tracking]'));
|
|
|
|
assert.ok(exists('select#in option[value=bookmarks]'));
|
2017-08-09 04:42:50 -04:00
|
|
|
|
|
|
|
assert.ok(exists('.search-advanced-options .in-likes'));
|
|
|
|
assert.ok(exists('.search-advanced-options .in-private'));
|
|
|
|
assert.ok(exists('.search-advanced-options .in-seen'));
|
2017-08-08 04:08:07 -04:00
|
|
|
});
|
|
|
|
});
|