@salesforcedevs/sfdocs-e2e 1.0.5-alpha → 1.0.6-alpha
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/package.json +2 -1
- package/src/shared/specs/liquid.test.ts +73 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/sfdocs-e2e",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6-alpha",
|
|
4
4
|
"description": "E2E test suite for SFDocs static portal pages (SSG)",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"bin": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@wdio/spec-reporter": "^7.19.0",
|
|
32
32
|
"allure-commandline": "2.20.1",
|
|
33
33
|
"got": "^11.8.3",
|
|
34
|
+
"gray-matter": "~4.0.3",
|
|
34
35
|
"ts-node": "^10.9.1",
|
|
35
36
|
"typescript": "^4.1.3",
|
|
36
37
|
"wdio-video-reporter": "^3.4.0",
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import GuidePage from '../pageobjects/guide.page';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import * as matter from 'gray-matter';
|
|
2
5
|
|
|
3
6
|
let page: GuidePage;
|
|
4
7
|
let liquidEnabled = false;
|
|
@@ -6,28 +9,21 @@ let liquidEnabled = false;
|
|
|
6
9
|
describe('Liquid Template Rendering', () => {
|
|
7
10
|
before(async () => {
|
|
8
11
|
try {
|
|
12
|
+
// Check frontmatter to determine if Liquid is enabled
|
|
13
|
+
const contentPath = path.resolve(
|
|
14
|
+
__dirname,
|
|
15
|
+
'../../../../example-repository/content/en-us/liquid-project/guides/liquid-quickstart.md',
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
if (fs.existsSync(contentPath)) {
|
|
19
|
+
const fileContent = fs.readFileSync(contentPath, 'utf-8');
|
|
20
|
+
const { data: frontmatter } = matter(fileContent);
|
|
21
|
+
liquidEnabled = frontmatter?.liquid?.enabled === true;
|
|
22
|
+
}
|
|
23
|
+
|
|
9
24
|
page = new GuidePage('/docs/liquid-project/guide/liquid-quickstart.html');
|
|
10
25
|
page.open();
|
|
11
26
|
await page.waitPageLoad();
|
|
12
|
-
|
|
13
|
-
const content = await $('>>>doc-content-layout');
|
|
14
|
-
const html = await content.getHTML();
|
|
15
|
-
const text = await content.getText();
|
|
16
|
-
|
|
17
|
-
const hasLiquidOutput = text.includes('Hello from data.yaml');
|
|
18
|
-
|
|
19
|
-
const hasRawSyntax =
|
|
20
|
-
html.includes('{{ data.greeting }}') ||
|
|
21
|
-
html.includes('{{ topic }}') ||
|
|
22
|
-
(html.includes('{{') && html.includes('{%'));
|
|
23
|
-
|
|
24
|
-
if (hasRawSyntax) {
|
|
25
|
-
liquidEnabled = false;
|
|
26
|
-
} else if (hasLiquidOutput) {
|
|
27
|
-
liquidEnabled = true;
|
|
28
|
-
} else {
|
|
29
|
-
liquidEnabled = false;
|
|
30
|
-
}
|
|
31
27
|
} catch (e) {
|
|
32
28
|
liquidEnabled = false;
|
|
33
29
|
}
|
|
@@ -91,4 +87,62 @@ describe('Liquid Template Rendering', () => {
|
|
|
91
87
|
expect(html.includes('{%- for')).toBeFalsy();
|
|
92
88
|
expect(html.includes('{% endfor')).toBeFalsy();
|
|
93
89
|
});
|
|
90
|
+
|
|
91
|
+
it('Should not process Liquid syntax inside code blocks', async function () {
|
|
92
|
+
if (!liquidEnabled) {
|
|
93
|
+
this.skip();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const content = await $('>>>doc-content-layout');
|
|
97
|
+
const html = await content.getHTML();
|
|
98
|
+
const codeBlock = await content.$('code');
|
|
99
|
+
|
|
100
|
+
expect(await codeBlock.isExisting()).toBeTruthy();
|
|
101
|
+
|
|
102
|
+
const codeHtml = await codeBlock.getHTML();
|
|
103
|
+
expect(codeHtml.includes('{{ data.greeting }}')).toBeTruthy();
|
|
104
|
+
expect(codeHtml.includes('{{ topic }}')).toBeTruthy();
|
|
105
|
+
expect(codeHtml.includes('{% for item in items %}')).toBeTruthy();
|
|
106
|
+
|
|
107
|
+
const text = await content.getText();
|
|
108
|
+
expect(text.includes('Visit')).toBeTruthy();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('Should render capture blocks from included files', async function () {
|
|
112
|
+
if (!liquidEnabled) {
|
|
113
|
+
this.skip();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const content = await $('>>>doc-content-layout');
|
|
117
|
+
const html = await content.getHTML();
|
|
118
|
+
const text = await content.getText();
|
|
119
|
+
|
|
120
|
+
expect(text.includes('My Heading')).toBeTruthy();
|
|
121
|
+
expect(text.includes('This is content for ID1.')).toBeTruthy();
|
|
122
|
+
expect(text.includes('Another Heading')).toBeTruthy();
|
|
123
|
+
expect(text.includes('Content for ID2.')).toBeTruthy();
|
|
124
|
+
|
|
125
|
+
expect(html.includes('{%- capture')).toBeFalsy();
|
|
126
|
+
expect(html.includes('{% endcapture')).toBeFalsy();
|
|
127
|
+
expect(html.includes('{{ id1 }}')).toBeFalsy();
|
|
128
|
+
expect(html.includes('{{ id2 }}')).toBeFalsy();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('Should not process Liquid when frontmatter has liquid.enabled as false', async function () {
|
|
132
|
+
if (!liquidEnabled) {
|
|
133
|
+
this.skip();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const disabledPage = new GuidePage(
|
|
137
|
+
'/docs/liquid-project/guide/liquid-learning-resources.html',
|
|
138
|
+
);
|
|
139
|
+
disabledPage.open();
|
|
140
|
+
await disabledPage.waitPageLoad();
|
|
141
|
+
|
|
142
|
+
const content = await $('>>>doc-content-layout');
|
|
143
|
+
const text = await content.getText();
|
|
144
|
+
|
|
145
|
+
expect(text.includes('Liquid Resource')).toBeTruthy();
|
|
146
|
+
expect(text.includes('Liquid is a templating language supported in SFDocs')).toBeTruthy();
|
|
147
|
+
});
|
|
94
148
|
});
|