Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 00f784c

Browse files
committed
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.
1 parent 3bc4e7f commit 00f784c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

docs/src/templates/index.html

+8-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
// we can't add css/js the usual way, because some browsers (FF) eagerly prefetch resources
2121
// before the base attribute is added, causing 404 and terribly slow loading of the docs app.
2222
(function() {
23+
if (window.name.indexOf('NG_DEFER_BOOTSTRAP!') == 0) {
24+
//TODO(i): super ugly hack to temporarily speed up our e2e tests until we move to protractor + extracted examples
25+
window.RUNNING_IN_NG_TEST_RUNNER = true;
26+
}
27+
2328
var indexFile = (location.pathname.match(/\/(index[^\.]*\.html)/) || ['', ''])[1],
2429
rUrl = /(#!\/|api|guide|misc|tutorial|cookbook|error|index[^\.]*\.html).*$/,
2530
baseUrl = location.href.replace(rUrl, indexFile),
@@ -50,7 +55,9 @@
5055
addTag('script', {src: 'components/angular-bootstrap.js' }, sync);
5156
addTag('script', {src: 'components/angular-bootstrap-prettify.js' }, sync);
5257
addTag('script', {src: 'components/google-code-prettify.js' }, sync);
53-
addTag('script', {src: 'components/' + (debug ? 'lunr.js' : 'lunr.min.js') }, sync);
58+
if (!window.RUNNING_IN_NG_TEST_RUNNER) {
59+
addTag('script', {src: 'components/' + (debug ? 'lunr.js' : 'lunr.min.js') }, sync);
60+
}
5461
addTag('script', {src: 'components/marked.js' }, sync);
5562
addTag('script', {src: 'docs-data.js'}, sync);
5663
addTag('script', {src: 'js/docs.js'}, sync);

docs/src/templates/js/docs.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ docsApp.controller.DocsNavigationCtrl = ['$scope', '$location', 'docsSearch', fu
109109

110110
docsApp.serviceFactory.lunrSearch = function() {
111111
return function(properties) {
112+
if (window.RUNNING_IN_NG_TEST_RUNNER) return null;
113+
112114
var engine = lunr(properties);
113115
return {
114116
store : function(values) {
@@ -122,7 +124,10 @@ docsApp.serviceFactory.lunrSearch = function() {
122124
};
123125

124126
docsApp.serviceFactory.docsSearch = ['$rootScope','lunrSearch', 'NG_PAGES',
125-
function($rootScope, lunrSearch, NG_PAGES) {
127+
function($rootScope, lunrSearch, NG_PAGES) {
128+
if (window.RUNNING_IN_NG_TEST_RUNNER) {
129+
return null;
130+
}
126131

127132
var index = lunrSearch(function() {
128133
this.ref('id');

0 commit comments

Comments
 (0)