@diplodoc/cli-tests 0.0.0-rc-liquid-conditions-saving-202509050811 → 0.0.0-rc-resolve-codeblock-202509151421

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.
Files changed (30) hide show
  1. package/e2e/__snapshots__/bundles.spec.ts.snap +168 -0
  2. package/e2e/__snapshots__/include-toc.test.ts.snap +34 -0
  3. package/e2e/__snapshots__/load-custom-resources.spec.ts.snap +15 -106
  4. package/e2e/__snapshots__/metadata.spec.ts.snap +9 -47
  5. package/e2e/__snapshots__/plugin-corner-cases.spec.ts.snap +0 -0
  6. package/e2e/__snapshots__/preprocess.test.ts.snap +32 -0
  7. package/e2e/__snapshots__/regression.test.ts.snap +59 -211
  8. package/e2e/__snapshots__/restricted-access.test.ts.snap +20 -0
  9. package/e2e/__snapshots__/rtl.spec.ts.snap +6 -105
  10. package/e2e/__snapshots__/search.test.ts.snap +1 -31
  11. package/e2e/__snapshots__/single-page.spec.ts.snap +157 -0
  12. package/e2e/__snapshots__/skip-html-extension.spec.ts.snap +4 -63
  13. package/e2e/__snapshots__/translation.spec.ts.snap +183 -1416
  14. package/e2e/bundles.spec.ts +15 -0
  15. package/e2e/single-page.spec.ts +22 -0
  16. package/e2e/translation.spec.ts +0 -26
  17. package/fixtures/utils/file.ts +49 -6
  18. package/mocks/bundles/input/.yfm +13 -0
  19. package/mocks/bundles/input/index.md +12 -0
  20. package/mocks/bundles/input/page1.md +3 -0
  21. package/mocks/bundles/input/page2.md +5 -0
  22. package/mocks/bundles/input/toc.yaml +9 -0
  23. package/mocks/errors/extract-filtered-link/input/index.md +1 -1
  24. package/mocks/regression/input/autotitle.md +3 -0
  25. package/mocks/single-page/input/ru/index.yaml +9 -0
  26. package/mocks/single-page/input/ru/page.md +14 -0
  27. package/mocks/single-page/input/ru/project/config.md +1 -0
  28. package/mocks/single-page/input/ru/toc.yaml +7 -0
  29. package/package.json +1 -1
  30. package/mocks/translation/conditions/input/index.md +0 -37
@@ -0,0 +1,15 @@
1
+ import {describe, it} from 'vitest';
2
+ import {TestAdapter, compareDirectories, getTestPaths} from '../fixtures';
3
+
4
+ describe('Check bundles', () => {
5
+ it('bundles list is correct', async () => {
6
+ const {inputPath, outputPath} = getTestPaths('mocks/bundles');
7
+
8
+ await TestAdapter.testBuildPass(inputPath, outputPath, {
9
+ md2md: false,
10
+ md2html: true,
11
+ args: '-j2',
12
+ });
13
+ await compareDirectories(outputPath, false, true);
14
+ });
15
+ });
@@ -0,0 +1,22 @@
1
+ import {describe, test} from 'vitest';
2
+ import {TestAdapter, compareDirectories, getTestPaths} from '../fixtures';
3
+
4
+ const generateMapTestSinglePageTemplate = (
5
+ testTitle: string,
6
+ testRootPath: string,
7
+ {md2md = true, md2html = true, args = '--single-page'},
8
+ ) => {
9
+ test(testTitle, async () => {
10
+ const {inputPath, outputPath} = getTestPaths(testRootPath);
11
+ await TestAdapter.testBuildPass(inputPath, outputPath, {md2md, md2html, args});
12
+ await compareDirectories(outputPath);
13
+ });
14
+ };
15
+
16
+ describe('Single page mode', () => {
17
+ generateMapTestSinglePageTemplate(
18
+ 'simple md2html single page with lang dirs',
19
+ 'mocks/single-page',
20
+ {md2md: false},
21
+ );
22
+ });
@@ -108,30 +108,4 @@ describe('Translate command', () => {
108
108
  source: 'ru-RU',
109
109
  target: 'en-US',
110
110
  });
