Skip to content

Commit

Permalink
Clean up document status filter (#641)
Browse files Browse the repository at this point in the history
* Update toolbar.ts

* Update tests

* Remove comment
  • Loading branch information
jeffdaley authored Mar 7, 2024
1 parent 87cd4c6 commit fe2550e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
5 changes: 4 additions & 1 deletion web/app/components/header/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ export default class ToolbarComponent extends Component<ToolbarComponentSignatur
let facetArray: FacetArrayItem[] = [];

Object.entries(this.args.facets).forEach(([key, value]) => {
if (key === FacetName.Status && this.args.scope === SearchScope.Docs) {
if (
key === FacetName.Status &&
this.args.scope !== SearchScope.Projects
) {
facetArray.push({ name: key, values: this.statuses });
} else {
facetArray.push({ name: key as FacetName, values: value });
Expand Down
37 changes: 32 additions & 5 deletions web/tests/integration/components/header/toolbar-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const OWNER_TOGGLE = `[data-test-facet-dropdown-trigger="${FacetLabel.Owners}"]`
const DROPDOWN_ITEM = "[data-test-facet-dropdown-link]";
const POPOVER = "[data-test-facet-dropdown-popover]";
const CHECK = "[data-test-x-dropdown-list-checkable-item-check]";
const LIST_ITEM_VALUE = "[data-test-x-dropdown-list-item-value]";

const FACETS = {
docType: {
Expand Down Expand Up @@ -63,15 +64,41 @@ module("Integration | Component | header/toolbar", function (hooks) {
<Header::Toolbar @scope={{this.scope}} @facets={{this.facets}} />
`);

await click("[data-test-facet-dropdown-trigger='Status']");
await click(STATUS_TOGGLE);

const docFilters = [
"Approved",
"In-Review",
"In Review",
"Obsolete",
"WIP",
];

assert.deepEqual(
findAll("[data-test-x-dropdown-list-item-value]")?.map(
(el) => el.textContent?.trim(),
),
["Approved", "In-Review", "In Review", "Obsolete", "WIP"],
findAll(LIST_ITEM_VALUE)?.map((el) => el.textContent?.trim()),
docFilters,
"Unsupported statuses are filtered out",
);

// Close and reopen (changing the scope closes the dropdown)
this.set("scope", SearchScope.Projects);
await click(STATUS_TOGGLE);

assert.deepEqual(
findAll(LIST_ITEM_VALUE)?.map((el) => el.textContent?.trim()),
STATUS_NAMES,
"All statuses are shown when the scope is not 'Docs'",
);

// Close and reopen
this.set("scope", undefined);
await click(STATUS_TOGGLE);

assert.deepEqual(
findAll(LIST_ITEM_VALUE)?.map((el) => el.textContent?.trim()),
docFilters,
"All statuses are shown when the scope is not defined",
);
});

test("it renders undefined facets disabled", async function (assert) {
Expand Down

0 comments on commit fe2550e

Please sign in to comment.