Skip to content

Commit 3c0438a

Browse files
fix: update package.json scripts to use correct binary paths and fix select-alignment story
- Fix storybook, test-storybook, start-server-and-test, and http-server commands to use full paths from root node_modules - Make select-alignment story controlled with useState to properly handle selection - Update test assertions to use exact string matches instead of regex - Add proper timing delays for async operations in tests This resolves the 'command not found' errors that were causing the test workflow to fail.
1 parent 9b037f0 commit 3c0438a

2 files changed

Lines changed: 28 additions & 13 deletions

File tree

apps/docs/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"name": "@lambdacurry/forms-docs",
33
"version": "0.2.0",
44
"scripts": {
5-
"dev": "storybook dev -p 6006",
6-
"build": "storybook build",
7-
"build-storybook": "storybook build",
8-
"storybook": "storybook dev -p 6006",
9-
"serve": "http-server ./storybook-static -p 6006 -s",
10-
"test": "start-server-and-test serve http://127.0.0.1:6006 'test-storybook --url http://127.0.0.1:6006'",
11-
"test:local": "test-storybook",
5+
"dev": "../../node_modules/.bin/storybook dev -p 6006",
6+
"build": "../../node_modules/.bin/storybook build",
7+
"build-storybook": "../../node_modules/.bin/storybook build",
8+
"storybook": "../../node_modules/.bin/storybook dev -p 6006",
9+
"serve": "../../node_modules/.bin/http-server ./storybook-static -p 6006 -s",
10+
"test": "../../node_modules/.bin/start-server-and-test serve http://127.0.0.1:6006 '../../node_modules/.bin/test-storybook --url http://127.0.0.1:6006'",
11+
"test:local": "../../node_modules/.bin/test-storybook",
1212
"type-check": "tsc -p tsconfig.json --noEmit"
1313
},
1414
"dependencies": {

apps/docs/src/ui/select-alignment.stories.tsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Meta, StoryObj } from '@storybook/react-vite';
22
import { expect, userEvent, within } from '@storybook/test';
3+
import { useState } from 'react';
34
import { Select, type SelectOption } from '@lambdacurry/forms/ui/select';
45

56
const meta: Meta<typeof Select> = {
@@ -25,11 +26,19 @@ export const RightAlignedWithEndContent: Story = {
2526
name: 'Right-aligned trigger with content align="end"',
2627
args: {},
2728
render: () => {
29+
const [value, setValue] = useState<string>('');
30+
2831
return (
2932
<div className="w-[480px]">
3033
<div className="flex justify-end">
3134
<div className="w-[280px]">
32-
<Select options={OPTIONS} placeholder="Choose a state" contentProps={{ align: 'end' }} />
35+
<Select
36+
options={OPTIONS}
37+
placeholder="Choose a state"
38+
contentProps={{ align: 'end' }}
39+
value={value}
40+
onChange={setValue}
41+
/>
3342
</div>
3443
</div>
3544
</div>
@@ -39,10 +48,12 @@ export const RightAlignedWithEndContent: Story = {
3948
const canvas = within(canvasElement);
4049

4150
await step('Open the select', async () => {
42-
const trigger = await canvas.findByRole('combobox', { name: /Choose a state/i });
51+
// Find the trigger by its role and accessible name (which should be the placeholder)
52+
const trigger = await canvas.findByRole('combobox', { name: 'Choose a state' });
4353
await userEvent.click(trigger);
4454

45-
// Ensure popover content is rendered
55+
// Wait for popover content to be rendered
56+
await new Promise((r) => setTimeout(r, 100));
4657
const contentEl = document.body.querySelector('[data-slot="popover-content"]') as HTMLElement | null;
4758
expect(contentEl).toBeTruthy();
4859

@@ -55,15 +66,19 @@ export const RightAlignedWithEndContent: Story = {
5566
await userEvent.keyboard('[ArrowDown]');
5667
await userEvent.keyboard('[Enter]');
5768

69+
// Wait for the selection to be processed
70+
await new Promise((r) => setTimeout(r, 100));
71+
5872
// The trigger should now show the selected option (first item: Alabama)
59-
await expect(canvas.findByRole('combobox', { name: /Alabama/i })).resolves.toBeInTheDocument();
73+
await expect(canvas.findByRole('combobox', { name: 'Alabama' })).resolves.toBeInTheDocument();
6074

6175
// Re-open and press Escape to close
62-
const trigger = await canvas.findByRole('combobox', { name: /Alabama/i });
76+
const trigger = await canvas.findByRole('combobox', { name: 'Alabama' });
6377
await userEvent.click(trigger);
6478
await userEvent.keyboard('[Escape]');
79+
6580
// Ensure popover content is removed
66-
await new Promise((r) => setTimeout(r, 100));
81+
await new Promise((r) => setTimeout(r, 200));
6782
const stillOpen = document.body.querySelector('[data-slot="popover-content"]');
6883
expect(stillOpen).toBeNull();
6984
});

0 commit comments

Comments
 (0)