Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Multiselect test helpers #254

Merged
merged 1 commit into from
Aug 15, 2023
Merged

Add Multiselect test helpers #254

merged 1 commit into from
Aug 15, 2023

Conversation

clintcs
Copy link
Contributor

@clintcs clintcs commented Aug 10, 2023

🚀 Description

  • Adds Multiselect test helpers
  • Reworks Multiselect tests to use the new test helpers

🔬 How to Test

We're good if the build is green.

@changeset-bot
Copy link

changeset-bot bot commented Aug 10, 2023

🦋 Changeset detected

Latest commit: 932ad6c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Aug 10, 2023

Preview URLs

Env: preview
Docs: https://96606c2d.ember-toucan-core.pages.dev

@clintcs clintcs force-pushed the add-multiselect-test-helpers branch from 16f42b0 to 05dd96d Compare August 10, 2023 15:22
@clintcs clintcs changed the title Add multiselect test helpers Add Multiselect test helpers Aug 10, 2023
onClick=(fn this.removeSelection index)
onMouseDown=this.handleRemoveMouseDown
isVisible=this.isEnabled
<div data-multiselect>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes other than I wrapped everything in <div data-multiselect>. This gives test helpers a parent (closest) to select, which lets them select various children.

@@ -96,12 +96,12 @@ export default class ToucanCoreAutocompleteOptionComponent extends Component<Tou
<template>
{{! template-lint-disable require-presentational-children }}
<li
aria-current={{if @isActive "true" "false"}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor Author

@clintcs clintcs Aug 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaces data-active.

@@ -97,12 +97,12 @@ export default class ToucanCoreMultiselectControlComponent extends Component<Tou
{{! template-lint-disable require-presentational-children }}
{{#let (uniqueId) as |id|}}
<li
aria-current={{if @isActive "true" "false"}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above screenshot and comment.

get active() {
return this.element
?.closest('[data-autocomplete]')
?.querySelector('[aria-current="true"]');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We spread attributes on the <input />, which seems right to me. However, it means we need to first get ahold of the parent element ([data-autocomplete]) before we can select children.

@@ -9,7 +9,7 @@ module('Integration | Component | Fields | Autocomplete', function (hooks) {

test('it renders', async function (assert) {
await render(<template>
<Autocomplete @noResultsText="No results" @label="Label" data-autocomplete />
<Autocomplete @noResultsText="No results" @label="Label" data-input />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to data-input throughout so it's clearer that it's the <input /> and not the component's wrapping element.

@@ -18,7 +18,7 @@ const ToucanCoreMultiselectChipComponent: TemplateOnlyComponent<ToucanCoreMultis
<div
class="min-h-6 bg-normal-idle flex items-center gap-x-2.5 rounded-sm px-2 py-1"
data-index={{@index}}
data-multiselect-selected-option
data-multiselect-chip
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Designers love their eats, huh? Chips, Snackbars, Toast, etc.)

Copy link
Contributor Author

@clintcs clintcs Aug 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Some formatting changes (whitespace mostly)
  • Some additional dom.exists() assertions
  • Swapped out selector strings for test helpers

@clintcs clintcs marked this pull request as ready for review August 15, 2023 13:51
@clintcs clintcs requested a review from ynotdraw August 15, 2023 13:52
@clintcs
Copy link
Contributor Author

clintcs commented Aug 15, 2023

Pushed an amended commit to resolve a merge conflict.

@clintcs clintcs force-pushed the add-multiselect-test-helpers branch from 932ad6c to 532ab89 Compare August 15, 2023 18:29
@clintcs clintcs merged commit 21ff39a into main Aug 15, 2023
@clintcs clintcs deleted the add-multiselect-test-helpers branch August 15, 2023 18:32
@github-actions github-actions bot mentioned this pull request Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants