@cdc/core 4.25.8 → 4.25.11

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 (163) hide show
  1. package/_stories/StoryRenderingTests.stories.tsx +164 -0
  2. package/components/AdvancedEditor/AdvancedEditor.tsx +32 -9
  3. package/components/CustomColorsEditor/CustomColorsEditor.css +299 -0
  4. package/components/CustomColorsEditor/CustomColorsEditor.tsx +209 -0
  5. package/components/CustomColorsEditor/index.ts +1 -0
  6. package/components/DataTable/DataTable.tsx +56 -38
  7. package/components/DataTable/DataTableStandAlone.tsx +8 -3
  8. package/components/DataTable/components/ChartHeader.tsx +44 -14
  9. package/components/DataTable/components/DataTableEditorPanel.tsx +12 -2
  10. package/components/DataTable/components/ExpandCollapse.tsx +10 -1
  11. package/components/DataTable/components/MapHeader.tsx +24 -13
  12. package/components/DataTable/data-table.css +12 -0
  13. package/components/DataTable/helpers/chartCellMatrix.tsx +11 -8
  14. package/components/DataTable/helpers/mapCellMatrix.tsx +33 -4
  15. package/components/DataTable/helpers/standardizeState.js +2 -2
  16. package/components/DataTable/helpers/tests/standardizeState.test.js +54 -0
  17. package/components/DownloadButton.tsx +40 -14
  18. package/components/EditorPanel/DataTableEditor.tsx +3 -3
  19. package/components/EditorPanel/EditorPanel.styles.css +423 -0
  20. package/components/EditorPanel/FootnotesEditor.tsx +44 -37
  21. package/components/EditorPanel/Inputs.tsx +12 -2
  22. package/components/EditorPanel/VizFilterEditor/NestedDropdownEditor.tsx +35 -62
  23. package/components/EditorPanel/VizFilterEditor/VizFilterEditor.tsx +12 -2
  24. package/components/EditorPanel/components/MarkupHighlightedTextField.tsx +227 -0
  25. package/components/EditorPanel/components/MarkupVariablesEditor.tsx +450 -0
  26. package/components/EditorPanel/components/PanelMarkup.tsx +59 -0
  27. package/components/ErrorBoundary.jsx +3 -1
  28. package/components/Filters/Filters.tsx +52 -24
  29. package/components/Filters/components/Dropdown.tsx +6 -1
  30. package/components/Filters/components/Tabs.tsx +1 -0
  31. package/components/Footnotes/Footnotes.tsx +35 -25
  32. package/components/Footnotes/FootnotesStandAlone.tsx +42 -6
  33. package/components/HeaderThemeSelector/HeaderThemeSelector.css +43 -0
  34. package/components/HeaderThemeSelector/HeaderThemeSelector.stories.tsx +74 -0
  35. package/components/HeaderThemeSelector/HeaderThemeSelector.tsx +61 -0
  36. package/components/HeaderThemeSelector/index.ts +2 -0
  37. package/components/Layout/styles/editor.scss +2 -1
  38. package/components/Legend/Legend.Gradient.tsx +3 -6
  39. package/components/LegendShape.tsx +121 -3
  40. package/components/Loader/Loader.tsx +1 -1
  41. package/components/MediaControls.tsx +72 -21
  42. package/components/PaletteConversionModal.tsx +90 -0
  43. package/components/PaletteSelector/DeveloperPaletteRollback.tsx +114 -0
  44. package/components/PaletteSelector/PaletteSelector.css +94 -0
  45. package/components/PaletteSelector/PaletteSelector.tsx +112 -0
  46. package/components/PaletteSelector/index.ts +2 -0
  47. package/components/RichTooltip/RichTooltip.tsx +1 -0
  48. package/components/Table/Table.tsx +3 -1
  49. package/components/Table/components/Cell.tsx +23 -2
  50. package/components/Table/components/Row.tsx +5 -3
  51. package/components/_stories/BlurStrokeTest.stories.tsx +1 -1
  52. package/components/_stories/DataTable.stories.tsx +1 -1
  53. package/components/_stories/Filters.stories.tsx +21 -2
  54. package/components/_stories/Footnotes.CSV.stories.tsx +247 -0
  55. package/components/_stories/Footnotes.stories.tsx +769 -4
  56. package/components/_stories/Inputs.stories.tsx +3 -3
  57. package/components/_stories/MultiSelect.stories.tsx +3 -3
  58. package/components/_stories/NestedDropdown.stories.tsx +1 -1
  59. package/components/_stories/Table.stories.tsx +1 -1
  60. package/components/_stories/styles.scss +0 -1
  61. package/components/elements/_stories/Button.stories.tsx +1 -1
  62. package/components/elements/_stories/Card.stories.tsx +1 -1
  63. package/components/inputs/InputToggle.tsx +2 -0
  64. package/components/managers/DataDesigner.tsx +10 -9
  65. package/components/managers/_stories/DataDesigner.stories.tsx +1 -1
  66. package/components/ui/Accordion.jsx +1 -1
  67. package/components/ui/Tooltip.tsx +2 -1
  68. package/components/ui/_stories/Accordion.stories.tsx +1 -1
  69. package/components/ui/_stories/ColorPaletteMigration.stories.mdx +275 -0
  70. package/components/ui/_stories/Colors.stories.tsx +330 -0
  71. package/components/ui/_stories/IconGallery.stories.tsx +316 -0
  72. package/components/ui/_stories/Title.stories.tsx +1 -1
  73. package/components/ui/accordion.styles.css +57 -0
  74. package/contexts/EditorContext.ts +18 -0
  75. package/contexts/editor.actions.ts +28 -0
  76. package/contexts/editor.reducer.ts +94 -0
  77. package/data/chartColorPalettes.ts +118 -0
  78. package/data/colorPalettes.ts +9 -0
  79. package/data/mapColorPalettes.ts +45 -0
  80. package/data/sharedPalettes.ts +50 -0
  81. package/dist/cove-main.css +63 -14
  82. package/dist/cove-main.css.map +1 -1
  83. package/generateViteConfig.js +80 -0
  84. package/helpers/addValuesToFilters.ts +7 -3
  85. package/helpers/cloneConfig.ts +31 -0
  86. package/helpers/configDataHelpers.ts +128 -0
  87. package/helpers/configHelpers.ts +27 -0
  88. package/helpers/constants.ts +42 -2
  89. package/helpers/cove/number.ts +33 -12
  90. package/helpers/coveUpdateWorker.ts +15 -3
  91. package/helpers/fetchRemoteData.ts +3 -15
  92. package/helpers/filterColorPalettes.ts +152 -0
  93. package/helpers/generateColorsArray.ts +13 -0
  94. package/helpers/getColorPaletteVersion.ts +33 -0
  95. package/helpers/getPaletteAccessor.ts +18 -0
  96. package/helpers/markupProcessor.ts +220 -0
  97. package/helpers/mergeCustomOrderValues.ts +37 -0
  98. package/helpers/metrics/helpers.ts +42 -19
  99. package/helpers/metrics/types.ts +48 -9
  100. package/helpers/metrics/utils.ts +34 -0
  101. package/helpers/palettes/colorDistributions.ts +56 -0
  102. package/helpers/palettes/migratePaletteName.ts +150 -0
  103. package/helpers/palettes/standardizePaletteNames.ts +77 -0
  104. package/helpers/palettes/utils.ts +267 -0
  105. package/helpers/parseCsvWithQuotes.ts +65 -0
  106. package/helpers/queryStringUtils.ts +13 -0
  107. package/helpers/testing.ts +358 -0
  108. package/helpers/tests/addValuesToFilters.test.ts +1 -2
  109. package/helpers/tests/generateColorsArray.test.ts +24 -0
  110. package/helpers/tests/markupProcessor.test.ts +538 -0
  111. package/helpers/tests/testStandaloneBuild.ts +44 -0
  112. package/helpers/useMarkupVariables.ts +31 -0
  113. package/helpers/vegaConfig.ts +0 -1
  114. package/helpers/ver/4.24.10.ts +2 -1
  115. package/helpers/ver/4.24.11.ts +2 -1
  116. package/helpers/ver/4.24.3.ts +2 -1
  117. package/helpers/ver/4.24.4.ts +2 -1
  118. package/helpers/ver/4.24.5.ts +2 -1
  119. package/helpers/ver/4.24.7.ts +2 -1
  120. package/helpers/ver/4.24.9.ts +2 -1
  121. package/helpers/ver/4.25.1.ts +2 -1
  122. package/helpers/ver/4.25.10.ts +36 -0
  123. package/helpers/ver/4.25.11.ts +13 -0
  124. package/helpers/ver/4.25.3.ts +2 -1
  125. package/helpers/ver/4.25.4.ts +2 -1
  126. package/helpers/ver/4.25.6.ts +2 -1
  127. package/helpers/ver/4.25.7.ts +2 -1
  128. package/helpers/ver/4.25.8.ts +2 -1
  129. package/helpers/ver/4.25.9.ts +293 -0
  130. package/helpers/ver/tests/4.25.10.test.ts +204 -0
  131. package/helpers/ver/tests/4.25.8.test.ts +1 -1
  132. package/helpers/ver/tests/4.25.9.test.ts +51 -0
  133. package/helpers/viewports.ts +2 -0
  134. package/hooks/useColorPalette.ts +79 -0
  135. package/package.json +13 -4
  136. package/styles/_common-components.css +73 -0
  137. package/styles/_global.scss +32 -10
  138. package/styles/base.scss +8 -55
  139. package/styles/cove-main.scss +3 -1
  140. package/styles/filters.scss +10 -3
  141. package/styles/v2/base/index.scss +0 -1
  142. package/styles/v2/components/button.scss +4 -3
  143. package/styles/v2/components/editor.scss +16 -7
  144. package/styles/v2/layout/_data-table.scss +3 -2
  145. package/styles/v2/themes/_color-definitions.scss +18 -17
  146. package/styles/v2/utils/_breakpoints.scss +1 -1
  147. package/styles/v2/utils/index.scss +0 -1
  148. package/styles/waiting.scss +1 -1
  149. package/testing-setup.js +32 -0
  150. package/types/MarkupInclude.ts +8 -2
  151. package/types/MarkupVariable.ts +19 -0
  152. package/types/VizFilter.ts +2 -0
  153. package/vitest.config.ts +16 -0
  154. package/components/ui/_stories/Colors.stories.mdx +0 -220
  155. package/components/ui/_stories/IconGallery.stories.mdx +0 -14
  156. package/data/colorPalettes.js +0 -171
  157. package/helpers/formatConfigBeforeSave.ts +0 -135
  158. package/helpers/tests/formatConfigBeforeSave.test.ts +0 -68
  159. package/styles/_mixins.scss +0 -13
  160. package/styles/v2/base/_typography.scss +0 -0
  161. package/styles/v2/components/guidance-block.scss +0 -74
  162. package/styles/v2/utils/_functions.scss +0 -0
  163. /package/{styles/_typography.scss → testBuild.js} +0 -0
