Skip to content

Commit

Permalink
Tests for no choices besides the current selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Xon committed Aug 30, 2024
1 parent 73b9c25 commit b402a00
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
16 changes: 15 additions & 1 deletion public/test/select-multiple/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ <h2>Select multiple inputs</h2>

<div data-test-hook="no-choices">
<label for="no-choices">No choices</label>
<select class="form-control" name="no-choices" id="no-choices">
<select class="form-control" name="no-choices" id="no-choices" multiple>
</select>
<script>
document.addEventListener('DOMContentLoaded', function() {
Expand All @@ -175,6 +175,20 @@ <h2>Select multiple inputs</h2>
</script>
</div>

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

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

<div data-test-hook="no-choices2">
<label for="no-choices2">No choices (besides selected)</label>
<select class="form-control" name="no-choices" id="no-choices2">
<option value="Choice 1">Choice 1</option>
</select>
<script>
document.addEventListener('DOMContentLoaded', function() {
new Choices('#no-choices2', {
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 @@ -386,6 +386,17 @@ describe(`Choices - select multiple`, () => {
});
});

describe('No choices (besides selected)', () => {
const testId = 'no-choices2';
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 @@ -243,6 +243,17 @@ describe(`Choices - select one`, () => {
});
});

describe('No choices (besides selected)', () => {
const testId = 'no-choices2';
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 b402a00

Please sign in to comment.