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

chore: remove Button's test helpers #257

Merged
merged 1 commit into from
Aug 17, 2023
Merged

Conversation

clintcs
Copy link
Contributor

@clintcs clintcs commented Aug 16, 2023

🚀 Description

I've been going through our components and adding test helpers so consumers don't have to select elements themselves, thereby digging into our implementation. It occurred to me while thinking about what needs test helpers and what doesn't that Button may not need any.

Because Button is more or less composed of one element (<button />) the consumer can spread an ID or data attribute onto Button and use that ID or data attribute to select that element. He can then use a combination of QUnit DOM and Ember Test Helpers to assert what needs asserting. No need, for example, to provide an abstraction for checking whether Button is disabled or for clicking it.


🔬 How to Test

If the build is green, we're good.

@changeset-bot
Copy link

changeset-bot bot commented Aug 16, 2023

🦋 Changeset detected

Latest commit: ce91639

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

This PR includes changesets to release 2 packages
Name Type
@crowdstrike/ember-toucan-core Minor
@crowdstrike/ember-toucan-form Major

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 16, 2023

Preview URLs

Env: preview
Docs: https://8609f6b5.ember-toucan-core.pages.dev

@clintcs
Copy link
Contributor Author

clintcs commented Aug 16, 2023

@ynotdraw: Before I take this out of draft, add a description, and send it out for review, I thought I'd see how you feel. I'm working on adding test helpers to components that need them, but I'm wondering: does Button need them?

@@ -55,8 +49,6 @@ module('Integration | Component | button', function (hooks) {
</Button>
</template>);

assert.false(buttonPageObject.isLoading);
Copy link
Contributor Author

@clintcs clintcs Aug 16, 2023

Choose a reason for hiding this comment

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

This is the only test helper I was able to see a decent argument for. Is it something we need to test? Or does the [data-test-loading] assertion below sufficiently cover it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel as though the assertion below is sufficient enough probably

@@ -55,8 +49,6 @@ module('Integration | Component | button', function (hooks) {
</Button>
</template>);

assert.false(buttonPageObject.isLoading);
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel as though the assertion below is sufficient enough probably

@ynotdraw
Copy link
Contributor

Before I take this out of draft, add a description, and send it out for review, I thought I'd see how you feel. I'm working on adding test helpers to components that need them, but I'm wondering: does Button need them?

Good question. I'm kind of thinking maybe these aren't super helpful? All of this stuff can be accomplished already with the built-in ember qunit assertions and/or with the built-in ember test helpers. I think components like our autocomplete and multi select are complicated enough that they warrant helpers; however, I'm not sure I feel the same with Button.

A bit tangential to this, but I also wonder if we should make Button more dumb eventually and not have those named blocks with styling. I feel as though they are implementation details that downstream/other consumers may not care about or want. And those states are something they can write themselves, rather than it being baked into the core Button. Nothing we need to do now, of course, but maybe something in the future to think about to make this less opinionated and force strong opinions upstream

@clintcs
Copy link
Contributor Author

clintcs commented Aug 17, 2023

I think components like our autocomplete and multi select are complicated enough that they warrant helpers; however, I'm not sure I feel the same with Button.

Sounds good. I'll move ahead with this PR.

A bit tangential to this, but I also wonder if we should make Button more dumb eventually and not have those named blocks with styling.

🤔

@clintcs clintcs marked this pull request as ready for review August 17, 2023 12:43
@github-actions github-actions bot requested a deployment to ember-toucan-core (Preview) August 17, 2023 13:38 Abandoned
@clintcs clintcs merged commit 8e9ecf4 into main Aug 17, 2023
14 checks passed
@clintcs clintcs deleted the remove-button-test-helpers branch August 17, 2023 14:10
@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