mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
chore(ngdocs): disable lunr search during e2e tests
lunr has been responsible for slowdown in our test suite by adding ~1sec per end-to-end test. (this is because it initializes the index when the app starts) since out test suite primarily tests the examples, it's reasonable do disable the search as a temporary meansure. the real fix is to use protractor and extract all of the examples into standalone apps which can be tested without bootstrapping the whole docs app.
This commit is contained in:
parent
3bc4e7fd20
commit
00f784cda8
2 changed files with 14 additions and 2 deletions
|
|
@ -20,6 +20,11 @@
|
|||
// we can't add css/js the usual way, because some browsers (FF) eagerly prefetch resources
|
||||
// before the base attribute is added, causing 404 and terribly slow loading of the docs app.
|
||||
(function() {
|
||||
if (window.name.indexOf('NG_DEFER_BOOTSTRAP!') == 0) {
|
||||
//TODO(i): super ugly hack to temporarily speed up our e2e tests until we move to protractor + extracted examples
|
||||
window.RUNNING_IN_NG_TEST_RUNNER = true;
|
||||
}
|
||||
|
||||
var indexFile = (location.pathname.match(/\/(index[^\.]*\.html)/) || ['', ''])[1],
|
||||
rUrl = /(#!\/|api|guide|misc|tutorial|cookbook|error|index[^\.]*\.html).*$/,
|
||||
baseUrl = location.href.replace(rUrl, indexFile),
|
||||
|
|
@ -50,7 +55,9 @@
|
|||
addTag('script', {src: 'components/angular-bootstrap.js' }, sync);
|
||||
addTag('script', {src: 'components/angular-bootstrap-prettify.js' }, sync);
|
||||
addTag('script', {src: 'components/google-code-prettify.js' }, sync);
|
||||
addTag('script', {src: 'components/' + (debug ? 'lunr.js' : 'lunr.min.js') }, sync);
|
||||
if (!window.RUNNING_IN_NG_TEST_RUNNER) {
|
||||
addTag('script', {src: 'components/' + (debug ? 'lunr.js' : 'lunr.min.js') }, sync);
|
||||
}
|
||||
addTag('script', {src: 'components/marked.js' }, sync);
|
||||
addTag('script', {src: 'docs-data.js'}, sync);
|
||||
addTag('script', {src: 'js/docs.js'}, sync);
|
||||
|
|
|
|||
|
|
@ -109,6 +109,8 @@ docsApp.controller.DocsNavigationCtrl = ['$scope', '$location', 'docsSearch', fu
|
|||
|
||||
docsApp.serviceFactory.lunrSearch = function() {
|
||||
return function(properties) {
|
||||
if (window.RUNNING_IN_NG_TEST_RUNNER) return null;
|
||||
|
||||
var engine = lunr(properties);
|
||||
return {
|
||||
store : function(values) {
|
||||
|
|
@ -122,7 +124,10 @@ docsApp.serviceFactory.lunrSearch = function() {
|
|||
};
|
||||
|
||||
docsApp.serviceFactory.docsSearch = ['$rootScope','lunrSearch', 'NG_PAGES',
|
||||
function($rootScope, lunrSearch, NG_PAGES) {
|
||||
function($rootScope, lunrSearch, NG_PAGES) {
|
||||
if (window.RUNNING_IN_NG_TEST_RUNNER) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var index = lunrSearch(function() {
|
||||
this.ref('id');
|
||||
|
|
|
|||
Loading…
Reference in a new issue