@diplodoc/cli-tests 5.28.0 → 5.30.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/e2e/__snapshots__/bundles.spec.ts.snap +1 -1
- package/e2e/__snapshots__/files.test.ts.snap +1 -1
- package/e2e/__snapshots__/include-toc.test.ts.snap +207 -0
- package/e2e/__snapshots__/includes.test.ts.snap +4 -4
- package/e2e/__snapshots__/neuro-expert.test.ts.snap +2 -2
- package/e2e/__snapshots__/pdf-page.spec.ts.snap +11 -7
- package/e2e/__snapshots__/regression.test.ts.snap +8 -8
- package/e2e/__snapshots__/skip-html-extension.spec.ts.snap +3 -3
- package/e2e/disable-csp.spec.ts +55 -0
- package/e2e/include-toc.test.ts +12 -0
- package/mocks/disable-csp/input/.yfm +8 -0
- package/mocks/disable-csp/input/en/index.md +3 -0
- package/mocks/disable-csp/input/en/page.md +3 -0
- package/mocks/disable-csp/input/en/toc.yaml +5 -0
- package/mocks/include-toc/test8/input/test/index.md +4 -0
- package/mocks/include-toc/test8/input/test/sub/index.md +1 -0
- package/mocks/include-toc/test8/input/test/sub/sub/sub-3.md +1 -0
- package/mocks/include-toc/test8/input/test/sub/sub-1.md +5 -0
- package/mocks/include-toc/test8/input/test/sub/sub-2.md +1 -0
- package/mocks/include-toc/test8/input/test/test.md +1 -0
- package/mocks/include-toc/test8/input/toc.yaml +9 -0
- package/mocks/include-toc/test9/input/test/index.md +4 -0
- package/mocks/include-toc/test9/input/test/sub/index.md +1 -0
- package/mocks/include-toc/test9/input/test/sub/sub/sub-3.md +1 -0
- package/mocks/include-toc/test9/input/test/sub/sub-1.md +5 -0
- package/mocks/include-toc/test9/input/test/sub/sub-2.md +1 -0
- package/mocks/include-toc/test9/input/test/test.md +1 -0
- package/mocks/include-toc/test9/input/toc.yaml +8 -0
- package/mocks/pdf-page/title-pages/input/pdf-endings/pdf-ending-page1.md +13 -0
- package/mocks/pdf-page/title-pages/input/pdf-endings/pdf-ending-page2.md +3 -0
- package/mocks/pdf-page/title-pages/input/toc.yaml +3 -0
- package/package.json +1 -1
|
@@ -143,7 +143,7 @@ exports[`Skip html extension > correctly trims .html and index.html on monolingu
|
|
|
143
143
|
<body class="g-root g-root_theme_light">
|
|
144
144
|
<div id="root"></div>
|
|
145
145
|
<script type="application/json" id="diplodoc-state">
|
|
146
|
-
{"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}}
|
|
146
|
+
{"data":{"leading":false,"html":"<h2 id=\\"hash\\"><a href=\\"page2#hash\\" class=\\"yfm-anchor yfm-clipboard-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}}
|
|
147
147
|
</script>
|
|
148
148
|
<script type="application/javascript">
|
|
149
149
|
const data = document.querySelector('script#diplodoc-state');
|
|
@@ -325,7 +325,7 @@ exports[`Skip html extension > correctly trims .html and index.html on multiling
|
|
|
325
325
|
<body class="g-root g-root_theme_light">
|
|
326
326
|
<div id="root"></div>
|
|
327
327
|
<script type="application/json" id="diplodoc-state">
|
|
328
|
-
{"data":{"leading":false,"html":"<h2 id=\\"hash\\"><a href=\\"en/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=\\"en/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"}],"alternate":[{"href":"en/page2","hreflang":"en"},{"href":"ru/page2","hreflang":"ru"}],"canonical":"en/page2","vcsPath":"en/page2.md"},"headings":[{"title":"hash","href":"en/page2#hash","level":2}],"title":"Page 2"},"router":{"pathname":"en/page2","depth":2,"base":"../"},"lang":"en","langs":["en","ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
|
|
328
|
+
{"data":{"leading":false,"html":"<h2 id=\\"hash\\"><a href=\\"en/page2#hash\\" class=\\"yfm-anchor yfm-clipboard-anchor\\" aria-hidden=\\"true\\"><span class=\\"visually-hidden\\" data-no-index=\\"true\\">hash</span></a>hash</h2>/n<p><a href=\\"en/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"}],"alternate":[{"href":"en/page2","hreflang":"en"},{"href":"ru/page2","hreflang":"ru"}],"canonical":"en/page2","vcsPath":"en/page2.md"},"headings":[{"title":"hash","href":"en/page2#hash","level":2}],"title":"Page 2"},"router":{"pathname":"en/page2","depth":2,"base":"../"},"lang":"en","langs":["en","ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
|
|
329
329
|
</script>
|
|
330
330
|
<script type="application/javascript">
|
|
331
331
|
const data = document.querySelector('script#diplodoc-state');
|
|
@@ -502,7 +502,7 @@ exports[`Skip html extension > correctly trims .html and index.html on multiling
|
|
|
502
502
|
<body class="g-root g-root_theme_light">
|
|
503
503
|
<div id="root"></div>
|
|
504
504
|
<script type="application/json" id="diplodoc-state">
|
|
505
|
-
{"data":{"leading":false,"html":"<h2 id=\\"hesh\\"><a href=\\"ru/page2#hesh\\" class=\\"yfm-anchor\\" aria-hidden=\\"true\\"><span class=\\"visually-hidden\\" data-no-index=\\"true\\">хэш</span></a>хэш</h2>/n<p><a href=\\"ru/folder/\\">Ссылка</a><br />/n<a href=\\"https://example.com\\" target=\\"_blank\\" rel=\\"noreferrer noopener\\">Внешняя ссылка</a></p>/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"alternate":[{"href":"en/page2","hreflang":"en"},{"href":"ru/page2","hreflang":"ru"}],"canonical":"ru/page2","vcsPath":"ru/page2.md"},"headings":[{"title":"хэш","href":"ru/page2#hesh","level":2}],"title":"Страница 2"},"router":{"pathname":"ru/page2","depth":2,"base":"../"},"lang":"ru","langs":["en","ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
|
|
505
|
+
{"data":{"leading":false,"html":"<h2 id=\\"hesh\\"><a href=\\"ru/page2#hesh\\" class=\\"yfm-anchor yfm-clipboard-anchor\\" aria-hidden=\\"true\\"><span class=\\"visually-hidden\\" data-no-index=\\"true\\">хэш</span></a>хэш</h2>/n<p><a href=\\"ru/folder/\\">Ссылка</a><br />/n<a href=\\"https://example.com\\" target=\\"_blank\\" rel=\\"noreferrer noopener\\">Внешняя ссылка</a></p>/n","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"alternate":[{"href":"en/page2","hreflang":"en"},{"href":"ru/page2","hreflang":"ru"}],"canonical":"ru/page2","vcsPath":"ru/page2.md"},"headings":[{"title":"хэш","href":"ru/page2#hesh","level":2}],"title":"Страница 2"},"router":{"pathname":"ru/page2","depth":2,"base":"../"},"lang":"ru","langs":["en","ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
|
|
506
506
|
</script>
|
|
507
507
|
<script type="application/javascript">
|
|
508
508
|
const data = document.querySelector('script#diplodoc-state');
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {readFileSync, readdirSync} from 'node:fs';
|
|
2
|
+
import {join, sep} from 'node:path';
|
|
3
|
+
import {describe, expect, test} from 'vitest';
|
|
4
|
+
|
|
5
|
+
import {TestAdapter, getTestPaths} from '../fixtures';
|
|
6
|
+
|
|
7
|
+
function findHtmlFiles(dir: string): string[] {
|
|
8
|
+
const results: string[] = [];
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
for (const entry of readdirSync(dir, {withFileTypes: true})) {
|
|
12
|
+
const full = join(dir, entry.name);
|
|
13
|
+
|
|
14
|
+
if (entry.isDirectory()) {
|
|
15
|
+
results.push(...findHtmlFiles(full));
|
|
16
|
+
} else if (entry.name.endsWith('.html')) {
|
|
17
|
+
results.push(full);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
} catch {
|
|
21
|
+
// ignore
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return results;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe('disableCsp', () => {
|
|
28
|
+
test('should not inject CSP meta tag when disableCsp is true with neuroExpert enabled', async () => {
|
|
29
|
+
const {inputPath, outputPath} = getTestPaths('mocks/disable-csp');
|
|
30
|
+
|
|
31
|
+
await TestAdapter.testBuildPass(inputPath, outputPath, {
|
|
32
|
+
md2md: false,
|
|
33
|
+
md2html: true,
|
|
34
|
+
args: '-j2',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const htmlFiles = findHtmlFiles(outputPath);
|
|
38
|
+
expect(htmlFiles.length).toBeGreaterThan(0);
|
|
39
|
+
|
|
40
|
+
// No HTML page should contain CSP meta tag
|
|
41
|
+
for (const htmlFile of htmlFiles) {
|
|
42
|
+
const html = readFileSync(htmlFile, 'utf8');
|
|
43
|
+
expect(html).not.toContain('Content-Security-Policy');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Content pages (under en/) should still have the neuroExpert widget script
|
|
47
|
+
const contentPages = htmlFiles.filter((f) => f.includes(`${sep}en${sep}`));
|
|
48
|
+
expect(contentPages.length).toBeGreaterThan(0);
|
|
49
|
+
|
|
50
|
+
for (const htmlFile of contentPages) {
|
|
51
|
+
const html = readFileSync(htmlFile, 'utf8');
|
|
52
|
+
expect(html).toContain('neuroexpert-widget');
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
package/e2e/include-toc.test.ts
CHANGED
|
@@ -52,4 +52,16 @@ describe('Include toc', () => {
|
|
|
52
52
|
await TestAdapter.testBuildPass(inputPath, outputPath);
|
|
53
53
|
await compareDirectories(outputPath);
|
|
54
54
|
});
|
|
55
|
+
|
|
56
|
+
test('Toc with generic includer and linkIndex option', async () => {
|
|
57
|
+
const {inputPath, outputPath} = getTestPaths('mocks/include-toc/test8');
|
|
58
|
+
await TestAdapter.testBuildPass(inputPath, outputPath);
|
|
59
|
+
await compareDirectories(outputPath);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('Toc with generic includer keeps index.md as child item by default', async () => {
|
|
63
|
+
const {inputPath, outputPath} = getTestPaths('mocks/include-toc/test9');
|
|
64
|
+
await TestAdapter.testBuildPass(inputPath, outputPath);
|
|
65
|
+
await compareDirectories(outputPath);
|
|
66
|
+
});
|
|
55
67
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Sub index
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# H1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# H1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# H1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Sub index
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# H1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# H1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# H1
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
### Pdf ending page 1
|
|
2
|
+
|
|
3
|
+
Should be able to use variables {{test}}
|
|
4
|
+
|
|
5
|
+
Should be able to use link to other pages [test](../page1.md)
|
|
6
|
+
|
|
7
|
+
Should be able to use inlcudes
|
|
8
|
+
|
|
9
|
+
{% include [test-include](../__includes/include1.md) %}
|
|
10
|
+
|
|
11
|
+
Should be able to resolve liquid syntax
|
|
12
|
+
|
|
13
|
+
{% if test == "pdf" %} should be visible {% endif %}
|