@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.
- package/e2e/__snapshots__/bundles.spec.ts.snap +168 -0
- package/e2e/__snapshots__/include-toc.test.ts.snap +34 -0
- package/e2e/__snapshots__/load-custom-resources.spec.ts.snap +15 -106
- package/e2e/__snapshots__/metadata.spec.ts.snap +9 -47
- package/e2e/__snapshots__/plugin-corner-cases.spec.ts.snap +0 -0
- package/e2e/__snapshots__/preprocess.test.ts.snap +32 -0
- package/e2e/__snapshots__/regression.test.ts.snap +59 -211
- package/e2e/__snapshots__/restricted-access.test.ts.snap +20 -0
- package/e2e/__snapshots__/rtl.spec.ts.snap +6 -105
- package/e2e/__snapshots__/search.test.ts.snap +1 -31
- package/e2e/__snapshots__/single-page.spec.ts.snap +157 -0
- package/e2e/__snapshots__/skip-html-extension.spec.ts.snap +4 -63
- package/e2e/__snapshots__/translation.spec.ts.snap +183 -1416
- package/e2e/bundles.spec.ts +15 -0
- package/e2e/single-page.spec.ts +22 -0
- package/e2e/translation.spec.ts +0 -26
- package/fixtures/utils/file.ts +49 -6
- package/mocks/bundles/input/.yfm +13 -0
- package/mocks/bundles/input/index.md +12 -0
- package/mocks/bundles/input/page1.md +3 -0
- package/mocks/bundles/input/page2.md +5 -0
- package/mocks/bundles/input/toc.yaml +9 -0
- package/mocks/errors/extract-filtered-link/input/index.md +1 -1
- package/mocks/regression/input/autotitle.md +3 -0
- package/mocks/single-page/input/ru/index.yaml +9 -0
- package/mocks/single-page/input/ru/page.md +14 -0
- package/mocks/single-page/input/ru/project/config.md +1 -0
- package/mocks/single-page/input/ru/toc.yaml +7 -0
- package/package.json +1 -1
- 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
|
+
});
|
package/e2e/translation.spec.ts
CHANGED
|
@@ -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
|
});
|
package/fixtures/utils/file.ts
CHANGED
|
@@ -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
|
-
!
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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 @@
|
|
|
1
|
+
Lorem
|
package/package.json
CHANGED
|
@@ -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 %}
|