|
@@ -1,4 +1,4 @@
|
|
-import { beVisible, beHidden, haveAttribute, haveClasses, haveText, html, notBeVisible, notHaveAttribute, notExist, haveFocus, test} from '../../../utils'
|
|
|
|
|
|
+import { beVisible, beHidden, haveAttribute, haveClasses, notHaveClasses, haveText, html, notBeVisible, notHaveAttribute, notExist, haveFocus, test} from '../../../utils'
|
|
|
|
|
|
test('it works with x-model',
|
|
test('it works with x-model',
|
|
[html`
|
|
[html`
|
|
@@ -520,7 +520,7 @@ test('keyboard controls',
|
|
get('[options]')
|
|
get('[options]')
|
|
.should(beVisible())
|
|
.should(beVisible())
|
|
.should(haveFocus())
|
|
.should(haveFocus())
|
|
- get('[option="1"')
|
|
|
|
|
|
+ get('[option="1"]')
|
|
.should(haveClasses(['active']))
|
|
.should(haveClasses(['active']))
|
|
get('[options]')
|
|
get('[options]')
|
|
.type('{downarrow}')
|
|
.type('{downarrow}')
|
|
@@ -536,7 +536,7 @@ test('keyboard controls',
|
|
.should(haveClasses(['active']))
|
|
.should(haveClasses(['active']))
|
|
get('[options]')
|
|
get('[options]')
|
|
.type('{home}')
|
|
.type('{home}')
|
|
- get('[option="1"')
|
|
|
|
|
|
+ get('[option="1"]')
|
|
.should(haveClasses(['active']))
|
|
.should(haveClasses(['active']))
|
|
get('[options]')
|
|
get('[options]')
|
|
.type('{end}')
|
|
.type('{end}')
|
|
@@ -544,7 +544,7 @@ test('keyboard controls',
|
|
.should(haveClasses(['active']))
|
|
.should(haveClasses(['active']))
|
|
get('[options]')
|
|
get('[options]')
|
|
.type('{pageUp}')
|
|
.type('{pageUp}')
|
|
- get('[option="1"')
|
|
|
|
|
|
+ get('[option="1"]')
|
|
.should(haveClasses(['active']))
|
|
.should(haveClasses(['active']))
|
|
get('[options]')
|
|
get('[options]')
|
|
.type('{pageDown}')
|
|
.type('{pageDown}')
|
|
@@ -608,9 +608,10 @@ test('"horizontal" keyboard controls',
|
|
get('.active').should(notExist())
|
|
get('.active').should(notExist())
|
|
get('button').focus().type(' ')
|
|
get('button').focus().type(' ')
|
|
get('[options]')
|
|
get('[options]')
|
|
|
|
+ .should(haveAttribute('orientation', 'horizontal'))
|
|
.should(beVisible())
|
|
.should(beVisible())
|
|
.should(haveFocus())
|
|
.should(haveFocus())
|
|
- get('[option="1"')
|
|
|
|
|
|
+ get('[option="1"]')
|
|
.should(haveClasses(['active']))
|
|
.should(haveClasses(['active']))
|
|
get('[options]')
|
|
get('[options]')
|
|
.type('{rightarrow}')
|
|
.type('{rightarrow}')
|
|
@@ -672,7 +673,7 @@ test('search',
|
|
get('button').click()
|
|
get('button').click()
|
|
get('[options]')
|
|
get('[options]')
|
|
.type('ar')
|
|
.type('ar')
|
|
- get('[option="2"')
|
|
|
|
|
|
+ get('[option="2"]')
|
|
.should(haveClasses(['active']))
|
|
.should(haveClasses(['active']))
|
|
wait(500)
|
|
wait(500)
|
|
get('[options]')
|
|
get('[options]')
|
|
@@ -682,6 +683,7 @@ test('search',
|
|
},
|
|
},
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+// @todo make sure $listboxOption.isSelected works in this case (aria-selected and the values are working correctly but the class is not applied)
|
|
test('changing value manually changes internal state',
|
|
test('changing value manually changes internal state',
|
|
[html`
|
|
[html`
|
|
<div
|
|
<div
|
|
@@ -725,18 +727,17 @@ test('changing value manually changes internal state',
|
|
</div>
|
|
</div>
|
|
`],
|
|
`],
|
|
({ get }) => {
|
|
({ get }) => {
|
|
- get('.active').should(notExist())
|
|
|
|
get('[toggle]').click()
|
|
get('[toggle]').click()
|
|
- get('[option="2"')
|
|
|
|
|
|
+ get('[option="2"]')
|
|
.click()
|
|
.click()
|
|
.should(haveClasses(['selected']))
|
|
.should(haveClasses(['selected']))
|
|
get('[select-tim]').click()
|
|
get('[select-tim]').click()
|
|
get('[option="4"]').should(haveClasses(['selected']))
|
|
get('[option="4"]').should(haveClasses(['selected']))
|
|
|
|
+ get('[option="1"]').should(notHaveClasses(['selected']))
|
|
get('[toggle]').should(haveText('4'))
|
|
get('[toggle]').should(haveText('4'))
|
|
},
|
|
},
|
|
)
|
|
)
|
|
|
|
|
|
-// @todo update these assertions to be accurate
|
|
|
|
test('has accessibility attributes',
|
|
test('has accessibility attributes',
|
|
[html`
|
|
[html`
|
|
<div
|
|
<div
|
|
@@ -786,35 +787,40 @@ test('has accessibility attributes',
|
|
.should(haveAttribute('id', 'alpine-listbox-button-1'))
|
|
.should(haveAttribute('id', 'alpine-listbox-button-1'))
|
|
.click()
|
|
.click()
|
|
.should(haveAttribute('aria-expanded', 'true'))
|
|
.should(haveAttribute('aria-expanded', 'true'))
|
|
- .should(haveAttribute('aria-controls', 'alpine-listbox-items-1'))
|
|
|
|
|
|
+ .should(haveAttribute('aria-controls', 'alpine-listbox-options-1'))
|
|
|
|
|
|
get('[options]')
|
|
get('[options]')
|
|
.should(haveAttribute('aria-orientation', 'vertical'))
|
|
.should(haveAttribute('aria-orientation', 'vertical'))
|
|
- .should(haveAttribute('role', 'menu'))
|
|
|
|
- .should(haveAttribute('id', 'alpine-listbox-items-1'))
|
|
|
|
|
|
+ .should(haveAttribute('role', 'listbox'))
|
|
|
|
+ .should(haveAttribute('id', 'alpine-listbox-options-1'))
|
|
.should(haveAttribute('aria-labelledby', 'alpine-listbox-button-1'))
|
|
.should(haveAttribute('aria-labelledby', 'alpine-listbox-button-1'))
|
|
.should(notHaveAttribute('aria-activedescendant'))
|
|
.should(notHaveAttribute('aria-activedescendant'))
|
|
.should(haveAttribute('tabindex', '0'))
|
|
.should(haveAttribute('tabindex', '0'))
|
|
- .type('{downarrow}')
|
|
|
|
- .should(haveAttribute('aria-activedescendant', 'alpine-listbox-item-1'))
|
|
|
|
|
|
+ .should(haveAttribute('aria-activedescendant', 'alpine-listbox-option-1'))
|
|
|
|
|
|
- get('[option="1"')
|
|
|
|
- .should(haveAttribute('role', 'menuitem'))
|
|
|
|
- .should(haveAttribute('id', 'alpine-listbox-item-1'))
|
|
|
|
|
|
+ get('[option="1"]')
|
|
|
|
+ .should(haveAttribute('role', 'option'))
|
|
|
|
+ .should(haveAttribute('id', 'alpine-listbox-option-1'))
|
|
.should(haveAttribute('tabindex', '-1'))
|
|
.should(haveAttribute('tabindex', '-1'))
|
|
|
|
+ .should(haveAttribute('aria-selected', 'false'))
|
|
|
|
|
|
get('[option="2"]')
|
|
get('[option="2"]')
|
|
- .should(haveAttribute('role', 'menuitem'))
|
|
|
|
- .should(haveAttribute('id', 'alpine-listbox-item-2'))
|
|
|
|
|
|
+ .should(haveAttribute('role', 'option'))
|
|
|
|
+ .should(haveAttribute('id', 'alpine-listbox-option-2'))
|
|
.should(haveAttribute('tabindex', '-1'))
|
|
.should(haveAttribute('tabindex', '-1'))
|
|
|
|
+ .should(haveAttribute('aria-selected', 'false'))
|
|
|
|
|
|
get('[options]')
|
|
get('[options]')
|
|
.type('{downarrow}')
|
|
.type('{downarrow}')
|
|
- .should(haveAttribute('aria-activedescendant', 'alpine-listbox-item-2'))
|
|
|
|
|
|
+ .should(haveAttribute('aria-activedescendant', 'alpine-listbox-option-2'))
|
|
|
|
+
|
|
|
|
+ get('[option="2"]')
|
|
|
|
+ .click()
|
|
|
|
+ .should(haveAttribute('aria-selected', 'true'))
|
|
},
|
|
},
|
|
)
|
|
)
|
|
|
|
|
|
-test.only('"static" prop',
|
|
|
|
|
|
+test('"static" prop',
|
|
[html`
|
|
[html`
|
|
<div
|
|
<div
|
|
x-data="{ active: null, show: false, people: [
|
|
x-data="{ active: null, show: false, people: [
|