@diplodoc/cli-tests 5.20.0 → 5.20.1

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.
@@ -0,0 +1,71 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`Cleanup empty directories with stage filtering > should cleanup directories that contain only presets.yaml when TOC is ignored by stage 1`] = `
4
+ "ignoreStage:
5
+ - internal"
6
+ `;
7
+
8
+ exports[`Cleanup empty directories with stage filtering > should cleanup directories that contain only presets.yaml when TOC is ignored by stage 2`] = `
9
+ "---
10
+ metadata:
11
+ - name: generator
12
+ content: Diplodoc Platform vDIPLODOC-VERSION
13
+ vcsPath: active/page.md
14
+ ---
15
+ # Active Page
16
+
17
+ This is an active page that should be included in the build.
18
+
19
+ Active variable: {{active_var}}"
20
+ `;
21
+
22
+ exports[`Cleanup empty directories with stage filtering > should cleanup directories that contain only presets.yaml when TOC is ignored by stage 3`] = `
23
+ "default:
24
+ active_var: active_value
25
+ "
26
+ `;
27
+
28
+ exports[`Cleanup empty directories with stage filtering > should cleanup directories that contain only presets.yaml when TOC is ignored by stage 4`] = `
29
+ "title: Active Section
30
+ items:
31
+ - name: Active Page
32
+ href: page.md
33
+ path: active/toc.yaml
34
+ "
35
+ `;
36
+
37
+ exports[`Cleanup empty directories with stage filtering > should cleanup directories that contain only presets.yaml when TOC is ignored by stage 5`] = `
38
+ "default:
39
+ empty_var: empty_value
40
+ "
41
+ `;
42
+
43
+ exports[`Cleanup empty directories with stage filtering > should cleanup directories that contain only presets.yaml when TOC is ignored by stage 6`] = `
44
+ "---
45
+ metadata:
46
+ - name: generator
47
+ content: Diplodoc Platform vDIPLODOC-VERSION
48
+ vcsPath: index.md
49
+ ---
50
+ # Main Page
51
+
52
+ This is the main page content.
53
+
54
+ Root variable: {{root_var}}"
55
+ `;
56
+
57
+ exports[`Cleanup empty directories with stage filtering > should cleanup directories that contain only presets.yaml when TOC is ignored by stage 7`] = `
58
+ "default:
59
+ root_var: root_value
60
+ "
61
+ `;
62
+
63
+ exports[`Cleanup empty directories with stage filtering > should cleanup directories that contain only presets.yaml when TOC is ignored by stage 8`] = `
64
+ "title: Test Documentation
65
+ href: index.md
66
+ items:
67
+ - name: Active Section
68
+ href: active/page.md
69
+ path: toc.yaml
70
+ "
71
+ `;
@@ -0,0 +1,59 @@
1
+ import {describe, expect, test} from 'vitest';
2
+ import {existsSync} from 'node:fs';
3
+ import {resolve} from 'node:path';
4
+
5
+ import {TestAdapter, compareDirectories, getTestPaths} from '../fixtures';
6
+
7
+ describe('Cleanup empty directories with stage filtering', () => {
8
+ test('should cleanup directories that contain only presets.yaml when TOC is ignored by stage', async () => {
9
+ const {inputPath, outputPath} = getTestPaths('mocks/cleanup-empty-dirs');
10
+
11
+ // Test with disabled templating to trigger cleanupEmptyDirectories
12
+ await TestAdapter.testBuildPass(inputPath, outputPath, {
13
+ md2md: true,
14
+ args: '--no-template',
15
+ });
16
+
17
+ // Verify that the output directory structure is correct
18
+ await compareDirectories(outputPath, false, false, true);
19
+
20
+ // Check that active section files are present
21
+ expect(existsSync(resolve(outputPath, 'active/page.md'))).toBe(true);
22
+ expect(existsSync(resolve(outputPath, 'active/presets.yaml'))).toBe(true);
23
+ expect(existsSync(resolve(outputPath, 'active/toc.yaml'))).toBe(true);
24
+
25
+ expect(existsSync(resolve(outputPath, 'empty-section'))).toBe(true);
26
+ expect(existsSync(resolve(outputPath, 'empty-section/presets.yaml'))).toBe(true);
27
+
28
+ // Check that root files are present
29
+ expect(existsSync(resolve(outputPath, 'index.md'))).toBe(true);
30
+ expect(existsSync(resolve(outputPath, 'presets.yaml'))).toBe(true);
31
+ expect(existsSync(resolve(outputPath, 'toc.yaml'))).toBe(true);
32
+ });
33
+
34
+ test('should not cleanup directories when templating is enabled', async () => {
35
+ const {inputPath, outputPath} = getTestPaths('mocks/cleanup-empty-dirs');
36
+
37
+ // Test with enabled templating - cleanup should not be triggered
38
+ await TestAdapter.testBuildPass(inputPath, outputPath + '-with-template', {
39
+ md2md: true,
40
+ args: '', // Default template enabled
41
+ });
42
+
43
+ // Check that empty-section directory exists (cleanup should not be triggered)
44
+ expect(existsSync(resolve(outputPath + '-with-template', 'empty-section'))).toBe(false);
45
+ expect(
46
+ existsSync(resolve(outputPath + '-with-template', 'empty-section/presets.yaml')),
47
+ ).toBe(false);
48
+
49
+ // Check that active section files are present
50
+ expect(existsSync(resolve(outputPath + '-with-template', 'active/page.md'))).toBe(true);
51
+ expect(existsSync(resolve(outputPath + '-with-template', 'active/presets.yaml'))).toBe(
52
+ false,
53
+ );
54
+
55
+ // Check that root files are present
56
+ expect(existsSync(resolve(outputPath + '-with-template', 'index.md'))).toBe(true);
57
+ expect(existsSync(resolve(outputPath + '-with-template', 'presets.yaml'))).toBe(false);
58
+ });
59
+ });
@@ -32,8 +32,8 @@ function test(path: string, expect: Function, additionalArgs: string[] = []) {
32
32
  describe('Errors', () => {
33
33
  test('mocks/errors/unreachable-link', ({html}: TestResult) => {
34
34
  expectErrors(html, [
35
- 'ERR index.md: 1: YFM003 / unreachable-link Link is unreachable [Context: "Unreachable link: "exists.html"; Reason: File is not declared in toc; Line: [existing file](./exists.md)"]',
36
- 'ERR index.md: 2: YFM003 / unreachable-link Link is unreachable [Context: "Unreachable link: "missed.html"; Reason: File is not declared in toc; Line: [missed file](./missed.md)"]',
35
+ 'ERR index.md: 1: YFM003 / unreachable-link Link is unreachable [Context: "Unreachable link: "exists.html"; Reason: File is not declared in toc; Line: 1"]',
36
+ 'ERR index.md: 2: YFM003 / unreachable-link Link is unreachable [Context: "Unreachable link: "missed.html"; Reason: File is not declared in toc; Line: 2"]',
37
37
  ]);
38
38
  });
39
39
 
@@ -86,7 +86,7 @@ describe('Errors', () => {
86
86
  describe('Warnings', () => {
87
87
  test('mocks/warning/unreachable-autotitle', ({html}: TestResult) => {
88
88
  expectWarnings(html, [
89
- 'WARN index.md: 1: YFM010 / unreachable-autotitle-anchor Auto title anchor is unreachable [Context: "[Unreachable autotitle anchor: "link.html#unknown_yfm010"][{#T}](./link.md#unknown_yfm010)"]',
89
+ 'WARN index.md: 1: YFM010 / unreachable-autotitle-anchor Auto title anchor is unreachable [Context: "[Unreachable autotitle anchor: "link.html#unknown_yfm010"] [{#T}](./link.md#unknown_yfm010)"]',
90
90
  ]);
91
91
  });
92
92
  });
@@ -0,0 +1,2 @@
1
+ ignoreStage:
2
+ - internal
@@ -0,0 +1,5 @@
1
+ # Active Page
2
+
3
+ This is an active page that should be included in the build.
4
+
5
+ Active variable: {{active_var}}
@@ -0,0 +1,2 @@
1
+ default:
2
+ active_var: active_value
@@ -0,0 +1,4 @@
1
+ title: Active Section
2
+ items:
3
+ - name: Active Page
4
+ href: page.md
@@ -0,0 +1,5 @@
1
+ # Empty Page
2
+
3
+ This page should be ignored because the TOC has stage "internal".
4
+
5
+ Empty variable: {{empty_var}}
@@ -0,0 +1,2 @@
1
+ default:
2
+ empty_var: empty_value
@@ -0,0 +1,5 @@
1
+ title: Empty Section
2
+ stage: internal
3
+ items:
4
+ - name: Empty Page
5
+ href: page.md
@@ -0,0 +1,5 @@
1
+ # Main Page
2
+
3
+ This is the main page content.
4
+
5
+ Root variable: {{root_var}}
@@ -0,0 +1,2 @@
1
+ default:
2
+ root_var: root_value
@@ -0,0 +1,5 @@
1
+ title: Test Documentation
2
+ href: index.md
3
+ items:
4
+ - name: Active Section
5
+ href: active/page.md
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diplodoc/cli-tests",
3
- "version": "5.20.0",
3
+ "version": "5.20.1",
4
4
  "bin": {
5
5
  "diplodoc-cli-test": "bin.mjs"
6
6
  },