Files
Nico 8ba889f701 Extract reusable Include/Exclude TargetLabelSelector component (#47212)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #46583

Before implementing changes in the Save policy / Edit policy modal (see
[Figma](https://www.figma.com/design/0F1sw63SuYaKVWlcL7mnc6/-33441-Policies--Custom-targets-with-%22Include-any%22-and-%22Exclude-any%22?node-id=5303-5687&t=Fszpf83KhcZ7ViWh-0)),
I though of making the label selection a reusable component that we
could reuse both in Configuration Profiles and in Policies, so that we
don't repeat ourselves.

## Testing

- [x] Added/updated automated tests

- [x] QA'd all new/changed functionality manually

I don't have MDM fully wired up but I checked the payloads were sent as
expected.



https://github.com/user-attachments/assets/b2c4898f-c69c-4c05-b76c-e89728842661



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a dropdown-based target selector and a tabbed Include/Exclude
label selector with Any/All mode.

* **Improvements**
* Unified target/label selection across packages, policies, queries, and
profiles.
* Better empty/loading/error states, selectable badges, help/subtitle
support, and cross-tab disabling of selected labels.

* **Tests**
* Added and updated test coverage for both dropdown and tabbed selector
behaviors.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-06-10 11:14:47 -03:00

18 lines
546 B
TypeScript

import { listNamesFromSelectedLabels } from "./labels";
describe("listNamesFromSelectedLabels", () => {
it("returns names of selected labels", () => {
expect(
listNamesFromSelectedLabels({ foo: true, bar: false, baz: true })
).toEqual(["foo", "baz"]);
});
it("returns empty array when nothing is selected", () => {
expect(listNamesFromSelectedLabels({ foo: false, bar: false })).toEqual([]);
});
it("returns empty array for an empty dict", () => {
expect(listNamesFromSelectedLabels({})).toEqual([]);
});
});