Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesPeck committed Nov 19, 2024
1 parent 8a541bb commit a3ed25c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/routes/explorer/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
searchResults as mockData,
searchResultPath,
picsureUser,
facetResponseWithZeroCount,
} from '../../mock-data';
import { type SearchResult } from '../../../src/lib/models/Search';
import { createCategoricalFilter, createNumericFilter } from '../../../src/lib/models/Filter';
Expand Down Expand Up @@ -55,6 +56,21 @@ userTest.describe('Explorer for authenticated users', () => {
await expect(page.locator('#search-bar')).toBeVisible();
await expect(page.locator('#facet-side-bar')).toBeVisible();
});
userTest('Facets with zero count are hidden', async ({ page }) => {
await page.route(facetResultPath, async (route: Route) =>
route.fulfill({ json: facetResponseWithZeroCount }),
);
// Given
await page.goto('/explorer?search=somedata');

// Then
await expect(page.locator('#facet-side-bar')).toBeVisible();
expect(page
.getByTestId('accordion-item')
.first()
.getByTestId(`facet-${facetResponseWithZeroCount[0].name}-label`)
).not.toBeVisible();
});
});

test.describe('explorer', () => {
Expand Down

0 comments on commit a3ed25c

Please sign in to comment.