This repository has been archived by the owner on Jun 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Pick-list filter now only filters on text, value and metadata p…
…rops (#461) * 3 new tests for filter. metadata wip * change filter data from to selected properties. Prior was using all attributes. * add event for modified properties filter depends on * split filter setup so it can called on prop change * fix bug in tests * remove .only from test * filter: add a warning when there is no data. * fix getTag to work with no attributes * add tests for filter * fix accessibility * PickList and ValueList: share more code between lists 461 (#484) * remove .only from test * fix lint errors * add temporary backup files to gitignore * abstract common methods to a shared location * share selection/deselection tests * fix shiftClick behavior for valueList * abstract shared tests between lists * improve method return type * normalize render functions * add this typing to shared logic file https://stackoverflow.com/questions/54710927/typescript-types-and-bind * moving compact prop to alpha order * added typing to items * add compact property to value list * fix type error on textHeading * fix typings * update lists to use common MO callback MO: Mutation Observer * comment touchup * fix backwards compat and event typing * add missing typings * space the tests out * code review follow up * abstracted some types * move comment up * PickList and ValueList: share render methods between lists 461 (#488) * fix lint errors * add temporary backup files to gitignore * abstract common methods to a shared location * share selection/deselection tests * fix shiftClick behavior for valueList * abstract shared tests between lists * improve method return type * normalize render functions * abstract the render methods to functional comp * switch value list over to use shared render * fix calcite-block accessible test. * update calciteListItemPropsUpdated event docs * calciteListItemPropsUpdated is internal only
- Loading branch information
Showing
16 changed files
with
666 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,7 @@ Thumbs.db | |
UserInterfaceState.xcuserstate | ||
.env | ||
src/**/components.d.ts | ||
|
||
# backup files | ||
*.bak | ||
*.orig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { E2EPage, newE2EPage } from "@stencil/core/testing"; | ||
import { accessible, hidden, renders } from "../../tests/commonTests"; | ||
|
||
describe("calcite-filter", () => { | ||
it("renders", async () => renders("calcite-filter")); | ||
|
||
it("honors hidden attribute", async () => hidden("calcite-filter")); | ||
it("is accessible", async () => accessible(`<calcite-filter></calcite-filter>`)); | ||
|
||
describe("filter behavior", () => { | ||
let page: E2EPage; | ||
beforeEach(async () => { | ||
page = await newE2EPage(); | ||
await page.setContent("<calcite-filter></calcite-filter>"); | ||
await page.evaluate(() => { | ||
const filter = document.querySelector("calcite-filter"); | ||
filter.data = [ | ||
{ | ||
name: "Harry", | ||
description: "developer", | ||
value: "harry", | ||
metadata: { haircolor: "red", favoriteBand: "MetallicA" } | ||
}, | ||
{ | ||
name: "Matt", | ||
description: "developer", | ||
value: "matt", | ||
metadata: { haircolor: "black", favoriteBand: "unknown" } | ||
}, | ||
{ | ||
name: "Franco", | ||
description: "developer", | ||
value: "franco", | ||
metadata: { haircolor: "black", favoriteBand: "The Mars Volta" } | ||
}, | ||
{ | ||
name: "Katy", | ||
description: "engineer", | ||
value: "katy", | ||
metadata: { haircolor: "red", favoriteBand: "unknown" } | ||
}, | ||
{ | ||
name: "Jon", | ||
description: "developer", | ||
value: "jon", | ||
metadata: { haircolor: "brown", favoriteBand: "Hippity Hops" } | ||
} | ||
]; | ||
}); | ||
}); | ||
it("emits an event with filtered data after a search query is typed into the input", async () => { | ||
await page.evaluate(() => { | ||
const filter = document.querySelector("calcite-filter"); | ||
const filterInput = filter.shadowRoot.querySelector("input"); | ||
filterInput.value = "developer"; | ||
filterInput.dispatchEvent(new Event("input")); | ||
}); | ||
const event = await page.waitForEvent("calciteFilterChange"); | ||
expect(event.detail).toBeDefined(); | ||
expect(event.detail.find((element) => element.value === "harry")).toBeDefined(); | ||
expect(event.detail.find((element) => element.value === "matt")).toBeDefined(); | ||
expect(event.detail.find((element) => element.value === "franco")).toBeDefined(); | ||
expect(event.detail.find((element) => element.value === "jon")).toBeDefined(); | ||
expect(event.detail.find((element) => element.value === "katy")).toBeUndefined(); | ||
}); | ||
it("searches recursively in data and works and matches on a partial string ignoring case", async () => { | ||
await page.evaluate(() => { | ||
const filter = document.querySelector("calcite-filter"); | ||
const filterInput = filter.shadowRoot.querySelector("input"); | ||
filterInput.value = "volt"; | ||
filterInput.dispatchEvent(new Event("input")); | ||
}); | ||
const event = await page.waitForEvent("calciteFilterChange"); | ||
expect(event.detail).toBeDefined(); | ||
expect(event.detail.length).toBe(1); | ||
expect(event.detail.find((element) => element.value === "franco")).toBeDefined(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.