@@ -0,0 +1,358 @@
1
+ import { expect, userEvent } from 'storybook/test'
2
+ import { waitFor } from '@testing-library/react'
3
+
4
+ /**
5
+ * Shared Testing Helpers for Editor Story Tests
6
+ *
7
+ * This file contains common testing utilities used across all visualization
8
+ * editor story tests (Chart, Map, Data Bite, Waffle Chart, etc.).
9
+ *
10
+ * Key Features:
11
+ * - Adaptive animation delays for test environments vs UI
12
+ * - Robust polling utilities for async state changes
13
+ * - Generic before/after assertion patterns
14
+ * - Element presence/absence waiting
15
+ * - Text content change detection
16
+ * - Editor loading and accordion interaction helpers
17
+ *
18
+ */
19
+
20
+ // ============================================================================
21
+ // ENVIRONMENT DETECTION & TIMING
22
+ // ============================================================================
23
+
24
+ /**
25
+ * Use 500ms delay for visual perception in Storybook UI, but skip in automated tests
26
+ * This ensures smooth visual feedback for manual testing while keeping automated tests fast
27
+ */
28
+ export const MIN_ANIMATION_DELAY_MS = (() => {
29
+ // Check if we're in automated test environment (Vitest/Jest)
30
+ if (typeof process !== 'undefined' && process.env.NODE_ENV === 'test') {
31
+ return 0
32
+ }
33
+
34
+ // Check if we're running via test runner (Vitest has __vitest__ global)
35
+ if (typeof globalThis !== 'undefined' && '__vitest__' in globalThis) {
36
+ return 0
37
+ }
38
+
39
+ return 500
40
+ })()
41
+
42
+ const WAIT_FOR_TIMEOUT_MS = 10000
43
+
44
+ // ============================================================================
45
+ // CORE POLLING UTILITIES
46
+ // ============================================================================
47
+
48
+ // Wrapper for waitFor that includes explicit animation delay
49
+ const waitForWithDelay = async (predicate: () => void, options?: { timeout?: number }) => {
50
+ if (MIN_ANIMATION_DELAY_MS > 0) {
51
+ await new Promise(resolve => setTimeout(resolve, MIN_ANIMATION_DELAY_MS))
52
+ }
53
+
54
+ await waitFor(predicate, {
55
+ timeout: options?.timeout || WAIT_FOR_TIMEOUT_MS
56
+ })
57
+ }
58
+
59
+ /**
60
+ * Perform an action and assert the result using polling
61
+ * This is the core pattern for testing state changes in editor components
62
+ *
63
+ * @param label Descriptive label for the test action
64
+ * @param read Function that reads the current state
65
+ * @param act Function that performs the action
66
+ * @param predicate Function that validates the state change
67
+ * @param extraAssert Optional additional assertion on the final value
68
+ */
69
+ export const performAndAssert = async <T extends unknown>(
70
+ label: string,
71
+ read: () => T,
72
+ act: () => Promise<void> | void,
73
+ predicate: (before: T, after: T) => boolean,
74
+ extraAssert?: (after: T) => void
75
+ ): Promise<void> => {
76
+ // Capture the call site stack trace
77
+ const callSite = new Error().stack
78
+
79
+ const before = read()
80
+ await act()
81
+
82
+ await waitForWithDelay(() => {
83
+ const after = read()
84
+ const result = predicate(before, after)
85
+ if (!result) {
86
+ // Create a more informative error with the original call site
87
+ const error = new Error(
88
+ `${label} failed: Expected predicate to return true. Before: ${JSON.stringify(before)}, After: ${JSON.stringify(
89
+ after
90
+ )}`
91
+ )
92
+
93
+ // Try to preserve the original call site in the stack trace
94
+ if (callSite) {
95
+ const originalStack = callSite.split('\n')
96
+ // Replace the generic helper stack with the original call site
97
+ if (originalStack.length > 2) {
98
+ error.stack = [
99
+ error.message,
100
+ ...originalStack.slice(2) // Skip the first two lines (error creation in helper)
101
+ ].join('\n')
102
+ }
103
+ }
104
+
105
+ throw error
106
+ }
107
+ if (extraAssert) extraAssert(after)
108
+ })
109
+ }
110
+
111
+ // ============================================================================
112
+ // ELEMENT WAITING UTILITIES
113
+ // ============================================================================
114
+
115
+ /**
116
+ * Wait for an element to appear in the DOM
117
+ *
118
+ * @param selector CSS selector for the element
119
+ * @param canvasElement Container element to search within
120
+ * @returns Promise that resolves to the found element
121
+ */
122
+ export const waitForPresence = async (selector: string, canvasElement: HTMLElement) => {
123
+ await waitForWithDelay(() => {
124
+ const element = canvasElement.querySelector(selector)
125
+ expect(element).toBeTruthy()
126
+ })
127
+ return canvasElement.querySelector(selector)
128
+ }
129
+
130
+ /**
131
+ * Wait for an element to disappear from the DOM
132
+ *
133
+ * @param selector CSS selector for the element
134
+ * @param canvasElement Container element to search within
135
+ */
136
+ export const waitForAbsence = async (selector: string, canvasElement: HTMLElement) => {
137
+ await waitForWithDelay(() => {
138
+ const element = canvasElement.querySelector(selector)
139
+ expect(element).toBeFalsy()
140
+ })
141
+ }
142
+
143
+ /**
144
+ * Wait for a select element's options to populate
145
+ *
146
+ * @param selectElement The select element to monitor
147
+ * @param minCount The minimum number of expected elements
148
+ */
149
+ export const waitForOptionsToPopulate = async (selectElement: HTMLSelectElement, minCount: number = 2) => {
150
+ await waitForWithDelay(() => {
151
+ expect(selectElement.options.length).toBeGreaterThanOrEqual(minCount)
152
+ })
153
+ }
154
+
155
+ /**
156
+ * Wait for an element's text content to change to a specific value
157
+ *
158
+ * @param el The element to monitor
159
+ * @param expected The expected text content
160
+ */
161
+ export const waitForTextContent = async (el: HTMLElement | null, expected: string) => {
162
+ expect(el).toBeTruthy()
163
+ await waitForWithDelay(() => {
164
+ expect(el!.textContent?.trim()).toBe(expected.trim())
165
+ })
166
+ }
167
+
168
+ // ============================================================================
169
+ // EDITOR-SPECIFIC UTILITIES
170
+ // ============================================================================
171
+
172
+ /**
173
+ * Wait for the editor to load and become interactive
174
+ * This ensures all accordion sections are present and the component is ready for testing
175
+ *
176
+ * @param canvas Storybook canvas object from within(canvasElement)
177
+ */
178
+ export const waitForEditor = async (canvas: any) => {
179
+ await waitForWithDelay(() => {
180
+ const accordionButtons = canvas.getAllByRole('button', { name: /general|data|visual/i })
181
+ expect(accordionButtons.length).toBeGreaterThan(0)
182
+ for (const button of accordionButtons) {
183
+ expect(button).toBeVisible()
184
+ }
185
+ })
186
+ }
187
+
188
+ /**
189
+ * Open an accordion section in the editor
190
+ *
191
+ * @param canvas Storybook canvas object from within(canvasElement)
192
+ * @param sectionName Name of the accordion section (case-insensitive)
193
+ */
194
+ export const openAccordion = async (canvas: any, sectionName: string) => {
195
+ // Get all buttons with matching name and filter to only accordion buttons
196
+ const allButtons = canvas.getAllByRole('button', { name: new RegExp(sectionName, 'i') })
197
+ const accordion = allButtons.find(
198
+ (button: HTMLElement) =>
199
+ button.classList.contains('accordion__button') || button.closest('.editor-panel, .accordion')
200
+ )
201
+
202
+ if (!accordion) {
203
+ throw new Error(`Could not find accordion button for "${sectionName}"`)
204
+ }
205
+
206
+ await userEvent.click(accordion)
207
+ await waitForWithDelay(() => {
208
+ const accordionContent = accordion.closest('.accordion-item, .accordion-section, [class*="accordion"]')
209
+ expect(accordionContent).toBeTruthy()
210
+ })
211
+ }
212
+
213
+ // ============================================================================
214
+ // VISUAL STATE HELPERS
215
+ // ============================================================================
216
+
217
+ /**
218
+ * Get visual state for boolean/checkbox testing
219
+ * This is a flexible helper that can be customized for different visual properties
220
+ *
221
+ * @param element The element to analyze
222
+ * @param options Configuration for what visual properties to check
223
+ * @returns Object containing the visual state
224
+ */
225
+ export const getVisualState = (
226
+ element: HTMLElement | null,
227
+ options: {
228
+ checkClasses?: string[] // CSS classes to check for presence
229
+ checkStyles?: string[] // CSS properties to read from computed styles
230
+ checkAttributes?: string[] // HTML attributes to read
231
+ customChecks?: ((el: HTMLElement) => Record<string, any>)[] // Custom visual checks
232
+ } = {}
233
+ ) => {
234
+ if (!element) return null
235
+
236
+ const state: Record<string, any> = {}
237
+
238
+ // Check for specific CSS classes
239
+ if (options.checkClasses) {
240
+ for (const className of options.checkClasses) {
241
+ state[`has_${className.replace(/[^a-zA-Z0-9]/g, '_')}`] = element.classList.contains(className)
242
+ }
243
+ }
244
+
245
+ // Check computed styles
246
+ if (options.checkStyles) {
247
+ const computedStyle = getComputedStyle(element)
248
+ for (const property of options.checkStyles) {
249
+ state[`style_${property.replace(/[^a-zA-Z0-9]/g, '_')}`] = computedStyle.getPropertyValue(property)
250
+ }
251
+ }
252
+
253
+ // Check attributes
254
+ if (options.checkAttributes) {
255
+ for (const attr of options.checkAttributes) {
256
+ state[`attr_${attr.replace(/[^a-zA-Z0-9]/g, '_')}`] = element.getAttribute(attr)
257
+ }
258
+ }
259
+
260
+ // Run custom checks
261
+ if (options.customChecks) {
262
+ for (const customCheck of options.customChecks) {
263
+ Object.assign(state, customCheck(element))
264
+ }
265
+ }
266
+
267
+ // Always include basic visibility state
268
+ state.isVisible = element.offsetParent !== null
269
+ state.classList = Array.from(element.classList).sort().join(' ')
270
+
271
+ return state
272
+ }
273
+
274
+ /**
275
+ * Create a comprehensive boolean testing function for checkbox controls
276
+ * Tests both enable/disable directions and verifies visual changes
277
+ *
278
+ * @param checkbox The checkbox element to test
279
+ * @param getVisualState Function that returns the current visual state
280
+ * @param testName Descriptive name for the test
281
+ */
282
+ export const testBooleanControl = async (checkbox: HTMLInputElement, getVisualState: () => any, testName: string) => {
283
+ // Get initial state
284
+ const initialCheckboxState = checkbox.checked
285
+ const initialVisualState = getVisualState()
286
+
287
+ // First toggle: change to opposite state
288
+ await userEvent.click(checkbox)
289
+ await new Promise(resolve => setTimeout(resolve, 100))
290
+ const firstToggleCheckboxState = checkbox.checked
291
+ const firstToggleVisualState = getVisualState()
292
+
293
+ // Verify checkbox changed
294
+ expect(firstToggleCheckboxState).not.toBe(initialCheckboxState)
295
+
296
+ // Verify visualization changed (with flexible handling)
297
+ if (JSON.stringify(firstToggleVisualState) === JSON.stringify(initialVisualState)) {
298
+ // Note: This warns but doesn't fail, allowing for controls that may not have
299
+ // visible effects under current data/settings
300
+ console.warn(`⚠️ ${testName}: Checkbox toggled but no visual change detected`)
301
+ } else {
302
+ expect(firstToggleVisualState).not.toEqual(initialVisualState)
303
+ }
304
+
305
+ // Second toggle: return to original state
306
+ await userEvent.click(checkbox)
307
+ await new Promise(resolve => setTimeout(resolve, 100))
308
+ const secondToggleCheckboxState = checkbox.checked
309
+ const secondToggleVisualState = getVisualState()
310
+
311
+ // Verify both checkbox AND visualization returned to original
312
+ expect(secondToggleCheckboxState).toBe(initialCheckboxState)
313
+ expect(secondToggleVisualState).toEqual(initialVisualState)
314
+ }
315
+
316
+ // ============================================================================
317
+ // DATA EXTRACTION HELPERS
318
+ // ============================================================================
319
+
320
+ /**
321
+ * Get the primary data value displayed in a visualization
322
+ * Tries multiple common selectors for data values
323
+ *
324
+ * @param canvasElement The container element to search within
325
+ * @returns The data value as a string, or empty string if not found
326
+ */
327
+ export const getDisplayValue = (canvasElement: HTMLElement): string => {
328
+ const selectors = ['svg text', '.bite-text', '.data-value', '[data-testid="data-value"]']
329
+
330
+ for (const selector of selectors) {
331
+ const elements = canvasElement.querySelectorAll(selector)
332
+ for (let i = 0; i < elements.length; i++) {
333
+ const element = elements[i]
334
+ const text = element.textContent?.trim()
335
+ if (text && /[\d,]+/.test(text)) {
336
+ return text
337
+ }
338
+ }
339
+ }
340
+
341
+ return ''
342
+ }
343
+
344
+ /**
345
+ * Get the title text from a visualization
346
+ * Tries multiple common selectors for titles
347
+ *
348
+ * @param canvas Storybook canvas object from within(canvasElement)
349
+ * @returns The title text as a string, or empty string if not found
350
+ */
351
+ export const getTitleText = (canvas: any): string => {
352
+ try {
353
+ const titleElement = canvas.getByRole('heading') || canvas.querySelector('h1, h2, h3, .title')
354
+ return titleElement?.textContent?.trim() || ''
355
+ } catch {
356
+ return ''
357
+ }
358
+ }
@@ -2,7 +2,6 @@ import _ from 'lodash'
2
2
  import { VizFilter } from '../../types/VizFilter'
