@nextsparkjs/testing 0.1.0-beta.44 → 0.1.0-beta.45
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/index.d.ts +1 -3
- package/dist/index.js +63 -1166
- package/dist/index.js.map +1 -1
- package/dist/pom/index.d.ts +25 -27
- package/dist/pom/index.js +59 -66
- package/dist/pom/index.js.map +1 -1
- package/dist/utils/index.d.ts +3 -163
- package/dist/utils/index.js +1 -100
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -6
- package/dist/selector-factory-BivSWXbw.d.ts +0 -123
- package/dist/selectors/index.d.ts +0 -1774
- package/dist/selectors/index.js +0 -1000
- package/dist/selectors/index.js.map +0 -1
package/dist/utils/index.js
CHANGED
|
@@ -2,15 +2,6 @@
|
|
|
2
2
|
var isDevelopment = process.env.NODE_ENV === "development";
|
|
3
3
|
var isTest = process.env.NODE_ENV === "test";
|
|
4
4
|
var enableTestingAttributes = isDevelopment || isTest;
|
|
5
|
-
function createTestId(component, element, action) {
|
|
6
|
-
if (!enableTestingAttributes) return void 0;
|
|
7
|
-
const parts = [component, element, action].filter(Boolean);
|
|
8
|
-
return parts.join("-");
|
|
9
|
-
}
|
|
10
|
-
function createCyId(domain, element) {
|
|
11
|
-
if (!enableTestingAttributes) return void 0;
|
|
12
|
-
return `${domain}-${element}`;
|
|
13
|
-
}
|
|
14
5
|
function createStateAttr(state) {
|
|
15
6
|
return state;
|
|
16
7
|
}
|
|
@@ -46,54 +37,6 @@ function createAriaLabel(template, values) {
|
|
|
46
37
|
return String(values[key] ?? match);
|
|
47
38
|
});
|
|
48
39
|
}
|
|
49
|
-
var testingPatterns = {
|
|
50
|
-
// Task/Todo components
|
|
51
|
-
task: {
|
|
52
|
-
card: (taskId) => createTestingProps({
|
|
53
|
-
testId: createTestId("task", "card"),
|
|
54
|
-
cyId: createCyId("task", "item"),
|
|
55
|
-
taskId
|
|
56
|
-
}),
|
|
57
|
-
checkbox: () => createTestingProps({
|
|
58
|
-
testId: createTestId("task", "checkbox"),
|
|
59
|
-
cyId: createCyId("task", "toggle")
|
|
60
|
-
}),
|
|
61
|
-
title: () => createTestingProps({
|
|
62
|
-
testId: createTestId("task", "title"),
|
|
63
|
-
cyId: createCyId("task", "title")
|
|
64
|
-
}),
|
|
65
|
-
deleteButton: () => createTestingProps({
|
|
66
|
-
testId: createTestId("task", "delete", "button"),
|
|
67
|
-
cyId: createCyId("task", "delete")
|
|
68
|
-
})
|
|
69
|
-
},
|
|
70
|
-
// Navigation components
|
|
71
|
-
nav: {
|
|
72
|
-
searchDropdown: () => createTestingProps({
|
|
73
|
-
testId: createTestId("nav", "search", "dropdown"),
|
|
74
|
-
cyId: createCyId("nav", "search")
|
|
75
|
-
}),
|
|
76
|
-
notifications: () => createTestingProps({
|
|
77
|
-
testId: createTestId("nav", "notifications", "button"),
|
|
78
|
-
cyId: createCyId("nav", "notifications")
|
|
79
|
-
}),
|
|
80
|
-
userMenu: () => createTestingProps({
|
|
81
|
-
testId: createTestId("nav", "user", "menu"),
|
|
82
|
-
cyId: createCyId("nav", "user-menu")
|
|
83
|
-
})
|
|
84
|
-
},
|
|
85
|
-
// Form components
|
|
86
|
-
form: {
|
|
87
|
-
input: (fieldName) => createTestingProps({
|
|
88
|
-
testId: createTestId("form", fieldName, "input"),
|
|
89
|
-
cyId: createCyId("form", fieldName)
|
|
90
|
-
}),
|
|
91
|
-
submitButton: () => createTestingProps({
|
|
92
|
-
testId: createTestId("form", "submit", "button"),
|
|
93
|
-
cyId: createCyId("form", "submit")
|
|
94
|
-
})
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
40
|
var keyboardHelpers = {
|
|
98
41
|
/**
|
|
99
42
|
* Handle Enter and Space key activation
|
|
@@ -135,49 +78,7 @@ var keyboardHelpers = {
|
|
|
135
78
|
};
|
|
136
79
|
}
|
|
137
80
|
};
|
|
138
|
-
function createEntityCyId(entitySlug, component, detail) {
|
|
139
|
-
if (!enableTestingAttributes) return void 0;
|
|
140
|
-
const parts = [entitySlug, component, detail].filter(Boolean);
|
|
141
|
-
return parts.join("-");
|
|
142
|
-
}
|
|
143
|
-
function createEntityTestingHelper(entitySlug) {
|
|
144
|
-
return {
|
|
145
|
-
// Generic (framework-agnostic)
|
|
146
|
-
get: (component, detail) => createEntityCyId(entitySlug, component, detail),
|
|
147
|
-
// Page
|
|
148
|
-
page: () => createEntityCyId(entitySlug, "page"),
|
|
149
|
-
formPage: () => createEntityCyId(entitySlug, "form-page"),
|
|
150
|
-
// Form
|
|
151
|
-
form: () => createEntityCyId(entitySlug, "form"),
|
|
152
|
-
formSubmit: () => createEntityCyId(entitySlug, "form-submit"),
|
|
153
|
-
formCancel: () => createEntityCyId(entitySlug, "form-cancel"),
|
|
154
|
-
// Fields
|
|
155
|
-
field: (name) => createEntityCyId(entitySlug, "field", name),
|
|
156
|
-
fieldOption: (name, value) => createEntityCyId(entitySlug, `field-${name}-option`, value),
|
|
157
|
-
fieldError: (name) => createEntityCyId(entitySlug, `field-${name}`, "error"),
|
|
158
|
-
// Sections
|
|
159
|
-
section: (name) => createEntityCyId(entitySlug, "section", name),
|
|
160
|
-
// Card
|
|
161
|
-
card: (id) => createEntityCyId(entitySlug, "card", id),
|
|
162
|
-
// List/Table
|
|
163
|
-
table: () => createEntityCyId(entitySlug, "table"),
|
|
164
|
-
row: (id) => createEntityCyId(entitySlug, "row", id),
|
|
165
|
-
createBtn: () => createEntityCyId(entitySlug, "create-btn"),
|
|
166
|
-
searchInput: () => createEntityCyId(entitySlug, "search-input"),
|
|
167
|
-
// Filters
|
|
168
|
-
filter: (field) => createEntityCyId(entitySlug, "filter", field),
|
|
169
|
-
filterTrigger: (field) => createEntityCyId(entitySlug, `filter-${field}`, "trigger"),
|
|
170
|
-
filterOption: (field, value) => createEntityCyId(entitySlug, `filter-${field}-option`, value),
|
|
171
|
-
// Actions
|
|
172
|
-
action: (action, id) => createEntityCyId(entitySlug, `action-${action}`, id),
|
|
173
|
-
actionsTrigger: (id) => createEntityCyId(entitySlug, "actions-trigger", id),
|
|
174
|
-
// Dialogs
|
|
175
|
-
confirmDelete: () => createEntityCyId(entitySlug, "confirm-delete"),
|
|
176
|
-
confirmDeleteBtn: () => createEntityCyId(entitySlug, "confirm-delete-btn"),
|
|
177
|
-
cancelDeleteBtn: () => createEntityCyId(entitySlug, "cancel-delete-btn")
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
81
|
|
|
181
|
-
export { createAriaLabel,
|
|
82
|
+
export { createAriaLabel, createPriorityAttr, createStateAttr, createTestingProps, keyboardHelpers };
|
|
182
83
|
//# sourceMappingURL=index.js.map
|
|
183
84
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/utils.ts"],"names":[],"mappings":";AA0BA,IAAM,aAAA,GAAgB,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,aAAA;AAC/C,IAAM,MAAA,GAAS,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,MAAA;AACxC,IAAM,0BAA0B,aAAA,IAAiB,MAAA;AAc1C,SAAS,YAAA,CACd,SAAA,EACA,OAAA,EACA,MAAA,EACoB;AACpB,EAAA,IAAI,CAAC,yBAAyB,OAAO,MAAA;AAErC,EAAA,MAAM,QAAQ,CAAC,SAAA,EAAW,SAAS,MAAM,CAAA,CAAE,OAAO,OAAO,CAAA;AACzD,EAAA,OAAO,KAAA,CAAM,KAAK,GAAG,CAAA;AACvB;AASO,SAAS,UAAA,CAAW,QAAgB,OAAA,EAAqC;AAC9E,EAAA,IAAI,CAAC,yBAAyB,OAAO,MAAA;AAErC,EAAA,OAAO,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,OAAO,CAAA,CAAA;AAC7B;AAYO,SAAS,gBACd,KAAA,EACQ;AACR,EAAA,OAAO,KAAA;AACT;AAQO,SAAS,mBAAmB,QAAA,EAA6C;AAC9E,EAAA,OAAO,QAAA;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AAiB,UAAA,EAAY,mBAAmB,EAAE,CAAA;AAAA;AAAA,IAGlF,aAAA,EAAe,MAAM,gBAAA,CAAiB,UAAA,EAAY,gBAAgB,CAAA;AAAA,IAClE,gBAAA,EAAkB,MAAM,gBAAA,CAAiB,UAAA,EAAY,oBAAoB,CAAA;AAAA,IACzE,eAAA,EAAiB,MAAM,gBAAA,CAAiB,UAAA,EAAY,mBAAmB;AAAA,GACzE;AACF","file":"index.js","sourcesContent":["/**\n * Testing Utilities\n * Helper functions for consistent testing attribute generation\n */\n\n// =============================================================================\n// TYPE DEFINITIONS (inlined to avoid external dependency)\n// =============================================================================\n\n/**\n * Test ID pattern type\n */\nexport type TestIdPattern = string\n\n/**\n * Cypress ID pattern type\n */\nexport type CypressIdPattern = string\n\n// =============================================================================\n// ENVIRONMENT DETECTION\n// =============================================================================\n\n/**\n * Environment-based testing mode\n */\nconst isDevelopment = process.env.NODE_ENV === 'development'\nconst isTest = process.env.NODE_ENV === 'test'\nconst enableTestingAttributes = isDevelopment || isTest\n\n// =============================================================================\n// BASIC TEST ID GENERATORS\n// =============================================================================\n\n/**\n * Create consistent test IDs following the pattern: [component]-[element]-[action?]\n *\n * @param component - Main component name (e.g., 'task', 'nav', 'user')\n * @param element - Element type (e.g., 'card', 'button', 'input')\n * @param action - Optional action (e.g., 'delete', 'edit', 'toggle')\n * @returns Test ID string or undefined in production\n */\nexport function createTestId(\n component: string,\n element: string,\n action?: string\n): string | undefined {\n if (!enableTestingAttributes) return undefined\n\n const parts = [component, element, action].filter(Boolean)\n return parts.join('-') as TestIdPattern\n}\n\n/**\n * Create Cypress-specific IDs following the pattern: [domain]-[element]\n *\n * @param domain - Application domain (e.g., 'todo', 'nav', 'user')\n * @param element - Element identifier (e.g., 'item', 'button', 'menu')\n * @returns Cypress ID string or undefined in production\n */\nexport function createCyId(domain: string, element: string): string | undefined {\n if (!enableTestingAttributes) return undefined\n\n return `${domain}-${element}` as CypressIdPattern\n}\n\n// =============================================================================\n// ATTRIBUTE GENERATORS\n// =============================================================================\n\n/**\n * Create state-based data attributes for conditional testing\n *\n * @param state - Current state value\n * @returns State attribute value\n */\nexport function createStateAttr(\n state: 'active' | 'completed' | 'pending' | 'loading' | 'error'\n): string {\n return state\n}\n\n/**\n * Create priority-based data attributes\n *\n * @param priority - Priority level\n * @returns Priority attribute value\n */\nexport function createPriorityAttr(priority: 'low' | 'medium' | 'high'): string {\n return priority\n}\n\n/**\n * Generate testing props object for components\n *\n * @param config - Testing configuration\n * @returns Testing props object\n */\nexport function createTestingProps(config: {\n testId?: string\n cyId?: string\n state?: 'active' | 'completed' | 'pending' | 'loading' | 'error'\n priority?: 'low' | 'medium' | 'high'\n taskId?: string\n userId?: string\n}) {\n const props: Record<string, string | undefined> = {}\n\n if (config.testId) {\n props['data-testid'] = enableTestingAttributes ? config.testId : undefined\n }\n\n if (config.cyId) {\n props['data-cy'] = enableTestingAttributes ? config.cyId : undefined\n }\n\n if (config.state) {\n props['data-state'] = config.state\n }\n\n if (config.priority) {\n props['data-priority'] = config.priority\n }\n\n if (config.taskId) {\n props['data-task-id'] = config.taskId\n }\n\n if (config.userId) {\n props['data-user-id'] = config.userId\n }\n\n // Filter out undefined values\n return Object.fromEntries(\n Object.entries(props).filter((entry) => entry[1] !== undefined)\n )\n}\n\n/**\n * Accessibility helper for dynamic aria-label generation\n *\n * @param template - Label template with placeholders\n * @param values - Values to replace placeholders\n * @returns Formatted aria-label\n */\nexport function createAriaLabel(\n template: string,\n values: Record<string, string | number | boolean>\n): string {\n return template.replace(/\\{(\\w+)\\}/g, (match, key) => {\n return String(values[key] ?? match)\n })\n}\n\n// =============================================================================\n// TESTING PATTERNS\n// =============================================================================\n\n/**\n * Common testing patterns for different component types\n */\nexport const testingPatterns = {\n // Task/Todo components\n task: {\n card: (taskId: string) =>\n createTestingProps({\n testId: createTestId('task', 'card'),\n cyId: createCyId('task', 'item'),\n taskId,\n }),\n checkbox: () =>\n createTestingProps({\n testId: createTestId('task', 'checkbox'),\n cyId: createCyId('task', 'toggle'),\n }),\n title: () =>\n createTestingProps({\n testId: createTestId('task', 'title'),\n cyId: createCyId('task', 'title'),\n }),\n deleteButton: () =>\n createTestingProps({\n testId: createTestId('task', 'delete', 'button'),\n cyId: createCyId('task', 'delete'),\n }),\n },\n\n // Navigation components\n nav: {\n searchDropdown: () =>\n createTestingProps({\n testId: createTestId('nav', 'search', 'dropdown'),\n cyId: createCyId('nav', 'search'),\n }),\n notifications: () =>\n createTestingProps({\n testId: createTestId('nav', 'notifications', 'button'),\n cyId: createCyId('nav', 'notifications'),\n }),\n userMenu: () =>\n createTestingProps({\n testId: createTestId('nav', 'user', 'menu'),\n cyId: createCyId('nav', 'user-menu'),\n }),\n },\n\n // Form components\n form: {\n input: (fieldName: string) =>\n createTestingProps({\n testId: createTestId('form', fieldName, 'input'),\n cyId: createCyId('form', fieldName),\n }),\n submitButton: () =>\n createTestingProps({\n testId: createTestId('form', 'submit', 'button'),\n cyId: createCyId('form', 'submit'),\n }),\n },\n}\n\n// =============================================================================\n// KEYBOARD HELPERS\n// =============================================================================\n\n/**\n * Keyboard navigation helpers\n */\nexport const keyboardHelpers = {\n /**\n * Handle Enter and Space key activation\n */\n createActivationHandler: (onActivate: () => void) => {\n return (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n onActivate()\n }\n }\n },\n\n /**\n * Handle Escape key for closing\n */\n createEscapeHandler: (onClose: () => void) => {\n return (e: React.KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.preventDefault()\n onClose()\n }\n }\n },\n\n /**\n * Handle arrow navigation in lists\n */\n createArrowNavigationHandler: (\n currentIndex: number,\n maxIndex: number,\n onIndexChange: (index: number) => void\n ) => {\n return (e: React.KeyboardEvent) => {\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault()\n onIndexChange(currentIndex < maxIndex ? currentIndex + 1 : 0)\n break\n case 'ArrowUp':\n e.preventDefault()\n onIndexChange(currentIndex > 0 ? currentIndex - 1 : maxIndex)\n break\n }\n }\n },\n}\n\n// ============================================================================\n// ENTITY TESTING HELPERS\n// ============================================================================\n\n/**\n * Create entity-specific Cypress ID following the convention: {slug}-{component}-{detail?}\n *\n * @param entitySlug - Entity slug from config (e.g., 'squads', 'people', 'projects')\n * @param component - Component type (e.g., 'form', 'field', 'section', 'table')\n * @param detail - Optional detail (e.g., field name, section name, action)\n * @returns Cypress ID string or undefined in production\n *\n * @example\n * createEntityCyId('squads', 'form') // 'squads-form'\n * createEntityCyId('squads', 'field', 'name') // 'squads-field-name'\n * createEntityCyId('squads', 'form', 'submit') // 'squads-form-submit'\n */\nexport function createEntityCyId(\n entitySlug: string,\n component: string,\n detail?: string\n): string | undefined {\n if (!enableTestingAttributes) return undefined\n\n const parts = [entitySlug, component, detail].filter(Boolean)\n return parts.join('-')\n}\n\n/**\n * Entity testing helper interface\n */\nexport interface EntityTestingHelper {\n /** Generic selector: {slug}-{component}-{detail?} - Use for custom/non-standard selectors */\n get: (component: string, detail?: string) => string | undefined\n\n // Page selectors\n /** {slug}-page */\n page: () => string | undefined\n /** {slug}-form-page */\n formPage: () => string | undefined\n\n // Form selectors\n /** {slug}-form */\n form: () => string | undefined\n /** {slug}-form-submit */\n formSubmit: () => string | undefined\n /** {slug}-form-cancel */\n formCancel: () => string | undefined\n\n // Field selectors\n /** {slug}-field-{name} */\n field: (name: string) => string | undefined\n /** {slug}-field-{name}-option-{value} */\n fieldOption: (name: string, value: string) => string | undefined\n /** {slug}-field-{name}-error */\n fieldError: (name: string) => string | undefined\n\n // Section selectors\n /** {slug}-section-{name} */\n section: (name: string) => string | undefined\n\n // Card selectors\n /** {slug}-card-{id} */\n card: (id: string) => string | undefined\n\n // List/Table selectors\n /** {slug}-table */\n table: () => string | undefined\n /** {slug}-row-{id} */\n row: (id: string) => string | undefined\n /** {slug}-create-btn */\n createBtn: () => string | undefined\n /** {slug}-search-input */\n searchInput: () => string | undefined\n\n // Filter selectors\n /** {slug}-filter-{field} */\n filter: (field: string) => string | undefined\n /** {slug}-filter-{field}-trigger */\n filterTrigger: (field: string) => string | undefined\n /** {slug}-filter-{field}-option-{value} */\n filterOption: (field: string, value: string) => string | undefined\n\n // Action selectors\n /** {slug}-action-{action}-{id} */\n action: (action: string, id: string) => string | undefined\n /** {slug}-actions-trigger-{id} */\n actionsTrigger: (id: string) => string | undefined\n\n // Dialog selectors\n /** {slug}-confirm-delete */\n confirmDelete: () => string | undefined\n /** {slug}-confirm-delete-btn */\n confirmDeleteBtn: () => string | undefined\n /** {slug}-cancel-delete-btn */\n cancelDeleteBtn: () => string | undefined\n}\n\n/**\n * Create a testing helper factory for a specific entity.\n * Uses the entity slug from config to generate consistent data-cy selectors.\n *\n * Convention: {slug}-{component}-{detail}\n *\n * @param entitySlug - Entity slug from EntityConfig (e.g., 'squads', 'people')\n * @returns EntityTestingHelper with pre-bound selector generators\n *\n * @example\n * // In your component file:\n * import { createEntityTestingHelper } from '@nextsparkjs/testing/utils'\n * import { squadsEntityConfig } from './squads.config'\n *\n * const testId = createEntityTestingHelper(squadsEntityConfig.slug)\n *\n * // Usage in JSX:\n * <div data-cy={testId.formPage()}> // squads-form-page\n * <form data-cy={testId.form()}> // squads-form\n * <div data-cy={testId.section('basic')}> // squads-section-basic\n * <input data-cy={testId.field('name')} /> // squads-field-name\n * </div>\n * <button data-cy={testId.formSubmit()}> // squads-form-submit\n * Submit\n * </button>\n * </form>\n * </div>\n *\n * // Card example:\n * <Card data-cy={testId.card(squad.id)}> // squads-card-{id}\n *\n * // Custom selector example (for non-standard selectors):\n * <div data-cy={testId.get('color-preset', color)}> // squads-color-preset-{color}\n */\nexport function createEntityTestingHelper(entitySlug: string): EntityTestingHelper {\n return {\n // Generic (framework-agnostic)\n get: (component: string, detail?: string) =>\n createEntityCyId(entitySlug, component, detail),\n\n // Page\n page: () => createEntityCyId(entitySlug, 'page'),\n formPage: () => createEntityCyId(entitySlug, 'form-page'),\n\n // Form\n form: () => createEntityCyId(entitySlug, 'form'),\n formSubmit: () => createEntityCyId(entitySlug, 'form-submit'),\n formCancel: () => createEntityCyId(entitySlug, 'form-cancel'),\n\n // Fields\n field: (name: string) => createEntityCyId(entitySlug, 'field', name),\n fieldOption: (name: string, value: string) =>\n createEntityCyId(entitySlug, `field-${name}-option`, value),\n fieldError: (name: string) => createEntityCyId(entitySlug, `field-${name}`, 'error'),\n\n // Sections\n section: (name: string) => createEntityCyId(entitySlug, 'section', name),\n\n // Card\n card: (id: string) => createEntityCyId(entitySlug, 'card', id),\n\n // List/Table\n table: () => createEntityCyId(entitySlug, 'table'),\n row: (id: string) => createEntityCyId(entitySlug, 'row', id),\n createBtn: () => createEntityCyId(entitySlug, 'create-btn'),\n searchInput: () => createEntityCyId(entitySlug, 'search-input'),\n\n // Filters\n filter: (field: string) => createEntityCyId(entitySlug, 'filter', field),\n filterTrigger: (field: string) =>\n createEntityCyId(entitySlug, `filter-${field}`, 'trigger'),\n filterOption: (field: string, value: string) =>\n createEntityCyId(entitySlug, `filter-${field}-option`, value),\n\n // Actions\n action: (action: string, id: string) =>\n createEntityCyId(entitySlug, `action-${action}`, id),\n actionsTrigger: (id: string) => createEntityCyId(entitySlug, 'actions-trigger', id),\n\n // Dialogs\n confirmDelete: () => createEntityCyId(entitySlug, 'confirm-delete'),\n confirmDeleteBtn: () => createEntityCyId(entitySlug, 'confirm-delete-btn'),\n cancelDeleteBtn: () => createEntityCyId(entitySlug, 'cancel-delete-btn'),\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/utils.ts"],"names":[],"mappings":";AAeA,IAAM,aAAA,GAAgB,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,aAAA;AAC/C,IAAM,MAAA,GAAS,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,MAAA;AACxC,IAAM,0BAA0B,aAAA,IAAiB,MAAA;AAY1C,SAAS,gBACd,KAAA,EACQ;AACR,EAAA,OAAO,KAAA;AACT;AAQO,SAAS,mBAAmB,QAAA,EAA6C;AAC9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AyB,CAAC,UAAA,KAA2B;AACnD,IAAA,OAAO,CAAC,CAAA,KAA2B;AACjC,MAAA,IAAI,CAAA,CAAE,GAAA,KAAQ,OAAA,IAAW,CAAA,CAAE,QAAQ,GAAA,EAAK;AACtC,QAAA,CAAA,CAAE,cAAA,EAAe;AACjB,QAAA,UAAA,EAAW;AAAA,MACb;AAAA,IACF,CAAA;AAAA,EACF,CAAA;AAAA;AAAA;AAAA;AAAA,EAKA,mBAAA,EAAqB,CAAC,OAAA,KAAwB;AAC5C,IAAA,OAAO,CAAC,CAAA,KAA2B;AACjC,MAAA,IAAI,CAAA,CAAE,QAAQ,QAAA,EAAU;AACtB,QAAA,CAAA,CAAE,cAAA,EAAe;AACjB,QAAA,OAAA,EAAQ;AAAA,MACV;AAAA,IACF,CAAA;AAAA,EACF,CAAA;AAAA;AAAA;AAAA;AAAA,EAKA,4BAAA,EAA8B,CAC5B,YAAA,EACA,QAAA,EACA,aAAA,KACG;AACH,IAAA,OAAO,CAAC,CAAA,KAA2B;AACjC,MAAA,QAAQ,EAAE,GAAA;AAAK,QACb,KAAK,WAAA;AACH,UAAA,CAAA,CAAE,cAAA,EAAe;AACjB,UAAA,aAAA,CAAc,YAAA,GAAe,QAAA,GAAW,YAAA,GAAe,CAAA,GAAI,CAAC,CAAA;AAC5D,UAAA;AAAA,QACF,KAAK,SAAA;AACH,UAAA,CAAA,CAAE,cAAA,EAAe;AACjB,UAAA,aAAA,CAAc,YAAA,GAAe,CAAA,GAAI,YAAA,GAAe,CAAA,GAAI,QAAQ,CAAA;AAC5D,UAAA;AAAA;AACJ,IACF,CAAA;AAAA,EACF;AACF","file":"index.js","sourcesContent":["/**\n * Testing Utilities\n * Helper functions for consistent testing attribute generation\n *\n * NOTE: For data-cy selectors, use sel() from '@nextsparkjs/core/selectors'\n * This file contains runtime utilities for accessibility and keyboard handling.\n */\n\n// =============================================================================\n// ENVIRONMENT DETECTION\n// =============================================================================\n\n/**\n * Environment-based testing mode\n */\nconst isDevelopment = process.env.NODE_ENV === 'development'\nconst isTest = process.env.NODE_ENV === 'test'\nconst enableTestingAttributes = isDevelopment || isTest\n\n// =============================================================================\n// ATTRIBUTE GENERATORS\n// =============================================================================\n\n/**\n * Create state-based data attributes for conditional testing\n *\n * @param state - Current state value\n * @returns State attribute value\n */\nexport function createStateAttr(\n state: 'active' | 'completed' | 'pending' | 'loading' | 'error'\n): string {\n return state\n}\n\n/**\n * Create priority-based data attributes\n *\n * @param priority - Priority level\n * @returns Priority attribute value\n */\nexport function createPriorityAttr(priority: 'low' | 'medium' | 'high'): string {\n return priority\n}\n\n/**\n * Generate testing props object for components\n *\n * @param config - Testing configuration\n * @returns Testing props object\n */\nexport function createTestingProps(config: {\n testId?: string\n cyId?: string\n state?: 'active' | 'completed' | 'pending' | 'loading' | 'error'\n priority?: 'low' | 'medium' | 'high'\n taskId?: string\n userId?: string\n}) {\n const props: Record<string, string | undefined> = {}\n\n if (config.testId) {\n props['data-testid'] = enableTestingAttributes ? config.testId : undefined\n }\n\n if (config.cyId) {\n props['data-cy'] = enableTestingAttributes ? config.cyId : undefined\n }\n\n if (config.state) {\n props['data-state'] = config.state\n }\n\n if (config.priority) {\n props['data-priority'] = config.priority\n }\n\n if (config.taskId) {\n props['data-task-id'] = config.taskId\n }\n\n if (config.userId) {\n props['data-user-id'] = config.userId\n }\n\n // Filter out undefined values\n return Object.fromEntries(\n Object.entries(props).filter((entry) => entry[1] !== undefined)\n )\n}\n\n/**\n * Accessibility helper for dynamic aria-label generation\n *\n * @param template - Label template with placeholders\n * @param values - Values to replace placeholders\n * @returns Formatted aria-label\n */\nexport function createAriaLabel(\n template: string,\n values: Record<string, string | number | boolean>\n): string {\n return template.replace(/\\{(\\w+)\\}/g, (match, key) => {\n return String(values[key] ?? match)\n })\n}\n\n// =============================================================================\n// KEYBOARD HELPERS\n// =============================================================================\n\n/**\n * Keyboard navigation helpers\n */\nexport const keyboardHelpers = {\n /**\n * Handle Enter and Space key activation\n */\n createActivationHandler: (onActivate: () => void) => {\n return (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n onActivate()\n }\n }\n },\n\n /**\n * Handle Escape key for closing\n */\n createEscapeHandler: (onClose: () => void) => {\n return (e: React.KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.preventDefault()\n onClose()\n }\n }\n },\n\n /**\n * Handle arrow navigation in lists\n */\n createArrowNavigationHandler: (\n currentIndex: number,\n maxIndex: number,\n onIndexChange: (index: number) => void\n ) => {\n return (e: React.KeyboardEvent) => {\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault()\n onIndexChange(currentIndex < maxIndex ? currentIndex + 1 : 0)\n break\n case 'ArrowUp':\n e.preventDefault()\n onIndexChange(currentIndex > 0 ? currentIndex - 1 : maxIndex)\n break\n }\n }\n },\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextsparkjs/testing",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.45",
|
|
4
4
|
"description": "Testing utilities for NextSpark applications - Selectors, POMs, and Cypress helpers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "NextSpark <hello@nextspark.dev>",
|
|
@@ -29,11 +29,6 @@
|
|
|
29
29
|
"import": "./dist/index.js",
|
|
30
30
|
"default": "./dist/index.js"
|
|
31
31
|
},
|
|
32
|
-
"./selectors": {
|
|
33
|
-
"types": "./dist/selectors/index.d.ts",
|
|
34
|
-
"import": "./dist/selectors/index.js",
|
|
35
|
-
"default": "./dist/selectors/index.js"
|
|
36
|
-
},
|
|
37
32
|
"./utils": {
|
|
38
33
|
"types": "./dist/utils/index.d.ts",
|
|
39
34
|
"import": "./dist/utils/index.js",
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Selector Factory
|
|
3
|
-
*
|
|
4
|
-
* Factory function and utilities for creating selector helpers.
|
|
5
|
-
* This file contains only the logic - no selector definitions.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import { createSelectorHelpers } from './selector-factory'
|
|
10
|
-
* import { CORE_SELECTORS } from './core-selectors'
|
|
11
|
-
*
|
|
12
|
-
* // Create helpers bound to your selectors
|
|
13
|
-
* const { sel, cySelector, selDev, SELECTORS } = createSelectorHelpers(CORE_SELECTORS)
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* Themes can extend core selectors:
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const THEME_SELECTORS = {
|
|
19
|
-
* ...CORE_SELECTORS,
|
|
20
|
-
* customFeature: { ... }
|
|
21
|
-
* }
|
|
22
|
-
* export const { sel, cySelector } = createSelectorHelpers(THEME_SELECTORS)
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
/**
|
|
26
|
-
* Placeholder replacements type
|
|
27
|
-
*/
|
|
28
|
-
type Replacements = Record<string, string | number>;
|
|
29
|
-
/**
|
|
30
|
-
* Generic selector object type
|
|
31
|
-
*/
|
|
32
|
-
type SelectorObject = Record<string, unknown>;
|
|
33
|
-
/**
|
|
34
|
-
* Return type for createSelectorHelpers
|
|
35
|
-
*/
|
|
36
|
-
interface SelectorHelpers<T extends SelectorObject> {
|
|
37
|
-
/** The selectors object */
|
|
38
|
-
SELECTORS: T;
|
|
39
|
-
/** Get selector value by path */
|
|
40
|
-
sel: (path: string, replacements?: Replacements) => string;
|
|
41
|
-
/** Alias for sel */
|
|
42
|
-
s: (path: string, replacements?: Replacements) => string;
|
|
43
|
-
/** Get selector only in dev/test environments */
|
|
44
|
-
selDev: (path: string, replacements?: Replacements) => string | undefined;
|
|
45
|
-
/** Get Cypress selector string [data-cy="..."] */
|
|
46
|
-
cySelector: (path: string, replacements?: Replacements) => string;
|
|
47
|
-
/** Create entity-specific selector helpers */
|
|
48
|
-
entitySelectors: (slug: string) => EntitySelectorHelpers;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Entity selector helpers return type
|
|
52
|
-
*/
|
|
53
|
-
interface EntitySelectorHelpers {
|
|
54
|
-
page: () => string;
|
|
55
|
-
title: () => string;
|
|
56
|
-
table: () => string;
|
|
57
|
-
tableContainer: () => string;
|
|
58
|
-
search: () => string;
|
|
59
|
-
addButton: () => string;
|
|
60
|
-
row: (id: string) => string;
|
|
61
|
-
rowMenu: (id: string) => string;
|
|
62
|
-
rowAction: (action: string, id: string) => string;
|
|
63
|
-
cell: (field: string, id: string) => string;
|
|
64
|
-
form: () => string;
|
|
65
|
-
field: (name: string) => string;
|
|
66
|
-
submitButton: () => string;
|
|
67
|
-
header: (mode: string) => string;
|
|
68
|
-
backButton: () => string;
|
|
69
|
-
editButton: () => string;
|
|
70
|
-
deleteButton: () => string;
|
|
71
|
-
detail: () => string;
|
|
72
|
-
filter: (field: string) => string;
|
|
73
|
-
filterTrigger: (field: string) => string;
|
|
74
|
-
filterOption: (field: string, value: string) => string;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Navigate to a value in a nested object using dot notation
|
|
78
|
-
*
|
|
79
|
-
* @param obj - Object to navigate
|
|
80
|
-
* @param path - Dot-separated path (e.g., "dashboard.navigation.main")
|
|
81
|
-
* @returns The value at the path, or undefined if not found
|
|
82
|
-
*/
|
|
83
|
-
declare function getNestedValue(obj: Record<string, unknown>, path: string): unknown;
|
|
84
|
-
/**
|
|
85
|
-
* Replace placeholders in a selector string
|
|
86
|
-
*
|
|
87
|
-
* @param selector - Selector pattern with {placeholder} syntax
|
|
88
|
-
* @param replacements - Object with replacement values
|
|
89
|
-
* @returns Selector with placeholders replaced
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* replacePlaceholders('{slug}-row-{id}', { slug: 'customers', id: '123' })
|
|
93
|
-
* // Returns: 'customers-row-123'
|
|
94
|
-
*/
|
|
95
|
-
declare function replacePlaceholders(selector: string, replacements?: Replacements): string;
|
|
96
|
-
/**
|
|
97
|
-
* Create selector helper functions bound to a specific selectors object.
|
|
98
|
-
*
|
|
99
|
-
* This factory allows themes to extend core selectors while using
|
|
100
|
-
* the same helper functions.
|
|
101
|
-
*
|
|
102
|
-
* @param selectors - The selectors object to bind helpers to
|
|
103
|
-
* @returns Object with sel, cySelector, selDev, and entitySelectors functions
|
|
104
|
-
*
|
|
105
|
-
* @example Core usage:
|
|
106
|
-
* ```typescript
|
|
107
|
-
* import { CORE_SELECTORS } from './core-selectors'
|
|
108
|
-
* const { sel, cySelector } = createSelectorHelpers(CORE_SELECTORS)
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* @example Theme extension:
|
|
112
|
-
* ```typescript
|
|
113
|
-
* const THEME_SELECTORS = {
|
|
114
|
-
* ...CORE_SELECTORS,
|
|
115
|
-
* myCustomFeature: { button: 'custom-btn' }
|
|
116
|
-
* }
|
|
117
|
-
* const { sel, cySelector } = createSelectorHelpers(THEME_SELECTORS)
|
|
118
|
-
* sel('myCustomFeature.button') // 'custom-btn'
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
declare function createSelectorHelpers<T extends SelectorObject>(selectors: T): SelectorHelpers<T>;
|
|
122
|
-
|
|
123
|
-
export { type EntitySelectorHelpers as E, type Replacements as R, type SelectorObject as S, type SelectorHelpers as a, createSelectorHelpers as c, getNestedValue as g, replacePlaceholders as r };
|