@nextsparkjs/core 0.1.0-beta.39 → 0.1.0-beta.40
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/dist/styles/classes.json +1 -1
- package/dist/templates/contents/themes/starter/tests/cypress/e2e/uat/entities/tasks/tasks-crud.bdd.md +278 -0
- package/dist/templates/contents/themes/starter/tests/cypress/e2e/uat/entities/tasks/tasks-crud.cy.ts +22 -14
- package/dist/templates/contents/themes/starter/tests/cypress/src/components/DevKeyringPOM.ts +160 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/components/EntityForm.ts +375 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/components/EntityList.ts +389 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/components/TeamSwitcherPOM.ts +450 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/components/index.ts +13 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/core/BlockEditorBasePOM.ts +576 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/core/index.ts +2 -0
- package/dist/templates/contents/themes/starter/tests/cypress/{e2e/uat/entities/tasks → src/entities}/TasksPOM.ts +1 -1
- package/dist/templates/contents/themes/starter/tests/cypress/src/entities/index.ts +10 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/features/BillingPOM.ts +385 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/features/DashboardPOM.ts +245 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/features/DevtoolsPOM.ts +750 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/features/ScheduledActionsPOM.ts +463 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/features/SettingsPOM.ts +362 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/features/SuperadminPOM.ts +331 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/features/index.ts +18 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/index.ts +88 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/session-helpers.ts +332 -88
- package/dist/templates/contents/themes/starter/tests/cypress.config.ts +4 -1
- package/package.json +1 -1
- package/scripts/test/jest-theme.mjs +7 -3
- package/templates/contents/themes/starter/tests/cypress/e2e/uat/entities/tasks/tasks-crud.bdd.md +278 -0
- package/templates/contents/themes/starter/tests/cypress/e2e/uat/entities/tasks/tasks-crud.cy.ts +22 -14
- package/templates/contents/themes/starter/tests/cypress/src/components/DevKeyringPOM.ts +160 -0
- package/templates/contents/themes/starter/tests/cypress/src/components/EntityForm.ts +375 -0
- package/templates/contents/themes/starter/tests/cypress/src/components/EntityList.ts +389 -0
- package/templates/contents/themes/starter/tests/cypress/src/components/TeamSwitcherPOM.ts +450 -0
- package/templates/contents/themes/starter/tests/cypress/src/components/index.ts +13 -0
- package/templates/contents/themes/starter/tests/cypress/src/core/BlockEditorBasePOM.ts +576 -0
- package/templates/contents/themes/starter/tests/cypress/src/core/index.ts +2 -0
- package/templates/contents/themes/starter/tests/cypress/{e2e/uat/entities/tasks → src/entities}/TasksPOM.ts +1 -1
- package/templates/contents/themes/starter/tests/cypress/src/entities/index.ts +10 -0
- package/templates/contents/themes/starter/tests/cypress/src/features/BillingPOM.ts +385 -0
- package/templates/contents/themes/starter/tests/cypress/src/features/DashboardPOM.ts +245 -0
- package/templates/contents/themes/starter/tests/cypress/src/features/DevtoolsPOM.ts +750 -0
- package/templates/contents/themes/starter/tests/cypress/src/features/ScheduledActionsPOM.ts +463 -0
- package/templates/contents/themes/starter/tests/cypress/src/features/SettingsPOM.ts +362 -0
- package/templates/contents/themes/starter/tests/cypress/src/features/SuperadminPOM.ts +331 -0
- package/templates/contents/themes/starter/tests/cypress/src/features/index.ts +18 -0
- package/templates/contents/themes/starter/tests/cypress/src/index.ts +88 -0
- package/templates/contents/themes/starter/tests/cypress/src/session-helpers.ts +332 -88
- package/templates/contents/themes/starter/tests/cypress.config.ts +4 -1
- package/dist/templates/contents/themes/starter/tests/cypress/e2e/_utils/selectors/pages-editor.bdd.md +0 -207
- package/dist/templates/contents/themes/starter/tests/cypress/e2e/_utils/selectors/pages-editor.cy.ts +0 -211
- package/dist/templates/contents/themes/starter/tests/cypress/e2e/_utils/selectors/posts-editor.bdd.md +0 -184
- package/dist/templates/contents/themes/starter/tests/cypress/e2e/_utils/selectors/posts-editor.cy.ts +0 -350
- package/dist/templates/contents/themes/starter/tests/cypress/e2e/_utils/selectors/public.cy.ts +0 -112
- package/dist/templates/contents/themes/starter/tests/cypress/e2e/_utils/selectors/taxonomies.cy.ts +0 -126
- package/templates/contents/themes/starter/tests/cypress/e2e/_utils/selectors/pages-editor.bdd.md +0 -207
- package/templates/contents/themes/starter/tests/cypress/e2e/_utils/selectors/pages-editor.cy.ts +0 -211
- package/templates/contents/themes/starter/tests/cypress/e2e/_utils/selectors/posts-editor.bdd.md +0 -184
- package/templates/contents/themes/starter/tests/cypress/e2e/_utils/selectors/posts-editor.cy.ts +0 -350
- package/templates/contents/themes/starter/tests/cypress/e2e/_utils/selectors/public.cy.ts +0 -112
- package/templates/contents/themes/starter/tests/cypress/e2e/_utils/selectors/taxonomies.cy.ts +0 -126
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Entity Form POM
|
|
3
|
+
*
|
|
4
|
+
* Page Object Model for entity create/edit forms in Default theme.
|
|
5
|
+
* Uses standardized data-cy selectors from entities.json.
|
|
6
|
+
*
|
|
7
|
+
* Convention: {slug}-{component}-{detail}
|
|
8
|
+
* Examples: tasks-form, customers-field-name, tasks-form-submit
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* const taskForm = EntityForm.for('tasks')
|
|
12
|
+
* const customerForm = EntityForm.for('customers')
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// Import entity configs from theme
|
|
16
|
+
import entitiesConfig from '../../fixtures/entities.json'
|
|
17
|
+
|
|
18
|
+
export interface EntityConfig {
|
|
19
|
+
slug: string
|
|
20
|
+
singular: string
|
|
21
|
+
plural: string
|
|
22
|
+
tableName: string
|
|
23
|
+
fields: string[]
|
|
24
|
+
sections: string[]
|
|
25
|
+
filters: string[]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class EntityForm {
|
|
29
|
+
private config: EntityConfig
|
|
30
|
+
private slug: string
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Create a new EntityForm POM instance from entity config
|
|
34
|
+
*/
|
|
35
|
+
constructor(entityKey: string) {
|
|
36
|
+
const config = entitiesConfig.entities[entityKey as keyof typeof entitiesConfig.entities]
|
|
37
|
+
if (!config) {
|
|
38
|
+
throw new Error(`Unknown entity: ${entityKey}. Available: ${Object.keys(entitiesConfig.entities).join(', ')}`)
|
|
39
|
+
}
|
|
40
|
+
this.config = config as EntityConfig
|
|
41
|
+
this.slug = config.slug
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ============================================
|
|
45
|
+
// STATIC FACTORY METHOD
|
|
46
|
+
// ============================================
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Create an EntityForm from entity key
|
|
50
|
+
*/
|
|
51
|
+
static for(entityKey: string): EntityForm {
|
|
52
|
+
return new EntityForm(entityKey)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ============================================
|
|
56
|
+
// DYNAMIC SELECTORS (from entities.json convention)
|
|
57
|
+
// ============================================
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get selectors for this entity form following the standard convention
|
|
61
|
+
*/
|
|
62
|
+
get selectors() {
|
|
63
|
+
const slug = this.slug
|
|
64
|
+
return {
|
|
65
|
+
// Page and form containers
|
|
66
|
+
page: `[data-cy="${slug}-form-page"]`,
|
|
67
|
+
form: `[data-cy="${slug}-form"]`,
|
|
68
|
+
pageTitle: '[data-cy="page-title"]',
|
|
69
|
+
|
|
70
|
+
// Buttons
|
|
71
|
+
submitButton: `[data-cy="${slug}-form-submit"]`,
|
|
72
|
+
cancelButton: `[data-cy="${slug}-form-cancel"]`,
|
|
73
|
+
|
|
74
|
+
// Sections
|
|
75
|
+
section: (sectionName: string) => `[data-cy="${slug}-section-${sectionName}"]`,
|
|
76
|
+
|
|
77
|
+
// Fields
|
|
78
|
+
field: (fieldName: string) => `[data-cy="${slug}-field-${fieldName}"]`,
|
|
79
|
+
fieldInput: (fieldName: string) => `[data-cy="${slug}-field-${fieldName}"] input`,
|
|
80
|
+
fieldTextarea: (fieldName: string) => `[data-cy="${slug}-field-${fieldName}"] textarea`,
|
|
81
|
+
fieldSelect: (fieldName: string) => `[data-cy="${slug}-field-${fieldName}"] [role="combobox"]`,
|
|
82
|
+
fieldCheckbox: (fieldName: string) => `[data-cy="${slug}-field-${fieldName}"] input[type="checkbox"]`,
|
|
83
|
+
fieldOption: (fieldName: string, value: string) => `[data-cy="${slug}-field-${fieldName}-option-${value}"]`,
|
|
84
|
+
fieldError: (fieldName: string) => `[data-cy="${slug}-field-${fieldName}-error"]`,
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get the entity config
|
|
90
|
+
*/
|
|
91
|
+
get entityConfig(): EntityConfig {
|
|
92
|
+
return this.config
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Get available fields for this entity
|
|
97
|
+
*/
|
|
98
|
+
get fields(): string[] {
|
|
99
|
+
return this.config.fields
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Get available sections for this entity
|
|
104
|
+
*/
|
|
105
|
+
get sections(): string[] {
|
|
106
|
+
return this.config.sections
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ============================================
|
|
110
|
+
// VALIDATION METHODS
|
|
111
|
+
// ============================================
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Validate the form page is visible
|
|
115
|
+
*/
|
|
116
|
+
validatePageVisible() {
|
|
117
|
+
cy.get(this.selectors.page).should('be.visible')
|
|
118
|
+
return this
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Validate the form is visible
|
|
123
|
+
*/
|
|
124
|
+
validateFormVisible() {
|
|
125
|
+
cy.get(this.selectors.form).should('be.visible')
|
|
126
|
+
return this
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Validate the page title text
|
|
131
|
+
*/
|
|
132
|
+
validatePageTitle(expectedTitle: string) {
|
|
133
|
+
cy.get(this.selectors.pageTitle).should('contain.text', expectedTitle)
|
|
134
|
+
return this
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Validate a section is visible
|
|
139
|
+
*/
|
|
140
|
+
validateSectionVisible(sectionName: string) {
|
|
141
|
+
cy.get(this.selectors.section(sectionName)).should('be.visible')
|
|
142
|
+
return this
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Validate a field is visible
|
|
147
|
+
*/
|
|
148
|
+
validateFieldVisible(fieldName: string) {
|
|
149
|
+
cy.get(this.selectors.field(fieldName)).should('be.visible')
|
|
150
|
+
return this
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Validate a field has an error message
|
|
155
|
+
*/
|
|
156
|
+
validateFieldHasError(fieldName: string, errorMessage?: string) {
|
|
157
|
+
const errorSelector = this.selectors.fieldError(fieldName)
|
|
158
|
+
cy.get(errorSelector).should('be.visible')
|
|
159
|
+
if (errorMessage) {
|
|
160
|
+
cy.get(errorSelector).should('contain.text', errorMessage)
|
|
161
|
+
}
|
|
162
|
+
return this
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Validate submit button is enabled
|
|
167
|
+
*/
|
|
168
|
+
validateSubmitEnabled() {
|
|
169
|
+
cy.get(this.selectors.submitButton).should('not.be.disabled')
|
|
170
|
+
return this
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Validate submit button is disabled
|
|
175
|
+
*/
|
|
176
|
+
validateSubmitDisabled() {
|
|
177
|
+
cy.get(this.selectors.submitButton).should('be.disabled')
|
|
178
|
+
return this
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// ============================================
|
|
182
|
+
// INPUT METHODS
|
|
183
|
+
// ============================================
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Type into a text input field
|
|
187
|
+
*/
|
|
188
|
+
typeInField(fieldName: string, value: string) {
|
|
189
|
+
cy.get(this.selectors.fieldInput(fieldName)).clear().type(value)
|
|
190
|
+
return this
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Type into a textarea field
|
|
195
|
+
*/
|
|
196
|
+
typeInTextarea(fieldName: string, value: string) {
|
|
197
|
+
cy.get(this.selectors.fieldTextarea(fieldName)).clear().type(value)
|
|
198
|
+
return this
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Clear a text input field
|
|
203
|
+
*/
|
|
204
|
+
clearField(fieldName: string) {
|
|
205
|
+
cy.get(this.selectors.fieldInput(fieldName)).clear()
|
|
206
|
+
return this
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Select an option from a select/combobox field
|
|
211
|
+
*/
|
|
212
|
+
selectOption(fieldName: string, optionValue: string) {
|
|
213
|
+
cy.get(this.selectors.fieldSelect(fieldName)).click()
|
|
214
|
+
cy.get(this.selectors.fieldOption(fieldName, optionValue)).click()
|
|
215
|
+
return this
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Check a checkbox field
|
|
220
|
+
*/
|
|
221
|
+
checkField(fieldName: string) {
|
|
222
|
+
cy.get(this.selectors.fieldCheckbox(fieldName)).check()
|
|
223
|
+
return this
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Uncheck a checkbox field
|
|
228
|
+
*/
|
|
229
|
+
uncheckField(fieldName: string) {
|
|
230
|
+
cy.get(this.selectors.fieldCheckbox(fieldName)).uncheck()
|
|
231
|
+
return this
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Fill a date input field
|
|
236
|
+
*/
|
|
237
|
+
fillDate(fieldName: string, dateString: string) {
|
|
238
|
+
cy.get(this.selectors.fieldInput(fieldName)).clear().type(dateString)
|
|
239
|
+
return this
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Fill a field (alias for typeInField)
|
|
244
|
+
*/
|
|
245
|
+
fillField(fieldName: string, value: string) {
|
|
246
|
+
// Try input first, then textarea
|
|
247
|
+
cy.get(this.selectors.field(fieldName)).then($field => {
|
|
248
|
+
const hasInput = $field.find('input:not([type="checkbox"])').length > 0
|
|
249
|
+
const hasTextarea = $field.find('textarea').length > 0
|
|
250
|
+
|
|
251
|
+
if (hasInput) {
|
|
252
|
+
this.typeInField(fieldName, value)
|
|
253
|
+
} else if (hasTextarea) {
|
|
254
|
+
this.typeInTextarea(fieldName, value)
|
|
255
|
+
}
|
|
256
|
+
})
|
|
257
|
+
return this
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// ============================================
|
|
261
|
+
// FORM SUBMISSION METHODS
|
|
262
|
+
// ============================================
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Click the submit button
|
|
266
|
+
*/
|
|
267
|
+
submit() {
|
|
268
|
+
cy.get(this.selectors.submitButton).click()
|
|
269
|
+
return this
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Click the cancel button
|
|
274
|
+
*/
|
|
275
|
+
cancel() {
|
|
276
|
+
cy.get(this.selectors.cancelButton).click()
|
|
277
|
+
return this
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ============================================
|
|
281
|
+
// BULK FILL METHODS
|
|
282
|
+
// ============================================
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Fill multiple fields at once
|
|
286
|
+
*/
|
|
287
|
+
fillForm(data: Record<string, string | boolean>) {
|
|
288
|
+
Object.entries(data).forEach(([fieldName, value]) => {
|
|
289
|
+
if (typeof value === 'boolean') {
|
|
290
|
+
if (value) {
|
|
291
|
+
this.checkField(fieldName)
|
|
292
|
+
} else {
|
|
293
|
+
this.uncheckField(fieldName)
|
|
294
|
+
}
|
|
295
|
+
} else {
|
|
296
|
+
// Try input first, then textarea
|
|
297
|
+
cy.get(this.selectors.field(fieldName)).then($field => {
|
|
298
|
+
const hasInput = $field.find('input:not([type="checkbox"])').length > 0
|
|
299
|
+
const hasTextarea = $field.find('textarea').length > 0
|
|
300
|
+
const hasSelect = $field.find('[role="combobox"]').length > 0
|
|
301
|
+
|
|
302
|
+
if (hasInput) {
|
|
303
|
+
this.typeInField(fieldName, value)
|
|
304
|
+
} else if (hasTextarea) {
|
|
305
|
+
this.typeInTextarea(fieldName, value)
|
|
306
|
+
} else if (hasSelect) {
|
|
307
|
+
this.selectOption(fieldName, value)
|
|
308
|
+
}
|
|
309
|
+
})
|
|
310
|
+
}
|
|
311
|
+
})
|
|
312
|
+
return this
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// ============================================
|
|
316
|
+
// NAVIGATION METHODS
|
|
317
|
+
// ============================================
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Visit the create form page
|
|
321
|
+
*/
|
|
322
|
+
visitCreate() {
|
|
323
|
+
cy.visit(`/dashboard/${this.slug}/create`)
|
|
324
|
+
this.validatePageVisible()
|
|
325
|
+
return this
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Visit the edit form page
|
|
330
|
+
*/
|
|
331
|
+
visitEdit(id: string) {
|
|
332
|
+
cy.visit(`/dashboard/${this.slug}/${id}/edit`)
|
|
333
|
+
this.validatePageVisible()
|
|
334
|
+
return this
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Wait for form to be ready (all fields loaded)
|
|
339
|
+
*/
|
|
340
|
+
waitForFormReady() {
|
|
341
|
+
cy.get(this.selectors.form).should('be.visible')
|
|
342
|
+
cy.get(this.selectors.submitButton).should('be.visible')
|
|
343
|
+
return this
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// ============================================
|
|
347
|
+
// ASSERTION HELPERS
|
|
348
|
+
// ============================================
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Assert field has specific value
|
|
352
|
+
*/
|
|
353
|
+
assertFieldValue(fieldName: string, expectedValue: string) {
|
|
354
|
+
cy.get(this.selectors.fieldInput(fieldName)).should('have.value', expectedValue)
|
|
355
|
+
return this
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Assert textarea has specific value
|
|
360
|
+
*/
|
|
361
|
+
assertTextareaValue(fieldName: string, expectedValue: string) {
|
|
362
|
+
cy.get(this.selectors.fieldTextarea(fieldName)).should('have.value', expectedValue)
|
|
363
|
+
return this
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Assert select displays specific option
|
|
368
|
+
*/
|
|
369
|
+
assertSelectValue(fieldName: string, expectedText: string) {
|
|
370
|
+
cy.get(this.selectors.fieldSelect(fieldName)).should('contain.text', expectedText)
|
|
371
|
+
return this
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export default EntityForm
|