Skip to content

Commit

Permalink
Chore: add e2e tests for "no choices" behavior to match v10
Browse files Browse the repository at this point in the history
  • Loading branch information
Xon committed Aug 30, 2024
1 parent e73f7e5 commit 7b7c1c7
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [11.0.2]

### Bug Fixes (from 11.0.0)

### Chore
* Add e2e tests for "no choices" behavior to match v10

## [11.0.1] (2024-08-30)

### Bug Fixes (from 11.0.0)
Expand Down
13 changes: 13 additions & 0 deletions public/test/select-multiple/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,19 @@ <h2>Select multiple inputs</h2>
</script>
</div>

<div data-test-hook="no-choices">
<label for="no-choices">No choices</label>
<select class="form-control" name="no-choices" id="no-choices">
</select>
<script>
document.addEventListener('DOMContentLoaded', function() {
new Choices('#no-choices', {
allowHTML: true,
});
});
</script>
</div>

<div data-test-hook="disabled-choice">
<label for="choices-disabled-choice">Disabled choice</label>
<select
Expand Down
13 changes: 13 additions & 0 deletions public/test/select-one/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ <h2>Select one inputs</h2>
</script>
</div>

<div data-test-hook="no-choices">
<label for="no-choices">No choices</label>
<select class="form-control" name="no-choices" id="no-choices">
</select>
<script>
document.addEventListener('DOMContentLoaded', function() {
new Choices('#no-choices', {
allowHTML: true,
});
});
</script>
</div>

<div data-test-hook="disabled-choice">
<label for="choices-disabled-choice">Disabled choice</label>
<select
Expand Down
11 changes: 11 additions & 0 deletions test-e2e/tests/select-multiple.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,17 @@ describe(`Choices - select multiple`, () => {
});
});

describe('no choices', () => {
const testId = 'no-choices';
test('shows no choices banner', async ({ page, bundle }) => {
const suite = new SelectTestSuit(page, bundle, testUrl, testId);
await suite.startWithClick();

await expect(suite.selectableChoices).toHaveCount(0);
await suite.expectVisibleNoticeHtml('No choices to choose from');
});
});

describe('disabled choice', () => {
const testId = 'disabled-choice';
const firstChoice = 'Choice 1';
Expand Down
11 changes: 11 additions & 0 deletions test-e2e/tests/select-one.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,17 @@ describe(`Choices - select one`, () => {
});
});

describe('no choices', () => {
const testId = 'no-choices';
test('shows no choices banner', async ({ page, bundle }) => {
const suite = new SelectTestSuit(page, bundle, testUrl, testId);
await suite.startWithClick();

await expect(suite.selectableChoices).toHaveCount(0);
await suite.expectVisibleNoticeHtml('No choices to choose from');
});
});

describe('disabled choice', () => {
const testId = 'disabled-choice';
const firstChoice = 'Choice 1';
Expand Down

0 comments on commit 7b7c1c7

Please sign in to comment.