111
-
112
- let conditionVars = {prod: true, inner: true, list: ['item']};
113
- generateMapTestTemplate(
114
- 'save truthy liquid conditions structures',
115
- 'mocks/translation/conditions',
116
- {
117
- subcommand: 'extract',
118
- source: 'ru-RU',
119
- target: 'es-ES',
120
- additionalArgs: `--vars ${JSON.stringify(conditionVars)}`,
121
- },
122
- false,
123
- );
124
-
125
- conditionVars = {prod: false, inner: false, list: ['item']};
126
- generateMapTestTemplate(
127
- 'remove falsy liquid conditions structures',
128
- 'mocks/translation/conditions',
129
- {
130
- subcommand: 'extract',
131
- source: 'ru-RU',
132
- target: 'es-ES',
133
- additionalArgs: `--vars ${JSON.stringify(conditionVars)}`,
134
- },
135
- false,
136
- );
137
111
  });
@@ -5,14 +5,38 @@ import {glob} from 'glob';
5
5
  import {bundleless, hashless, platformless} from './test';
6
6
  import {expect} from 'vitest';
7
7
 
8
+ const SYSTEM_DIRS = ['_bundle/', '_search/'];
9
+
8
10
  export function getFileContent(filePath: string) {
9
11
  return platformless(bundleless(readFileSync(filePath, 'utf8')));
10
12
  }
11
13
 
12
- const uselessFile = (file: string) =>
13
- !['_bundle/', '_assets/', '_search/'].some((part) => file.includes(part));
14
+ const uselessFile = (file: string, dirs: string[]) =>
15
+ !dirs.some((part) => file.includes(part));
16
+
17
+ export function stripSystemLinks(content: string) {
18
+ const dirPattern = SYSTEM_DIRS.map(d => d.replace('/', '\\/')).join('|');
19
+
20
+ content = content.replace(
21
+ new RegExp(`<script[^>]+src="(?:${dirPattern})[^"]*"[^>]*></script>`, 'g'),
22
+ ''
23
+ );
24
+
25
+ content = content.replace(
26
+ new RegExp(`<link[^>]+href="(?:${dirPattern})[^"]*"[^>]*\\/?>`, 'g'),
27
+ ''
28
+ );
29
+
30
+ content = content.replace(/^[ \t]*\r?\n/gm, '');
31
+
32
+ return content;
33
+ }
14
34
 
