Skip to content

Commit fda2083

Browse files
committed
Add example test for storybook
1 parent 49ff559 commit fda2083

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/smart-forms-renderer/src/stories/sdc/RenderingTextAppearance.stories.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
import type { Meta, StoryObj } from '@storybook/react-vite';
19+
import { expect, within } from 'storybook/test';
1920
import BuildFormWrapperForStorybook from '../storybookWrappers/BuildFormWrapperForStorybook';
2021
import {
2122
qDisplayCategoryInstructions,
@@ -103,6 +104,19 @@ export const RenderingAnswerOptionValueString: Story = createStory({
103104
export const DisplayCategoryInstructions: Story = createStory({
104105
args: {
105106
questionnaire: qDisplayCategoryInstructions
107+
},
108+
play: async ({ canvasElement }) => {
109+
const expectedText = 'Have not claimed a health check in the past nine months';
110+
const canvas = within(canvasElement);
111+
112+
const instructionsTextElement = await canvas.findByText(expectedText, { exact: true });
113+
expect(instructionsTextElement.textContent).toBe(expectedText);
114+
115+
const computedStyle = window.getComputedStyle(instructionsTextElement);
116+
expect(computedStyle.fontSize).toBe('12px');
117+
expect(computedStyle.fontWeight).toBe('500');
118+
expect(computedStyle.lineHeight).toBe('18px');
119+
expect(computedStyle.color).toBe('rgb(66, 66, 66)');
106120
}
107121
}) as Story;
108122

0 commit comments

Comments
 (0)