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

test: improve tabs tests #6898

Merged
merged 14 commits into from
Jul 16, 2024

Conversation

bvandercar-vt
Copy link
Contributor

Fixes #0000

Checklist

  • Includes tests
  • [N/A] Update documentation

@changelog-app
Copy link

changelog-app bot commented Jul 8, 2024

Generate changelog in packages/core/changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

test: improve tabs tests

Check the box to generate changelog(s)

  • Generate changelog entry

const TAB = "[role='tab']";
const TAB_LIST = "[role='tablist']";
const TAB_PANEL = "[role='tabpanel']";
const TAB_SELECTOR = `.${Classes.TAB}`;
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 other test grabs by role-- use Classes like the rest.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've always heard it's best to select elements in tests as close as possible as to how your users would. Ideally by actual text content, followed by accessibility roles/element types (ex user searches for and clicks a <button>), and as a last resort something like targeting by an id or special test-id attribute.

So I don't think we should change these tests just because other tests are selecting by class name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK! Changed.

const NUM_TABS = 3;
assert.lengthOf(wrapper.find(TAB_SELECTOR), NUM_TABS);
assert.lengthOf(wrapper.find(TAB_PANEL_SELECTOR), NUM_TABS);
assert.lengthOf(wrapper.find(`.${tabClassName}`).hostNodes(), NUM_TABS * 2);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should not have length 9, should have length 6. Need to use hostNodes to remove the React nodes.

@bvandercar-vt bvandercar-vt mentioned this pull request Jul 8, 2024
2 tasks
Copy link
Contributor

@evansjohnson evansjohnson left a comment

Choose a reason for hiding this comment

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

lemme know if you think the hostNodes change is important, but I'd prefer to not churn how we're targeting elements here

const TAB = "[role='tab']";
const TAB_LIST = "[role='tablist']";
const TAB_PANEL = "[role='tabpanel']";
const TAB_SELECTOR = `.${Classes.TAB}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

I've always heard it's best to select elements in tests as close as possible as to how your users would. Ideally by actual text content, followed by accessibility roles/element types (ex user searches for and clicks a <button>), and as a last resort something like targeting by an id or special test-id attribute.

So I don't think we should change these tests just because other tests are selecting by class name.

@@ -0,0 +1,5 @@
type: improvement
fix:
description: '[core] a11y(Tooltip): wrap contents in "tooltip" aria role'
Copy link
Contributor

Choose a reason for hiding this comment

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

✂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lemme know if you think the hostNodes change is important###

This PR is a precursor to #6896 , where this change is more beneficial

Copy link
Contributor

@evansjohnson evansjohnson left a comment

Choose a reason for hiding this comment

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

Thank you for the PR and splitting this out!

I think this is bordering on diff churn without real benefit, but provides a marginally better example for future tests so I'm okay merging. Though I wouldn't want to continue seeing more PRs like this.

@evansjohnson evansjohnson merged commit 1f3241d into palantir:develop Jul 16, 2024
12 of 14 checks passed
@bvandercar-vt bvandercar-vt deleted the bvandercar/test/tabs branch November 7, 2024 19:52
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