Skip to content

Commit 661a702

Browse files
committed
Fix out of order embedding of files
- added double quote as attribute marker - fixed inject order of embedded files - added e2e test covering order of embedded files
1 parent eb1a3ce commit 661a702

15 files changed

+93
-18
lines changed

cypress/inline/embed-order.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Embedded file order
2+
3+
Then the content of `delayed.md` `non-delayed.md` and will be displayed directly here in correct order
4+
5+
[delayed](_media/delayed.md ':include')
6+
7+
---
8+
9+
[non-delayed](_media/non-delayed.md ':include')
10+
11+
You can check the original content for [delayed.md](_media/delayed.md ':ignore'), [non-delayed.md](_media/non-delayed.md ':ignore').

cypress/integration/sidebar/config.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ context('sidebar.configurations', () => {
326326
const embedFilesIds = [
327327
'embedded-file-type',
328328
'embedded-code-fragments',
329+
'embedded-file-order',
329330
'tag-attribute',
330331
'the-code-block-highlight',
331332
];
@@ -336,7 +337,7 @@ context('sidebar.configurations', () => {
336337
cy.get(`a.section-link[href='#/embed-files?id=${id}']`)
337338
.click()
338339
.then(() => {
339-
cy.wait(500);
340+
cy.wait(750);
340341
cy.matchImageSnapshot();
341342
});
342343
});

cypress/live.server.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ console.log('[e2e tests] : args passed to live server', args)
77
const params = {
88
port: args[0] || 3000,
99
root: args[1] || fixturePath,
10-
open: false
10+
open: false,
11+
middleware: [
12+
function(req, res, next) {
13+
if (req.url === '/_media/delayed.md') {
14+
setTimeout(next, 250);
15+
} else {
16+
next();
17+
}
18+
},
19+
],
1120
// NoBrowser: true
12-
}
13-
LiveServer.start(params)
21+
};
22+
LiveServer.start(params)

cypress/setup.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ const setup = async () => {
2323
// 1
2424
const docsPath = path.join(process.cwd(), './docs')
2525
const fixtureDocsPath = path.join(__dirname, './fixtures/docs')
26+
const embeddedFiles = [
27+
{
28+
tag: '## Tag attribute',
29+
srcFile: 'embed-order.md',
30+
dstFile: 'embed-files.md',
31+
},
32+
];
2633

2734
// 1.1
2835
console.log('[cypress test docs] Copying the docs --> cypress/fixtures/docs')
@@ -38,6 +45,21 @@ const setup = async () => {
3845
copyDir.sync(fromPath, toPath)
3946
})
4047

48+
// 1.3
49+
embeddedFiles.forEach(({ tag, srcFile, dstFile }) => {
50+
const content = fs.readFileSync(`${__dirname}/inline/${srcFile}`).toString();
51+
const originalFile = `${fixtureDocsPath}/${dstFile}`;
52+
53+
let originalContent = fs
54+
.readFileSync(originalFile)
55+
.toString()
56+
.split('\n');
57+
const tagLine = originalContent.findIndex(l => l.indexOf(tag) >= 0);
58+
originalContent.splice(tagLine, 0, content);
59+
60+
fs.writeFileSync(originalFile, originalContent.join('\n'));
61+
});
62+
4163
// 2
4264
console.log(
4365
'[cypress test docs] Replacing content the tpl/index.html --> cypress/fixtures/docs/index.html'

0 commit comments

Comments
 (0)