Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2f128c9

Browse files
committed
fix(e2e): add index-nocache.html to run e2e tests without cache
using appcache while running e2e tests was causing the following problems: - Safari would occasionally reload the app (as a result of the appcache refresh) during the angular.validator.asychronous test, which would result in test failure and false positivy. - Firefox6 would run the tests very slowly, disabling the cache resolved the latency issues - Sometimes tests would run with stale code pulled from cache, which would result in flaky tests.
1 parent f7a5f17 commit 2f128c9

File tree

4 files changed

+47
-11
lines changed

4 files changed

+47
-11
lines changed

Rakefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,22 @@ task :package => [:clean, :compile, :docs] do
270270
end
271271

272272

273+
File.open("#{pkg_dir}/docs-#{NG_VERSION.full}/index-nocache.html", File::RDWR) do |f|
274+
text = f.read
275+
f.truncate 0
276+
f.rewind
277+
f.write text.sub('angular.min.js', "angular-#{NG_VERSION.full}.min.js")
278+
end
279+
280+
281+
File.open("#{pkg_dir}/docs-#{NG_VERSION.full}/index-jq-nocache.html", File::RDWR) do |f|
282+
text = f.read
283+
f.truncate 0
284+
f.rewind
285+
f.write text.sub('angular.min.js', "angular-#{NG_VERSION.full}.min.js")
286+
end
287+
288+
273289
File.open("#{pkg_dir}/docs-#{NG_VERSION.full}/docs-scenario.html", File::RDWR) do |f|
274290
text = f.read
275291
f.truncate 0

docs/src/gen-docs.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,17 @@ function writeTheRest(writesFuture) {
4343
writesFuture.push(writer.copyDir('img'));
4444
writesFuture.push(writer.copyDir('examples'));
4545
writesFuture.push(writer.copyTpl('index.html'));
46-
writesFuture.push(writer.copy('docs/src/templates/index.html',
47-
'build/docs/index-jq.html',
48-
'<!-- jquery place holder -->',
49-
'<script src=\"jquery.min.js\"><\/script>'));
46+
47+
writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index-jq.html',
48+
'<!-- jquery place holder -->', '<script src=\"jquery.min.js\"><\/script>'));
49+
50+
writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index-nocache.html',
51+
'manifest="appcache.manifest"', ''));
52+
53+
writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index-jq-nocache.html',
54+
'manifest="appcache.manifest"', '',
55+
'<!-- jquery place holder -->', '<script src=\"jquery.min.js\"><\/script>'));
56+
5057
writesFuture.push(writer.copyTpl('offline.html'));
5158
writesFuture.push(writer.copyTpl('docs-scenario.html'));
5259
writesFuture.push(writer.copyTpl('jquery.min.js'));

docs/src/ngdoc.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,15 +549,15 @@ Doc.prototype = {
549549
function scenarios(docs){
550550
var specs = [];
551551

552-
specs.push('describe("angular without jquery", function() {');
553-
appendSpecs('index.html');
552+
specs.push('describe("angular+jqlite", function() {');
553+
appendSpecs('index-nocache.html');
554554
specs.push('});');
555555

556556
specs.push('');
557557
specs.push('');
558558

559-
specs.push('describe("angular with jquery", function() {');
560-
appendSpecs('index-jq.html');
559+
specs.push('describe("angular+jquery", function() {');
560+
appendSpecs('index-jq-nocache.html');
561561
specs.push('});');
562562

563563
return specs.join('\n');

docs/src/writer.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,25 @@ exports.copyTpl = function(filename) {
4444
return exports.copy('docs/src/templates/' + filename, OUTPUT_DIR + filename);
4545
};
4646

47-
exports.copy = function (from, to, replacementKey, replacement) {
47+
exports.copy = function (from, to) {
48+
var args = [].slice.call(arguments);
49+
50+
args.shift(); // drop 'from'
51+
args.shift(); // drop 'to'
52+
4853
// Have to use rb (read binary), char 'r' is infered by library.
4954
return qfs.read(from,'b').then(function(content) {
50-
if(replacementKey && replacement) {
51-
content = content.toString().replace(replacementKey, replacement);
55+
var replacementKey,
56+
replacement;
57+
58+
while (args.length) {
59+
replacementKey = args.shift();
60+
replacement = args.shift();
61+
if(replacementKey != undefined && replacement != undefined) {
62+
content = content.toString().replace(replacementKey, replacement);
63+
}
5264
}
65+
5366
qfs.write(to, content);
5467
});
5568
}

0 commit comments

Comments
 (0)