@squiz/dxp-cli-next 5.31.0-develop.3 → 5.31.0-develop.5

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.
Files changed (38) hide show
  1. package/lib/cdp/instance/activate/activate.js +6 -7
  2. package/lib/cdp/instance/activate/activate.spec.js +2 -8
  3. package/lib/cdp/utils.d.ts +2 -1
  4. package/lib/cdp/utils.js +4 -2
  5. package/lib/page/layouts/deploy/deploy.js +43 -8
  6. package/lib/page/layouts/deploy/deploy.spec.js +110 -19
  7. package/lib/page/layouts/dev/dev.js +7 -3
  8. package/lib/page/layouts/dev/dev.spec.js +35 -8
  9. package/lib/page/layouts/validation/index.d.ts +2 -0
  10. package/lib/page/layouts/validation/index.js +5 -1
  11. package/lib/page/layouts/validation/property-consistency.d.ts +7 -0
  12. package/lib/page/layouts/validation/property-consistency.js +92 -0
  13. package/lib/page/layouts/validation/property-consistency.spec.d.ts +1 -0
  14. package/lib/page/layouts/validation/property-consistency.spec.js +305 -0
  15. package/lib/page/layouts/validation/validateLayoutFormat.d.ts +2 -0
  16. package/lib/page/layouts/validation/validateLayoutFormat.js +25 -0
  17. package/lib/page/layouts/validation/validateLayoutFormat.spec.d.ts +1 -0
  18. package/lib/page/layouts/validation/validateLayoutFormat.spec.js +40 -0
  19. package/lib/page/layouts/validation/zone-consistency.d.ts +1 -1
  20. package/lib/page/layouts/validation/zone-consistency.js +10 -9
  21. package/lib/page/layouts/validation/zone-consistency.spec.js +32 -34
  22. package/lib/page/utils/definitions.d.ts +346 -49
  23. package/lib/page/utils/definitions.js +102 -21
  24. package/lib/page/utils/definitions.spec.js +460 -267
  25. package/lib/page/utils/normalize.d.ts +8 -0
  26. package/lib/page/utils/normalize.js +61 -0
  27. package/lib/page/utils/normalize.spec.d.ts +1 -0
  28. package/lib/page/utils/normalize.spec.js +315 -0
  29. package/lib/page/utils/parse-args.d.ts +20 -4
  30. package/lib/page/utils/parse-args.js +48 -13
  31. package/lib/page/utils/parse-args.spec.js +159 -21
  32. package/lib/page/utils/render.d.ts +27 -9
  33. package/lib/page/utils/render.js +66 -12
  34. package/lib/page/utils/render.spec.js +14 -14
  35. package/lib/page/utils/server.d.ts +1 -1
  36. package/lib/page/utils/server.js +2 -2
  37. package/lib/page/utils/server.spec.js +13 -13
  38. package/package.json +1 -1
