-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add framed works filter to artwork screens
- Loading branch information
1 parent
35383e0
commit 42cc57a
Showing
8 changed files
with
324 additions
and
75 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
97 changes: 97 additions & 0 deletions
97
src/app/Components/ArtworkFilter/Filters/FramedOptions.tests.tsx
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,97 @@ | ||
import { fireEvent, screen } from "@testing-library/react-native" | ||
import { FilterParamName } from "app/Components/ArtworkFilter/ArtworkFilterHelpers" | ||
import { | ||
ArtworkFiltersState, | ||
ArtworkFiltersStoreProvider, | ||
getArtworkFiltersModel, | ||
} from "app/Components/ArtworkFilter/ArtworkFilterStore" | ||
import { MockFilterScreen } from "app/Components/ArtworkFilter/FilterTestHelper" | ||
import { FramedOptionsScreen } from "app/Components/ArtworkFilter/Filters/FramedOptions.tsx" | ||
import { __globalStoreTestUtils__ } from "app/store/GlobalStore" | ||
import { renderWithWrappers } from "app/utils/tests/renderWithWrappers" | ||
import { getEssentialProps } from "./helper" | ||
|
||
describe(FramedOptionsScreen, () => { | ||
beforeEach(() => { | ||
__globalStoreTestUtils__?.injectFeatureFlags({ AREnableFramedFilter: true }) | ||
}) | ||
|
||
const initialState: ArtworkFiltersState = { | ||
aggregations: [], | ||
appliedFilters: [], | ||
applyFilters: false, | ||
counts: { | ||
total: null, | ||
followedArtists: null, | ||
}, | ||
showFilterArtworksModal: false, | ||
sizeMetric: "cm", | ||
filterType: "artwork", | ||
previouslyAppliedFilters: [], | ||
selectedFilters: [], | ||
} | ||
|
||
const MockFramedOptionsScreen = ({ | ||
initialData = initialState, | ||
}: { | ||
initialData?: ArtworkFiltersState | ||
}) => { | ||
return ( | ||
<ArtworkFiltersStoreProvider | ||
runtimeModel={{ | ||
...getArtworkFiltersModel(), | ||
...initialData, | ||
}} | ||
> | ||
<FramedOptionsScreen {...getEssentialProps()} /> | ||
</ArtworkFiltersStoreProvider> | ||
) | ||
} | ||
|
||
describe("no filters are selected", () => { | ||
it("renders all options", () => { | ||
renderWithWrappers(<MockFramedOptionsScreen initialData={initialState} />) | ||
|
||
expect(screen.getByText("Show only framed works")).toBeTruthy() | ||
}) | ||
}) | ||
|
||
describe("a filter is selected", () => { | ||
const state: ArtworkFiltersState = { | ||
...initialState, | ||
selectedFilters: [ | ||
{ | ||
displayText: "Show only framed works", | ||
paramName: FilterParamName.framed, | ||
paramValue: true, | ||
}, | ||
], | ||
} | ||
|
||
it("displays the number of the selected filters on the filter modal screen", () => { | ||
renderWithWrappers(<MockFilterScreen initialState={state} />) | ||
|
||
expect(screen.getByText("Frame • 1")).toBeTruthy() | ||
}) | ||
|
||
it("toggles selected filters 'ON' and unselected filters 'OFF", async () => { | ||
renderWithWrappers(<MockFramedOptionsScreen initialData={state} />) | ||
|
||
const options = screen.getAllByTestId("multi-select-option-button") | ||
const checkboxes = screen.getAllByTestId("multi-select-option-checkbox") | ||
|
||
expect(options).toHaveLength(1) | ||
expect(options[0]).toHaveTextContent("Show only framed works") | ||
|
||
expect(checkboxes[0]).toHaveProp("selected", true) | ||
|
||
fireEvent.press(options[0]) | ||
|
||
expect(checkboxes[0]).toHaveProp("selected", false) | ||
|
||
fireEvent.press(options[0]) | ||
|
||
expect(checkboxes[0]).toHaveProp("selected", true) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.