@salesforcedevs/sfdocs-e2e 1.0.5 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/sfdocs-e2e",
3
- "version": "1.0.5",
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",
@@ -0,0 +1,148 @@
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';
5
+
6
+ let page: GuidePage;
7
+ let liquidEnabled = false;
8
+
9
+ describe('Liquid Template Rendering', () => {
10
+ before(async () => {
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
+
24
+ page = new GuidePage('/docs/liquid-project/guide/liquid-quickstart.html');
25
+ page.open();
26
+ await page.waitPageLoad();
27
+ } catch (e) {
28
+ liquidEnabled = false;
29
+ }
30
+ });
31
+
32
+ beforeEach(async () => {
33
+ if (liquidEnabled) {
34
+ page = new GuidePage('/docs/liquid-project/guide/liquid-quickstart.html');
35
+ page.open();
36
+ await page.waitPageLoad();
37
+ }
38
+ });
39
+
40
+ it('Should render Liquid variables from frontmatter and data.yaml', async function () {
41
+ if (!liquidEnabled) {
42
+ this.skip();
43
+ }
44
+
45
+ const content = await $('>>>doc-content-layout');
46
+ const text = await content.getText();
47
+
48
+ expect(text.includes('GitHub for writers')).toBeTruthy();
49
+ expect(text.includes('Hello from data.yaml')).toBeTruthy();
50
+
51
+ const html = await content.getHTML();
52
+ expect(html.includes('{{ topic }}')).toBeFalsy();
53
+ expect(html.includes('{{ data.greeting }}')).toBeFalsy();
54
+ });
55
+
56
+ it('Should render included templates from shared directory', async function () {
57
+ if (!liquidEnabled) {
58
+ this.skip();
59
+ }
60
+
61
+ const content = await $('>>>doc-content-layout');
62
+ const html = await content.getHTML();
63
+
64
+ expect(html.includes('AccountId') || html.includes('Type:')).toBeTruthy();
65
+ expect(html.includes('Properties:')).toBeTruthy();
66
+ expect(html.includes('Special Access Rules')).toBeTruthy();
67
+ expect(html.includes('{% include')).toBeFalsy();
68
+ });
69
+
70
+ it('Should render loops over data arrays', async function () {
71
+ if (!liquidEnabled) {
72
+ this.skip();
73
+ }
74
+
75
+ const content = await $('>>>doc-content-layout');
76
+ const html = await content.getHTML();
77
+ const text = await content.getText();
78
+
79
+ expect(text.includes('create()')).toBeTruthy();
80
+ expect(text.includes('query()')).toBeTruthy();
81
+ expect(text.includes('update()')).toBeTruthy();
82
+
83
+ const listItems = await content.$$('li');
84
+ expect(listItems.length).toBeGreaterThan(5);
85
+
86
+ expect(html.includes('{% for')).toBeFalsy();
87
+ expect(html.includes('{%- for')).toBeFalsy();
88
+ expect(html.includes('{% endfor')).toBeFalsy();
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
+ });
148
+ });