@cdc/data-bite 4.26.1 → 4.26.3

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.
@@ -100,7 +100,7 @@ export const GeneralSectionTests: Story = {
100
100
  return {
101
101
  hasSvg: !!svg,
102
102
  textCount: textElements.length,
103
- containerClasses: canvasElement.querySelector('.cdc-open-viz-module')?.className || ''
103
+ containerClasses: canvasElement.querySelector('.cove-visualization')?.className || ''
104
104
  }
105
105
  }
106
106
 
@@ -145,7 +145,7 @@ export const GeneralSectionTests: Story = {
145
145
 
146
146
  await performAndAssert(
147
147
  'Title Update',
148
- () => canvasElement.querySelector('.cove-component__header')?.textContent?.trim() || '',
148
+ () => canvasElement.querySelector('.cove-visualization__header')?.textContent?.trim() || '',
149
149
  async () => {}, // action already performed above
150
150
  (before, after) => after === 'Updated Data Bite Title'
151
151
  )
@@ -158,7 +158,7 @@ export const GeneralSectionTests: Story = {
158
158
  expect(showTitleCheckbox).toBeTruthy()
159
159
 
160
160
  const getTitleVisibility = () => {
161
- const titleElement = canvasElement.querySelector('.cove-component__header') as HTMLElement
161
+ const titleElement = canvasElement.querySelector('.cove-visualization__header') as HTMLElement
162
162
  return titleElement && titleElement.offsetParent !== null
163
163
  }
164
164
 
@@ -702,7 +702,7 @@ export const VisualSectionTests: Story = {
702
702
  // TEST 3: Display Border Toggle
703
703
  // Expectation: Border styling changes when toggled (classes or computed styles)
704
704
  // ============================================================================
705
- const contentContainer = () => canvasElement.querySelector('.cove-component__content') as HTMLElement
705
+ const contentContainer = () => canvasElement.querySelector('.cove-visualization__body') as HTMLElement
706
706
  expect(contentContainer()).toBeTruthy()
707
707
 
708
708
  // Note: Border checkbox uses name="border", other checkboxes use similar simple names
@@ -736,7 +736,7 @@ export const VisualSectionTests: Story = {
736
736
 
737
737
  // Test border checkbox with comprehensive boolean testing AND visual validation
738
738
  const getBorderVisualState = () => {
739
- const element = canvasElement.querySelector('.cove-component__content')
739
+ const element = canvasElement.querySelector('.cove-visualization__body')
740
740
  return {
741
741
  classes: Array.from(element!.classList).sort().join(' '),
742
742
  hasNoBordersClass: element!.classList.contains('no-borders'),
@@ -792,14 +792,14 @@ export const VisualSectionTests: Story = {
792
792
 
793
793
  // Test remaining checkboxes with comprehensive boolean testing AND visual validation
794
794
  const getGeneralVisualState = () => {
795
- const element = canvasElement.querySelector('.cove-component__content')
795
+ const element = canvasElement.querySelector('.cove-visualization__body')
796
796
  return {
797
797
  classes: Array.from(element!.classList).sort().join(' '),
798
798
  // Check for specific component classes that these controls add
799
799
  hasAccentClass: element!.classList.contains('component--has-accent'),
800
800
  hasBackgroundClass: element!.classList.contains('component--has-background'),
801
- hasBorderColorThemeClass: element!.classList.contains('component--has-borderColorTheme'),
802
- hideBackgroundColorClass: element!.classList.contains('component--hideBackgroundColor'),
801
+ hasBorderColorThemeClass: element!.classList.contains('component--has-border-color-theme'),
802
+ hideBackgroundColorClass: element!.classList.contains('component--hide-background-color'),
803
803
  themeClass: Array.from(element!.classList).find(cls => cls.includes('theme-')) || 'no-theme',
804
804
  backgroundStyle: getComputedStyle(element!).backgroundColor
805
805
  }
@@ -1,5 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import DataBite from '../CdcDataBite'
3
+ import { assertVisualizationRendered, waitForPresence } from '@cdc/core/helpers/testing'
4
+ import { expect } from 'storybook/test'
3
5
 
4
6
  const meta: Meta<typeof DataBite> = {
5
7
  title: 'Components/Templates/Data Bite',
@@ -21,24 +23,36 @@ type Story = StoryObj<typeof DataBite>
21
23
  export const Data_Bite_Circle_Average: Story = {
22
24
  args: {
23
25
  configUrl: 'https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/Data_Bite_Circle_Average.json'
26
+ },
27
+ play: async ({ canvasElement }) => {
28
+ await assertVisualizationRendered(canvasElement)
24
29
  }
25
30
  }
26
31
 
27
32
  export const Data_Bite_Text_Max_Pic: Story = {
28
33
  args: {
29
34
  configUrl: 'https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/Data_Bite_Text_Max_Pic.json'
35
+ },
36
+ play: async ({ canvasElement }) => {
37
+ await assertVisualizationRendered(canvasElement)
30
38
  }
31
39
  }
32
40
 
33
41
  export const Data_Bite_Circle_Sum: Story = {
34
42
  args: {
35
43
  configUrl: 'https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/Data_Bite_Circle_Sum.json'
44
+ },
45
+ play: async ({ canvasElement }) => {
46
+ await assertVisualizationRendered(canvasElement)
36
47
  }
37
48
  }
38
49
 
39
50
  export const Data_Bite_Text_Average_Pic: Story = {
40
51
  args: {
41
52
  configUrl: 'https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/Data_Bite_Text_Average_Pic.json'
53
+ },
54
+ play: async ({ canvasElement }) => {
55
+ await assertVisualizationRendered(canvasElement)
42
56
  }
43
57
  }
44
58
 
@@ -53,6 +67,9 @@ export const Data_Bite_TP5_Style: Story = {
53
67
  'TP5 Style - A new layout style that displays the data value and message side by side, centered. The title appears above, and subtext appears below the message. On mobile devices, the message wraps below the data value. This style mimics the CDC Template Package 5.0 callout component design.'
54
68
  }
55
69
  }
70
+ },
71
+ play: async ({ canvasElement }) => {
72
+ await assertVisualizationRendered(canvasElement)
56
73
  }
57
74
  }
58
75
 
@@ -67,6 +84,20 @@ export const Data_Bite_TP5_White_Background: Story = {
67
84
  'TP5 Style with White Background - This variant uses a white background with a 1px border and 6px border radius, providing a cleaner look while maintaining the TP5 layout style.'
68
85
  }
69
86
  }
87
+ },
88
+ play: async ({ canvasElement }) => {
89
+ await assertVisualizationRendered(canvasElement)
90
+ }
91
+ }
92
+
93
+ export const Data_Bite_With_Metadata: Story = {
94
+ args: {
95
+ configUrl: '/packages/data-bite/tests/fixtures/data-bite-config-with-metadata.json'
96
+ },
97
+ play: async ({ canvasElement }) => {
98
+ await assertVisualizationRendered(canvasElement)
99
+ const subtext = await waitForPresence('.bite-subtext', canvasElement)
100
+ expect(subtext?.textContent).toContain('January 15, 2026')
70
101
  }
71
102
  }
72
103
 
@@ -83,5 +114,8 @@ export const Editor_Mode_Basic: Story = {
83
114
  'Basic editor mode rendering. For comprehensive editor testing with interactions, see "Data Bite/Editor Tests" stories.'
84
115
  }
85
116
  }
117
+ },
118
+ play: async ({ canvasElement }) => {
119
+ await assertVisualizationRendered(canvasElement)
86
120
  }
87
121
  }