Add back acceptance tests for full page search

This commit is contained in:
Robin Ward 2016-08-09 12:16:29 -04:00
parent 282f9948cb
commit d8808aa9ab
3 changed files with 48 additions and 24 deletions

View file

@ -41,24 +41,26 @@ export function translateResults(results, opts) {
results.resultTypes = []; results.resultTypes = [];
// TODO: consider refactoring front end to take a better structure // TODO: consider refactoring front end to take a better structure
[['topic','posts'],['user','users'],['category','categories']].forEach(function(pair){ if (r) {
const type = pair[0], name = pair[1]; [['topic','posts'],['user','users'],['category','categories']].forEach(function(pair){
if (results[name].length > 0) { const type = pair[0], name = pair[1];
var result = { if (results[name].length > 0) {
results: results[name], var result = {
componentName: "search-result-" + ((opts.searchContext && opts.searchContext.type === 'topic' && type === 'topic') ? 'post' : type), results: results[name],
type, componentName: "search-result-" + ((opts.searchContext && opts.searchContext.type === 'topic' && type === 'topic') ? 'post' : type),
more: r['more_' + name] type,
}; more: r['more_' + name]
};
if (result.more && name === "posts" && opts.fullSearchUrl) { if (result.more && name === "posts" && opts.fullSearchUrl) {
result.more = false; result.more = false;
result.moreUrl = opts.fullSearchUrl; result.moreUrl = opts.fullSearchUrl;
}
results.resultTypes.push(result);
} }
});
results.resultTypes.push(result); }
}
});
const noResults = !!(results.topics.length === 0 && const noResults = !!(results.topics.length === 0 &&
results.posts.length === 0 && results.posts.length === 0 &&

View file

@ -1,12 +1,21 @@
import { acceptance } from "helpers/qunit-helpers"; import { acceptance } from "helpers/qunit-helpers";
acceptance("Search - Full Page"); acceptance("Search - Full Page");
// TODO: needs fixing (cc @sam) test("perform various searches", assert => {
// test("search", (assert) => { visit("/search");
// visit("/search?q=trout");
// andThen(() => { andThen(() => {
// assert.ok(find('input.search').length > 0); assert.ok(find('input.search').length > 0);
// assert.ok(find('.topic-list-item').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'));
});

View file

@ -78,6 +78,19 @@ export default function() {
this.get('/clicks/track', success); 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.put('/users/eviltrout', () => response({ user: {} }));
this.get("/t/280.json", () => response(fixturesByUrl['/t/280/1.json'])); this.get("/t/280.json", () => response(fixturesByUrl['/t/280/1.json']));