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{n as i,t as a}from"./Checkbox-BV4Be-fH.js";import{n as o,t as s}from"./Tooltip-F-35Ygr4.js";var c,l,u,d,f,p,m,h,g,_,v,y;t((()=>{e(n(),1),o(),i(),c=r(),{userEvent:l,expect:u,within:d,waitFor:f,fireEvent:p,waitForElementToBeRemoved:m}=__STORYBOOK_MODULE_TEST__,h={title:`Components/Checkbox/Tests`,component:a,parameters:{controls:{disable:!0},chromatic:{disableSnapshot:!0}},tags:[`!autodocs`,`!a11y-test`,`test`]},g={render:function(){return(0,c.jsx)(a,{"aria-label":`checkboxLabel`,"aria-labelledby":`checkboxLabelledby`,"aria-describedby":`checkboxDescribedby`,hasError:!0})},play:async({canvasElement:e})=>{let t=d(e).getByRole(`checkbox`);u(t).toHaveAttribute(`aria-label`,`checkboxLabel`),u(t).toHaveAttribute(`aria-labelledby`,`checkboxLabelledby`),u(t).toHaveAttribute(`aria-describedby`,`checkboxDescribedby`),u(t).toHaveAttribute(`aria-invalid`,`true`)}},_={render:function(){return(0,c.jsx)(a,{dataset:{foo:1,bar:`2`,baz:!1},"aria-label":`checkbox`})},play:async({canvas:e})=>{let t=e.getByRole(`checkbox`);u(t).toHaveAttribute(`data-foo`,`1`),u(t).toHaveAttribute(`data-bar`,`2`),u(t).toHaveAttribute(`data-baz`,`false`)}},v={render:function(){return(0,c.jsx)(s,{content:`This is a tooltip`,trigger:`hover-and-touch`,dataset:{testid:`tooltip`},children:(0,c.jsx)(a,{"aria-label":`checkbox`})})},play:async({canvasElement:e,step:t})=>{let n=d(e),r=n.getByRole(`checkbox`);await t(`hover trigger element`,async()=>{await l.hover(r)}),await t(`tooltip should be shown`,async()=>{await f(()=>u(n.getByTestId(`tooltip`)).toBeInTheDocument())}),await t(`unhover trigger element`,async()=>{await l.unhover(r),p.pointerMove(document,{clientX:0,clientY:0})}),await t(`tooltip should be hidden`,async()=>{await m(()=>n.queryByTestId(`tooltip`))})}},g.parameters={...g.parameters,docs:{...g.parameters?.docs,source:{originalSource:`{
  render: function Story() {
    return <Checkbox aria-label="checkboxLabel" aria-labelledby="checkboxLabelledby" aria-describedby="checkboxDescribedby" hasError />;
  },
  play: async ({
    canvasElement
  }) => {
    const canvas = within(canvasElement);
    const checkbox = canvas.getByRole('checkbox');
    expect(checkbox).toHaveAttribute('aria-label', 'checkboxLabel');
    expect(checkbox).toHaveAttribute('aria-labelledby', 'checkboxLabelledby');
    expect(checkbox).toHaveAttribute('aria-describedby', 'checkboxDescribedby');
    expect(checkbox).toHaveAttribute('aria-invalid', 'true');
  }
}`,...g.parameters?.docs?.source}}},_.parameters={..._.parameters,docs:{..._.parameters?.docs,source:{originalSource:`{
  render: function Story() {
    return <Checkbox dataset={{
      foo: 1,
      bar: '2',
      baz: false
    }} aria-label="checkbox" />;
  },
  play: async ({
    canvas
  }) => {
    const checkbox = canvas.getByRole('checkbox');
    expect(checkbox).toHaveAttribute('data-foo', '1');
    expect(checkbox).toHaveAttribute('data-bar', '2');
    expect(checkbox).toHaveAttribute('data-baz', 'false');
  }
}`,..._.parameters?.docs?.source}}},v.parameters={...v.parameters,docs:{...v.parameters?.docs,source:{originalSource:`{
  render: function Story() {
    return <Tooltip content="This is a tooltip" trigger="hover-and-touch" dataset={{
      testid: 'tooltip'
    }}>
                <Checkbox aria-label="checkbox" />
            </Tooltip>;
  },
  play: async ({
    canvasElement,
    step
  }) => {
    const canvas = within(canvasElement);
    const trigger = canvas.getByRole('checkbox');
    await step('hover trigger element', async () => {
      await userEvent.hover(trigger);
    });
    await step('tooltip should be shown', async () => {
      await waitFor(() => {
        const tooltip = canvas.getByTestId('tooltip');
        return expect(tooltip).toBeInTheDocument();
      });
    });
    await step('unhover trigger element', async () => {
      await userEvent.unhover(trigger);
      // Radix Tooltip uses a "grace area" polygon that requires
      // a pointermove on document to trigger dismissal.
      // userEvent.unhover doesn't fire this event.
      fireEvent.pointerMove(document, {
        clientX: 0,
        clientY: 0
      });
    });
    await step('tooltip should be hidden', async () => {
      await waitForElementToBeRemoved(() => canvas.queryByTestId('tooltip'));
    });
  }
}`,...v.parameters?.docs?.source}}},y=[`AriaAttributesAreSet`,`TestDataset`,`IntegrationWithDSTooltip`]}))();export{g as AriaAttributesAreSet,v as IntegrationWithDSTooltip,_ as TestDataset,y as __namedExportsOrder,h as default};