fixes search-full-test for revamped search page

This commit is contained in:
Joffrey JAFFEUX 2018-04-10 09:59:24 +02:00 committed by GitHub
parent 3a86a2588c
commit d9ac0152e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 58 deletions

View File

@ -1,4 +1,4 @@
import { acceptance } from "helpers/qunit-helpers"; import { acceptance, waitFor } from "helpers/qunit-helpers";
acceptance("Search - Full Page", { acceptance("Search - Full Page", {
settings: {tagging_enabled: true}, settings: {tagging_enabled: true},
loggedIn: true, loggedIn: true,
@ -40,46 +40,34 @@ acceptance("Search - Full Page", {
} }
}); });
/*
QUnit.test("perform various searches", assert => { QUnit.test("perform various searches", assert => {
visit("/search"); visit("/search");
andThen(() => { andThen(() => {
assert.ok($('body.search-page').length, "has body class"); assert.ok($('body.search-page').length, "has body class");
assert.ok(exists('.search-container'), "has container class"); assert.ok(exists('.search-container'), "has container class");
assert.ok(find('input.search').length > 0); assert.ok(find('.search-query').length > 0);
assert.ok(find('.fps-topic').length === 0); assert.ok(find('.fps-topic').length === 0);
}); });
fillIn('.search input.full-page-search', 'none'); fillIn('.search-query', 'none');
click('.search .btn-primary'); click('.search-cta');
andThen(() => { andThen(() => {
assert.ok(find('.fps-topic').length === 0, 'has no results'); assert.ok(find('.fps-topic').length === 0, 'has no results');
assert.ok(find('.no-results-suggestion .google-search-form')); assert.ok(find('.no-results-suggestion .google-search-form'));
}); });
fillIn('.search input.full-page-search', 'posts'); fillIn('.search-query', 'posts');
click('.search .btn-primary'); click('.search-cta');
andThen(() => assert.ok(find('.fps-topic').length === 1, 'has one post')); andThen(() => assert.ok(find('.fps-topic').length === 1, 'has one post'));
}); });
QUnit.test("open advanced search", assert => {
visit("/search");
andThen(() => assert.ok(exists('.search .search-advanced'), 'shows advanced search panel'));
fillIn('.search input.full-page-search', 'none');
click('.search-advanced-btn');
andThen(() => assert.ok(visible('.search-advanced .search-advanced-options'), '"search-advanced-options" is visible'));
});
QUnit.test("escape search term", (assert) => { QUnit.test("escape search term", (assert) => {
visit("/search"); visit("/search");
fillIn('.search input.full-page-search', '@<script>prompt(1337)</script>gmail.com'); fillIn('.search-query', '@<script>prompt(1337)</script>gmail.com');
click('.search-advanced-btn');
andThen(() => { andThen(() => {
assert.ok(exists('.search-advanced-options span:contains("<script>prompt(1337)</script>gmail.com")'), 'it escapes search term'); assert.ok(exists('.search-advanced-options span:contains("<script>prompt(1337)</script>gmail.com")'), 'it escapes search term');
@ -88,8 +76,7 @@ QUnit.test("escape search term", (assert) => {
QUnit.test("update username through advanced search ui", assert => { QUnit.test("update username through advanced search ui", assert => {
visit("/search"); visit("/search");
fillIn('.search input.full-page-search', 'none'); fillIn('.search-query', 'none');
click('.search-advanced-btn');
fillIn('.search-advanced-options .user-selector', 'admin'); fillIn('.search-advanced-options .user-selector', 'admin');
click('.search-advanced-options .user-selector'); click('.search-advanced-options .user-selector');
keyEvent('.search-advanced-options .user-selector', 'keydown', 8); keyEvent('.search-advanced-options .user-selector', 'keydown', 8);
@ -103,7 +90,7 @@ QUnit.test("update username through advanced search ui", assert => {
andThen(() => { andThen(() => {
assert.ok(exists('.search-advanced-options span:contains("admin")'), 'has "admin" pre-populated'); assert.ok(exists('.search-advanced-options span:contains("admin")'), 'has "admin" pre-populated');
assert.equal(find('.search input.full-page-search').val(), "none @admin", 'has updated search term to "none user:admin"'); assert.equal(find('.search-query').val(), "none @admin", 'has updated search term to "none user:admin"');
}); });
}); });
}); });
@ -114,20 +101,19 @@ QUnit.test("update category through advanced search ui", assert => {
visit("/search"); visit("/search");
fillIn('.search input.full-page-search', 'none'); fillIn('.search-query', 'none');
click('.search-advanced-btn');
categoryChooser.expand().fillInFilter('faq').selectRowByValue(4); categoryChooser.expand().fillInFilter('faq').selectRowByValue(4);
andThen(() => { andThen(() => {
assert.ok(exists('.search-advanced-options .badge-category:contains("faq")'), 'has "faq" populated'); assert.ok(exists('.search-advanced-options .badge-category:contains("faq")'), 'has "faq" populated');
assert.equal(find('.search input.full-page-search').val(), "none #faq", 'has updated search term to "none #faq"'); assert.equal(find('.search-query').val(), "none #faq", 'has updated search term to "none #faq"');
}); });
}); });
// test("update group through advanced search ui", assert => { // test("update group through advanced search ui", assert => {
// visit("/search"); // visit("/search");
// fillIn('.search input.full-page-search', 'none'); // fillIn('.search-query', 'none');
// click('.search-advanced-btn'); //
// fillIn('.search-advanced-options .group-selector', 'moderators'); // fillIn('.search-advanced-options .group-selector', 'moderators');
// click('.search-advanced-options .group-selector'); // click('.search-advanced-options .group-selector');
// keyEvent('.search-advanced-options .group-selector', 'keydown', 8); // keyEvent('.search-advanced-options .group-selector', 'keydown', 8);
@ -141,7 +127,7 @@ QUnit.test("update category through advanced search ui", assert => {
// //
// andThen(() => { // andThen(() => {
// assert.ok(exists('.search-advanced-options span:contains("moderators")'), 'has "moderators" pre-populated'); // assert.ok(exists('.search-advanced-options span:contains("moderators")'), 'has "moderators" pre-populated');
// assert.equal(find('.search input.full-page-search').val(), "none group:moderators", 'has updated search term to "none group:moderators"'); // assert.equal(find('.search-query').val(), "none group:moderators", 'has updated search term to "none group:moderators"');
// }); // });
// }); // });
// }); // });
@ -149,8 +135,8 @@ QUnit.test("update category through advanced search ui", assert => {
// test("update badges through advanced search ui", assert => { // test("update badges through advanced search ui", assert => {
// visit("/search"); // visit("/search");
// fillIn('.search input.full-page-search', 'none'); // fillIn('.search-query', 'none');
// click('.search-advanced-btn'); //
// fillIn('.search-advanced-options .badge-names', 'Reader'); // fillIn('.search-advanced-options .badge-names', 'Reader');
// click('.search-advanced-options .badge-names'); // click('.search-advanced-options .badge-names');
// keyEvent('.search-advanced-options .badge-names', 'keydown', 8); // keyEvent('.search-advanced-options .badge-names', 'keydown', 8);
@ -164,7 +150,7 @@ QUnit.test("update category through advanced search ui", assert => {
// //
// andThen(() => { // andThen(() => {
// assert.ok(exists('.search-advanced-options span:contains("Reader")'), 'has "Reader" pre-populated'); // assert.ok(exists('.search-advanced-options span:contains("Reader")'), 'has "Reader" pre-populated');
// assert.equal(find('.search input.full-page-search').val(), "none badge:Reader", 'has updated search term to "none badge:Reader"'); // assert.equal(find('.search-query').val(), "none badge:Reader", 'has updated search term to "none badge:Reader"');
// }); // });
// }); // });
// }); // });
@ -172,8 +158,8 @@ QUnit.test("update category through advanced search ui", assert => {
// test("update tags through advanced search ui", assert => { // test("update tags through advanced search ui", assert => {
// visit("/search"); // visit("/search");
// fillIn('.search input.full-page-search', 'none'); // fillIn('.search-query', 'none');
// click('.search-advanced-btn'); //
// //
// keyEvent('.search-advanced-options .tag-chooser input.select2-input', 'keydown', 110); // keyEvent('.search-advanced-options .tag-chooser input.select2-input', 'keydown', 110);
// fillIn('.search-advanced-options .tag-chooser input.select2-input', 'monkey'); // fillIn('.search-advanced-options .tag-chooser input.select2-input', 'monkey');
@ -184,7 +170,7 @@ QUnit.test("update category through advanced search ui", assert => {
// click('li.select2-result-selectable:first'); // click('li.select2-result-selectable:first');
// andThen(() => { // andThen(() => {
// assert.ok(exists('.search-advanced-options .tag-chooser .tag-monkey'), 'has "monkey" pre-populated'); // assert.ok(exists('.search-advanced-options .tag-chooser .tag-monkey'), 'has "monkey" pre-populated');
// assert.equal(find('.search input.full-page-search').val(), "none tags:monkey", 'has updated search term to "none tags:monkey"'); // assert.equal(find('.search-query').val(), "none tags:monkey", 'has updated search term to "none tags:monkey"');
// }); // });
// }); // });
// }); // });
@ -192,38 +178,35 @@ QUnit.test("update category through advanced search ui", assert => {
QUnit.test("update in:likes filter through advanced search ui", assert => { QUnit.test("update in:likes filter through advanced search ui", assert => {
visit("/search"); visit("/search");
fillIn('.search input.full-page-search', 'none'); fillIn('.search-query', 'none');
click('.search-advanced-btn');
click('.search-advanced-options .in-likes'); click('.search-advanced-options .in-likes');
andThen(() => { andThen(() => {
assert.ok(exists('.search-advanced-options .in-likes:checked'), 'has "I liked" populated'); assert.ok(exists('.search-advanced-options .in-likes:checked'), 'has "I liked" populated');
assert.equal(find('.search input.full-page-search').val(), "none in:likes", 'has updated search term to "none in:likes"'); assert.equal(find('.search-query').val(), "none in:likes", 'has updated search term to "none in:likes"');
}); });
}); });
QUnit.test("update in:private filter through advanced search ui", assert => { QUnit.test("update in:private filter through advanced search ui", assert => {
visit("/search"); visit("/search");
fillIn('.search input.full-page-search', 'none'); fillIn('.search-query', 'none');
click('.search-advanced-btn');
click('.search-advanced-options .in-private'); click('.search-advanced-options .in-private');
andThen(() => { andThen(() => {
assert.ok(exists('.search-advanced-options .in-private:checked'), 'has "are in my messages" populated'); assert.ok(exists('.search-advanced-options .in-private:checked'), 'has "are in my messages" populated');
assert.equal(find('.search input.full-page-search').val(), "none in:private", 'has updated search term to "none in:private"'); assert.equal(find('.search-query').val(), "none in:private", 'has updated search term to "none in:private"');
}); });
}); });
QUnit.test("update in:seen filter through advanced search ui", assert => { QUnit.test("update in:seen filter through advanced search ui", assert => {
visit("/search"); visit("/search");
fillIn('.search input.full-page-search', 'none'); fillIn('.search-query', 'none');
click('.search-advanced-btn');
click('.search-advanced-options .in-seen'); click('.search-advanced-options .in-seen');
andThen(() => { andThen(() => {
assert.ok(exists('.search-advanced-options .in-seen:checked'), 'it should check the right checkbox'); assert.ok(exists('.search-advanced-options .in-seen:checked'), 'it should check the right checkbox');
assert.equal(find('.search input.full-page-search').val(), "none in:seen", assert.equal(find('.search-query').val(), "none in:seen",
'it should update the search term' 'it should update the search term'
); );
}); });
@ -234,13 +217,12 @@ QUnit.test("update in filter through advanced search ui", assert => {
visit("/search"); visit("/search");
fillIn('.search input.full-page-search', 'none'); fillIn('.search-query', 'none');
click('.search-advanced-btn');
inSelector.expand().selectRowByValue('bookmarks'); inSelector.expand().selectRowByValue('bookmarks');
andThen(() => { andThen(() => {
assert.ok(inSelector.rowByName("I bookmarked").exists(), 'has "I bookmarked" populated'); assert.ok(inSelector.rowByName("I bookmarked").exists(), 'has "I bookmarked" populated');
assert.equal(find('.search input.full-page-search').val(), "none in:bookmarks", 'has updated search term to "none in:bookmarks"'); assert.equal(find('.search-query').val(), "none in:bookmarks", 'has updated search term to "none in:bookmarks"');
}); });
}); });
@ -249,13 +231,12 @@ QUnit.test("update status through advanced search ui", assert => {
visit("/search"); visit("/search");
fillIn('.search input.full-page-search', 'none'); fillIn('.search-query', 'none');
click('.search-advanced-btn');
statusSelector.expand().selectRowByValue('closed'); statusSelector.expand().selectRowByValue('closed');
andThen(() => { andThen(() => {
assert.ok(statusSelector.rowByName("are closed").exists(), 'has "are closed" populated'); assert.ok(statusSelector.rowByName("are closed").exists(), 'has "are closed" populated');
assert.equal(find('.search input.full-page-search').val(), "none status:closed", 'has updated search term to "none status:closed"'); assert.equal(find('.search-query').val(), "none status:closed", 'has updated search term to "none status:closed"');
}); });
}); });
@ -264,26 +245,24 @@ QUnit.test("update post time through advanced search ui", assert => {
visit("/search"); visit("/search");
fillIn('.search input.full-page-search', 'none'); fillIn('.search-query', 'none');
click('.search-advanced-btn');
fillIn('#search-post-date .date-picker', '2016-10-05'); fillIn('#search-post-date .date-picker', '2016-10-05');
postTimeSelector.expand().selectRowByValue('after'); postTimeSelector.expand().selectRowByValue('after');
andThen(() => { andThen(() => {
assert.ok(postTimeSelector.rowByName("after").exists(), 'has "after" populated'); assert.ok(postTimeSelector.rowByName("after").exists(), 'has "after" populated');
assert.equal(find('.search input.full-page-search').val(), "none after:2016-10-05", 'has updated search term to "none after:2016-10-05"'); assert.equal(find('.search-query').val(), "none after:2016-10-05", 'has updated search term to "none after:2016-10-05"');
}); });
}); });
QUnit.test("update min post count through advanced search ui", assert => { QUnit.test("update min post count through advanced search ui", assert => {
visit("/search"); visit("/search");
fillIn('.search input.full-page-search', 'none'); fillIn('.search-query', 'none');
click('.search-advanced-btn');
fillIn('#search-min-post-count', '5'); fillIn('#search-min-post-count', '5');
andThen(() => { andThen(() => {
assert.equal(find('.search-advanced-options #search-min-post-count').val(), "5", 'has "5" populated'); assert.equal(find('.search-advanced-options #search-min-post-count').val(), "5", 'has "5" populated');
assert.equal(find('.search input.full-page-search').val(), "none min_post_count:5", 'has updated search term to "none min_post_count:5"'); assert.equal(find('.search-query').val(), "none min_post_count:5", 'has updated search term to "none min_post_count:5"');
}); });
}); });
@ -293,7 +272,6 @@ QUnit.test("validate advanced search when initially empty", assert => {
andThen(() => { andThen(() => {
assert.ok(exists('.search-advanced-options .in-likes:checked'), 'has "I liked" populated'); assert.ok(exists('.search-advanced-options .in-likes:checked'), 'has "I liked" populated');
assert.equal(find('.search input.full-page-search').val(), "in:likes", 'has updated search term to "in:likes"'); assert.equal(find('.search-query').val(), "in:likes", 'has updated search term to "in:likes"');
}); });
}); });
*/