@@ -10,6 +10,7 @@ import {
1010import { Conference } from '@/lib/conference/types'
1111import { Topic } from '@/lib/topic/types'
1212import { fn } from 'storybook/test'
13+ import { expect , userEvent , waitFor , within } from 'storybook/test'
1314import { convertStringToPortableTextBlocks } from '@/lib/proposal'
1415
1516const mockTopics : Topic [ ] = [
@@ -173,3 +174,115 @@ export const WorkshopFormat: Story = {
173174 allowedFormats : [ Format . workshop_120 ] ,
174175 } ,
175176}
177+
178+ export const TitleInputCallsSetProposal : Story = {
179+ args : {
180+ proposal : emptyProposal ,
181+ setProposal : fn ( ) ,
182+ conference : mockConference ,
183+ allowedFormats : [ Format . lightning_10 , Format . presentation_25 ] ,
184+ } ,
185+ play : async ( { args, canvasElement } ) => {
186+ const canvas = within ( canvasElement )
187+ const titleInput = canvas . getByLabelText ( 'Title' )
188+ await userEvent . type ( titleInput , 'My New Talk' )
189+ await waitFor ( ( ) => {
190+ expect ( args . setProposal ) . toHaveBeenCalledWith (
191+ expect . objectContaining ( { title : 'My New Talk' } ) ,
192+ )
193+ } )
194+ } ,
195+ }
196+
197+ export const FormatDropdownChange : Story = {
198+ args : {
199+ proposal : emptyProposal ,
200+ setProposal : fn ( ) ,
201+ conference : mockConference ,
202+ allowedFormats : [
203+ Format . lightning_10 ,
204+ Format . presentation_25 ,
205+ Format . presentation_45 ,
206+ ] ,
207+ } ,
208+ play : async ( { args, canvasElement } ) => {
209+ const canvas = within ( canvasElement )
210+ const formatSelect = canvas . getByLabelText ( 'Presentation Format' )
211+ await userEvent . selectOptions ( formatSelect , Format . presentation_45 )
212+ await waitFor ( ( ) => {
213+ expect ( args . setProposal ) . toHaveBeenCalledWith (
214+ expect . objectContaining ( { format : Format . presentation_45 } ) ,
215+ )
216+ } )
217+ } ,
218+ }
219+
220+ export const TosCheckboxToggle : Story = {
221+ args : {
222+ proposal : emptyProposal ,
223+ setProposal : fn ( ) ,
224+ conference : mockConference ,
225+ allowedFormats : [ Format . lightning_10 ] ,
226+ } ,
227+ play : async ( { args, canvasElement } ) => {
228+ const canvas = within ( canvasElement )
229+ const tosCheckbox = canvas . getByLabelText ( 'I agree to the Code of Conduct' )
230+ expect ( tosCheckbox ) . not . toBeChecked ( )
231+ await userEvent . click ( tosCheckbox )
232+ await waitFor ( ( ) => {
233+ expect ( args . setProposal ) . toHaveBeenCalledWith (
234+ expect . objectContaining ( { tos : true } ) ,
235+ )
236+ } )
237+ } ,
238+ }
239+
240+ export const ReadOnlyShowsContent : Story = {
241+ args : {
242+ proposal : filledProposal ,
243+ setProposal : fn ( ) ,
244+ conference : mockConference ,
245+ allowedFormats : [ Format . presentation_45 ] ,
246+ readOnly : true ,
247+ } ,
248+ play : async ( { canvasElement } ) => {
249+ const canvas = within ( canvasElement )
250+ // Read-only mode renders text, not inputs
251+ expect (
252+ canvas . getByText ( 'Building Scalable Kubernetes Applications' ) ,
253+ ) . toBeInTheDocument ( )
254+ expect ( canvas . getByText ( 'English' ) ) . toBeInTheDocument ( )
255+ expect ( canvas . getByText ( 'Intermediate' ) ) . toBeInTheDocument ( )
256+ // Should not have editable inputs
257+ expect ( canvas . queryByLabelText ( 'Title' ) ) . not . toBeInTheDocument ( )
258+ } ,
259+ }
260+
261+ export const WorkshopShowsPrerequisites : Story = {
262+ args : {
263+ proposal : {
264+ ...emptyProposal ,
265+ format : Format . workshop_120 ,
266+ } ,
267+ setProposal : fn ( ) ,
268+ conference : mockConference ,
269+ allowedFormats : [ Format . workshop_120 ] ,
270+ } ,
271+ play : async ( { canvasElement } ) => {
272+ const canvas = within ( canvasElement )
273+ expect ( canvas . getByLabelText ( 'Prerequisites' ) ) . toBeInTheDocument ( )
274+ } ,
275+ }
276+
277+ export const NonWorkshopHidesPrerequisites : Story = {
278+ args : {
279+ proposal : emptyProposal ,
280+ setProposal : fn ( ) ,
281+ conference : mockConference ,
282+ allowedFormats : [ Format . lightning_10 ] ,
283+ } ,
284+ play : async ( { canvasElement } ) => {
285+ const canvas = within ( canvasElement )
286+ expect ( canvas . queryByLabelText ( 'Prerequisites' ) ) . not . toBeInTheDocument ( )
287+ } ,
288+ }
0 commit comments