@@ -0,0 +1,305 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const property_consistency_1 = require("./property-consistency");
4
+ describe('validatePropertyConsistency', () => {
5
+ const createMockLayout = (layout) => (Object.assign({ name: 'test-layout', displayName: 'Test Layout', description: 'A test layout', zones: [], template: '' }, layout));
6
+ describe('new format (manifest.json)', () => {
7
+ it('should return null for valid property consistency', () => {
8
+ const layout = createMockLayout({
9
+ properties: {
10
+ title: {
11
+ type: 'string',
12
+ title: 'Title',
13
+ description: 'Page title',
14
+ },
15
+ showHeader: {
16
+ type: 'boolean',
17
+ title: 'Show Header',
18
+ description: 'Whether to show header',
19
+ },
20
+ },
21
+ template: '<div>{{properties.title}}</div><div>{{#if properties.showHeader}}Header{{/if}}</div>',
22
+ });
23
+ const result = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/manifest.json');
24
+ expect(result).toBeNull();
25
+ });
26
+ it('should return null when no template is provided', () => {
27
+ const layout = createMockLayout({
28
+ properties: {
29
+ title: {
30
+ type: 'string',
31
+ title: 'Title',
32
+ description: 'Page title',
33
+ },
34
+ },
35
+ });
36
+ const result = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/manifest.json');
37
+ expect(result).toBeNull();
38
+ });
39
+ it('should return null when layout has empty properties object', () => {
40
+ const layout = createMockLayout({
41
+ properties: {},
42
+ template: '<div>Static content only</div>',
43
+ });
44
+ const result = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/manifest.json');
45
+ expect(result).toBeNull();
46
+ });
47
+ it('should return null when layout has undefined properties', () => {
48
+ const layout = createMockLayout({
49
+ template: '<div>Static content only</div>',
50
+ });
51
+ const result = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/manifest.json');
52
+ expect(result).toBeNull();
53
+ });
54
+ it('should allow properties that are defined in the layout, but not used in template', () => {
55
+ const layout = createMockLayout({
56
+ properties: {
57
+ title: {
58
+ type: 'string',
59
+ title: 'Title',
60
+ description: 'Page title',
61
+ },
62
+ unused: {
63
+ type: 'string',
64
+ title: 'Unused',
65
+ description: 'Unused property',
66
+ },
67
+ },
68
+ template: '<div>{{properties.title}}</div>',
69
+ });
70
+ const result = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/manifest.json');
71
+ expect(result).toBeNull();
72
+ });
73
+ it('should detect properties used in template but not defined in layout', () => {
74
+ const layout = createMockLayout({
75
+ properties: {
76
+ title: {
77
+ type: 'string',
78
+ title: 'Title',
79
+ description: 'Page title',
80
+ },
81
+ },
82
+ template: '<div>{{properties.title}}</div><div>{{properties.undefined}}</div>',
83
+ });
84
+ const result = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/manifest.json');
85
+ expect(result).toContain('Property consistency validation failed');
86
+ expect(result).toContain('Properties used in template but not defined in layout definition: undefined');
87
+ });
88
+ it('should handle both unused and undefined properties', () => {
89
+ const layout = createMockLayout({
90
+ properties: {
91
+ title: {
92
+ type: 'string',
93
+ title: 'Title',
94
+ description: 'Page title',
95
+ },
96
+ unused: {
97
+ type: 'string',
98
+ title: 'Unused',
99
+ description: 'Unused property',
100
+ },
101
+ },
102
+ template: '<div>{{properties.title}}</div><div>{{properties.undefined}}</div>',
103
+ });
104
+ const result = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/manifest.json');
105
+ expect(result).toContain('Property consistency validation failed');
106
+ expect(result).toContain('Properties used in template but not defined in layout definition: undefined');
107
+ });
108
+ it('should reject options usage in manifest.json format', () => {
109
+ const layout = createMockLayout({
110
+ properties: {
111
+ title: {
112
+ type: 'string',
113
+ title: 'Title',
114
+ description: 'Page title',
115
+ },
116
+ },
117
+ template: '<div>{{properties.title}}</div><div>{{options.invalid}}</div>',
118
+ });
119
+ const result = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/manifest.json');
120
+ expect(result).toContain('Property consistency validation failed');
121
+ expect(result).toContain('Options are not supported in the Handlebars template for a layout defined with "manifest.json". Please use properties instead.');
122
+ });
123
+ it('should handle complex Handlebars patterns', () => {
124
+ const layout = createMockLayout({
125
+ properties: {
126
+ title: {
127
+ type: 'string',
128
+ title: 'Title',
129
+ description: 'Page title',
130
+ },
131
+ showHeader: {
132
+ type: 'boolean',
133
+ title: 'Show Header',
134
+ description: 'Whether to show header',
135
+ },
136
+ theme: {
137
+ type: 'string',
138
+ title: 'Theme',
139
+ description: 'Page theme',
140
+ },
141
+ },
142
+ template: `
143
+ <div>{{properties.title}}</div>
144
+ <div>{{toLowerCase properties.title}}</div>
145
+ <div>
146
+ {{#if properties.showHeader}}
147
+ <header>Header</header>
148
+ {{/if}}
149
+ {{#ifEq "dark" properties.theme}}
150
+ <div class="dark">Dark theme</div>
151
+ {{/ifEq}}
152
+ </div>
153
+ `,
154
+ });
155
+ const manifestResult = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/manifest.json');
156
+ expect(manifestResult).toBeNull();
157
+ const pageLayoutResult = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/page-layout.yaml');
158
+ expect(pageLayoutResult).toContain('Option consistency validation failed');
159
+ expect(pageLayoutResult).toContain('Properties are only allowed in the Handlebars template for a layout defined with "manifest.json". Please use options instead.');
160
+ });
161
+ });
162
+ describe('old format (page-layout.yaml)', () => {
163
+ it('should return null for valid option consistency', () => {
164
+ const layout = createMockLayout({
165
+ properties: {
166
+ title: {
167
+ type: 'string',
168
+ title: 'Title',
169
+ description: 'Page title',
170
+ },
171
+ showHeader: {
172
+ type: 'boolean',
173
+ title: 'Show Header',
174
+ description: 'Whether to show header',
175
+ },
176
+ },
177
+ template: '<div>{{options.title}}</div><div>{{#if options.showHeader}}Header{{/if}}</div>',
178
+ });
179
+ const result = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/page-layout.yaml');
180
+ expect(result).toBeNull();
181
+ });
182
+ it('should allow options that are defined in the layout, but not used in template', () => {
183
+ const layout = createMockLayout({
184
+ properties: {
185
+ title: {
186
+ type: 'string',
187
+ title: 'Title',
188
+ description: 'Page title',
189
+ },
190
+ unused: {
191
+ type: 'string',
192
+ title: 'Unused',
193
+ description: 'Unused option',
194
+ },
195
+ },
196
+ template: '<div>{{options.title}}</div>',
197
+ });
198
+ const result = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/page-layout.yaml');
199
+ expect(result).toBeNull();
200
+ });
201
+ it('should detect options used in template but not defined in layout', () => {
202
+ const layout = createMockLayout({
203
+ properties: {
204
+ title: {
205
+ type: 'string',
206
+ title: 'Title',
207
+ description: 'Page title',
208
+ },
209
+ },
210
+ template: '<div>{{options.title}}</div><div>{{options.undefined}}</div>',
211
+ });
212
+ const result = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/page-layout.yaml');
213
+ expect(result).toContain('Option consistency validation failed');
214
+ expect(result).toContain('Options used in template but not defined in layout definition: undefined');
215
+ });
216
+ it('should reject properties usage in old format', () => {
217
+ const layout = createMockLayout({
218
+ properties: {
219
+ title: {
220
+ type: 'string',
221
+ title: 'Title',
222
+ description: 'Page title',
223
+ },
224
+ },
225
+ template: '<div>{{options.title}}</div><div>{{properties.invalid}}</div>',
226
+ });
227
+ const result = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/page-layout.yaml');
228
+ expect(result).toContain('Option consistency validation failed');
229
+ expect(result).toContain('Properties are only allowed in the Handlebars template for a layout defined with "manifest.json". Please use options instead.');
230
+ });
231
+ it('should handle complex Handlebars patterns', () => {
232
+ const layout = createMockLayout({
233
+ properties: {
234
+ title: {
235
+ type: 'string',
236
+ title: 'Title',
237
+ description: 'Page title',
238
+ },
239
+ showHeader: {
240
+ type: 'boolean',
241
+ title: 'Show Header',
242
+ description: 'Whether to show header',
243
+ },
244
+ theme: {
245
+ type: 'string',
246
+ title: 'Theme',
247
+ description: 'Page theme',
248
+ },
249
+ },
250
+ template: `
251
+ <div>{{options.title}}</div>
252
+ <div>{{toLowerCase options.title}}</div>
253
+ <div>
254
+ {{#if options.showHeader}}
255
+ <header>Header</header>
256
+ {{/if}}
257
+ {{#ifEq "dark" options.theme}}
258
+ <div class="dark">Dark theme</div>
259
+ {{/ifEq}}
260
+ </div>
261
+ `,
262
+ });
263
+ const pageLayoutResult = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/page-layout.yaml');
264
+ expect(pageLayoutResult).toBeNull();
265
+ const manifestResult = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/manifest.json');
266
+ expect(manifestResult).toContain('Property consistency validation failed');
267
+ expect(manifestResult).toContain('Options are not supported in the Handlebars template for a layout defined with "manifest.json". Please use properties instead.');
268
+ });
269
+ });
270
+ describe('edge cases', () => {
271
+ it('should handle multiple property references in same template', () => {
272
+ const layout = createMockLayout({
273
+ properties: {
274
+ title: {
275
+ type: 'string',
276
+ title: 'Title',
277
+ description: 'Page title',
278
+ },
279
+ },
280
+ template: '<div>{{properties.title}}</div><div>{{properties.title}}</div><div>{{#if properties.title}}Yes{{/if}}</div>',
281
+ });
282
+ const result = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/manifest.json');
283
+ expect(result).toBeNull();
284
+ });
285
+ it('should handle property names with different casing', () => {
286
+ const layout = createMockLayout({
287
+ properties: {
288
+ title: {
289
+ type: 'string',
290
+ title: 'Title',
291
+ description: 'Page title',
292
+ },
293
+ Title: {
294
+ type: 'string',
295
+ title: 'Title Capitalized',
296
+ description: 'Title with capital T',
297
+ },
298
+ },
299
+ template: '<div>{{properties.title}}</div><div>{{properties.Title}}</div>',
300
+ });
301
+ const result = (0, property_consistency_1.validatePropertyConsistency)(layout, '/path/to/manifest.json');
302
+ expect(result).toBeNull();
303
+ });
304
+ });
305
+ });
@@ -0,0 +1,2 @@
1
+ import { Logger } from '@squiz/dx-logger-lib';
2
+ export declare function validateLayoutFormat(logger: Logger, layoutFile?: string): void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.validateLayoutFormat = void 0;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const definitions_1 = require("../../utils/definitions");
9
+ function validateLayoutFormat(logger, layoutFile) {
10
+ // Warn that the default layout file has been changed
11
+ if (!layoutFile) {
12
+ logger.warn(`⚠️ DEFAULT CONFIG FILE: "${definitions_1.LAYOUT_MANIFEST_FILE}" has replaced "page-layout.yaml" as the default config file. ` +
13
+ `Please migrate to "${definitions_1.LAYOUT_MANIFEST_FILE}" using the new layout definition format. ` +
14
+ 'Support for "page-layout.yaml" and any other file format will be removed in a future version. ');
15
+ return;
16
+ }
17
+ // Warn that any file other than manifest.json is deprecated
18
+ const fileName = node_path_1.default.basename(layoutFile);
19
+ if (fileName !== definitions_1.LAYOUT_MANIFEST_FILE) {
20
+ logger.warn(`⚠️ DEPRECATED: The file name "${fileName}" is deprecated. ` +
21
+ `Please migrate to "${definitions_1.LAYOUT_MANIFEST_FILE}" using the new layout definition format. ` +
22
+ 'Support for any other file format will be removed in a future version. ');
23
+ }
24
+ }
25
+ exports.validateLayoutFormat = validateLayoutFormat;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const validateLayoutFormat_1 = require("./validateLayoutFormat");
4
+ const definitions_1 = require("../../utils/definitions");
5
+ describe('validateLayoutFormat', () => {
6
+ let mockLogger;
7
+ beforeEach(() => {
8
+ mockLogger = {
9
+ warn: jest.fn(),
10
+ };
11
+ });
12
+ afterEach(() => {
13
+ jest.clearAllMocks();
14
+ });
15
+ it('should not log a warning when file is manifest.json', () => {
16
+ const layoutFile = `/some/path/${definitions_1.LAYOUT_MANIFEST_FILE}`;
17
+ (0, validateLayoutFormat_1.validateLayoutFormat)(mockLogger, layoutFile);
18
+ expect(mockLogger.warn).not.toHaveBeenCalled();
19
+ });
20
+ it('should log a deprecation warning when file is not manifest.json', () => {
21
+ const layoutFile = '/some/path/page-layout.yaml';
22
+ (0, validateLayoutFormat_1.validateLayoutFormat)(mockLogger, layoutFile);
23
+ expect(mockLogger.warn).toHaveBeenCalledTimes(1);
24
+ expect(mockLogger.warn).toHaveBeenCalledWith('⚠️ DEPRECATED: The file name "page-layout.yaml" is deprecated. ' +
25
+ `Please migrate to "${definitions_1.LAYOUT_MANIFEST_FILE}" using the new layout definition format. ` +
26
+ 'Support for any other file format will be removed in a future version. ');
27
+ });
28
+ it('should extract filename correctly from full path', () => {
29
+ const layoutFile = '/very/deep/nested/path/to/layout/page-layout.yaml';
30
+ (0, validateLayoutFormat_1.validateLayoutFormat)(mockLogger, layoutFile);
31
+ expect(mockLogger.warn).toHaveBeenCalledWith(expect.stringContaining('"page-layout.yaml"'));
32
+ });
33
+ it('should log a default config file warning when file is not provided', () => {
34
+ (0, validateLayoutFormat_1.validateLayoutFormat)(mockLogger);
35
+ expect(mockLogger.warn).toHaveBeenCalledTimes(1);
36
+ expect(mockLogger.warn).toHaveBeenCalledWith('⚠️ DEFAULT CONFIG FILE: "manifest.json" has replaced "page-layout.yaml" as the default config file. ' +
37
+ `Please migrate to "${definitions_1.LAYOUT_MANIFEST_FILE}" using the new layout definition format. ` +
38
+ 'Support for "page-layout.yaml" and any other file format will be removed in a future version. ');
39
+ });
40
+ });
@@ -1,6 +1,6 @@
1
1
  import { LayoutDefinition } from '../../utils/definitions';
