@diplodoc/cli-tests 5.12.0 → 5.12.2
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/e2e/__snapshots__/alternates.test.ts.snap +18 -27
- package/e2e/__snapshots__/bundles.spec.ts.snap +3 -3
- package/e2e/__snapshots__/include-toc.test.ts.snap +0 -13
- package/e2e/__snapshots__/load-custom-resources.spec.ts.snap +6 -9
- package/e2e/__snapshots__/metadata.spec.ts.snap +3 -6
- package/e2e/__snapshots__/plugin-corner-cases.spec.ts.snap +0 -0
- package/e2e/__snapshots__/preprocess.test.ts.snap +297 -63
- package/e2e/__snapshots__/regression.test.ts.snap +18 -36
- package/e2e/__snapshots__/restricted-access.test.ts.snap +0 -10
- package/e2e/__snapshots__/rtl.spec.ts.snap +6 -6
- package/e2e/__snapshots__/search.test.ts.snap +1 -1
- package/e2e/__snapshots__/single-page.spec.ts.snap +3 -3
- package/e2e/__snapshots__/skip-html-extension.spec.ts.snap +4 -4
- package/e2e/__snapshots__/translation.spec.ts.snap +0 -10
- package/e2e/alternates.test.ts +1 -0
- package/e2e/bundles.spec.ts +1 -0
- package/e2e/errors.spec.ts +18 -8
- package/e2e/generate-map.spec.ts +6 -2
- package/e2e/include-toc.test.ts +1 -0
- package/e2e/load-custom-resources.spec.ts +1 -0
- package/e2e/metadata.spec.ts +1 -0
- package/e2e/plugin-corner-cases.spec.ts +1 -0
- package/e2e/preprocess.test.ts +8 -5
- package/e2e/redirects-validation.spec.ts +5 -4
- package/e2e/regression.test.ts +1 -0
- package/e2e/restricted-access.test.ts +3 -5
- package/e2e/rtl.spec.ts +1 -0
- package/e2e/search.test.ts +1 -0
- package/e2e/single-page.spec.ts +1 -0
- package/e2e/skip-html-extension.spec.ts +1 -0
- package/e2e/translation.spec.ts +17 -6
- package/fixtures/cliAdapter.ts +7 -3
- package/fixtures/globals.d.ts +1 -1
- package/fixtures/runners/binary.ts +5 -2
- package/fixtures/runners/index.ts +2 -1
- package/fixtures/runners/source.ts +1 -1
- package/fixtures/utils/file.ts +20 -16
- package/fixtures/utils/test.ts +19 -19
- package/mocks/preprocess/input/autotitle.md +3 -0
- package/mocks/preprocess/input/includes/level1.md +9 -0
- package/mocks/preprocess/input/includes/level11.md +1 -0
- package/mocks/preprocess/input/includes/sub/level2.md +7 -0
- package/mocks/preprocess/input/level0.md +7 -0
- package/mocks/preprocess/input/level1/level1.md +7 -0
- package/mocks/preprocess/input/level1/level2/level2.md +6 -0
- package/mocks/preprocess/input/level1/toc.yaml +5 -0
- package/mocks/preprocess/input/toc.yaml +8 -0
- package/package.json +1 -1
|
@@ -49,7 +49,7 @@ exports[`Single page mode > simple md2html single page with lang dirs 2`] = `
|
|
|
49
49
|
<body class="g-root g-root_theme_light">
|
|
50
50
|
<div id="root"></div>
|
|
51
51
|
<script type="application/json" id="diplodoc-state">
|
|
52
|
-
{"data":{"leading":true,"data":{"title":"Documentation","description":"","links":[{"title":"Getting started with Documentation","description":"This guide will show you the basics of working with Documentation","href":"ru/page.html"}]},"meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"alternate":[{"href":"ru/index.html","hreflang":"ru"}],"canonical":"ru/index.html","title":"Documentation","noIndex":true,"vcsPath":"ru/index.yaml"
|
|
52
|
+
{"data":{"leading":true,"data":{"title":"Documentation","description":"","links":[{"title":"Getting started with Documentation","description":"This guide will show you the basics of working with Documentation","href":"ru/page.html"}]},"meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"alternate":[{"href":"ru/index.html","hreflang":"ru"}],"canonical":"ru/index.html","title":"Documentation","noIndex":true,"vcsPath":"ru/index.yaml"},"title":"Documentation"},"router":{"pathname":"ru/index","depth":2,"base":"../"},"lang":"ru","langs":["ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
|
|
53
53
|
</script>
|
|
54
54
|
<script type="application/javascript">
|
|
55
55
|
const data = document.querySelector('script#diplodoc-state');
|
|
@@ -82,7 +82,7 @@ exports[`Single page mode > simple md2html single page with lang dirs 3`] = `
|
|
|
82
82
|
<body class="g-root g-root_theme_light">
|
|
83
83
|
<div id="root"></div>
|
|
84
84
|
<script type="application/json" id="diplodoc-state">
|
|
85
|
-
{"data":{"leading":false,"html":"<p>Lorem</p>/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"},{"name":"yfm","content":"builder in page"},{"name":"description","content":"Some test description"}],"alternate":[{"href":"ru/page.html","hreflang":"ru"}],"canonical":"ru/page.html","title":"Page Title","description":"Some test description","interface":{"toc":false,"favicon-src":"/favicon.ico"},"vcsPath":"ru/page.md"
|
|
85
|
+
{"data":{"leading":false,"html":"<p>Lorem</p>/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"},{"name":"yfm","content":"builder in page"},{"name":"description","content":"Some test description"}],"alternate":[{"href":"ru/page.html","hreflang":"ru"}],"canonical":"ru/page.html","title":"Page Title","description":"Some test description","interface":{"toc":false,"favicon-src":"/favicon.ico"},"vcsPath":"ru/page.md"},"headings":[],"title":"Page Title"},"router":{"pathname":"ru/page","depth":2,"base":"../"},"lang":"ru","langs":["ru"],"viewerInterface":{"toc":false,"search":true,"feedback":true,"favicon-src":"/favicon.ico"}}
|
|
86
86
|
</script>
|
|
87
87
|
<script type="application/javascript">
|
|
88
88
|
const data = document.querySelector('script#diplodoc-state');
|
|
@@ -112,7 +112,7 @@ exports[`Single page mode > simple md2html single page with lang dirs 4`] = `
|
|
|
112
112
|
<body class="g-root g-root_theme_light">
|
|
113
113
|
<div id="root"></div>
|
|
114
114
|
<script type="application/json" id="diplodoc-state">
|
|
115
|
-
{"data":{"leading":false,"html":"<p>Lorem</p>/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"alternate":[{"href":"ru/project/config.html","hreflang":"ru"}],"canonical":"ru/project/config.html","vcsPath":"ru/project/config.md"
|
|
115
|
+
{"data":{"leading":false,"html":"<p>Lorem</p>/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"alternate":[{"href":"ru/project/config.html","hreflang":"ru"}],"canonical":"ru/project/config.html","vcsPath":"ru/project/config.md"},"headings":[],"title":""},"router":{"pathname":"ru/project/config","depth":3,"base":"../../"},"lang":"ru","langs":["ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
|
|
116
116
|
</script>
|
|
117
117
|
<script type="application/javascript">
|
|
118
118
|
const data = document.querySelector('script#diplodoc-state');
|
|
@@ -31,7 +31,7 @@ exports[`Skip html extension > transforms links correctly 2`] = `
|
|
|
31
31
|
<body class="g-root g-root_theme_light">
|
|
32
32
|
<div id="root"></div>
|
|
33
33
|
<script type="application/json" id="diplodoc-state">
|
|
34
|
-
{"data":{"leading":false,"html":"","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"vcsPath":"folder/index.md"
|
|
34
|
+
{"data":{"leading":false,"html":"","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"vcsPath":"folder/index.md"},"headings":[],"title":"Page 3"},"router":{"pathname":"folder/index","depth":2,"base":"../"},"lang":"ru","langs":["ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
|
|
35
35
|
</script>
|
|
36
36
|
<script type="application/javascript">
|
|
37
37
|
const data = document.querySelector('script#diplodoc-state');
|
|
@@ -59,7 +59,7 @@ exports[`Skip html extension > transforms links correctly 3`] = `
|
|
|
59
59
|
<body class="g-root g-root_theme_light">
|
|
60
60
|
<div id="root"></div>
|
|
61
61
|
<script type="application/json" id="diplodoc-state">
|
|
62
|
-
{"data":{"leading":false,"html":"<p><a href=\\"page1\\">Link 1</a><br />/n<a href=\\"page2\\">Link 2</a></p>/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"vcsPath":"index-test-html/index.md"
|
|
62
|
+
{"data":{"leading":false,"html":"<p><a href=\\"page1\\">Link 1</a><br />/n<a href=\\"page2\\">Link 2</a></p>/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"vcsPath":"index-test-html/index.md"},"headings":[],"title":"Folder"},"router":{"pathname":"index-test-html/index","depth":2,"base":"../"},"lang":"ru","langs":["ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
|
|
63
63
|
</script>
|
|
64
64
|
<script type="application/javascript">
|
|
65
65
|
const data = document.querySelector('script#diplodoc-state');
|
|
@@ -107,7 +107,7 @@ exports[`Skip html extension > transforms links correctly 5`] = `
|
|
|
107
107
|
<body class="g-root g-root_theme_light">
|
|
108
108
|
<div id="root"></div>
|
|
109
109
|
<script type="application/json" id="diplodoc-state">
|
|
110
|
-
{"data":{"leading":false,"html":"<p><a href=\\"page2#hash\\">Link</a></p>/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"vcsPath":"page1.md"
|
|
110
|
+
{"data":{"leading":false,"html":"<p><a href=\\"page2#hash\\">Link</a></p>/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"vcsPath":"page1.md"},"headings":[],"title":"Page 1"},"router":{"pathname":"page1","depth":1,"base":"./"},"lang":"ru","langs":["ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
|
|
111
111
|
</script>
|
|
112
112
|
<script type="application/javascript">
|
|
113
113
|
const data = document.querySelector('script#diplodoc-state');
|
|
@@ -135,7 +135,7 @@ exports[`Skip html extension > transforms links correctly 6`] = `
|
|
|
135
135
|
<body class="g-root g-root_theme_light">
|
|
136
136
|
<div id="root"></div>
|
|
137
137
|
<script type="application/json" id="diplodoc-state">
|
|
138
|
-
{"data":{"leading":false,"html":"<h2 id=\\"hash\\"><a href=\\"page2#hash\\" class=\\"yfm-anchor\\" aria-hidden=\\"true\\"><span class=\\"visually-hidden\\" data-no-index=\\"true\\">hash</span></a>hash</h2>/n<p><a href=\\"folder/\\">Link</a><br />/n<a href=\\"https://example.com\\" target=\\"_blank\\" rel=\\"noreferrer noopener\\">External link</a></p>/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"vcsPath":"page2.md"
|
|
138
|
+
{"data":{"leading":false,"html":"<h2 id=\\"hash\\"><a href=\\"page2#hash\\" class=\\"yfm-anchor\\" aria-hidden=\\"true\\"><span class=\\"visually-hidden\\" data-no-index=\\"true\\">hash</span></a>hash</h2>/n<p><a href=\\"folder/\\">Link</a><br />/n<a href=\\"https://example.com\\" target=\\"_blank\\" rel=\\"noreferrer noopener\\">External link</a></p>/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"vcsPath":"page2.md"},"headings":[{"title":"hash","href":"page2#hash","level":2}],"title":"Page 2"},"router":{"pathname":"page2","depth":1,"base":"./"},"lang":"ru","langs":["ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
|
|
139
139
|
</script>
|
|
140
140
|
<script type="application/javascript">
|
|
141
141
|
const data = document.querySelector('script#diplodoc-state');
|
|
@@ -17,7 +17,6 @@ metadata:
|
|
|
17
17
|
- name: generator
|
|
18
18
|
content: Diplodoc Platform vDIPLODOC-VERSION
|
|
19
19
|
vcsPath: index.md
|
|
20
|
-
sourcePath: index.md
|
|
21
20
|
---
|
|
22
21
|
## Index header
|
|
23
22
|
|
|
@@ -34,7 +33,6 @@ metadata:
|
|
|
34
33
|
- name: generator
|
|
35
34
|
content: Diplodoc Platform vDIPLODOC-VERSION
|
|
36
35
|
vcsPath: no-translate.md
|
|
37
|
-
sourcePath: no-translate.md
|
|
38
36
|
---
|
|
39
37
|
# No-translate directive
|
|
40
38
|
|
|
@@ -98,7 +96,6 @@ metadata:
|
|
|
98
96
|
- name: generator
|
|
99
97
|
content: Diplodoc Platform vDIPLODOC-VERSION
|
|
100
98
|
vcsPath: openapi/index.md
|
|
101
|
-
sourcePath: openapi/index.md
|
|
102
99
|
---
|
|
103
100
|
# OpenAPI definition
|
|
104
101
|
|
|
@@ -199,7 +196,6 @@ metadata:
|
|
|
199
196
|
- name: generator
|
|
200
197
|
content: Diplodoc Platform vDIPLODOC-VERSION
|
|
201
198
|
vcsPath: openapi/test-controller/getWithPayloadResponse.md
|
|
202
|
-
sourcePath: openapi/test-controller/getWithPayloadResponse.md
|
|
203
199
|
---
|
|
204
200
|
<div class="openapi">
|
|
205
201
|
|
|
@@ -285,7 +281,6 @@ metadata:
|
|
|
285
281
|
- name: generator
|
|
286
282
|
content: Diplodoc Platform vDIPLODOC-VERSION
|
|
287
283
|
vcsPath: openapi/test-controller/index.md
|
|
288
|
-
sourcePath: openapi/test-controller/index.md
|
|
289
284
|
---
|
|
290
285
|
# test-controller
|
|
291
286
|
|
|
@@ -333,7 +328,6 @@ metadata:
|
|
|
333
328
|
- name: generator
|
|
334
329
|
content: Diplodoc Platform vDIPLODOC-VERSION
|
|
335
330
|
vcsPath: index.md
|
|
336
|
-
sourcePath: index.md
|
|
337
331
|
---
|
|
338
332
|
## Index header
|
|
339
333
|
|
|
@@ -350,7 +344,6 @@ metadata:
|
|
|
350
344
|
- name: generator
|
|
351
345
|
content: Diplodoc Platform vDIPLODOC-VERSION
|
|
352
346
|
vcsPath: no-translate.md
|
|
353
|
-
sourcePath: no-translate.md
|
|
354
347
|
---
|
|
355
348
|
# No-translate directive
|
|
356
349
|
|
|
@@ -414,7 +407,6 @@ metadata:
|
|
|
414
407
|
- name: generator
|
|
415
408
|
content: Diplodoc Platform vDIPLODOC-VERSION
|
|
416
409
|
vcsPath: openapi/index.md
|
|
417
|
-
sourcePath: openapi/index.md
|
|
418
410
|
---
|
|
419
411
|
# OpenAPI definition
|
|
420
412
|
|
|
@@ -515,7 +507,6 @@ metadata:
|
|
|
515
507
|
- name: generator
|
|
516
508
|
content: Diplodoc Platform vDIPLODOC-VERSION
|
|
517
509
|
vcsPath: openapi/test-controller/getWithPayloadResponse.md
|
|
518
|
-
sourcePath: openapi/test-controller/getWithPayloadResponse.md
|
|
519
510
|
---
|
|
520
511
|
<div class="openapi">
|
|
521
512
|
|
|
@@ -601,7 +592,6 @@ metadata:
|
|
|
601
592
|
- name: generator
|
|
602
593
|
content: Diplodoc Platform vDIPLODOC-VERSION
|
|
603
594
|
vcsPath: openapi/test-controller/index.md
|
|
604
|
-
sourcePath: openapi/test-controller/index.md
|
|
605
595
|
---
|
|
606
596
|
# test-controller
|
|
607
597
|
|
package/e2e/alternates.test.ts
CHANGED
package/e2e/bundles.spec.ts
CHANGED
package/e2e/errors.spec.ts
CHANGED
|
@@ -1,45 +1,55 @@
|
|
|
1
1
|
import type {Report} from '../fixtures/runners/types';
|
|
2
2
|
|
|
3
3
|
import {describe, expect, it} from 'vitest';
|
|
4
|
+
|
|
4
5
|
import {TestAdapter, getTestPaths} from '../fixtures';
|
|
5
6
|
|
|
6
7
|
type TestResult = {
|
|
7
8
|
md: Report;
|
|
8
9
|
html: Report;
|
|
9
|
-
}
|
|
10
|
+
};
|
|
10
11
|
|
|
11
12
|
function test(path: string, expect: Function) {
|
|
12
13
|
it(path, async () => {
|
|
13
14
|
const {inputPath, outputPath} = getTestPaths(path);
|
|
14
15
|
|
|
15
16
|
const md = await TestAdapter.build.run(inputPath, outputPath, ['-j2', '-f', 'md']);
|
|
16
|
-
const html = await TestAdapter.build.run(inputPath, outputPath + '-html', [
|
|
17
|
+
const html = await TestAdapter.build.run(inputPath, outputPath + '-html', [
|
|
18
|
+
'-j2',
|
|
19
|
+
'-f',
|
|
20
|
+
'html',
|
|
21
|
+
]);
|
|
17
22
|
return expect({md, html});
|
|
18
23
|
});
|
|
19
24
|
}
|
|
20
25
|
|
|
21
|
-
|
|
22
26
|
describe('Errors', () => {
|
|
23
27
|
test('mocks/errors/unreachable-link', ({html}: TestResult) => {
|
|
24
28
|
expectErrors(html, [
|
|
25
29
|
'ERR index.md: 1: YFM003 / unreachable-link Link is unreachable [Context: "[Unreachable link: "exists.html"][existing file](./exists.md)"]',
|
|
26
|
-
'ERR index.md: 2: YFM003 / unreachable-link Link is unreachable [Context: "[Unreachable link: "missed.html"][missed file](./missed.md)"]'
|
|
30
|
+
'ERR index.md: 2: YFM003 / unreachable-link Link is unreachable [Context: "[Unreachable link: "missed.html"][missed file](./missed.md)"]',
|
|
27
31
|
]);
|
|
28
32
|
});
|
|
29
33
|
|
|
30
34
|
it('translate extract with filtered links', async () => {
|
|
31
35
|
const {inputPath, outputPath} = getTestPaths('mocks/errors/extract-filtered-link');
|
|
32
36
|
|
|
33
|
-
const result = await TestAdapter.extract.run(inputPath, outputPath, [
|
|
34
|
-
|
|
37
|
+
const result = await TestAdapter.extract.run(inputPath, outputPath, [
|
|
38
|
+
'--source',
|
|
39
|
+
'ru-RU',
|
|
40
|
+
'--target',
|
|
41
|
+
'es-ES',
|
|
42
|
+
'--filter',
|
|
43
|
+
]);
|
|
44
|
+
|
|
35
45
|
expect(result.code).toEqual(1);
|
|
36
|
-
|
|
46
|
+
|
|
37
47
|
expect(result.errors).toEqual([
|
|
38
48
|
"ERR File index.md contains link to filtered.md, which was filtered from toc.yaml or it's not been included initially",
|
|
39
49
|
"ERR File index.md contains link to filtered2.md, which was filtered from toc.yaml or it's not been included initially",
|
|
40
50
|
"ERR File index.md contains link to filtered2.md, which was filtered from toc.yaml or it's not been included initially",
|
|
41
51
|
"ERR File index.md contains link to filtered3.md, which was filtered from toc.yaml or it's not been included initially",
|
|
42
|
-
])
|
|
52
|
+
]);
|
|
43
53
|
});
|
|
44
54
|
});
|
|
45
55
|
|
package/e2e/generate-map.spec.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {describe, expect, test} from 'vitest';
|
|
2
|
-
import {TestAdapter, bundleless, getFileContent, getTestPaths} from '../fixtures';
|
|
3
2
|
import {join} from 'node:path';
|
|
4
3
|
import {readFile} from 'node:fs/promises';
|
|
5
4
|
|
|
5
|
+
import {TestAdapter, bundleless, getFileContent, getTestPaths} from '../fixtures';
|
|
6
|
+
|
|
6
7
|
const generateMapTestTemplate = (
|
|
7
8
|
testTitle: string,
|
|
8
9
|
testRootPath: string,
|
|
@@ -19,7 +20,10 @@ const generateMapTestTemplate = (
|
|
|
19
20
|
});
|
|
20
21
|
|
|
21
22
|
const content = getFileContent(join(outputPath, 'files.json'));
|
|
22
|
-
const manifestContent = await readFile(
|
|
23
|
+
const manifestContent = await readFile(
|
|
24
|
+
join(outputPath, 'yfm-build-manifest.json'),
|
|
25
|
+
'utf-8',
|
|
26
|
+
);
|
|
23
27
|
|
|
24
28
|
expect(bundleless(content)).toMatchSnapshot();
|
|
25
29
|
expect(JSON.parse(manifestContent)).toMatchSnapshot();
|
package/e2e/include-toc.test.ts
CHANGED
package/e2e/metadata.spec.ts
CHANGED
package/e2e/preprocess.test.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {describe, test} from 'vitest';
|
|
2
|
+
|
|
2
3
|
import {TestAdapter, compareDirectories, getTestPaths} from '../fixtures';
|
|
3
4
|
|
|
4
5
|
const generateFilesYamlTestTemplate = (
|
|
@@ -9,7 +10,7 @@ const generateFilesYamlTestTemplate = (
|
|
|
9
10
|
test(testTitle, async () => {
|
|
10
11
|
const {inputPath, outputPath} = getTestPaths(testRootPath);
|
|
11
12
|
await TestAdapter.testBuildPass(inputPath, outputPath, {
|
|
12
|
-
md2md:true,
|
|
13
|
+
md2md: true,
|
|
13
14
|
md2html: false,
|
|
14
15
|
args: args.join(' '),
|
|
15
16
|
});
|
|
@@ -24,14 +25,16 @@ const generateFilesYamlTestTemplate = (
|
|
|
24
25
|
|
|
25
26
|
describe('Preprocess', () => {
|
|
26
27
|
generateFilesYamlTestTemplate('HashIncludes=true,Autotitles=false', 'mocks/preprocess', [
|
|
27
|
-
'--no-merge-autotitles'
|
|
28
|
+
'--no-merge-autotitles',
|
|
28
29
|
]);
|
|
29
30
|
|
|
30
31
|
generateFilesYamlTestTemplate('HashIncludes=true,Autotitles=true', 'mocks/preprocess');
|
|
31
32
|
|
|
32
|
-
generateFilesYamlTestTemplate(
|
|
33
|
-
'
|
|
34
|
-
|
|
33
|
+
generateFilesYamlTestTemplate(
|
|
34
|
+
'HashIncludes=true,Autotitles=true,Svg=true',
|
|
35
|
+
'mocks/preprocess',
|
|
36
|
+
['--merge-svg'],
|
|
37
|
+
);
|
|
35
38
|
|
|
36
39
|
// generateFilesYamlTestTemplate('Nested toc restricted access', 'mocks/preprocess/test3');
|
|
37
40
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {describe, expect, it} from 'vitest';
|
|
2
|
+
|
|
2
3
|
import {TestAdapter, getTestPaths} from '../fixtures';
|
|
3
4
|
|
|
4
5
|
describe('Redirects validation', () => {
|
|
@@ -38,7 +39,9 @@ describe('Redirects validation', () => {
|
|
|
38
39
|
});
|
|
39
40
|
|
|
40
41
|
it('should emit an error when a redirect is malformed', async () => {
|
|
41
|
-
const {inputPath, outputPath} = getTestPaths(
|
|
42
|
+
const {inputPath, outputPath} = getTestPaths(
|
|
43
|
+
'mocks/redirects-validation/malformed-redirect',
|
|
44
|
+
);
|
|
42
45
|
|
|
43
46
|
const report = await TestAdapter.build.run(inputPath, outputPath, ['-f', 'md']);
|
|
44
47
|
|
|
@@ -54,8 +57,6 @@ describe('Redirects validation', () => {
|
|
|
54
57
|
const report = await TestAdapter.build.run(inputPath, outputPath, ['-f', 'md']);
|
|
55
58
|
|
|
56
59
|
expect(report.code).toBe(1);
|
|
57
|
-
expect(report.errors).toContainEqual(
|
|
58
|
-
expect.stringMatching(/Parameters must be different/),
|
|
59
|
-
);
|
|
60
|
+
expect(report.errors).toContainEqual(expect.stringMatching(/Parameters must be different/));
|
|
60
61
|
});
|
|
61
62
|
});
|
package/e2e/regression.test.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import {describe, test} from 'vitest';
|
|
2
|
+
|
|
2
3
|
import {TestAdapter, compareDirectories, getTestPaths} from '../fixtures';
|
|
3
4
|
|
|
4
|
-
const generateFilesYamlTestTemplate = (
|
|
5
|
-
testTitle: string,
|
|
6
|
-
testRootPath: string
|
|
7
|
-
) => {
|
|
5
|
+
const generateFilesYamlTestTemplate = (testTitle: string, testRootPath: string) => {
|
|
8
6
|
test(testTitle, async () => {
|
|
9
7
|
const {inputPath, outputPath} = getTestPaths(testRootPath);
|
|
10
|
-
await TestAdapter.testBuildPass(inputPath, outputPath, {md2md:true});
|
|
8
|
+
await TestAdapter.testBuildPass(inputPath, outputPath, {md2md: true});
|
|
11
9
|
await compareDirectories(outputPath);
|
|
12
10
|
});
|
|
13
11
|
};
|
package/e2e/rtl.spec.ts
CHANGED
package/e2e/search.test.ts
CHANGED
package/e2e/single-page.spec.ts
CHANGED
package/e2e/translation.spec.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type {TranslateRunArgs} from '../fixtures';
|
|
2
|
+
|
|
1
3
|
import {describe, test} from 'vitest';
|
|
2
|
-
|
|
4
|
+
|
|
5
|
+
import {TestAdapter, compareDirectories, getTestPaths} from '../fixtures';
|
|
3
6
|
|
|
4
7
|
const generateMapTestTemplate = (
|
|
5
8
|
testTitle: string,
|
|
@@ -46,9 +49,17 @@ const buildFilesYamlTestTemplate = (
|
|
|
46
49
|
};
|
|
47
50
|
|
|
48
51
|
describe('Translate command', () => {
|
|
49
|
-
buildFilesYamlTestTemplate(
|
|
52
|
+
buildFilesYamlTestTemplate(
|
|
53
|
+
'build translated md files and remove no-translate directives',
|
|
54
|
+
'mocks/translation/no-translate',
|
|
55
|
+
{md2md: true},
|
|
56
|
+
);
|
|
50
57
|
|
|
51
|
-
buildFilesYamlTestTemplate(
|
|
58
|
+
buildFilesYamlTestTemplate(
|
|
59
|
+
'build translated static files and remove no-translate directives',
|
|
60
|
+
'mocks/translation/no-translate',
|
|
61
|
+
{md2html: true},
|
|
62
|
+
);
|
|
52
63
|
|
|
53
64
|
generateFilesYamlTestTemplate('extract openapi spec files', 'mocks/translation/openapi', {
|
|
54
65
|
subcommand: 'extract',
|
|
@@ -66,7 +77,7 @@ describe('Translate command', () => {
|
|
|
66
77
|
subcommand: 'extract',
|
|
67
78
|
source: 'ru-RU',
|
|
68
79
|
target: 'es-ES',
|
|
69
|
-
additionalArgs: '--filter'
|
|
80
|
+
additionalArgs: '--filter',
|
|
70
81
|
});
|
|
71
82
|
|
|
72
83
|
generateMapTestTemplate(
|
|
@@ -80,7 +91,7 @@ describe('Translate command', () => {
|
|
|
80
91
|
},
|
|
81
92
|
);
|
|
82
93
|
|
|
83
|
-
const vars = {skip: 'prod'}
|
|
94
|
+
const vars = {skip: 'prod'};
|
|
84
95
|
generateMapTestTemplate(
|
|
85
96
|
'filter files on extract with extra vars option',
|
|
86
97
|
'mocks/translation/dir-files',
|
|
@@ -98,7 +109,7 @@ describe('Translate command', () => {
|
|
|
98
109
|
{
|
|
99
110
|
subcommand: 'extract',
|
|
100
111
|
source: 'ru-RU',
|
|
101
|
-
target: 'es-ES',
|
|
112
|
+
target: 'es-ES',
|
|
102
113
|
},
|
|
103
114
|
false,
|
|
104
115
|
);
|
package/fixtures/cliAdapter.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {Runner
|
|
1
|
+
import type {Runner} from './runners';
|
|
2
|
+
|
|
3
|
+
import {createRunner} from './runners';
|
|
2
4
|
import {cleanupDirectory} from './utils/file';
|
|
3
5
|
|
|
4
6
|
export interface BuildRunArgs {
|
|
@@ -76,8 +78,10 @@ export class CliTestAdapter {
|
|
|
76
78
|
const tasks = [];
|
|
77
79
|
|
|
78
80
|
if (md2md && md2html) {
|
|
79
|
-
tasks.push(() => this.build.run(inputPath, outputPath,[...baseArgs, '-f', 'md']));
|
|
80
|
-
tasks.push(() =>
|
|
81
|
+
tasks.push(() => this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'md']));
|
|
82
|
+
tasks.push(() =>
|
|
83
|
+
this.build.run(inputPath, `${outputPath}-html`, [...baseArgs, '-f', 'html']),
|
|
84
|
+
);
|
|
81
85
|
} else if (md2md) {
|
|
82
86
|
tasks.push(() => this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'md']));
|
|
83
87
|
} else {
|
package/fixtures/globals.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {Runner} from './types';
|
|
1
|
+
import type {Runner} from './types';
|
|
2
|
+
|
|
2
3
|
import {execa} from 'execa';
|
|
3
4
|
import strip from 'strip-ansi';
|
|
4
5
|
|
|
@@ -20,6 +21,7 @@ export class BinaryRunner implements Runner {
|
|
|
20
21
|
const restLog = fillLog(/^(?!INFO|WARN|ERR)/, stderr);
|
|
21
22
|
if (restLog.length) {
|
|
22
23
|
for (const line of restLog) {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
23
25
|
console.log(line);
|
|
24
26
|
}
|
|
25
27
|
}
|
|
@@ -29,7 +31,8 @@ export class BinaryRunner implements Runner {
|
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
function fillLog(filter: RegExp, source: string) {
|
|
32
|
-
return source
|
|
34
|
+
return source
|
|
35
|
+
.split('\n')
|
|
33
36
|
.map((line) => strip(line).trim())
|
|
34
37
|
.filter(Boolean)
|
|
35
38
|
.filter((line) => line.match(filter));
|
|
@@ -7,7 +7,8 @@ import {Runner} from './types';
|
|
|
7
7
|
export {Runner};
|
|
8
8
|
|
|
9
9
|
export function createRunner(): Runner {
|
|
10
|
-
const binaryPath =
|
|
10
|
+
const binaryPath =
|
|
11
|
+
process.env.DIPLODOC_BINARY_PATH || resolve(__dirname, '../../../build/index.js');
|
|
11
12
|
|
|
12
13
|
if (binaryPath) {
|
|
13
14
|
return new BinaryRunner(binaryPath);
|
package/fixtures/utils/file.ts
CHANGED
|
@@ -2,29 +2,29 @@ import {readFileSync} from 'node:fs';
|
|
|
2
2
|
import {rm} from 'node:fs/promises';
|
|
3
3
|
import {join, resolve} from 'node:path';
|
|
4
4
|
import {glob} from 'glob';
|
|
5
|
-
import {bundleless, hashless, platformless} from './test';
|
|
6
5
|
import {expect} from 'vitest';
|
|
7
6
|
|
|
7
|
+
import {bundleless, hashless, platformless} from './test';
|
|
8
|
+
|
|
8
9
|
const SYSTEM_DIRS = ['_bundle/', '_search/'];
|
|
9
10
|
|
|
10
11
|
export function getFileContent(filePath: string) {
|
|
11
12
|
return platformless(bundleless(readFileSync(filePath, 'utf8')));
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
const uselessFile = (file: string, dirs: string[]) =>
|
|
15
|
-
!dirs.some((part) => file.includes(part));
|
|
15
|
+
const uselessFile = (file: string, dirs: string[]) => !dirs.some((part) => file.includes(part));
|
|
16
16
|
|
|
17
17
|
export function stripSystemLinks(content: string) {
|
|
18
|
-
const dirPattern = SYSTEM_DIRS.map(d => d.replace('/', '\\/')).join('|');
|
|
18
|
+
const dirPattern = SYSTEM_DIRS.map((d) => d.replace('/', '\\/')).join('|');
|
|
19
19
|
|
|
20
20
|
content = content.replace(
|
|
21
21
|
new RegExp(`<script[^>]+src="(?:${dirPattern})[^"]*"[^>]*></script>`, 'g'),
|
|
22
|
-
''
|
|
22
|
+
'',
|
|
23
23
|
);
|
|
24
24
|
|
|
25
25
|
content = content.replace(
|
|
26
26
|
new RegExp(`<link[^>]+href="(?:${dirPattern})[^"]*"[^>]*\\/?>`, 'g'),
|
|
27
|
-
''
|
|
27
|
+
'',
|
|
28
28
|
);
|
|
29
29
|
|
|
30
30
|
content = content.replace(/^[ \t]*\r?\n/gm, '');
|
|
@@ -45,34 +45,38 @@ export async function compareDirectories(
|
|
|
45
45
|
nodir: true,
|
|
46
46
|
posix: true,
|
|
47
47
|
})
|
|
48
|
-
)
|
|
48
|
+
)
|
|
49
|
+
.map(bundleless)
|
|
50
|
+
.sort();
|
|
49
51
|
|
|
50
52
|
let filesForSnapshot;
|
|
51
53
|
|
|
52
54
|
if (checkBundle) {
|
|
53
55
|
filesForSnapshot = filesFromOutput;
|
|
54
56
|
} else {
|
|
55
|
-
filesForSnapshot = filesFromOutput.filter(file => uselessFile(file, SYSTEM_DIRS));
|
|
57
|
+
filesForSnapshot = filesFromOutput.filter((file) => uselessFile(file, SYSTEM_DIRS));
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
// Here we sort the order of the included files after all processing
|
|
59
61
|
// This is necessary for better test stability
|
|
60
62
|
// We do not care in what order these files were received and processed
|
|
61
63
|
// We sort only the final list and put it in the snapshot
|
|
62
|
-
filesForSnapshot = filesForSnapshot.map(hashless).sort();
|
|
64
|
+
filesForSnapshot = filesForSnapshot.map(hashless).sort();
|
|
63
65
|
|
|
64
66
|
expect(JSON.stringify(filesForSnapshot, null, 2)).toMatchSnapshot('filelist');
|
|
65
67
|
|
|
66
68
|
if (!ignoreFileContent) {
|
|
67
|
-
filesFromOutput
|
|
68
|
-
|
|
69
|
+
filesFromOutput
|
|
70
|
+
.filter((file) => uselessFile(file, ['_assets/', ...SYSTEM_DIRS]))
|
|
71
|
+
.forEach((filePath) => {
|
|
72
|
+
let content = getFileContent(resolve(outputPath, filePath));
|
|
69
73
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
if (!checkBundle && filePath.endsWith('.html')) {
|
|
75
|
+
content = stripSystemLinks(content);
|
|
76
|
+
}
|
|
73
77
|
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
expect(content).toMatchSnapshot();
|
|
79
|
+
});
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
82
|
|