import{a as e,n as t}from"./chunk-BneVvdWh.js";import{t as n}from"./react-C7IZe2D1.js";import{t as r}from"./jsx-runtime-C2wGStra.js";import{a as i,i as a,n as o,r as s,t as c}from"./Accordion-CAQuyt5K.js";import{n as l,t as u}from"./OnboardingTour-BoyNpT36.js";import{r as d,t as f}from"./styled-components.browser.esm-BF2I7YPU.js";var p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k;t((()=>{e(n(),1),i(),l(),d(),p=r(),{userEvent:m,expect:h,within:g,waitFor:_,fn:v}=__STORYBOOK_MODULE_TEST__,y={title:`Components/Accordion/Tests`,component:c,parameters:{controls:{disable:!0},chromatic:{disableSnapshot:!0}},tags:[`!autodocs`,`!a11y-test`,`test`]},b={render:function(){return(0,p.jsx)(c,{"aria-label":`accordionLabel`,children:(0,p.jsxs)(a,{children:[(0,p.jsx)(s,{children:`Is Preply the best platform for learning a language?`}),(0,p.jsx)(o,{children:`Of course it is!`})]})})},play:async({canvasElement:e})=>{h(g(e).getByLabelText(`accordionLabel`)).toBeVisible()}},x={args:{},render:function(){return(0,p.jsxs)(c,{children:[(0,p.jsxs)(a,{children:[(0,p.jsx)(s,{children:`Is Preply the best platform for learning a language?`}),(0,p.jsx)(o,{children:`Of course it is!`})]}),(0,p.jsxs)(a,{children:[(0,p.jsx)(s,{children:`Why?`}),(0,p.jsx)(o,{children:`If you are wondering, it means you have not tried it out yet!`})]})]})},play:async({canvas:e,step:t})=>{let n=e.getByText(`Is Preply the best platform for learning a language?`),r=e.getByText(`Of course it is!`),i=e.getByText(`Why?`),a=e.getByText(`If you are wondering, it means you have not tried it out yet!`);await t(`Contents are hidden`,async()=>{h(r).not.toBeVisible(),h(a).not.toBeVisible()}),await t(`Content 1 is revelable`,async()=>{await m.click(n),h(r).toBeVisible()}),await t(`Content 2 is revelable`,async()=>{await m.click(i),h(a).toBeVisible()}),await t(`Both contents are visible (non-exclusivity check)`,async()=>{h(r).toBeVisible(),h(a).toBeVisible()}),await t(`Item 1 is hidable`,async()=>{await m.click(n),h(r).not.toBeVisible()}),await t(`Item 2 is hidable`,async()=>{await m.click(i),h(a).not.toBeVisible()})}},S=f.div`
    details[open]::details-content {
        block-size: initial;
    }
`,C={args:{},decorators:[e=>(0,p.jsx)(S,{children:(0,p.jsx)(e,{})})],render:function(){return(0,p.jsx)(c,{children:(0,p.jsxs)(a,{children:[(0,p.jsx)(s,{children:`Is Preply the best platform for learning a language?`}),(0,p.jsx)(o,{children:`Of course it is!`})]})})},play:async({canvas:e,step:t})=>{let n=e.getByText(`Is Preply the best platform for learning a language?`),r=e.getByText(`Of course it is!`);await t(`Contents are hidden`,async()=>{h(r).not.toBeVisible()}),await t(`Content is revelable`,async()=>{await m.click(n),h(r).toBeVisible()}),await t(`Content is hidable`,async()=>{await m.click(n),h(r).not.toBeVisible()})}},w={args:{},render:function(){return(0,p.jsxs)(c,{children:[(0,p.jsxs)(a,{name:`choose-subscription-duration`,children:[(0,p.jsx)(s,{children:`Two-week subscription`}),(0,p.jsx)(o,{children:`We will charge you every two weeks.`})]}),(0,p.jsxs)(a,{name:`choose-subscription-duration`,children:[(0,p.jsx)(s,{children:`Four-week subscription`}),(0,p.jsx)(o,{children:`We will charge you every four weeks.`})]})]})},play:async({canvas:e,step:t})=>{let n=e.getByText(`Two-week subscription`),r=e.getByText(`We will charge you every two weeks.`),i=e.getByText(`Four-week subscription`),a=e.getByText(`We will charge you every four weeks.`);await t(`Contents are hidden`,async()=>{h(r).not.toBeVisible(),h(a).not.toBeVisible()}),await t(`Content 1 is revelable`,async()=>{await m.click(n),h(r).toBeVisible()}),await t(`Content 2 is revelable`,async()=>{await m.click(i),h(a).toBeVisible()}),await t(`Item 1 is hidden`,async()=>{h(r).not.toBeVisible()})}},T={args:{onOpenChange:v()},render:function(e){return(0,p.jsx)(c,{children:(0,p.jsxs)(a,{onOpenChange:e.onOpenChange,children:[(0,p.jsx)(s,{children:`Is Preply the best platform for learning a language?`}),(0,p.jsx)(o,{children:`Of course it is!`})]})})},play:async({canvas:e,args:t,step:n})=>{let r=e.getByText(`Is Preply the best platform for learning a language?`);await n(`onOpenChange is not called`,async()=>{h(t.onOpenChange).not.toBeCalled()}),await n(`onOpenChange is called with true`,async()=>{await m.click(r),h(t.onOpenChange).toBeCalledWith(!0)}),await n(`onOpenChange is called with false`,async()=>{await m.click(r),h(t.onOpenChange).toBeCalledWith(!1)})}},E={args:{onClick:v()},render:function(e){return(0,p.jsx)(c,{children:(0,p.jsxs)(a,{children:[(0,p.jsx)(s,{onClick:e.onClick,children:`Is Preply the best platform for learning a language?`}),(0,p.jsx)(o,{children:`Of course it is!`})]})})},play:async({canvas:e,args:t,step:n})=>{let r=e.getByText(`Is Preply the best platform for learning a language?`);await n(`onClick is not called`,async()=>{h(t.onClick).not.toBeCalled()}),await n(`onClick is called`,async()=>{await m.click(r),h(t.onClick).toBeCalled()})}},D={render:function(){return(0,p.jsx)(c,{"aria-label":`accordion`,dataset:{foo:1},children:(0,p.jsxs)(a,{dataset:{"qa-id":`firstItem`},children:[(0,p.jsx)(s,{dataset:{"qa-id":`firstItemHeader`},children:`Is Preply the best platform for learning a language?`}),(0,p.jsx)(o,{dataset:{"qa-id":`firstItemContent`},children:`Yes!`})]})})},play:async({canvas:e})=>{h(e.getByLabelText(`accordion`)).toHaveAttribute(`data-foo`,`1`)}},O={render:function(){let e=u();return(0,p.jsx)(e.Provider,{totalSteps:2,children:(0,p.jsxs)(c,{children:[(0,p.jsx)(e.Step,{step:0,title:`Step 1`,text:`Ensure you can answer this question`,children:(0,p.jsxs)(a,{children:[(0,p.jsx)(s,{children:`Is Preply the best platform for learning a language?`}),(0,p.jsx)(o,{children:`Of course it is!`})]})}),(0,p.jsx)(e.Step,{step:1,title:`Step 2`,text:`Push them to try Preply out!`,children:(0,p.jsxs)(a,{children:[(0,p.jsx)(s,{children:`Why?`}),(0,p.jsx)(o,{children:`If you are wondering, it means you have not tried it out yet!`})]})})]})})},play:async({canvasElement:e,step:t})=>{let n=g(e);await t(`Step 1 should be visible`,async()=>{await _(()=>{h(n.getByText(`Ensure you can answer this question`)).toBeVisible()})}),await t(`Click Next`,async()=>{let e=n.getByRole(`button`,{name:`Next`});await m.click(e)}),await t(`Step 2 should be visible`,async()=>{await _(()=>{h(n.getByText(`Push them to try Preply out!`)).toBeVisible()})})}},b.parameters={...b.parameters,docs:{...b.parameters?.docs,source:{originalSource:`{
  render: function Story() {
    return <Accordion aria-label="accordionLabel">
                <AccordionItem>
                    <AccordionHeader>
                        Is Preply the best platform for learning a language?
                    </AccordionHeader>
                    <AccordionContent>Of course it is!</AccordionContent>
                </AccordionItem>
            </Accordion>;
  },
  play: async ({
    canvasElement
  }) => {
    const canvas = within(canvasElement);
    const accordion = canvas.getByLabelText('accordionLabel');
    expect(accordion).toBeVisible();
  }
}`,...b.parameters?.docs?.source}}},x.parameters={...x.parameters,docs:{...x.parameters?.docs,source:{originalSource:`{
  args: {},
  render: function Story() {
    return <Accordion>
                <AccordionItem>
                    <AccordionHeader>
                        Is Preply the best platform for learning a language?
                    </AccordionHeader>
                    <AccordionContent>Of course it is!</AccordionContent>
                </AccordionItem>
                <AccordionItem>
                    <AccordionHeader>Why?</AccordionHeader>
                    <AccordionContent>
                        If you are wondering, it means you have not tried it out yet!
                    </AccordionContent>
                </AccordionItem>
            </Accordion>;
  },
  play: async ({
    canvas,
    step
  }) => {
    const item1Header = canvas.getByText('Is Preply the best platform for learning a language?');
    const item1Content = canvas.getByText('Of course it is!');
    const item2Header = canvas.getByText('Why?');
    const item2Content = canvas.getByText('If you are wondering, it means you have not tried it out yet!');
    await step('Contents are hidden', async () => {
      expect(item1Content).not.toBeVisible();
      expect(item2Content).not.toBeVisible();
    });
    await step('Content 1 is revelable', async () => {
      await userEvent.click(item1Header);
      expect(item1Content).toBeVisible();
    });
    await step('Content 2 is revelable', async () => {
      await userEvent.click(item2Header);
      expect(item2Content).toBeVisible();
    });
    await step('Both contents are visible (non-exclusivity check)', async () => {
      expect(item1Content).toBeVisible();
      expect(item2Content).toBeVisible();
    });
    await step('Item 1 is hidable', async () => {
      await userEvent.click(item1Header);
      expect(item1Content).not.toBeVisible();
    });
    await step('Item 2 is hidable', async () => {
      await userEvent.click(item2Header);
      expect(item2Content).not.toBeVisible();
    });
  }
}`,...x.parameters?.docs?.source}}},C.parameters={...C.parameters,docs:{...C.parameters?.docs,source:{originalSource:`{
  args: {},
  decorators: [Story => <SimulateNoAnimationSupport>
                <Story />
            </SimulateNoAnimationSupport>],
  render: function Story() {
    return <Accordion>
                <AccordionItem>
                    <AccordionHeader>
                        Is Preply the best platform for learning a language?
                    </AccordionHeader>
                    <AccordionContent>Of course it is!</AccordionContent>
                </AccordionItem>
            </Accordion>;
  },
  play: async ({
    canvas,
    step
  }) => {
    const item1Header = canvas.getByText('Is Preply the best platform for learning a language?');
    const item1Content = canvas.getByText('Of course it is!');
    await step('Contents are hidden', async () => {
      expect(item1Content).not.toBeVisible();
    });
    await step('Content is revelable', async () => {
      await userEvent.click(item1Header);
      expect(item1Content).toBeVisible();
    });
    await step('Content is hidable', async () => {
      await userEvent.click(item1Header);
      expect(item1Content).not.toBeVisible();
    });
  }
}`,...C.parameters?.docs?.source}}},w.parameters={...w.parameters,docs:{...w.parameters?.docs,source:{originalSource:`{
  args: {},
  render: function Story() {
    return <Accordion>
                <AccordionItem name="choose-subscription-duration">
                    <AccordionHeader>Two-week subscription</AccordionHeader>
                    <AccordionContent>We will charge you every two weeks.</AccordionContent>
                </AccordionItem>
                <AccordionItem name="choose-subscription-duration">
                    <AccordionHeader>Four-week subscription</AccordionHeader>
                    <AccordionContent>We will charge you every four weeks.</AccordionContent>
                </AccordionItem>
            </Accordion>;
  },
  play: async ({
    canvas,
    step
  }) => {
    const item1Header = canvas.getByText('Two-week subscription');
    const item1Content = canvas.getByText('We will charge you every two weeks.');
    const item2Header = canvas.getByText('Four-week subscription');
    const item2Content = canvas.getByText('We will charge you every four weeks.');
    await step('Contents are hidden', async () => {
      expect(item1Content).not.toBeVisible();
      expect(item2Content).not.toBeVisible();
    });
    await step('Content 1 is revelable', async () => {
      await userEvent.click(item1Header);
      expect(item1Content).toBeVisible();
    });
    await step('Content 2 is revelable', async () => {
      await userEvent.click(item2Header);
      expect(item2Content).toBeVisible();
    });
    await step('Item 1 is hidden', async () => {
      expect(item1Content).not.toBeVisible();
    });
  }
}`,...w.parameters?.docs?.source}}},T.parameters={...T.parameters,docs:{...T.parameters?.docs,source:{originalSource:`{
  args: {
    onOpenChange: fn()
  },
  render: function Story(args) {
    return <Accordion>
                <AccordionItem onOpenChange={args.onOpenChange}>
                    <AccordionHeader>
                        Is Preply the best platform for learning a language?
                    </AccordionHeader>
                    <AccordionContent>Of course it is!</AccordionContent>
                </AccordionItem>
            </Accordion>;
  },
  play: async ({
    canvas,
    args,
    step
  }) => {
    const header = canvas.getByText('Is Preply the best platform for learning a language?');
    await step('onOpenChange is not called', async () => {
      expect(args.onOpenChange).not.toBeCalled();
    });
    await step('onOpenChange is called with true', async () => {
      await userEvent.click(header);
      expect(args.onOpenChange).toBeCalledWith(true);
    });
    await step('onOpenChange is called with false', async () => {
      await userEvent.click(header);
      expect(args.onOpenChange).toBeCalledWith(false);
    });
  }
}`,...T.parameters?.docs?.source}}},E.parameters={...E.parameters,docs:{...E.parameters?.docs,source:{originalSource:`{
  args: {
    onClick: fn()
  },
  render: function Story(args) {
    return <Accordion>
                <AccordionItem>
                    <AccordionHeader onClick={args.onClick}>
                        Is Preply the best platform for learning a language?
                    </AccordionHeader>
                    <AccordionContent>Of course it is!</AccordionContent>
                </AccordionItem>
            </Accordion>;
  },
  play: async ({
    canvas,
    args,
    step
  }) => {
    const header = canvas.getByText('Is Preply the best platform for learning a language?');
    await step('onClick is not called', async () => {
      expect(args.onClick).not.toBeCalled();
    });
    await step('onClick is called', async () => {
      await userEvent.click(header);
      expect(args.onClick).toBeCalled();
    });
  }
}`,...E.parameters?.docs?.source}}},D.parameters={...D.parameters,docs:{...D.parameters?.docs,source:{originalSource:`{
  render: function Story() {
    return <Accordion aria-label="accordion" dataset={{
      foo: 1
    }}>
                <AccordionItem dataset={{
        'qa-id': 'firstItem'
      }}>
                    <AccordionHeader dataset={{
          'qa-id': 'firstItemHeader'
        }}>
                        Is Preply the best platform for learning a language?
                    </AccordionHeader>
                    <AccordionContent dataset={{
          'qa-id': 'firstItemContent'
        }}>
                        Yes!
                    </AccordionContent>
                </AccordionItem>
            </Accordion>;
  },
  play: async ({
    canvas
  }) => {
    const accordion = canvas.getByLabelText('accordion');
    expect(accordion).toHaveAttribute('data-foo', '1');
  }
}`,...D.parameters?.docs?.source}}},O.parameters={...O.parameters,docs:{...O.parameters?.docs,source:{originalSource:`{
  render: function Story() {
    const Tour = createOnboardingTour();
    return <Tour.Provider totalSteps={2}>
                <Accordion>
                    <Tour.Step step={0} title="Step 1" text="Ensure you can answer this question">
                        <AccordionItem>
                            <AccordionHeader>
                                Is Preply the best platform for learning a language?
                            </AccordionHeader>
                            <AccordionContent>Of course it is!</AccordionContent>
                        </AccordionItem>
                    </Tour.Step>
                    <Tour.Step step={1} title="Step 2" text="Push them to try Preply out!">
                        <AccordionItem>
                            <AccordionHeader>Why?</AccordionHeader>
                            <AccordionContent>
                                If you are wondering, it means you have not tried it out yet!
                            </AccordionContent>
                        </AccordionItem>
                    </Tour.Step>
                </Accordion>
            </Tour.Provider>;
  },
  play: async ({
    canvasElement,
    step
  }) => {
    const canvas = within(canvasElement);
    await step('Step 1 should be visible', async () => {
      await waitFor(() => {
        const step1 = canvas.getByText('Ensure you can answer this question');
        expect(step1).toBeVisible();
      });
    });
    await step('Click Next', async () => {
      const nextButton = canvas.getByRole('button', {
        name: 'Next'
      });
      await userEvent.click(nextButton);
    });
    await step('Step 2 should be visible', async () => {
      await waitFor(() => {
        const step1 = canvas.getByText('Push them to try Preply out!');
        expect(step1).toBeVisible();
      });
    });
  }
}`,...O.parameters?.docs?.source}}},k=[`AriaAttributesAreSet`,`TestDisclosableContent`,`TestWithoutAnimation`,`TestExclusiveAccordion`,`TestItemOnOpenChange`,`TestHeaderOnClick`,`TestDataset`,`IntegrationWithOnboardingTour`]}))();export{b as AriaAttributesAreSet,O as IntegrationWithOnboardingTour,D as TestDataset,x as TestDisclosableContent,w as TestExclusiveAccordion,E as TestHeaderOnClick,T as TestItemOnOpenChange,C as TestWithoutAnimation,k as __namedExportsOrder,y as default};