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

Clean up document status filter #641

Merged
merged 3 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Comment on lines +71 to +72
Copy link
Collaborator

Choose a reason for hiding this comment

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

😭

"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
Loading