diff --git a/src/js/filterOptions.ts b/src/js/filterOptions.ts index cf7002cf..c2347aa2 100644 --- a/src/js/filterOptions.ts +++ b/src/js/filterOptions.ts @@ -19,6 +19,12 @@ const FILTER_CONFIG = { ["All Uses", true], ["Commercial", true], ["Residential", true], + ["Multi-Family Residential", true], + ["Low Density (SF) Residential", true], + ["High Density Residential", true], + ["Industrial", true], + ["Medical", true], + ["Other", true], ], implementationStage: [ ["Implemented", true], @@ -26,11 +32,16 @@ const FILTER_CONFIG = { ["Planned", false], ["Proposed", false], ["Repealed", false], + ["Unverified", false], ], } as const; type FilterGroupKey = keyof typeof FILTER_CONFIG; +export function getAllFilterOptions(groupKey: FilterGroupKey): string[] { + return FILTER_CONFIG[groupKey].map((option) => option[0]); +} + export function getDefaultFilterOptions(groupKey: FilterGroupKey): string[] { return FILTER_CONFIG[groupKey] .filter(([, isDefaultSelected]) => isDefaultSelected) diff --git a/tests/app/filter.test.ts b/tests/app/filter.test.ts index d66ae3de..6b2ff7c6 100644 --- a/tests/app/filter.test.ts +++ b/tests/app/filter.test.ts @@ -1,10 +1,13 @@ import { Page, test } from "@playwright/test"; + import { loadMap, assertNumPlaces, deselectToggle, DEFAULT_PLACE_RANGE, + getTotalNumPlaces, } from "./utils"; +import { getAllFilterOptions } from "../../src/js/filterOptions"; interface EdgeCase { desc: string; @@ -14,7 +17,7 @@ interface EdgeCase { implementation?: string[]; populationIntervals?: [number, number]; noRequirements?: boolean; - expectedRange: [number, number]; + expectedRange: [number, number] | "all"; } // The expected ranges can be updated as the data is updated! @@ -46,14 +49,8 @@ const TESTS: EdgeCase[] = [ { desc: "all places", // The other filters already enable all options by default. - implementation: [ - "Implemented", - "Passed", - "Planned", - "Proposed", - "Repealed", - ], - expectedRange: [2900, 4000], + implementation: getAllFilterOptions("implementationStage"), + expectedRange: "all", }, ]; @@ -116,6 +113,11 @@ for (const edgeCase of TESTS) { .fill(rightInterval.toString()); } - await assertNumPlaces(page, edgeCase.expectedRange); + if (edgeCase.expectedRange === "all") { + const expected = await getTotalNumPlaces(); + await assertNumPlaces(page, [expected, expected]); + } else { + await assertNumPlaces(page, edgeCase.expectedRange); + } }); } diff --git a/tests/app/utils.ts b/tests/app/utils.ts index e5f9c2e1..d3001a5d 100644 --- a/tests/app/utils.ts +++ b/tests/app/utils.ts @@ -1,16 +1,24 @@ import { expect } from "@playwright/test"; import type { Page } from "@playwright/test"; +import { readCsv } from "../../scripts/syncLatLng"; + const PLACE_MARKER = "path.leaflet-interactive"; -const DEFAULT_PLACE_RANGE: [number, number] = [2930, 4000]; +export const DEFAULT_PLACE_RANGE: [number, number] = [3000, 4000]; -const loadMap = async (page: Page): Promise => { +export const loadMap = async (page: Page): Promise => { await page.goto(""); // Wait for data to load. await page.waitForSelector(PLACE_MARKER); }; -const assertNumPlaces = async ( +export async function getTotalNumPlaces(): Promise { + const mapData = await readCsv("map/tidied_map_data.csv"); + // For some reason, the CSV has one extra line than the data used in prod. + return mapData.length - 1; +} + +export const assertNumPlaces = async ( page: Page, range: [number, number], ): Promise => { @@ -29,10 +37,8 @@ const assertNumPlaces = async ( expect(mapNumPlaces).toEqual(counterNumPlaces); }; -const deselectToggle = async (page: Page): Promise => { +export const deselectToggle = async (page: Page): Promise => { // Default has requirement toggle on, so first de-select it by opening filter pop-up and clicking toggle. await page.locator(".header-filter-icon-container").click(); await page.locator("#no-requirements-toggle").click({ force: true }); }; - -export { assertNumPlaces, loadMap, deselectToggle, DEFAULT_PLACE_RANGE };