Add back acceptance tests for full page search
This commit is contained in:
parent
282f9948cb
commit
d8808aa9ab
|
@ -41,24 +41,26 @@ export function translateResults(results, opts) {
|
|||
results.resultTypes = [];
|
||||
|
||||
// TODO: consider refactoring front end to take a better structure
|
||||
[['topic','posts'],['user','users'],['category','categories']].forEach(function(pair){
|
||||
const type = pair[0], name = pair[1];
|
||||
if (results[name].length > 0) {
|
||||
var result = {
|
||||
results: results[name],
|
||||
componentName: "search-result-" + ((opts.searchContext && opts.searchContext.type === 'topic' && type === 'topic') ? 'post' : type),
|
||||
type,
|
||||
more: r['more_' + name]
|
||||
};
|
||||
if (r) {
|
||||
[['topic','posts'],['user','users'],['category','categories']].forEach(function(pair){
|
||||
const type = pair[0], name = pair[1];
|
||||
if (results[name].length > 0) {
|
||||
var result = {
|
||||
results: results[name],
|
||||
componentName: "search-result-" + ((opts.searchContext && opts.searchContext.type === 'topic' && type === 'topic') ? 'post' : type),
|
||||
type,
|
||||
more: r['more_' + name]
|
||||
};
|
||||
|
||||
if (result.more && name === "posts" && opts.fullSearchUrl) {
|
||||
result.more = false;
|
||||
result.moreUrl = opts.fullSearchUrl;
|
||||
if (result.more && name === "posts" && opts.fullSearchUrl) {
|
||||
result.more = false;
|
||||
result.moreUrl = opts.fullSearchUrl;
|
||||
}
|
||||
|
||||
results.resultTypes.push(result);
|
||||
}
|
||||
|
||||
results.resultTypes.push(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const noResults = !!(results.topics.length === 0 &&
|
||||
results.posts.length === 0 &&
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
import { acceptance } from "helpers/qunit-helpers";
|
||||
acceptance("Search - Full Page");
|
||||
|
||||
// TODO: needs fixing (cc @sam)
|
||||
// test("search", (assert) => {
|
||||
// visit("/search?q=trout");
|
||||
test("perform various searches", assert => {
|
||||
visit("/search");
|
||||
|
||||
// andThen(() => {
|
||||
// assert.ok(find('input.search').length > 0);
|
||||
// assert.ok(find('.topic-list-item').length > 0);
|
||||
// });
|
||||
// });
|
||||
andThen(() => {
|
||||
assert.ok(find('input.search').length > 0);
|
||||
assert.ok(find('.topic').length === 0);
|
||||
});
|
||||
|
||||
fillIn('.search input', 'none');
|
||||
click('.search .btn-primary');
|
||||
|
||||
andThen(() => assert.ok(find('.topic').length === 0), 'has no results');
|
||||
|
||||
fillIn('.search input', 'posts');
|
||||
click('.search .btn-primary');
|
||||
|
||||
andThen(() => assert.ok(find('.topic').length === 1, 'has one post'));
|
||||
});
|
||||
|
|
|
@ -78,6 +78,19 @@ export default function() {
|
|||
|
||||
this.get('/clicks/track', success);
|
||||
|
||||
this.get('/search', request => {
|
||||
if (request.queryParams.q === 'posts') {
|
||||
return response({
|
||||
posts: [{
|
||||
id: 1234
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
return response({});
|
||||
});
|
||||
|
||||
|
||||
this.put('/users/eviltrout', () => response({ user: {} }));
|
||||
|
||||
this.get("/t/280.json", () => response(fixturesByUrl['/t/280/1.json']));
|
||||
|
|
Loading…
Reference in New Issue