html-snapshots 0.18.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +4 -5
- package/.github/workflows/verify.yml +2 -2
- package/HISTORY.md +42 -0
- package/README.md +109 -256
- package/examples/README.md +149 -0
- package/examples/custom/myFilter.js +2 -2
- package/examples/custom/package-lock.json +2021 -5
- package/examples/custom/package.json +1 -1
- package/examples/custom/snapshot.js +8 -10
- package/examples/debug-phantomjs/package-lock.json +6 -6
- package/examples/debug-phantomjs/package.json +1 -1
- package/examples/debug-phantomjs/snapshot.js +13 -14
- package/examples/debug-puppeteer/README.md +18 -0
- package/examples/debug-puppeteer/package-lock.json +2804 -0
- package/examples/debug-puppeteer/package.json +12 -0
- package/examples/debug-puppeteer/snapshot.js +30 -0
- package/examples/html5rocks/package-lock.json +1306 -5
- package/examples/html5rocks/package.json +1 -1
- package/examples/html5rocks/snapshot.js +14 -23
- package/examples/process-limit/package-lock.json +1306 -5
- package/examples/process-limit/package.json +1 -1
- package/examples/process-limit/snapshot.js +8 -10
- package/examples/simple-promise/package-lock.json +1306 -5
- package/examples/simple-promise/package.json +1 -1
- package/examples/simple-promise/snapshot.js +6 -8
- package/examples/sitemap-index/package-lock.json +1306 -5
- package/examples/sitemap-index/package.json +1 -1
- package/examples/sitemap-index/snapshot.js +6 -6
- package/examples/utils/index.js +2 -4
- package/examples/verbose/package-lock.json +1306 -5
- package/examples/verbose/package.json +1 -1
- package/examples/verbose/snapshot.js +12 -14
- package/lib/async/index.js +0 -1
- package/lib/common/index.js +1 -1
- package/lib/common/sitemap/index.js +16 -0
- package/lib/common/sitemap/sitemap-collection.js +94 -0
- package/lib/common/sitemap/sitemap-index.js +68 -0
- package/lib/common/{sitemap.js → sitemap/sitemap.js} +68 -57
- package/lib/html-snapshots.js +87 -5
- package/lib/input-generators/_base.js +7 -1
- package/lib/input-generators/array.js +0 -1
- package/lib/input-generators/robots.js +98 -58
- package/lib/input-generators/sitemap-index.js +3 -124
- package/lib/input-generators/sitemap.js +3 -7
- package/lib/input-generators/textfile.js +2 -6
- package/lib/puppeteer/index.js +98 -0
- package/lib/puppeteer/removeScripts.js +8 -0
- package/package.json +9 -4
- package/test/helpers/options.js +4 -2
- package/test/mocha/browsers/puppeteer.js +106 -0
- package/test/mocha/browsers/server/index.html +9 -0
- package/test/mocha/browsers/test.js +11 -0
- package/test/mocha/html-snapshots/basics.js +60 -47
- package/test/mocha/html-snapshots/phantomjs-options.js +54 -60
- package/test/mocha/html-snapshots/process-limit.js +126 -120
- package/test/mocha/html-snapshots/puppeteer.js +47 -0
- package/test/mocha/html-snapshots/robots.js +156 -121
- package/test/mocha/html-snapshots/server/public/page-sitemap.xml +16 -0
- package/test/mocha/html-snapshots/server/test_robots.txt +13 -0
- package/test/mocha/html-snapshots/server/test_robots_sitemap.txt +15 -0
- package/test/mocha/html-snapshots/server/test_robots_sitemap.xml +22 -0
- package/test/mocha/html-snapshots/sitemap-index.js +100 -90
- package/test/mocha/html-snapshots/sitemap.js +75 -31
- package/test/mocha/html-snapshots/snapshot-scripts.js +150 -145
- package/test/mocha/html-snapshots/test.js +23 -14
- package/test/mocha/html-snapshots/test_robots.txt +0 -2
- package/test/mocha/html-snapshots/use-jquery.js +65 -64
- package/test/mocha/html-snapshots/utils.js +29 -30
- package/test/mocha/input-generators/server/test_robots.txt +0 -2
- package/test/mocha/input-generators/server/test_robots_bad.txt +0 -2
- package/test/mocha/input-generators/server/test_robots_sitemap.txt +17 -0
- package/test/mocha/input-generators/server/test_robots_sitemap_bad.txt +17 -0
- package/test/mocha/input-generators/server/test_robots_sitemap_multi.txt +18 -0
- package/test/mocha/input-generators/server/test_sitemap_index_empty.xml +3 -0
- package/test/mocha/input-generators/server/test_sitemap_index_malformed.xml +2 -0
- package/test/mocha/input-generators/sitemap-index.js +65 -9
- package/test/mocha/input-generators/test.js +276 -280
- package/test/mocha/input-generators/test_robots.txt +0 -2
- package/test/mocha/input-generators/test_robots_bad.txt +0 -2
- package/test/mocha/input-generators/test_robots_sitemap.txt +17 -0
- package/test/mocha/input-generators/test_robots_sitemap_bad.txt +17 -0
- package/test/mocha/input-generators/test_robots_sitemap_multi.txt +18 -0
- package/lib/common/node.js +0 -26
- package/test/mocha/common/node.js +0 -100
|
@@ -4,156 +4,191 @@
|
|
|
4
4
|
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
5
|
*/
|
|
6
6
|
/* global it */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var urls = 3; // must match test_robots.txt
|
|
7
|
+
const rimraf = require("rimraf").sync;
|
|
8
|
+
const _ = require("lodash");
|
|
9
|
+
const common = require("../../../lib/common");
|
|
10
|
+
const optHelp = require("../../helpers/options");
|
|
11
|
+
const ss = require("../../../lib/html-snapshots");
|
|
12
|
+
const utils = require("./utils");
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
timeout,
|
|
16
|
+
outputDir,
|
|
17
|
+
cleanup,
|
|
18
|
+
cleanupSuccess,
|
|
19
|
+
cleanupError,
|
|
20
|
+
testSuccess,
|
|
21
|
+
bogusFile,
|
|
22
|
+
unexpectedSuccess,
|
|
23
|
+
checkActualFiles
|
|
24
|
+
} = utils;
|
|
25
|
+
|
|
26
|
+
const urls = 3; // must match url # in robots files test fixtures.
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
29
|
* The robots test suite.
|
|
31
30
|
*/
|
|
32
31
|
function robotsTests (options) {
|
|
33
|
-
|
|
32
|
+
const {
|
|
33
|
+
port,
|
|
34
|
+
localRobotsFile,
|
|
35
|
+
browsers
|
|
36
|
+
} = options;
|
|
37
|
+
|
|
38
|
+
// Robots.txt fixtures
|
|
39
|
+
const inputFiles = [
|
|
40
|
+
localRobotsFile,
|
|
41
|
+
`http://localhost:${port}/test_robots.txt`,
|
|
42
|
+
`http://localhost:${port}/test_robots_sitemap.txt`
|
|
43
|
+
];
|
|
34
44
|
|
|
35
45
|
return function () {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
source: inputFile,
|
|
46
|
+
function createOptions (newOptions) {
|
|
47
|
+
const options = {
|
|
39
48
|
hostname: "localhost",
|
|
40
|
-
port: port,
|
|
41
49
|
selector: "#dynamic-content",
|
|
42
|
-
outputDir: outputDir,
|
|
43
50
|
outputDirClean: true,
|
|
44
|
-
|
|
51
|
+
outputDir,
|
|
52
|
+
timeout,
|
|
53
|
+
port
|
|
45
54
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
return {
|
|
56
|
+
...options,
|
|
57
|
+
...newOptions
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
browsers.forEach(browser => {
|
|
61
|
+
inputFiles.forEach(inputFile => {
|
|
62
|
+
it(`should succeed, no output dir pre-exists, ${browser}, ${inputFile}`, function (done) {
|
|
63
|
+
const options = createOptions({
|
|
64
|
+
source: inputFile,
|
|
65
|
+
browser
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const twice = _.after(2, cleanupSuccess.bind(null, done));
|
|
69
|
+
|
|
70
|
+
rimraf(outputDir);
|
|
71
|
+
|
|
72
|
+
ss.run(optHelp.decorate(options), twice)
|
|
73
|
+
.then(testSuccess.bind(null, twice))
|
|
74
|
+
.catch(e => {
|
|
75
|
+
checkActualFiles(e.notCompleted)
|
|
76
|
+
.then(() => {
|
|
77
|
+
cleanup(done, e);
|
|
78
|
+
});
|
|
56
79
|
});
|
|
57
80
|
});
|
|
58
|
-
});
|
|
59
81
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
checkActualFiles(e.notCompleted)
|
|
76
|
-
.then(function () {
|
|
77
|
-
cleanup(done, e);
|
|
82
|
+
it(`should succeed, output dir does pre-exist, ${browser}, ${inputFile}`, function (done) {
|
|
83
|
+
const options = createOptions({
|
|
84
|
+
source: inputFile,
|
|
85
|
+
browser
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const twice = _.after(2, cleanupSuccess.bind(null, done));
|
|
89
|
+
|
|
90
|
+
ss.run(optHelp.decorate(options), twice)
|
|
91
|
+
.then(testSuccess.bind(null, twice))
|
|
92
|
+
.catch(e => {
|
|
93
|
+
checkActualFiles(e.notCompleted)
|
|
94
|
+
.then(() => {
|
|
95
|
+
cleanup(done, e);
|
|
96
|
+
});
|
|
78
97
|
});
|
|
79
98
|
});
|
|
80
|
-
});
|
|
81
99
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
it(`should fail with bad phantomjs process to spawn, succeed otherwise, ${browser}, ${inputFile}`,
|
|
101
|
+
function (done) {
|
|
102
|
+
const options = createOptions({
|
|
103
|
+
source: inputFile,
|
|
104
|
+
browser,
|
|
105
|
+
phantomjs: bogusFile,
|
|
106
|
+
timeout: 1000
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
if (browser === "phantomjs") {
|
|
110
|
+
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
111
|
+
|
|
112
|
+
ss.run(options, twice)
|
|
113
|
+
.then(unexpectedSuccess.bind(null, done))
|
|
114
|
+
.catch(twice);
|
|
115
|
+
} else {
|
|
116
|
+
options.timeout = utils.timeout;
|
|
117
|
+
const twice = _.after(2, cleanupSuccess.bind(null, done));
|
|
118
|
+
|
|
119
|
+
ss.run(optHelp.decorate(options), twice)
|
|
120
|
+
.then(testSuccess.bind(null, twice))
|
|
121
|
+
.catch(e => {
|
|
122
|
+
checkActualFiles(e.notCompleted)
|
|
123
|
+
.then(() => {
|
|
124
|
+
cleanup(done, e);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
95
129
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
130
|
+
it(`should fail, bad remote robots, ${browser}, ${inputFile}`, function (done) {
|
|
131
|
+
const options = createOptions({
|
|
132
|
+
input: "robots",
|
|
133
|
+
source: `http://localhost:${port}/index.html`,
|
|
134
|
+
timeout: 5000,
|
|
135
|
+
browser
|
|
136
|
+
});
|
|
100
137
|
|
|
101
|
-
|
|
102
|
-
var options = {
|
|
103
|
-
input: "robots",
|
|
104
|
-
source: "http://localhost:"+port+"/index.html",
|
|
105
|
-
port: port,
|
|
106
|
-
selector: "#dynamic-content",
|
|
107
|
-
outputDir: outputDir,
|
|
108
|
-
outputDirClean: true,
|
|
109
|
-
timeout: 6000
|
|
110
|
-
};
|
|
111
|
-
var twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
138
|
+
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
112
139
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
140
|
+
ss.run(optHelp.decorate(options), twice)
|
|
141
|
+
.then(unexpectedSuccess.bind(null, done))
|
|
142
|
+
.catch(twice);
|
|
143
|
+
});
|
|
117
144
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
outputDirClean: true,
|
|
126
|
-
timeout: 6000
|
|
127
|
-
};
|
|
128
|
-
var twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
145
|
+
it(`should fail, non-existent selector, ${browser}, ${inputFile}`, function (done) {
|
|
146
|
+
const options = createOptions({
|
|
147
|
+
source: inputFile,
|
|
148
|
+
selector: "#dynamic-content-notexist",
|
|
149
|
+
timeout: 5000,
|
|
150
|
+
browser
|
|
151
|
+
});
|
|
129
152
|
|
|
130
|
-
|
|
131
|
-
.then(unexpectedSuccess.bind(null, done))
|
|
132
|
-
.catch(twice);
|
|
133
|
-
});
|
|
153
|
+
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
134
154
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
hostname: "localhost",
|
|
140
|
-
port: port,
|
|
141
|
-
selector: { "__default": "#dynamic-content", "/": "#dynamic-content-notexist" },
|
|
142
|
-
outputDir: outputDir,
|
|
143
|
-
outputDirClean: true,
|
|
144
|
-
timeout: 6000
|
|
145
|
-
};
|
|
146
|
-
var twice = _.after(2, cleanupError.bind(null, done, urls - 1));
|
|
155
|
+
ss.run(optHelp.decorate(options), twice)
|
|
156
|
+
.then(unexpectedSuccess.bind(null, done))
|
|
157
|
+
.catch(twice);
|
|
158
|
+
});
|
|
147
159
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
160
|
+
it(`should fail one snapshot, one non-existent selector, ${browser}, ${inputFile}`, function (done) {
|
|
161
|
+
let exceptionUrl = "/";
|
|
162
|
+
if (common.isUrl(inputFile)) {
|
|
163
|
+
// assume the origin of the inputFile is the same as the contents of the remote urls within it.
|
|
164
|
+
const url = new URL(inputFile);
|
|
165
|
+
const isSitemap = url.pathname.includes('sitemap');
|
|
166
|
+
if (isSitemap) {
|
|
167
|
+
exceptionUrl = `${url.origin}${exceptionUrl}`;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const options = createOptions({
|
|
171
|
+
source: inputFile,
|
|
172
|
+
selector: {
|
|
173
|
+
"__default": "#dynamic-content",
|
|
174
|
+
[exceptionUrl]: "#dynamic-content-notexist"
|
|
175
|
+
},
|
|
176
|
+
timeout: 5000,
|
|
177
|
+
browser
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const twice = _.after(2, cleanupError.bind(null, done, urls - 1));
|
|
181
|
+
|
|
182
|
+
ss.run(optHelp.decorate(options), twice)
|
|
183
|
+
.then(unexpectedSuccess.bind(null, done))
|
|
184
|
+
.catch(twice);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
151
187
|
});
|
|
152
188
|
};
|
|
153
189
|
}
|
|
154
190
|
|
|
155
191
|
module.exports = {
|
|
156
192
|
testSuite: robotsTests,
|
|
157
|
-
inputFile: inputFile,
|
|
158
193
|
urlCount: urls
|
|
159
194
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//core.codekraft.it/public/wordpress/main-sitemap.xsl"?>
|
|
2
|
+
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
3
|
+
<url>
|
|
4
|
+
<loc>http://localhost:8039/</loc>
|
|
5
|
+
</url>
|
|
6
|
+
<url>
|
|
7
|
+
<loc>http://localhost:8039/contact</loc>
|
|
8
|
+
<lastmod>2017-01-06T21:06:08+01:00</lastmod>
|
|
9
|
+
</url>
|
|
10
|
+
<url>
|
|
11
|
+
<loc>http://localhost:8039/services/carpets</loc>
|
|
12
|
+
<lastmod>2017-01-09T22:38:33+01:00</lastmod>
|
|
13
|
+
</url>
|
|
14
|
+
</urlset>
|
|
15
|
+
<!-- XML Sitemap generated by Yoast SEO -->
|
|
16
|
+
<!-- 24.04MB | Served from transient cache -->
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
User-agent: *
|
|
2
|
+
|
|
3
|
+
Allow: /
|
|
4
|
+
Allow: /contact
|
|
5
|
+
Allow: /services/carpets
|
|
6
|
+
|
|
7
|
+
Disallow: /api/
|
|
8
|
+
Disallow: /vendor/
|
|
9
|
+
Disallow: /fonts/
|
|
10
|
+
Disallow: /images/
|
|
11
|
+
|
|
12
|
+
User-agent: ia_archiver
|
|
13
|
+
Disallow: /
|
|
14
|
+
|
|
15
|
+
Sitemap: http://localhost:8038/test_robots_sitemap.xml
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
|
|
3
|
+
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
4
|
+
<url>
|
|
5
|
+
<loc>http://localhost:8038/</loc>
|
|
6
|
+
<lastmod>2012-08-11T12:16:09+00:00</lastmod>
|
|
7
|
+
<changefreq>daily</changefreq>
|
|
8
|
+
<priority>1.0</priority>
|
|
9
|
+
</url>
|
|
10
|
+
<url>
|
|
11
|
+
<loc>http://localhost:8038/contact</loc>
|
|
12
|
+
<lastmod>2012-11-02T02:53:40+00:00</lastmod>
|
|
13
|
+
<changefreq>weekly</changefreq>
|
|
14
|
+
<priority>0.6</priority>
|
|
15
|
+
</url>
|
|
16
|
+
<url>
|
|
17
|
+
<loc>http://localhost:8038/services/carpets</loc>
|
|
18
|
+
<lastmod>2012-10-19T10:45:23+00:00</lastmod>
|
|
19
|
+
<changefreq>weekly</changefreq>
|
|
20
|
+
<priority>0.6</priority>
|
|
21
|
+
</url>
|
|
22
|
+
</urlset>
|
|
@@ -4,80 +4,92 @@
|
|
|
4
4
|
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
5
|
*/
|
|
6
6
|
/* global it */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const assert = require("assert");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const optHelp = require("../../helpers/options");
|
|
10
|
+
const ss = require("../../../lib/html-snapshots");
|
|
11
|
+
const utils = require("./utils");
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
const {
|
|
14
|
+
outputDir,
|
|
15
|
+
timeout,
|
|
16
|
+
unexpectedError,
|
|
17
|
+
unexpectedSuccess,
|
|
18
|
+
cleanup,
|
|
19
|
+
checkActualFiles
|
|
20
|
+
} = utils;
|
|
20
21
|
|
|
21
22
|
// Sitemap-index constants
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const sitemapIndexFile = "test_sitemap_index.xml";
|
|
24
|
+
const inputFile = path.join(__dirname, "./", sitemapIndexFile);
|
|
25
|
+
const urls = 3; // must match the unqiue # of urls in all the sitemap files referenced in sitemap-index.
|
|
25
26
|
|
|
26
27
|
function getClass (obj) {
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const string = Object.prototype.toString.call(obj);
|
|
29
|
+
const m = /\[object ([^\]]+)/.exec(string);
|
|
29
30
|
return m && m[1];
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
function sitemapIndexTests (options) {
|
|
33
|
-
|
|
34
|
+
const {
|
|
35
|
+
port,
|
|
36
|
+
browsers
|
|
37
|
+
} = options;
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
function createOptions (newOptions) {
|
|
40
|
+
const options = {
|
|
41
|
+
source: `http://localhost:${port}/${sitemapIndexFile}`,
|
|
42
|
+
input: "sitemap-index",
|
|
43
|
+
selector: "#dynamic-content",
|
|
44
|
+
outputDirClean: true,
|
|
45
|
+
outputDir,
|
|
46
|
+
timeout
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
...options,
|
|
51
|
+
...newOptions
|
|
52
|
+
};
|
|
53
|
+
}
|
|
45
54
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
assert.equal(completed.length, urls);
|
|
52
|
-
} catch (e) {
|
|
53
|
-
assertionError = e;
|
|
54
|
-
}
|
|
55
|
-
cleanup(done, assertionError);
|
|
56
|
-
})
|
|
57
|
-
.catch(function (err) {
|
|
58
|
-
checkActualFiles(err.notCompleted)
|
|
59
|
-
.then(function () {
|
|
60
|
-
cleanup(done, err || unexpectedError);
|
|
61
|
-
});
|
|
55
|
+
return function () {
|
|
56
|
+
browsers.forEach(browser => {
|
|
57
|
+
it(`should succeed for typical sitemap-index usage - ${browser}`, function (done) {
|
|
58
|
+
const options = createOptions({
|
|
59
|
+
browser
|
|
62
60
|
});
|
|
63
|
-
});
|
|
64
61
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
62
|
+
ss.run(optHelp.decorate(options))
|
|
63
|
+
.then(function (completed) {
|
|
64
|
+
let assertionError;
|
|
65
|
+
try {
|
|
66
|
+
assert.equal(getClass(completed), "Array");
|
|
67
|
+
assert.equal(completed.length, urls);
|
|
68
|
+
} catch (e) {
|
|
69
|
+
assertionError = e;
|
|
70
|
+
}
|
|
71
|
+
cleanup(done, assertionError);
|
|
72
|
+
})
|
|
73
|
+
.catch(err => {
|
|
74
|
+
checkActualFiles(err.notCompleted)
|
|
75
|
+
.then(() => {
|
|
76
|
+
cleanup(done, err || unexpectedError);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it(`should fail fast for bad sitemap url - ${browser}`, function (done) {
|
|
82
|
+
const sitemapIndexFile3 = path.basename(sitemapIndexFile, ".xml") + "-3" +
|
|
83
|
+
path.extname(sitemapIndexFile);
|
|
84
|
+
const options = createOptions({
|
|
85
|
+
source: `http://localhost:${port}/${sitemapIndexFile3}`,
|
|
86
|
+
browser
|
|
87
|
+
});
|
|
76
88
|
|
|
77
89
|
ss.run(optHelp.decorate(options))
|
|
78
90
|
.then(unexpectedSuccess)
|
|
79
|
-
.catch(
|
|
80
|
-
|
|
91
|
+
.catch(err => {
|
|
92
|
+
let assertionError;
|
|
81
93
|
try {
|
|
82
94
|
assert.equal(getClass(err.notCompleted), "Array");
|
|
83
95
|
// fails fast:
|
|
@@ -87,44 +99,42 @@ function sitemapIndexTests (options) {
|
|
|
87
99
|
}
|
|
88
100
|
cleanup(done, assertionError);
|
|
89
101
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
it("should eventually fail for bad page url", function (done) {
|
|
93
|
-
var eventually = 1000;
|
|
94
|
-
var sitemapIndexFile2 = path.basename(sitemapIndexFile, ".xml") + "-2" +
|
|
95
|
-
path.extname(sitemapIndexFile);
|
|
96
|
-
var options = {
|
|
97
|
-
source: "http://localhost:" + port + "/" + sitemapIndexFile2,
|
|
98
|
-
input: "sitemap-index",
|
|
99
|
-
selector: "#dynamic-content",
|
|
100
|
-
outputDir: outputDir,
|
|
101
|
-
outputDirClean: true,
|
|
102
|
-
timeout: {
|
|
103
|
-
"http://localhost:8040/services/bad": eventually,
|
|
104
|
-
__default: timeout
|
|
105
|
-
}
|
|
106
|
-
};
|
|
102
|
+
});
|
|
107
103
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
cleanup(done, assertionError);
|
|
104
|
+
it(`should eventually fail for bad page url - ${browser}`, function (done) {
|
|
105
|
+
const eventually = 1000;
|
|
106
|
+
const sitemapIndexFile2 = path.basename(sitemapIndexFile, ".xml") + "-2" +
|
|
107
|
+
path.extname(sitemapIndexFile);
|
|
108
|
+
const options = createOptions({
|
|
109
|
+
source: `http://localhost:${port}/${sitemapIndexFile2}`,
|
|
110
|
+
timeout: {
|
|
111
|
+
"http://localhost:8040/services/bad": eventually,
|
|
112
|
+
__default: timeout
|
|
113
|
+
},
|
|
114
|
+
browser
|
|
121
115
|
});
|
|
116
|
+
|
|
117
|
+
ss.run(optHelp.decorate(options))
|
|
118
|
+
.then(unexpectedSuccess)
|
|
119
|
+
.catch(err => {
|
|
120
|
+
let assertionError;
|
|
121
|
+
try {
|
|
122
|
+
assert.equal(getClass(err.completed), "Array");
|
|
123
|
+
assert.equal(err.completed.length, urls - 1);
|
|
124
|
+
assert.equal(getClass(err.notCompleted), "Array");
|
|
125
|
+
assert.equal(err.notCompleted.length, 1);
|
|
126
|
+
} catch (e) {
|
|
127
|
+
assertionError = e;
|
|
128
|
+
}
|
|
129
|
+
cleanup(done, assertionError);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
122
132
|
});
|
|
123
133
|
};
|
|
124
134
|
}
|
|
125
135
|
|
|
126
136
|
module.exports = {
|
|
127
137
|
testSuite: sitemapIndexTests,
|
|
128
|
-
|
|
129
|
-
|
|
138
|
+
urlCount: urls,
|
|
139
|
+
inputFile
|
|
130
140
|
};
|