@lilaquadrat/design-core 0.2.1 → 0.3.0
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/README.md +76 -3
- package/html/index.server.html +1 -8
- package/package.json +54 -54
- package/src/client-entry.ts +8 -8
- package/src/components/partials/error.partial.vue +19 -19
- package/src/components/partials/main-components.partial.vue +75 -70
- package/src/components/partials/qrcode.partial.vue +8 -8
- package/src/functions/AuthProviderFactory.ts +30 -0
- package/src/functions/PaymenyProviderFactory.ts +11 -11
- package/src/functions/auth0.provider.ts +75 -0
- package/src/functions/keycloak.provider.ts +228 -0
- package/src/functions/lila-dom.ts +50 -50
- package/src/functions/shopify.provider.ts +176 -154
- package/src/functions/stripe.provider.ts +120 -108
- package/src/globals.d.ts +1 -2
- package/src/index.ts +9 -7
- package/src/interfaces/AuthCallbackResult.interface.ts +5 -0
- package/src/interfaces/AuthConfig.interface.ts +13 -0
- package/src/interfaces/AuthProvider.interface.ts +15 -0
- package/src/interfaces/FrontendConfig.interface.ts +11 -40
- package/src/interfaces/GenericEvents.interface.ts +1 -1
- package/src/interfaces/IdTokenExtended.interface.ts +13 -4
- package/src/interfaces/PaymentProvider.interface.ts +2 -2
- package/src/interfaces/RenderOptions.interface.ts +12 -0
- package/src/libs/ActionNotice.ts +125 -125
- package/src/libs/Models.class.ts +219 -221
- package/src/main.ts +41 -36
- package/src/mixins/createCookieString.ts +50 -36
- package/src/mixins/createModelDeclaration.ts +22 -19
- package/src/mixins/createRouter.ts +12 -12
- package/src/mixins/date.ts +4 -2
- package/src/mixins/formatSize.ts +5 -5
- package/src/mixins/getAnchor.ts +1 -1
- package/src/mixins/getRoutes.ts +13 -25
- package/src/mixins/hasSlotContent.ts +22 -16
- package/src/mixins/hooks.ts +101 -60
- package/src/mixins/loadComponents.ts +60 -58
- package/src/mixins/logger.ts +17 -13
- package/src/mixins/replaceVariables.ts +10 -8
- package/src/mixins/scroll.ts +61 -45
- package/src/models/Address.model.ts +7 -7
- package/src/models/Contact.model.ts +14 -14
- package/src/plugins/analytics.ts +198 -0
- package/src/plugins/auth.ts +74 -60
- package/src/plugins/currency.ts +10 -10
- package/src/plugins/events.ts +101 -97
- package/src/plugins/filters.ts +21 -18
- package/src/plugins/replacer.ts +7 -6
- package/src/plugins/signupFlow.ts +45 -43
- package/src/plugins/traceable.ts +28 -26
- package/src/plugins/translations.ts +9 -9
- package/src/plugins/youtube.ts +39 -34
- package/src/routes.ts +108 -108
- package/src/server-entry.ts +75 -77
- package/src/stores/calls.store.ts +14 -14
- package/src/stores/cart.store.ts +116 -107
- package/src/stores/content.store.ts +87 -45
- package/src/stores/editor.store.ts +16 -16
- package/src/stores/files.store.ts +72 -72
- package/src/stores/main.store.ts +155 -109
- package/src/stores/user.store.ts +72 -68
- package/src/translations/de.ts +127 -127
- package/src/views/content.view.vue +81 -143
- package/src/views/download.view.vue +25 -23
- package/src/views/editor.view.vue +150 -125
- package/src/views/login.view.vue +35 -36
- package/src/views/signup-account.view.vue +14 -14
- package/tooling/cypress/config.ts +68 -54
- package/tooling/cypress/manifest-utils.mjs +34 -22
- package/tooling/cypress/run-parallel.mjs +41 -35
- package/tooling/cypress/support/commands.ts +458 -300
- package/tooling/eslint.config.js +1 -223
- package/tooling/preview.plugin.js +132 -0
- package/tooling/ssr-test/index.mjs +205 -203
- package/tooling/vite.d.ts +36 -0
- package/tooling/vite.js +234 -0
- package/src/interfaces/EditorConfiguration.interface.ts +0 -15
- package/tooling/preview.plugin.ts +0 -134
- package/tooling/stylelint.config.mjs +0 -24
- package/tooling/vite.ts +0 -260
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="cypress" />
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
declare global {
|
|
4
4
|
namespace Cypress {
|
|
5
5
|
interface Chainable {
|
|
@@ -18,419 +18,577 @@ declare global {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
/* eslint-enable no-unused-vars */
|
|
22
|
-
|
|
23
21
|
Cypress.Commands.add('captureScreenSizes', (module: string, variant: string, ...args: string[]) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
|
|
23
|
+
const viewports = [
|
|
24
|
+
{ width: 375, height: 667, viewport: 'iphone-6' },
|
|
25
|
+
{ width: 768, height: 1024, viewport: 'tablet' },
|
|
26
|
+
{ width: 1366, height: 768, viewport: 'laptop' },
|
|
27
|
+
{ width: 1920, height: 1080, viewport: 'desktop' },
|
|
28
|
+
];
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
cy.document().then((doc) => {
|
|
36
|
-
const fullHeight = Math.max(
|
|
37
|
-
doc.body.scrollHeight,
|
|
38
|
-
doc.body.offsetHeight,
|
|
39
|
-
doc.documentElement.scrollHeight,
|
|
40
|
-
doc.documentElement.offsetHeight
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
if (fullHeight > viewport.height) {
|
|
44
|
-
cy.viewport(viewport.width, fullHeight);
|
|
30
|
+
viewports.forEach(viewport => {
|
|
31
|
+
|
|
32
|
+
cy.viewport(viewport.width, viewport.height);
|
|
45
33
|
cy.wait(200);
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
|
|
35
|
+
cy.document().then((doc) => {
|
|
36
|
+
|
|
37
|
+
const fullHeight = Math.max(
|
|
38
|
+
doc.body.scrollHeight,
|
|
39
|
+
doc.body.offsetHeight,
|
|
40
|
+
doc.documentElement.scrollHeight,
|
|
41
|
+
doc.documentElement.offsetHeight
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
if (fullHeight > viewport.height) {
|
|
45
|
+
|
|
46
|
+
cy.viewport(viewport.width, fullHeight);
|
|
47
|
+
cy.wait(200);
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
});
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
const variantLabel = `variant=${variant || 'default'}`;
|
|
54
|
+
const contentLabel = `content=${args.join('_')}`;
|
|
55
|
+
const screenLabel = `screen=${viewport.viewport}-${viewport.width}x${viewport.height}`;
|
|
52
56
|
|
|
53
|
-
|
|
57
|
+
cy.screenshot(`${module}/${variantLabel}--${contentLabel}--${screenLabel}`, { capture: 'fullPage', overwrite: true });
|
|
54
58
|
|
|
55
|
-
|
|
59
|
+
});
|
|
60
|
+
|
|
56
61
|
});
|
|
57
62
|
|
|
58
63
|
Cypress.Commands.add('getModuleVariantKeysFromString', (moduleName: string) => {
|
|
59
|
-
cy.readFile('src/modules.browser.ts').then((content) => {
|
|
60
64
|
|
|
61
|
-
|
|
62
|
-
`{\\s*name\\s*:\\s*['"]${moduleName}['"][\\s\\S]*?variants\\s*:\\s*\\[([\\s\\S]*?)\\]`,
|
|
63
|
-
'm'
|
|
64
|
-
);
|
|
65
|
-
const match = content.match(moduleRegex);
|
|
65
|
+
cy.readFile('src/modules.browser.ts').then((content) => {
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const moduleRegex = new RegExp(
|
|
68
|
+
`{\\s*name\\s*:\\s*['"]${moduleName}['"][\\s\\S]*?variants\\s*:\\s*\\[([\\s\\S]*?)\\]`,
|
|
69
|
+
'm'
|
|
70
|
+
);
|
|
71
|
+
const match = content.match(moduleRegex);
|
|
72
|
+
|
|
73
|
+
if (!match) {
|
|
70
74
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
let variantMatch;
|
|
75
|
+
return cy.wrap([]);
|
|
76
|
+
|
|
77
|
+
}
|
|
75
78
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
const variantsBlock = match[1];
|
|
80
|
+
const variantRegex = /{[\s\S]*?key\s*:\s*['"]([^'"]+)['"][\s\S]*?}/g;
|
|
81
|
+
const keys: string[] = [];
|
|
82
|
+
let variantMatch;
|
|
80
83
|
|
|
81
|
-
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
+
while ((variantMatch = variantRegex.exec(variantsBlock)) !== null) {
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
const variantChunk = variantMatch[0];
|
|
87
|
+
const key = variantMatch[1];
|
|
88
|
+
const hasGroup = /group\s*:/.test(variantChunk);
|
|
89
|
+
|
|
90
|
+
if (hasGroup || key.startsWith('pdf-')) {
|
|
91
|
+
|
|
92
|
+
continue;
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
keys.push(key);
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return cy.wrap(keys);
|
|
101
|
+
|
|
102
|
+
});
|
|
87
103
|
|
|
88
|
-
return cy.wrap(keys);
|
|
89
|
-
});
|
|
90
104
|
});
|
|
91
105
|
|
|
92
106
|
Cypress.Commands.add('updateVariant', (variant: string) => {
|
|
93
|
-
|
|
94
|
-
.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
107
|
+
|
|
108
|
+
cy.get('.presentation')
|
|
109
|
+
.first()
|
|
110
|
+
.children()
|
|
111
|
+
.first()
|
|
112
|
+
.then(($module) => {
|
|
113
|
+
|
|
114
|
+
const prev = $module.data('activeVariant');
|
|
115
|
+
|
|
116
|
+
if (prev) $module.removeClass(prev);
|
|
117
|
+
if (variant) $module.addClass(variant);
|
|
118
|
+
$module.data('activeVariant', variant || '');
|
|
119
|
+
|
|
120
|
+
const $defaultEls = $module.find('.default');
|
|
121
|
+
|
|
122
|
+
$defaultEls.each((_, el) => {
|
|
123
|
+
|
|
124
|
+
const $el = Cypress.$(el);
|
|
125
|
+
const prevElVariant = $el.data('activeVariant');
|
|
126
|
+
|
|
127
|
+
if (prevElVariant) $el.removeClass(prevElVariant);
|
|
128
|
+
if (variant) $el.addClass(variant);
|
|
129
|
+
$el.data('activeVariant', variant || '');
|
|
130
|
+
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
});
|
|
134
|
+
|
|
115
135
|
});
|
|
116
136
|
|
|
117
137
|
// todo:
|
|
118
138
|
// - fix updating list items
|
|
119
139
|
// parameter sample ('h1', 'short', 'intro-container') or ('h1', 'short')
|
|
120
140
|
Cypress.Commands.add('updateTextEl', (selector: string, textSize: string, parentElement?: string) => {
|
|
121
|
-
cy.fixture('textblock-inputs').then((data) => {
|
|
122
|
-
const sizeOptions = ['short', 'medium', 'long'] as const;
|
|
123
|
-
let resolvedTextSize: string;
|
|
124
|
-
let pool: string[];
|
|
125
141
|
|
|
126
|
-
|
|
127
|
-
pool = data.number;
|
|
128
|
-
} else if (textSize === 'button') {
|
|
129
|
-
pool = data.button;
|
|
130
|
-
} else {
|
|
131
|
-
resolvedTextSize = textSize === 'random'
|
|
132
|
-
? sizeOptions[Math.floor(Math.random() * sizeOptions.length)]
|
|
133
|
-
: textSize;
|
|
142
|
+
cy.fixture('textblock-inputs').then((data) => {
|
|
134
143
|
|
|
135
|
-
|
|
136
|
-
|
|
144
|
+
const sizeOptions = ['short', 'medium', 'long'] as const;
|
|
145
|
+
let resolvedTextSize: string;
|
|
146
|
+
let pool: string[];
|
|
137
147
|
|
|
138
|
-
|
|
148
|
+
if (textSize === 'number') {
|
|
139
149
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (
|
|
150
|
+
pool = data.number;
|
|
151
|
+
|
|
152
|
+
} else if (textSize === 'button') {
|
|
143
153
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
} else {
|
|
151
|
-
cy.get('body').then(($body) => {
|
|
152
|
-
if (!$body.find(`.${parentElement}`).length) return;
|
|
154
|
+
pool = data.button;
|
|
155
|
+
|
|
156
|
+
} else {
|
|
153
157
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
158
|
+
resolvedTextSize = textSize === 'random'
|
|
159
|
+
? sizeOptions[Math.floor(Math.random() * sizeOptions.length)]
|
|
160
|
+
: textSize;
|
|
157
161
|
|
|
158
|
-
|
|
162
|
+
pool = data.list[resolvedTextSize];
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const randomText = pool ? pool[Math.floor(Math.random() * pool.length)] : '';
|
|
167
|
+
|
|
168
|
+
if (!parentElement) {
|
|
169
|
+
|
|
170
|
+
cy.get('body').then(($body) => {
|
|
171
|
+
|
|
172
|
+
if (!$body.find(selector).length) return;
|
|
173
|
+
|
|
174
|
+
cy.get(selector).then($els => {
|
|
159
175
|
|
|
160
|
-
|
|
161
|
-
|
|
176
|
+
$els.each((_, el) => {
|
|
177
|
+
|
|
178
|
+
Cypress.$(el).text(randomText);
|
|
179
|
+
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
});
|
|
183
|
+
|
|
162
184
|
});
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
185
|
+
|
|
186
|
+
} else {
|
|
187
|
+
|
|
188
|
+
cy.get('body').then(($body) => {
|
|
189
|
+
|
|
190
|
+
if (!$body.find(`.${parentElement}`).length) return;
|
|
191
|
+
|
|
192
|
+
cy.get(`.${parentElement}`)
|
|
193
|
+
.first().then($el => {
|
|
194
|
+
|
|
195
|
+
const $selected = $el.find(selector);
|
|
196
|
+
|
|
197
|
+
if (!$selected.length) return;
|
|
198
|
+
|
|
199
|
+
$selected.each((_, el) => {
|
|
200
|
+
|
|
201
|
+
Cypress.$(el).text(randomText);
|
|
202
|
+
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
});
|
|
212
|
+
|
|
167
213
|
});
|
|
168
214
|
|
|
169
215
|
// parameter sample ('short', 'intro-container') or ('short')
|
|
170
216
|
Cypress.Commands.add('updateTextblock', (textSize: string, parentClassname?: string | null) => {
|
|
171
|
-
const tags = ['h1', 'h2', 'h3', 'p'] as const;
|
|
172
|
-
const sizeOptions = ['short', 'medium', 'long'] as const;
|
|
173
|
-
const listTypes = ['list', 'links'] as const;
|
|
174
|
-
const tagToDataKey = {
|
|
175
|
-
h1: 'headline',
|
|
176
|
-
h2: 'subline',
|
|
177
|
-
h3: 'intro',
|
|
178
|
-
p : 'paragraph',
|
|
179
|
-
} as const;
|
|
180
|
-
const selector = parentClassname
|
|
181
|
-
? `.lila-textblock.${parentClassname}`
|
|
182
|
-
: '.lila-textblock';
|
|
183
|
-
|
|
184
|
-
cy.fixture('textblock-inputs').then((data) => {
|
|
185
|
-
cy.get('body').then(($body) => {
|
|
186
|
-
if (!$body.find(selector).length) return;
|
|
187
217
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
218
|
+
const tags = ['h1', 'h2', 'h3', 'p'] as const;
|
|
219
|
+
const sizeOptions = ['short', 'medium', 'long'] as const;
|
|
220
|
+
const listTypes = ['list', 'links'] as const;
|
|
221
|
+
const tagToDataKey = {
|
|
222
|
+
h1: 'headline',
|
|
223
|
+
h2: 'subline',
|
|
224
|
+
h3: 'intro',
|
|
225
|
+
p: 'paragraph',
|
|
226
|
+
} as const;
|
|
227
|
+
const selector = parentClassname
|
|
228
|
+
? `.lila-textblock.${parentClassname}`
|
|
229
|
+
: '.lila-textblock';
|
|
230
|
+
|
|
231
|
+
cy.fixture('textblock-inputs').then((data) => {
|
|
232
|
+
|
|
233
|
+
cy.get('body').then(($body) => {
|
|
234
|
+
|
|
235
|
+
if (!$body.find(selector).length) return;
|
|
236
|
+
|
|
237
|
+
cy.get(selector)
|
|
238
|
+
.first()
|
|
239
|
+
.then(($block) => {
|
|
194
240
|
|
|
195
|
-
|
|
241
|
+
tags.forEach((tag) => {
|
|
196
242
|
|
|
197
|
-
|
|
243
|
+
const dataKey = tagToDataKey[tag];
|
|
244
|
+
const $tag = $block.find(tag).first();
|
|
245
|
+
|
|
246
|
+
if (!$tag.length) return;
|
|
247
|
+
|
|
248
|
+
const currentSize =
|
|
198
249
|
textSize === 'random'
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
250
|
+
? sizeOptions[Math.floor(Math.random() * sizeOptions.length)]
|
|
251
|
+
: textSize;
|
|
252
|
+
const pool = data[dataKey]?.[currentSize];
|
|
202
253
|
|
|
203
|
-
|
|
254
|
+
if (!pool?.length) return;
|
|
204
255
|
|
|
205
|
-
|
|
256
|
+
const randomText = pool[Math.floor(Math.random() * pool.length)];
|
|
206
257
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
258
|
+
cy.wrap($tag).invoke('text', randomText);
|
|
259
|
+
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
});
|
|
210
263
|
|
|
211
|
-
|
|
212
|
-
if (!$body.find(`.${listType}`).length) return;
|
|
264
|
+
listTypes.forEach((listType) => {
|
|
213
265
|
|
|
214
|
-
|
|
215
|
-
? sizeOptions[Math.floor(Math.random() * sizeOptions.length)]
|
|
216
|
-
: textSize;
|
|
266
|
+
if (!$body.find(`.${listType}`).length) return;
|
|
217
267
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
268
|
+
const currentSize = textSize === 'random'
|
|
269
|
+
? sizeOptions[Math.floor(Math.random() * sizeOptions.length)]
|
|
270
|
+
: textSize;
|
|
221
271
|
|
|
222
|
-
|
|
223
|
-
'text',
|
|
224
|
-
data.list[currentSize][Math.floor(Math.random() * data.list[currentSize].length)]
|
|
225
|
-
);
|
|
226
|
-
});
|
|
272
|
+
cy.get(`.${listType}`).first().then(($block) => {
|
|
227
273
|
|
|
228
|
-
|
|
274
|
+
cy.get(`.${listType}`).first().then(($parent) => {
|
|
229
275
|
|
|
230
|
-
|
|
231
|
-
const text = data.list[currentSize][index % data.list[currentSize].length];
|
|
276
|
+
if (!$parent.find('h4').length) return;
|
|
232
277
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
278
|
+
cy.wrap($parent.find('h4').first()).invoke(
|
|
279
|
+
'text',
|
|
280
|
+
data.list[currentSize][Math.floor(Math.random() * data.list[currentSize].length)]
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
});
|
|
236
284
|
|
|
237
|
-
|
|
238
|
-
$link.text(text);
|
|
239
|
-
}
|
|
240
|
-
} else {
|
|
241
|
-
const li = $li[0];
|
|
285
|
+
const items = $block.find('li');
|
|
242
286
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
287
|
+
items.each((index, item) => {
|
|
288
|
+
|
|
289
|
+
const text = data.list[currentSize][index % data.list[currentSize].length];
|
|
290
|
+
|
|
291
|
+
cy.wrap(item).then(($li) => {
|
|
292
|
+
|
|
293
|
+
if (listType === 'links') {
|
|
294
|
+
|
|
295
|
+
const $link = $li.find('a:first');
|
|
296
|
+
|
|
297
|
+
if ($link.length) {
|
|
298
|
+
|
|
299
|
+
$link.text(text);
|
|
300
|
+
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
} else {
|
|
304
|
+
|
|
305
|
+
const li = $li[0];
|
|
306
|
+
|
|
307
|
+
if (li.lastChild && li.lastChild.nodeType === Node.TEXT_NODE) {
|
|
308
|
+
|
|
309
|
+
li.lastChild.nodeValue = text;
|
|
310
|
+
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
});
|
|
320
|
+
|
|
247
321
|
});
|
|
248
|
-
|
|
322
|
+
|
|
249
323
|
});
|
|
250
|
-
|
|
324
|
+
|
|
251
325
|
});
|
|
252
|
-
|
|
326
|
+
|
|
253
327
|
});
|
|
254
328
|
|
|
255
329
|
Cypress.Commands.add('updateListLinks', (textSize: string, parentElement?: string) => {
|
|
256
|
-
const target = parentElement ? `.${parentElement} .lila-list-links` : '.lila-list-links';
|
|
257
330
|
|
|
258
|
-
|
|
259
|
-
const sizeOptions = ['short', 'medium', 'long'] as const;
|
|
260
|
-
const resolvedTextSize = textSize === 'random' ? sizeOptions[Math.floor(Math.random() * sizeOptions.length)] : textSize;
|
|
261
|
-
const pool = data.list[resolvedTextSize];
|
|
331
|
+
const target = parentElement ? `.${parentElement} .lila-list-links` : '.lila-list-links';
|
|
262
332
|
|
|
263
|
-
|
|
333
|
+
cy.fixture('textblock-inputs').then((data) => {
|
|
264
334
|
|
|
265
|
-
|
|
266
|
-
|
|
335
|
+
const sizeOptions = ['short', 'medium', 'long'] as const;
|
|
336
|
+
const resolvedTextSize = textSize === 'random' ? sizeOptions[Math.floor(Math.random() * sizeOptions.length)] : textSize;
|
|
337
|
+
const pool = data.list[resolvedTextSize];
|
|
267
338
|
|
|
268
|
-
|
|
269
|
-
const $h4 = $list.find('h4');
|
|
339
|
+
if (!pool?.length) return;
|
|
270
340
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
341
|
+
cy.get('body').then(($body) => {
|
|
342
|
+
|
|
343
|
+
if (!$body.find(target).length) return;
|
|
344
|
+
|
|
345
|
+
cy.get(target).each(($list) => {
|
|
346
|
+
|
|
347
|
+
const $h4 = $list.find('h4');
|
|
348
|
+
|
|
349
|
+
if ($h4.length) {
|
|
350
|
+
|
|
351
|
+
$h4.text(pool[Math.floor(Math.random() * pool.length)]);
|
|
352
|
+
|
|
353
|
+
}
|
|
274
354
|
|
|
275
|
-
|
|
276
|
-
const text = pool[index % pool.length];
|
|
277
|
-
const $a = Cypress.$(item).find('a:first');
|
|
355
|
+
$list.find('li').each((index, item) => {
|
|
278
356
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
357
|
+
const text = pool[index % pool.length];
|
|
358
|
+
const $a = Cypress.$(item).find('a:first');
|
|
359
|
+
|
|
360
|
+
if ($a.length) {
|
|
361
|
+
|
|
362
|
+
$a.text(text);
|
|
363
|
+
|
|
364
|
+
} else if (item.lastChild && item.lastChild.nodeType === Node.TEXT_NODE) {
|
|
365
|
+
|
|
366
|
+
item.lastChild.nodeValue = text;
|
|
367
|
+
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
});
|
|
373
|
+
|
|
284
374
|
});
|
|
285
|
-
|
|
375
|
+
|
|
286
376
|
});
|
|
287
|
-
|
|
377
|
+
|
|
288
378
|
});
|
|
289
379
|
|
|
290
380
|
Cypress.Commands.add('updatePictureSrc', (data: { src: string; alt?: string; caption?: string } | string) => {
|
|
291
|
-
// Define tag selectors at the top
|
|
292
|
-
const selectors = {
|
|
293
|
-
img : 'picture img',
|
|
294
|
-
caption: 'figcaption',
|
|
295
|
-
};
|
|
296
|
-
const applyImageData = (imageData: { src: string; alt?: string; caption?: string }) => {
|
|
297
|
-
cy.get('body').then(($body) => {
|
|
298
|
-
if ($body.find(selectors.img).length) {
|
|
299
|
-
cy.get(selectors.img).invoke('attr', 'src', imageData.src);
|
|
300
381
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
382
|
+
// Define tag selectors at the top
|
|
383
|
+
const selectors = {
|
|
384
|
+
img: 'picture img',
|
|
385
|
+
caption: 'figcaption',
|
|
386
|
+
};
|
|
387
|
+
const applyImageData = (imageData: { src: string; alt?: string; caption?: string }) => {
|
|
305
388
|
|
|
306
|
-
|
|
307
|
-
cy.get(selectors.caption).invoke('text', imageData.caption);
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
};
|
|
389
|
+
cy.get('body').then(($body) => {
|
|
311
390
|
|
|
312
|
-
|
|
313
|
-
// Resolve string like 'horizontal-0' or 'horizontal-0.jpg' to fixture object
|
|
314
|
-
const key = data.replace(/\.[^/.]+$/, ''); // strip extension
|
|
315
|
-
const match = key.match(/^(.+)-(\d+)$/);
|
|
391
|
+
if ($body.find(selectors.img).length) {
|
|
316
392
|
|
|
317
|
-
|
|
318
|
-
const [, category, indexStr] = match;
|
|
319
|
-
const index = parseInt(indexStr, 10);
|
|
393
|
+
cy.get(selectors.img).invoke('attr', 'src', imageData.src);
|
|
320
394
|
|
|
321
|
-
|
|
322
|
-
|
|
395
|
+
if (imageData.alt) {
|
|
396
|
+
|
|
397
|
+
cy.get(selectors.img).invoke('attr', 'alt', imageData.alt);
|
|
398
|
+
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
}
|
|
323
402
|
|
|
324
|
-
|
|
325
|
-
|
|
403
|
+
if (imageData.caption && $body.find(selectors.caption).length) {
|
|
404
|
+
|
|
405
|
+
cy.get(selectors.caption).invoke('text', imageData.caption);
|
|
406
|
+
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
if (typeof data === 'string') {
|
|
414
|
+
|
|
415
|
+
// Resolve string like 'horizontal-0' or 'horizontal-0.jpg' to fixture object
|
|
416
|
+
const key = data.replace(/\.[^/.]+$/, ''); // strip extension
|
|
417
|
+
const match = key.match(/^(.+)-(\d+)$/);
|
|
418
|
+
|
|
419
|
+
if (match) {
|
|
420
|
+
|
|
421
|
+
const [, category, indexStr] = match;
|
|
422
|
+
const index = parseInt(indexStr, 10);
|
|
423
|
+
|
|
424
|
+
cy.fixture('image-inputs').then((fixtureData) => {
|
|
425
|
+
|
|
426
|
+
const resolved = fixtureData[category]?.[index];
|
|
427
|
+
|
|
428
|
+
if (resolved) {
|
|
429
|
+
|
|
430
|
+
applyImageData(resolved);
|
|
431
|
+
|
|
432
|
+
} else {
|
|
433
|
+
|
|
434
|
+
applyImageData({ src: data });
|
|
435
|
+
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
});
|
|
439
|
+
|
|
326
440
|
} else {
|
|
327
|
-
|
|
441
|
+
|
|
442
|
+
applyImageData({ src: data });
|
|
443
|
+
|
|
328
444
|
}
|
|
329
|
-
|
|
445
|
+
|
|
330
446
|
} else {
|
|
331
|
-
|
|
447
|
+
|
|
448
|
+
applyImageData(data);
|
|
449
|
+
|
|
332
450
|
}
|
|
333
|
-
|
|
334
|
-
applyImageData(data);
|
|
335
|
-
}
|
|
451
|
+
|
|
336
452
|
});
|
|
337
453
|
|
|
338
454
|
Cypress.Commands.add('updateGalleryImage', (index: number, data: { src: string; alt?: string; caption?: string } | string) => {
|
|
339
|
-
const imageData = typeof data === 'string' ? { src: data } : data;
|
|
340
455
|
|
|
341
|
-
|
|
342
|
-
const $elements = $body.find('.gallery-module .element');
|
|
456
|
+
const imageData = typeof data === 'string' ? { src: data } : data;
|
|
343
457
|
|
|
344
|
-
|
|
458
|
+
cy.get('body').then(($body) => {
|
|
345
459
|
|
|
346
|
-
|
|
460
|
+
const $elements = $body.find('.gallery-module .element');
|
|
347
461
|
|
|
348
|
-
|
|
349
|
-
cy.get('.gallery-module .element').eq(index).find('picture img').invoke('attr', 'src', imageData.src);
|
|
462
|
+
if (!$elements.length || !$elements.eq(index).length) return;
|
|
350
463
|
|
|
351
|
-
|
|
352
|
-
cy.get('.gallery-module .element').eq(index).find('picture img').invoke('attr', 'alt', imageData.alt);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
464
|
+
const $img = $elements.eq(index).find('picture img');
|
|
355
465
|
|
|
356
|
-
|
|
357
|
-
|
|
466
|
+
if ($img.length) {
|
|
467
|
+
|
|
468
|
+
cy.get('.gallery-module .element').eq(index).find('picture img').invoke('attr', 'src', imageData.src);
|
|
469
|
+
|
|
470
|
+
if (imageData.alt) {
|
|
471
|
+
|
|
472
|
+
cy.get('.gallery-module .element').eq(index).find('picture img').invoke('attr', 'alt', imageData.alt);
|
|
473
|
+
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
if (imageData.caption) {
|
|
479
|
+
|
|
480
|
+
const $caption = $elements.eq(index).find('figcaption');
|
|
481
|
+
|
|
482
|
+
if ($caption.length) {
|
|
483
|
+
|
|
484
|
+
cy.get('.gallery-module .element').eq(index).find('figcaption').invoke('text', imageData.caption);
|
|
485
|
+
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
});
|
|
358
491
|
|
|
359
|
-
if ($caption.length) {
|
|
360
|
-
cy.get('.gallery-module .element').eq(index).find('figcaption').invoke('text', imageData.caption);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
492
|
});
|
|
365
493
|
|
|
366
494
|
Cypress.Commands.add('navigateGallery', (direction: 'next' | 'prev') => {
|
|
367
|
-
const selector = direction === 'next' ? '.gallery-controls button:last-child' : '.gallery-controls button:first-child';
|
|
368
495
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
496
|
+
const selector = direction === 'next' ? '.gallery-controls button:last-child' : '.gallery-controls button:first-child';
|
|
497
|
+
|
|
498
|
+
cy.get('body').then(($body) => {
|
|
499
|
+
|
|
500
|
+
if ($body.find(selector).length) {
|
|
501
|
+
|
|
502
|
+
cy.get(selector).click();
|
|
503
|
+
cy.wait(500);
|
|
504
|
+
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
});
|
|
508
|
+
|
|
375
509
|
});
|
|
376
510
|
|
|
377
511
|
Cypress.Commands.add('updateButton', (text: string, className?: string) => {
|
|
378
|
-
cy.get('body').then(($body) => {
|
|
379
|
-
if (!$body.find('.lila-button, .button').length) return;
|
|
380
512
|
|
|
381
|
-
cy.get('
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
const pool = data.button;
|
|
385
|
-
const randomText = pool[Math.floor(Math.random() * pool.length)];
|
|
513
|
+
cy.get('body').then(($body) => {
|
|
514
|
+
|
|
515
|
+
if (!$body.find('.lila-button, .button').length) return;
|
|
386
516
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
517
|
+
cy.get('.lila-button, .button').each(($btn) => {
|
|
518
|
+
|
|
519
|
+
if (text === 'random') {
|
|
520
|
+
|
|
521
|
+
cy.fixture('textblock-inputs').then((data) => {
|
|
522
|
+
|
|
523
|
+
const pool = data.button;
|
|
524
|
+
const randomText = pool[Math.floor(Math.random() * pool.length)];
|
|
525
|
+
|
|
526
|
+
cy.wrap($btn).invoke('text', randomText);
|
|
527
|
+
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
} else {
|
|
392
531
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
532
|
+
cy.wrap($btn).invoke('text', text);
|
|
533
|
+
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
if (className) {
|
|
537
|
+
|
|
538
|
+
cy.wrap($btn).invoke('addClass', className);
|
|
539
|
+
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
});
|
|
543
|
+
|
|
396
544
|
});
|
|
397
|
-
|
|
545
|
+
|
|
398
546
|
});
|
|
399
547
|
|
|
400
548
|
Cypress.Commands.add('updateAllTextblocks', (textSize: string, parentElement?: string) => {
|
|
401
|
-
const tags = ['h1', 'h2', 'h3', 'p'] as const;
|
|
402
|
-
const sizeOptions = ['short', 'medium', 'long'] as const;
|
|
403
|
-
const tagToDataKey = {
|
|
404
|
-
h1: 'headline',
|
|
405
|
-
h2: 'subline',
|
|
406
|
-
h3: 'intro',
|
|
407
|
-
p : 'paragraph',
|
|
408
|
-
} as const;
|
|
409
|
-
const selector = parentElement ? `.${parentElement} .lila-textblock` : '.lila-textblock';
|
|
410
|
-
|
|
411
|
-
cy.fixture('textblock-inputs').then((data) => {
|
|
412
|
-
cy.get('body').then(($body) => {
|
|
413
|
-
if (!$body.find(selector).length) return;
|
|
414
549
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
550
|
+
const tags = ['h1', 'h2', 'h3', 'p'] as const;
|
|
551
|
+
const sizeOptions = ['short', 'medium', 'long'] as const;
|
|
552
|
+
const tagToDataKey = {
|
|
553
|
+
h1: 'headline',
|
|
554
|
+
h2: 'subline',
|
|
555
|
+
h3: 'intro',
|
|
556
|
+
p: 'paragraph',
|
|
557
|
+
} as const;
|
|
558
|
+
const selector = parentElement ? `.${parentElement} .lila-textblock` : '.lila-textblock';
|
|
559
|
+
|
|
560
|
+
cy.fixture('textblock-inputs').then((data) => {
|
|
561
|
+
|
|
562
|
+
cy.get('body').then(($body) => {
|
|
563
|
+
|
|
564
|
+
if (!$body.find(selector).length) return;
|
|
565
|
+
|
|
566
|
+
cy.get(selector).each(($block) => {
|
|
419
567
|
|
|
420
|
-
|
|
568
|
+
tags.forEach((tag) => {
|
|
421
569
|
|
|
422
|
-
|
|
423
|
-
|
|
570
|
+
const dataKey = tagToDataKey[tag];
|
|
571
|
+
const $tag = $block.find(tag).first();
|
|
424
572
|
|
|
425
|
-
|
|
573
|
+
if (!$tag.length) return;
|
|
426
574
|
|
|
427
|
-
|
|
575
|
+
const currentSize = textSize === 'random' ? sizeOptions[Math.floor(Math.random() * sizeOptions.length)] : textSize as typeof sizeOptions[number];
|
|
576
|
+
const pool = data[dataKey]?.[currentSize];
|
|
428
577
|
|
|
429
|
-
|
|
578
|
+
if (!pool?.length) return;
|
|
579
|
+
|
|
580
|
+
const randomText = pool[Math.floor(Math.random() * pool.length)];
|
|
581
|
+
|
|
582
|
+
cy.wrap($tag).invoke('text', randomText);
|
|
583
|
+
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
});
|
|
587
|
+
|
|
430
588
|
});
|
|
431
|
-
|
|
589
|
+
|
|
432
590
|
});
|
|
433
|
-
|
|
591
|
+
|
|
434
592
|
});
|
|
435
593
|
|
|
436
594
|
export {}
|