15
- export async function compareDirectories(outputPath: string, ignoreFileContent = false) {
35
+ export async function compareDirectories(
36
+ outputPath: string,
37
+ ignoreFileContent = false,
38
+ checkBundle = false,
39
+ ) {
16
40
  const filesFromOutput = (
17
41
  await glob(`**/*`, {
18
42
  cwd: outputPath,
@@ -23,11 +47,30 @@ export async function compareDirectories(outputPath: string, ignoreFileContent =
23
47
  })
24
48
  ).map(bundleless).sort();
25
49
 
26
- expect(hashless(JSON.stringify(filesFromOutput, null, 2))).toMatchSnapshot('filelist');
50
+ let filesForSnapshot;
51
+
52
+ if (checkBundle) {
53
+ filesForSnapshot = filesFromOutput;
54
+ } else {
55
+ filesForSnapshot = filesFromOutput.filter(file => uselessFile(file, SYSTEM_DIRS));
56
+ }
57
+
58
+ // Here we sort the order of the included files after all processing
59
+ // This is necessary for better test stability
60
+ // We do not care in what order these files were received and processed
61
+ // We sort only the final list and put it in the snapshot
62
+ filesForSnapshot = filesForSnapshot.map(hashless).sort();
63
+
64
+ expect(JSON.stringify(filesForSnapshot, null, 2)).toMatchSnapshot('filelist');
27
65
 
28
66
  if (!ignoreFileContent) {
29
- filesFromOutput.filter(uselessFile).forEach((filePath) => {
30
- const content = getFileContent(resolve(outputPath, filePath));
67
+ filesFromOutput.filter(file => uselessFile(file, ['_assets/', ...SYSTEM_DIRS])).forEach((filePath) => {
68
+ let content = getFileContent(resolve(outputPath, filePath));
69
+
70
+ if (!checkBundle && filePath.endsWith('.html')) {
71
+ content = stripSystemLinks(content);
72
+ }
73
+
31
74
  expect(content).toMatchSnapshot();
32
75
  });
33
76
  }
@@ -0,0 +1,13 @@
1
+ allowHTML: true
2
+
3
+ meta:
4
+ rootPath: http://127.0.0.1:5000/
5
+
6
+ interface:
7
+ toc-header: false
8
+ favicon-src: https://storage.yandexcloud.net/diplodoc-www-assets/favicon/favicon.ico
9
+
10
+ search:
11
+ provider: local
12
+ tolerance: 2
13
+ confidense: phrased
@@ -0,0 +1,12 @@
1
+ ---
2
+ availableLangs:
3
+ - en
4
+ - ru
5
+ ---
6
+
7
+ # Header
8
+
9
+ Content
10
+
11
+ [Link 1](page1.md)
12
+ [Link 2](page2.md)
@@ -0,0 +1,3 @@
1
+ # Page 1
2
+
3
+ [Link](page2.md#hash)
@@ -0,0 +1,5 @@
1
+ # Page 2
2
+
3
+ ## hash
4
+
5
+ [External link](https://example.com)
@@ -0,0 +1,9 @@
1
+ title: Skip html extension
2
+ href: index.md
3
+
4
+ items:
5
+ - name: Title 1
6
+ href: page1.md
7
+ - name: Title 2
8
+ href: page2.md
9
+
@@ -4,4 +4,4 @@
4
4
 
5
5
  [second missed link](./filtered2.md)
6
6
  [second missed link](./filtered2.md)
7
- [second missed link](./filtered3.md)
7
+ [second missed link](./filtered3.md)
@@ -18,6 +18,9 @@ Empty local title
18
18
  Special local title
19
19
  [{#T}](#header)
20
20
 
21
+ Circular title
22
+ [{#T}](./autotitle.md#header)
23
+
21
24
  ## Header {#header}
22
25
 
23
26
  Content
@@ -0,0 +1,9 @@
1
+ title: Documentation
2
+ description: ""
3
+ meta:
4
+ title: Documentation
5
+ noIndex: true
6
+ links:
7
+ - title: Getting started with Documentation
8
+ description: This guide will show you the basics of working with Documentation
9
+ href: page.md
@@ -0,0 +1,14 @@
1
+ ---
2
+ title: Page Title
3
+ description: Some test description
4
+
5
+ interface:
6
+ toc: false
7
+ favicon-src: /favicon.ico
8
+
9
+ metadata:
10
+ - name: yfm
11
+ content: builder in page
12
+ ---
13
+
14
+ Lorem
@@ -0,0 +1,7 @@
1
+ title: Documentation
2
+ href: index.yaml
3
+ items:
4
+ - name: Documentation
5
+ href: page.md
6
+ - name: Config
7
+ href: project/config.md
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diplodoc/cli-tests",
3
- "version": "0.0.0-rc-liquid-conditions-saving-202509050811",
3
+ "version": "0.0.0-rc-resolve-codeblock-202509151421",
4
4
  "bin": {
5
5
  "diplodoc-cli-test": "bin.mjs"
6
6
  },
@@ -1,37 +0,0 @@
1
- [existing file](./exists.md)
2
- <!-- [missed file](./missed.md) -->
3
- {% if prod == true %}Test text{% endif %}
4
-
5
- {% if inner == true %}inner test text{% endif %}
6
-
7
- {% if prod == true %}Test text{% if inner == true %}inner test text{% endif %}{% endif %}
8
-
9
- {% if prod == true %}
10
-
11
- {% if list contains "item" %}
12
-
13
- #### List
14
-
15
- {% if item == true %}1. Item {% endif %}
16
-
17
- Some text
18
-
19
- {% endif %}
20
-
21
- {% endif %}
22
-
23
- #### Standalone contains condition
24
-
25
- {% if list contains "item" %}
26
-
27
- #### List
28
-
29
- {% endif %}
30
-
31
- #### Inline contains condition
32
-
33
- {% if prod == true %}
34
-
35
- #### List {% if list contains "item" %} sub text {% endif %}
36
-
37
- {% endif %}