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

147 lines
4.3 KiB
Plaintext
Raw Normal View History

import { acceptance, logIn } from "helpers/qunit-helpers";
acceptance("Search");
2017-06-14 13:57:58 -04: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-10 15:31:10 -04:00
fillIn('#search-term', 'dev');
keyEvent('#search-term', 'keyup', 16);
2015-08-10 15:31:10 -04:00
andThen(() => {
assert.ok(exists('.search-menu .results ul li'), 'it shows results');
2015-08-10 15:31:10 -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');
});
});
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 => {
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');
});
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');
});
click('#search-button');
2017-03-28 14:27:54 -04:00
visit("/u/eviltrout");
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-06-14 13:57:58 -04: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');
assert.ok(
exists('.cooked span.highlight-strong'),
'it should highlight the search term'
);
});
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"));
});
});
QUnit.test("Right filters are shown to anonymous users", assert => {
const inSelector = selectKit('.select-kit#in');
visit("/search?expanded=true");
inSelector.expand();
2017-10-19 15:51:08 -04:00
andThen(() => {
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());
assert.notOk(exists('.search-advanced-options .in-likes'));
assert.notOk(exists('.search-advanced-options .in-private'));
assert.notOk(exists('.search-advanced-options .in-seen'));
});
});
QUnit.test("Right filters are shown to logged-in users", assert => {
const inSelector = selectKit('.select-kit#in');
logIn();
Discourse.reset();
visit("/search?expanded=true");
inSelector.expand();
2017-10-19 15:51:08 -04:00
andThen(() => {
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());
assert.ok(exists('.search-advanced-options .in-likes'));
assert.ok(exists('.search-advanced-options .in-private'));
assert.ok(exists('.search-advanced-options .in-seen'));
});
});