2
2
  /**
3
- * Validates that zones defined in YAML match zones used in the Handlebars template
3
+ * Validates that zones defined in layout definition match zones used in the Handlebars template
4
4
  * @param layout The layout definition containing zones and template
5
5
  * @returns Error message if validation fails, null if validation passes
6
6
  */
@@ -2,12 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateZoneConsistency = void 0;
4
4
  /**
5
- * Validates that zones defined in YAML match zones used in the Handlebars template
5
+ * Validates that zones defined in layout definition match zones used in the Handlebars template
6
6
  * @param layout The layout definition containing zones and template
7
7
  * @returns Error message if validation fails, null if validation passes
8
8
  */
9
9
  function validateZoneConsistency(layout) {
10
- const yamlZones = Object.keys(layout.zones || {});
10
+ var _a, _b;
11
+ const layoutZones = (_b = (_a = layout.zones) === null || _a === void 0 ? void 0 : _a.map(zone => zone.key)) !== null && _b !== void 0 ? _b : [];
11
12
  const template = layout.template;
12
13
  // If no template is provided, skip validation
13
14
  if (!template) {
@@ -24,19 +25,19 @@ function validateZoneConsistency(layout) {
24
25
  }
25
26
  // Convert the set to an array
26
27
  const templateZoneArray = Array.from(templateZones);
27
- // Find zones defined in YAML but not used in template
28
- const unusedYamlZones = yamlZones.filter(zone => !templateZones.has(zone));
29
- // Find zones used in template but not defined in YAML
30
- const undefinedTemplateZones = templateZoneArray.filter(zone => !yamlZones.includes(zone));
28
+ // Find zones defined in layout definition but not used in template
29
+ const unusedLayoutZones = layoutZones.filter(zone => !templateZones.has(zone));
30
+ // Find zones used in template but not defined in layout definition
31
+ const undefinedTemplateZones = templateZoneArray.filter(zone => !layoutZones.includes(zone));
31
32
  // Create an array of errors
32
33
  const errors = [];
33
34
  // Add the unused zones to the errors
34
- if (unusedYamlZones.length > 0) {
35
- errors.push(`Zones defined in YAML but not used in template: ${unusedYamlZones.join(', ')}`);
35
+ if (unusedLayoutZones.length > 0) {
36
+ errors.push(`Zones defined in layout definition but not used in template: ${unusedLayoutZones.join(', ')}`);
36
37
  }
37
38
  // Add the undefined zones to the errors
38
39
  if (undefinedTemplateZones.length > 0) {
39
- errors.push(`Zones used in template but not defined in YAML: ${undefinedTemplateZones.join(', ')}`);
40
+ errors.push(`Zones used in template but not defined in layout definition: ${undefinedTemplateZones.join(', ')}`);
40
41
  }
41
42
  // If there are errors, return the errors
42
43
  if (errors.length > 0) {
@@ -10,67 +10,65 @@ describe('validateZoneConsistency', () => {
10
10
  template,
11
11
  });
12
12
  it('should return null for valid zone consistency', () => {
13
- const layout = createMockLayout({
14
- header: { displayName: 'Header', description: 'Header zone' },
15
- content: { displayName: 'Content', description: 'Content zone' },
16
- }, '<div>{{zones.header}}</div><div>{{zones.content}}</div>');
13
+ const layout = createMockLayout([
14
+ { key: 'header', displayName: 'Header', description: 'Header zone' },
15
+ { key: 'content', displayName: 'Content', description: 'Content zone' },
16
+ ], '<div>{{zones.header}}</div><div>{{zones.content}}</div>');
17
17
  const result = (0, zone_consistency_1.validateZoneConsistency)(layout);
18
18
  expect(result).toBeNull();
19
19
  });
20
20
  it('should return null when no template is provided', () => {
21
- const layout = createMockLayout({
22
- header: { displayName: 'Header', description: 'Header zone' },
23
- }, '');
21
+ const layout = createMockLayout([{ key: 'header', displayName: 'Header', description: 'Header zone' }], '');
24
22
  const result = (0, zone_consistency_1.validateZoneConsistency)(layout);
25
23
  expect(result).toBeNull();
26
24
  });
27
25
  it('should detect zones defined in YAML but not used in template', () => {
28
- const layout = createMockLayout({
29
- header: { displayName: 'Header', description: 'Header zone' },
30
- sidebar: { displayName: 'Sidebar', description: 'Sidebar zone' },
31
- }, '<div>{{zones.header}}</div>');
26
+ const layout = createMockLayout([
27
+ { key: 'header', displayName: 'Header', description: 'Header zone' },
28
+ { key: 'sidebar', displayName: 'Sidebar', description: 'Sidebar zone' },
29
+ ], '<div>{{zones.header}}</div>');
32
30
  const result = (0, zone_consistency_1.validateZoneConsistency)(layout);
33
31
  expect(result).toContain('Zone consistency validation failed');
34
- expect(result).toContain('Zones defined in YAML but not used in template: sidebar');
32
+ expect(result).toContain('Zones defined in layout definition but not used in template: sidebar');
35
33
  });
36
34
  it('should detect zones used in template but not defined in YAML', () => {
37
- const layout = createMockLayout({
38
- header: { displayName: 'Header', description: 'Header zone' },
39
- }, '<div>{{zones.header}}</div><div>{{zones.footer}}</div>');
35
+ const layout = createMockLayout([{ key: 'header', displayName: 'Header', description: 'Header zone' }], '<div>{{zones.header}}</div><div>{{zones.footer}}</div>');
40
36
  const result = (0, zone_consistency_1.validateZoneConsistency)(layout);
41
37
  expect(result).toContain('Zone consistency validation failed');
42
- expect(result).toContain('Zones used in template but not defined in YAML: footer');
38
+ expect(result).toContain('Zones used in template but not defined in layout definition: footer');
43
39
  });
44
40
  it('should detect both unused and undefined zones', () => {
45
- const layout = createMockLayout({
46
- header: { displayName: 'Header', description: 'Header zone' },
47
- sidebar: { displayName: 'Sidebar', description: 'Sidebar zone' },
48
- }, '<div>{{zones.header}}</div><div>{{zones.footer}}</div>');
41
+ const layout = createMockLayout([
42
+ { key: 'header', displayName: 'Header', description: 'Header zone' },
43
+ { key: 'sidebar', displayName: 'Sidebar', description: 'Sidebar zone' },
44
+ ], '<div>{{zones.header}}</div><div>{{zones.footer}}</div>');
49
45
  const result = (0, zone_consistency_1.validateZoneConsistency)(layout);
50
46
  expect(result).toContain('Zone consistency validation failed');
51
- expect(result).toContain('Zones defined in YAML but not used in template: sidebar');
52
- expect(result).toContain('Zones used in template but not defined in YAML: footer');
47
+ expect(result).toContain('Zones defined in layout definition but not used in template: sidebar');
48
+ expect(result).toContain('Zones used in template but not defined in layout definition: footer');
53
49
  });
54
50
  it('should handle Handlebars each loops', () => {
55
- const layout = createMockLayout({
56
- items: { displayName: 'Items', description: 'Items zone' },
57
- }, '<div>{{#each zones.items}}<p>{{this}}</p>{{/each}}</div>');
51
+ const layout = createMockLayout([{ key: 'items', displayName: 'Items', description: 'Items zone' }], '<div>{{#each zones.items}}<p>{{this}}</p>{{/each}}</div>');
58
52
  const result = (0, zone_consistency_1.validateZoneConsistency)(layout);
59
53
  expect(result).toBeNull();
60
54
  });
61
55
  it('should handle Handlebars if conditions', () => {
62
- const layout = createMockLayout({
63
- optional: { displayName: 'Optional', description: 'Optional zone' },
64
- }, '<div>{{#if zones.optional}}{{zones.optional}}{{/if}}</div>');
56
+ const layout = createMockLayout([
57
+ {
58
+ key: 'optional',
59
+ displayName: 'Optional',
60
+ description: 'Optional zone',
61
+ },
62
+ ], '<div>{{#if zones.optional}}{{zones.optional}}{{/if}}</div>');
65
63
  const result = (0, zone_consistency_1.validateZoneConsistency)(layout);
66
64
  expect(result).toBeNull();
67
65
  });
68
66
  it('should handle complex Handlebars patterns', () => {
69
- const layout = createMockLayout({
70
- header: { displayName: 'Header', description: 'Header zone' },
71
- content: { displayName: 'Content', description: 'Content zone' },
72
- sidebar: { displayName: 'Sidebar', description: 'Sidebar zone' },
73
- }, `
67
+ const layout = createMockLayout([
68
+ { key: 'header', displayName: 'Header', description: 'Header zone' },
69
+ { key: 'content', displayName: 'Content', description: 'Content zone' },
70
+ { key: 'sidebar', displayName: 'Sidebar', description: 'Sidebar zone' },
71
+ ], `
74
72
  <div>{{zones.header}}</div>
75
73
  <div>
76
74
  {{#if zones.sidebar}}
@@ -83,7 +81,7 @@ describe('validateZoneConsistency', () => {
83
81
  expect(result).toBeNull();
84
82
  });
85
83
  it('should handle empty zones object', () => {
86
- const layout = createMockLayout({}, '<div>Static content only</div>');
84
+ const layout = createMockLayout([], '<div>Static content only</div>');
87
85
  const result = (0, zone_consistency_1.validateZoneConsistency)(layout);
88
86
  expect(result).toBeNull();
89
87
  });