2017-08-08 16:08:07 +08:00
|
|
|
import { acceptance, logIn } from "helpers/qunit-helpers";
|
2015-06-23 02:05:35 +08:00
|
|
|
acceptance("Search");
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("search", (assert) => {
|
2015-06-23 02:05:35 +08:00
|
|
|
visit("/");
|
|
|
|
|
|
|
|
click('#search-button');
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(exists('#search-term'), 'it shows the search bar');
|
2015-08-27 04:55:01 +08:00
|
|
|
assert.ok(!exists('.search-menu .results ul li'), 'no results by default');
|
2015-06-23 02:05:35 +08:00
|
|
|
});
|
|
|
|
|
2015-08-11 03:31:10 +08:00
|
|
|
fillIn('#search-term', 'dev');
|
2016-04-15 03:23:05 +08:00
|
|
|
keyEvent('#search-term', 'keyup', 16);
|
2015-08-11 03:31:10 +08:00
|
|
|
andThen(() => {
|
2015-08-27 04:55:01 +08:00
|
|
|
assert.ok(exists('.search-menu .results ul li'), 'it shows results');
|
2015-08-11 03:31:10 +08:00
|
|
|
});
|
2016-10-25 11:46:50 +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');
|
|
|
|
});
|
2015-06-23 02:05:35 +08:00
|
|
|
});
|
2017-02-21 06:02:02 +08:00
|
|
|
|
2017-08-25 23:52:18 +08: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-15 01:57:58 +08:00
|
|
|
QUnit.test("search scope checkbox", assert => {
|
2017-02-21 06:02:02 +08:00
|
|
|
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');
|
2017-02-21 06:02:02 +08:00
|
|
|
});
|
|
|
|
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');
|
2017-02-21 06:02:02 +08:00
|
|
|
});
|
|
|
|
click('#search-button');
|
|
|
|
|
2017-03-29 02:27:54 +08:00
|
|
|
visit("/u/eviltrout");
|
2017-02-21 06:02:02 +08:00
|
|
|
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-02-21 06:02:02 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test("Search with context", assert => {
|
2017-02-03 11:28:54 +08: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-18 03:42:32 +08:00
|
|
|
});
|
2017-08-08 16:08:07 +08:00
|
|
|
|
2017-08-09 16:42:50 +08:00
|
|
|
QUnit.test("Right filters are shown to anonymous users", assert => {
|
2017-12-22 20:08:12 +08:00
|
|
|
const inSelector = selectKit('.select-kit#in');
|
|
|
|
|
2017-08-08 16:08:07 +08:00
|
|
|
visit("/search?expanded=true");
|
|
|
|
|
2017-12-22 20:08:12 +08:00
|
|
|
inSelector.expand();
|
2017-10-20 03:51:08 +08:00
|
|
|
|
2017-08-08 16:08:07 +08:00
|
|
|
andThen(() => {
|
2017-12-22 20:08:12 +08:00
|
|
|
assert.ok(inSelector.rowByValue('first').exists());
|
|
|
|
assert.ok(inSelector.rowByValue('pinned').exists());
|
|
|
|
assert.ok(inSelector.rowByValue('unpinned').exists());
|
|
|
|
assert.ok(inSelector.rowByValue('wiki').exists());
|
|
|
|
assert.ok(inSelector.rowByValue('images').exists());
|
|
|
|
|
|
|
|
assert.notOk(inSelector.rowByValue('unseen').exists());
|
|
|
|
assert.notOk(inSelector.rowByValue('posted').exists());
|
|
|
|
assert.notOk(inSelector.rowByValue('watching').exists());
|
|
|
|
assert.notOk(inSelector.rowByValue('tracking').exists());
|
|
|
|
assert.notOk(inSelector.rowByValue('bookmarks').exists());
|
2017-08-09 16:42:50 +08: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 16:08:07 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-08-09 16:42:50 +08:00
|
|
|
QUnit.test("Right filters are shown to logged-in users", assert => {
|
2017-12-22 20:08:12 +08:00
|
|
|
const inSelector = selectKit('.select-kit#in');
|
|
|
|
|
2017-08-08 16:08:07 +08:00
|
|
|
logIn();
|
|
|
|
Discourse.reset();
|
|
|
|
visit("/search?expanded=true");
|
|
|
|
|
2017-12-22 20:08:12 +08:00
|
|
|
inSelector.expand();
|
2017-10-20 03:51:08 +08:00
|
|
|
|
2017-08-08 16:08:07 +08:00
|
|
|
andThen(() => {
|
2017-12-22 20:08:12 +08:00
|
|
|
assert.ok(inSelector.rowByValue('first').exists());
|
|
|
|
assert.ok(inSelector.rowByValue('pinned').exists());
|
|
|
|
assert.ok(inSelector.rowByValue('unpinned').exists());
|
|
|
|
assert.ok(inSelector.rowByValue('wiki').exists());
|
|
|
|
assert.ok(inSelector.rowByValue('images').exists());
|
|
|
|
|
|
|
|
assert.ok(inSelector.rowByValue('unseen').exists());
|
|
|
|
assert.ok(inSelector.rowByValue('posted').exists());
|
|
|
|
assert.ok(inSelector.rowByValue('watching').exists());
|
|
|
|
assert.ok(inSelector.rowByValue('tracking').exists());
|
|
|
|
assert.ok(inSelector.rowByValue('bookmarks').exists());
|
2017-08-09 16:42:50 +08: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 16:08:07 +08:00
|
|
|
});
|
|
|
|
});
|