Skip to content

Commit 4ab93a5

Browse files
committed
chore: added test cases for search input in disabled state
1 parent 50354c7 commit 4ab93a5

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

elements/pf-search-input/test/pf-search-input.spec.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,5 +855,58 @@ describe('<pf-search-input>', function() {
855855
});
856856
});
857857
});
858+
859+
describe('with `disabled` attribute', function() {
860+
let element: PfSearchInput;
861+
const updateComplete = () => element.updateComplete;
862+
const focus = () => element.focus();
863+
864+
beforeEach(async function() {
865+
element = await createFixture<PfSearchInput>(html`
866+
<pf-search-input id="disabled-search" disabled>
867+
<pf-option value="1">1</pf-option>
868+
<pf-option value="2">2</pf-option>
869+
<pf-option value="3">3</pf-option>
870+
</pf-search-input>
871+
<label for="disabled-search">Disabled</label>`);
872+
await updateComplete();
873+
});
874+
875+
it('passes aXe audit', async function() {
876+
await expect(element).to.be.accessible();
877+
});
878+
879+
it('is marked as disabled in accessibility tree', async function() {
880+
expect(await a11ySnapshot()).to.axContainQuery({
881+
role: 'combobox',
882+
disabled: true,
883+
});
884+
});
885+
886+
describe('focus()', function() {
887+
beforeEach(focus);
888+
beforeEach(updateComplete);
889+
describe('ArrowDown', function() {
890+
beforeEach(press('ArrowDown'));
891+
beforeEach(updateComplete);
892+
893+
it('does not open on focus and keyboard interaction', async function() {
894+
// Should remain closed
895+
expect(element.expanded).to.be.false;
896+
expect(await a11ySnapshot()).to.not.axContainRole('listbox');
897+
});
898+
});
899+
});
900+
901+
describe('clicking the element', function() {
902+
beforeEach(async function() {
903+
await clickElementAtOffset(element, [10, 10]);
904+
});
905+
it('cannot be interacted with via click', async function() {
906+
expect(element.expanded).to.be.false;
907+
expect(await a11ySnapshot()).to.not.axContainRole('listbox');
908+
});
909+
});
910+
});
858911
});
859912
});

0 commit comments

Comments
 (0)