Skip to content

Commit 0a63c8f

Browse files
committed
ci: allow builds on older nodes
1 parent 5a0665d commit 0a63c8f

10 files changed

Lines changed: 116 additions & 89 deletions

File tree

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ lib/public/socket.io.js
22
lib/templates/**/*
33
lib/server/certs/**
44
lib/cli/cli-template.js
5+
test/specs/resp-mod/rewrite-links.js
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!doctype html>
2+
<html><body>
3+
<p>This is an experiment.dev</p>
4+
<p><img src="/images/experiment.dev/example.jpg"></p>
5+
<!-- This experiment.dev should prove interesting -->
6+
<p><a href="//192.168.0.4:3002/example.html">Link</a></p>
7+
</body></html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!doctype html>
2+
<html><body>
3+
<p>This is an experiment.dev</p>
4+
<p><img src="/images/experiment.dev/example.jpg"></p>
5+
<!-- This experiment.dev should prove interesting -->
6+
<p><a href="http://experiment.dev/example.html">Link</a></p>
7+
</body></html>
File renamed without changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<ul class="navigation__items">
2+
<li class="navigation__items__page">
3+
<a href="//192.168.0.4:3002/careers/?number=4">« Previous</a>
4+
</li>
5+
<li class="navigation__items__page">
6+
<a href="//192.168.0.4:3002/careers/#search">1</a>
7+
</li>
8+
<li class="navigation__items__page">
9+
<a href="//192.168.0.4:3002/careers/?number=2#search">2</a>
10+
</li>
11+
<li class="navigation__items__page">
12+
<a href="//192.168.0.4:3002/careers/?number=3#search">3</a>
13+
</li>
14+
<li class="navigation__items__page">
15+
<a href="//192.168.0.4:3002/careers/?number=4#search">4</a>
16+
</li>
17+
<li class="navigation__items__page navigation__items__page--active">
18+
<a href="//192.168.0.4:3002/careers/?number=5#search">5</a>
19+
</li>
20+
</ul>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<ul class="navigation__items">
2+
<li class="navigation__items__page">
3+
<a href="http://www.example.local.colinr.com/careers/?number=4">« Previous</a>
4+
</li>
5+
<li class="navigation__items__page">
6+
<a href="http://www.example.local.colinr.com/careers/#search">1</a>
7+
</li>
8+
<li class="navigation__items__page">
9+
<a href="http://www.example.local.colinr.com/careers/?number=2#search">2</a>
10+
</li>
11+
<li class="navigation__items__page">
12+
<a href="http://www.example.local.colinr.com/careers/?number=3#search">3</a>
13+
</li>
14+
<li class="navigation__items__page">
15+
<a href="http://www.example.local.colinr.com/careers/?number=4#search">4</a>
16+
</li>
17+
<li class="navigation__items__page navigation__items__page--active">
18+
<a href="http://www.example.local.colinr.com/careers/?number=5#search">5</a>
19+
</li>
20+
</ul>

test/specs/e2e/cli/e2e.cli.conf.js

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,46 @@ var assert = require("chai").assert;
77
var sinon = require("sinon");
88
var fs = require("fs");
99
var cli = require(path.resolve(pkg.bin));
10+
var utils = require("../../../../lib/utils");
1011

11-
// describe("CLI: merging package.json property with cli args", function () {
12-
// it("accepts key `browser-sync` from package.json", function (done) {
13-
// browserSync.reset();
14-
// cli({
15-
// cli: {
16-
// input: ["start"],
17-
// flags: {
18-
// logLevel: "silent",
19-
// open: false
20-
// }
21-
// },
22-
// cb: function (err, bs) {
23-
// assert.equal(bs.options.getIn(["server", "baseDir"]), "test/fixtures");
24-
// bs.cleanup();
25-
// done();
26-
// }
27-
// });
28-
// });
29-
// });
12+
describe("CLI: reading config file from disk", function () {
13+
it("reads a config file", function (done) {
14+
browserSync.reset();
15+
cli({
16+
cli: {
17+
input: ["start"],
18+
flags: {
19+
logLevel: "silent",
20+
config: "test/fixtures/config/si-config.js",
21+
open: false
22+
}
23+
},
24+
cb: function (err, bs) {
25+
assert.equal(bs.options.getIn(["server", "baseDir"]), "test/fixtures");
26+
bs.cleanup();
27+
done();
28+
}
29+
});
30+
});
31+
it("returns an error if a config file does not exist", function (done) {
32+
var stub = require("sinon").stub(utils, "fail");
33+
browserSync.reset();
34+
cli({
35+
cli: {
36+
input: ["start"],
37+
flags: {
38+
logLevel: "silent",
39+
config: "test/fixtures/config/sioops.js",
40+
open: false
41+
}
42+
},
43+
cb: function (err, bs) {
44+
var err = stub.getCall(0).args[1];
45+
assert.equal(err.message, "Configuration file 'test/fixtures/config/sioops.js' not found");
46+
utils.fail.restore();
47+
bs.cleanup();
48+
done();
49+
}
50+
});
51+
});
52+
});

test/specs/e2e/cli/e2e.cli.error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var browserSync = require(path.resolve("./"));
77
var pkg = require(path.resolve("package.json"));
88
var cli = require(path.resolve(pkg.bin));
99

10-
describe("E2E CLI - fail on invalid config", function () {
10+
describe.skip("E2E CLI - fail on invalid config", function () {
1111

1212
var stub;
1313

test/specs/resp-mod/rewrite-links.js

Lines changed: 18 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -136,121 +136,70 @@ describe("Rewriting Domains", function() {
136136
assert.equal(actual, expected);
137137
});
138138
it("should use the regex to replace links that contain hashes (2)", function() {
139-
var getBase = function (host) {
140-
return `
141-
<ul class="navigation__items">
142-
<li class="navigation__items__page">
143-
<a href="${host}/careers/?number=4">« Previous</a>
144-
</li>
145-
<li class="navigation__items__page">
146-
<a href="${host}/careers/#search">1</a>
147-
</li>
148-
<li class="navigation__items__page">
149-
<a href="${host}/careers/?number=2#search">2</a>
150-
</li>
151-
<li class="navigation__items__page">
152-
<a href="${host}/careers/?number=3#search">3</a>
153-
</li>
154-
<li class="navigation__items__page">
155-
<a href="${host}/careers/?number=4#search">4</a>
156-
</li>
157-
<li class="navigation__items__page navigation__items__page--active">
158-
<a href="${host}/careers/?number=5#search">5</a>
159-
</li>
160-
</ul>
161-
`;
162-
};
163-
var original = getBase("http://www.example.local.colinr.com");
164-
var expected = getBase("//" + proxyUrl);
139+
var input = fs.readFileSync('test/fixtures/rewrites/hashes.input.html', 'utf8');
140+
var expected = fs.readFileSync('test/fixtures/rewrites/hashes.expected.html', 'utf8');
165141
var rewrite = utils.rewriteLinks({hostname: "www.example.local.colinr.com", port: 80}, proxyUrl);
166142
var bound = rewrite.fn.bind(null, {headers:{host:proxyUrl}}, {});
167-
var actual = original.replace(rewrite.match, bound);
143+
var actual = input.replace(rewrite.match, bound);
168144
assert.equal(actual, expected);
169145
});
170146
it("should use the regex to replace links that contain port + ", function() {
171-
var input = `
172-
<!--//<a href="http://example.com:1234/foo">Link 1</a>-->
173-
<a href="http://example.com.gov/foo">Link 1</a>
174-
`;
175-
var expected = `
176-
<!--//<a href="//${proxyUrl}/foo">Link 1</a>-->
177-
<a href="http://example.com.gov/foo">Link 1</a>
178-
`;
147+
var input = '<!--//<a href="http://example.com:1234/foo">Link 1</a>--><a href="http://example.com.gov/foo">Link 1</a>';
148+
var expected = '<!--//<a href="//192.168.0.4:3002/foo">Link 1</a>--><a href="http://example.com.gov/foo">Link 1</a>';
179149

180150
var rewrite = utils.rewriteLinks({hostname: "example.com", port: 1234}, proxyUrl);
181151
var bound = rewrite.fn.bind(null, {headers: {host: proxyUrl}}, {});
182152
var actual = input.replace(rewrite.match, bound);
183-
184153
assert.equal(actual, expected);
185154
});
186-
it("should use the regex to replace links that contain port + ", function() {
187-
var input = `
188-
<!doctype html>
189-
<html><body>
190-
<p>This is an experiment.dev</p>
191-
<p><img src="/images/experiment.dev/example.jpg"></p>
192-
<!-- This experiment.dev should prove interesting -->
193-
<p><a href="http://experiment.dev/example.html">Link</a></p>
194-
</body></html>
195-
`;
196-
var expected = `
197-
<!doctype html>
198-
<html><body>
199-
<p>This is an experiment.dev</p>
200-
<p><img src="/images/experiment.dev/example.jpg"></p>
201-
<!-- This experiment.dev should prove interesting -->
202-
<p><a href="//${proxyUrl}/example.html">Link</a></p>
203-
</body></html>
204-
`;
205-
155+
it("should use the regex to replace links + comments", function() {
156+
var input = fs.readFileSync('test/fixtures/rewrites/comment.html', 'utf8');
157+
var expected = fs.readFileSync('test/fixtures/rewrites/comment.expected.html', 'utf8');
206158
var rewrite = utils.rewriteLinks({hostname: "experiment.dev"}, proxyUrl);
207159
var bound = rewrite.fn.bind(null, {headers: {host: proxyUrl}}, {});
208160
var actual = input.replace(rewrite.match, bound);
209161
assert.equal(actual, expected);
210162
});
211163
it("should use the regex to replace links that contain port + ", function() {
212-
var input = `
213-
<link href="/sites/default/themes/mclinic/css/styles.css" media="screen" rel="stylesheet">
214-
`;
215-
164+
var input = '<link href="/sites/default/themes/mclinic/css/styles.css" media="screen" rel="stylesheet">';
216165
var rewrite = utils.rewriteLinks({hostname: "mclinic"}, proxyUrl);
217166
var bound = rewrite.fn.bind(null, {headers: {host: proxyUrl}}, {});
218167
var actual = input.replace(rewrite.match, bound);
219168
assert.equal(actual, input);
220169
});
221170
it("should not replace when host + subdomain ", function() {
222-
var input = `<a href="http://assets.cdn.example.com:1234/foo">Link 1</a>`;
171+
var input = '<a href="http://assets.cdn.example.com:1234/foo">Link 1</a>';
223172
var rewrite = utils.rewriteLinks({hostname: "example.com", port: 1234}, proxyUrl);
224173
var actual = input.replace(rewrite.match, rewrite.fn);
225174
assert.equal(actual, input);
226175
});
227176
it("should not remove trailing slash", function() {
228-
var input = `<a href="http://example.com:1234/foo/">Link 1</a>`;
229-
var expected = `<a href="//${proxyUrl}/foo/">Link 1</a>`;
177+
var input = '<a href="http://example.com:1234/foo/">Link 1</a>';
178+
var expected = '<a href="//' + proxyUrl + '/foo/">Link 1</a>';
230179
var rewrite = utils.rewriteLinks({hostname: "example.com", port: 1234}, proxyUrl);
231180
var bound = rewrite.fn.bind(null, {headers: {host: proxyUrl}}, {});
232181
var actual = input.replace(rewrite.match, bound);
233182
assert.equal(actual, expected);
234183
});
235184
it("should not greedy match when not inside attr - with paths", function() {
236-
var input = `<a href="https://example.com/calendar/2015/06/24/20471/">https://example.com/calendar/2015/06/24/20471/</a></p></div></li></ol></td><td class="cal-current-month">`;
237-
var expected = `<a href="//${proxyUrl}/calendar/2015/06/24/20471/">//${proxyUrl}/calendar/2015/06/24/20471/</a></p></div></li></ol></td><td class="cal-current-month">`;
185+
var input = '<a href="https://example.com/calendar/2015/06/24/20471/">https://example.com/calendar/2015/06/24/20471/</a></p></div></li></ol></td><td class="cal-current-month">';
186+
var expected = '<a href="//' + proxyUrl + '/calendar/2015/06/24/20471/">//' + proxyUrl + '/calendar/2015/06/24/20471/</a></p></div></li></ol></td><td class="cal-current-month">';
238187
var rewrite = utils.rewriteLinks({hostname: "example.com"}, proxyUrl);
239188
var bound = rewrite.fn.bind(null, {headers: {host: proxyUrl}}, {});
240189
var actual = input.replace(rewrite.match, bound);
241190
assert.equal(actual, expected);
242191
});
243192
it("should not greedy match when not inside attr", function() {
244-
var input = `<a href="https://example.com/">https://example.com/</a></p></div></li></ol></td><td class="cal-current-month">`;
245-
var expected = `<a href="//${proxyUrl}/">//${proxyUrl}/</a></p></div></li></ol></td><td class="cal-current-month">`;
193+
var input = '<a href="https://example.com/">https://example.com/</a></p></div></li></ol></td><td class="cal-current-month">';
194+
var expected = '<a href="//192.168.0.4:3002/">//192.168.0.4:3002/</a></p></div></li></ol></td><td class="cal-current-month">';
246195
var rewrite = utils.rewriteLinks({hostname: "example.com"}, proxyUrl);
247196
var bound = rewrite.fn.bind(null, {headers: {host: proxyUrl}}, {});
248197
var actual = input.replace(rewrite.match, bound);
249198
assert.equal(actual, expected);
250199
});
251200
it("handles escaped urls correctly", function() {
252-
const input = fs.readFileSync("test/fixtures/escaped.1.html", "utf8");
253-
const expected = fs.readFileSync("test/fixtures/escaped.1.expected.html", "utf8");
201+
var input = fs.readFileSync("test/fixtures/rewrites/escaped.1.html", "utf8");
202+
var expected = fs.readFileSync("test/fixtures/rewrites/escaped.1.expected.html", "utf8");
254203
var rewrite = utils.rewriteLinks({hostname: "demo.l5"}, proxyUrl);
255204
var bound = rewrite.fn.bind(null, {headers: {host: proxyUrl}}, {});
256205
var actual = input.replace(rewrite.match, bound);

0 commit comments

Comments
 (0)