123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- import { beVisible, haveAttribute, html, notBeVisible, notHaveAttribute, test } from '../../../utils'
- test.skip('button toggles panel',
- [html`
- <div x-data x-popover>
- <button x-popover:button>Toggle</button>
- <ul x-popover:panel>
- Dialog Contents!
- </ul>
- </div>
- `],
- ({ get }) => {
- get('ul').should(notBeVisible())
- get('button').click()
- get('ul').should(beVisible())
- get('button').click()
- get('ul').should(notBeVisible())
- },
- )
- test.skip('has accessibility attributes',
- [html`
- <div x-data x-popover>
- <button x-popover:button>Toggle</button>
- <ul x-popover:panel>
- Dialog Contents!
- </ul>
- </div>
- `],
- ({ get }) => {
- get('button').should(haveAttribute('aria-expanded', 'false'))
- get('button').should(notHaveAttribute('aria-controls'))
- get('button').click()
- get('button').should(haveAttribute('aria-expanded', 'true'))
- get('button').should(haveAttribute('aria-controls', 'alpine-popover-panel-1'))
- },
- )
- test.skip('escape closes panel',
- [html`
- <div x-data x-popover>
- <button x-popover:button>Toggle</button>
- <ul x-popover:panel>
- Dialog Contents!
- </ul>
- </div>
- `],
- ({ get }) => {
- get('ul').should(notBeVisible())
- get('button').click()
- get('ul').should(beVisible())
- get('body').type('{esc}')
- get('ul').should(notBeVisible())
- },
- )
- test.skip('clicking outside closes panel',
- [html`
- <div>
- <div x-data x-popover>
- <button x-popover:button>Toggle</button>
- <ul x-popover:panel>
- Dialog Contents!
- </ul>
- </div>
- <h1>Click away to me</h1>
- </div>
- `],
- ({ get }) => {
- get('ul').should(notBeVisible())
- get('button').click()
- get('ul').should(beVisible())
- get('h1').click()
- get('ul').should(notBeVisible())
- },
- )
- test.skip('focusing away closes panel',
- [html`
- <div>
- <div x-data x-popover>
- <button x-popover:button>Toggle</button>
- <ul x-popover:panel>
- Dialog Contents!
- </ul>
- </div>
- <a href="#">Focus Me</a>
- </div>
- `],
- ({ get }) => {
- get('ul').should(notBeVisible())
- get('button').click()
- get('ul').should(beVisible())
- cy.focused().tab()
- get('ul').should(notBeVisible())
- },
- )
- test.skip('focusing away doesnt close panel if focusing inside a group',
- [html`
- <div x-data>
- <div x-popover:group>
- <div x-data x-popover id="1">
- <button x-popover:button>Toggle 1</button>
- <ul x-popover:panel>
- Dialog 1 Contents!
- </ul>
- </div>
- <div x-data x-popover id="2">
- <button x-popover:button>Toggle 2</button>
- <ul x-popover:panel>
- Dialog 2 Contents!
- </ul>
- </div>
- </div>
- <a href="#">Focus Me</a>
- </div>
- `],
- ({ get }) => {
- get('#1 ul').should(notBeVisible())
- get('#2 ul').should(notBeVisible())
- get('#1 button').click()
- get('#1 ul').should(beVisible())
- get('#2 ul').should(notBeVisible())
- cy.focused().tab()
- get('#1 ul').should(beVisible())
- get('#2 ul').should(notBeVisible())
- cy.focused().tab()
- get('#1 ul').should(notBeVisible())
- get('#2 ul').should(notBeVisible())
- },
- )
|