3
3
  import { addValuesToFilters } from '../addValuesToFilters'
4
4
  import { describe, it, expect, vi } from 'vitest'
5
- import { FILTER_STYLE } from '@cdc/dashboard/src/types/FilterStyles'
6
5
 
7
6
  describe('addValuesToFilters', () => {
8
7
  const parentFilter = { columnName: 'parentColumn', id: 11, active: 'apple', values: [] } as VizFilter
@@ -52,7 +51,7 @@ describe('addValuesToFilters', () => {
52
51
  it('works for nested dropdowns', () => {
53
52
  const nestedParentFilter = {
54
53
  ...parentFilter,
55
- filterStyle: FILTER_STYLE.nestedDropdown,
54
+ filterStyle: 'nested-dropdown',
56
55
  subGrouping: { columnName: 'childColumn' }
57
56
  }
58
57
  const newFilters = addValuesToFilters([nestedParentFilter], data)
@@ -0,0 +1,24 @@
1
+ import { generateColorsArray } from '../generateColorsArray'
2
+ import { describe, it, expect } from 'vitest'
3
+
4
+ describe('generateColorsArray', () => {
5
+ it('should return an array of colors', () => {
6
+ const colors = generateColorsArray('#fde0dd', false)
7
+ expect(colors).toEqual(expect.arrayContaining(['#fde0dd', '#ffd0c9', '#edd1ce']))
8
+ })
9
+
10
+ it('should return a brighter hover color when special flag is true', () => {
11
+ const colors = generateColorsArray('#fde0dd', true)
12
+ expect(colors[1]).toEqual('#fffaf7')
13
+ })
14
+
15
+ it('should return a darker color for the third element in the array', () => {
16
+ const colors = generateColorsArray('#fde0dd', false)
17
+ expect(colors[2]).toBe('#edd1ce')
18
+ })
19
+
20
+ it('should use black as default color', () => {
21
+ const colors = generateColorsArray()
22
+ expect(colors[0]).toBe('#000000')
23
+ })
24
+ })