From 49ce7d821b7f2ede4d2c49e9f7d165867dbfc50e Mon Sep 17 00:00:00 2001 From: Samantha Piatt Date: Thu, 30 Jan 2025 10:49:46 -0500 Subject: [PATCH 1/3] Remove disable from facet checkbox if facet count is 0. --- .gitignore | 1 + src/lib/components/explorer/FacetItem.svelte | 3 +- tests/routes/explorer/facets/test.ts | 55 ++++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c7342eee..66bd52f8 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ vite.config.ts.timestamp-* /httpd-docker-logs httpd-vhosts.conf .idea/ +.nvmrc *.iml supervisord.log supervisord.pid \ No newline at end of file diff --git a/src/lib/components/explorer/FacetItem.svelte b/src/lib/components/explorer/FacetItem.svelte index 237cba42..7f946a25 100644 --- a/src/lib/components/explorer/FacetItem.svelte +++ b/src/lib/components/explorer/FacetItem.svelte @@ -92,12 +92,11 @@ {/if} diff --git a/tests/routes/explorer/facets/test.ts b/tests/routes/explorer/facets/test.ts index 6ba69439..d62ed396 100644 --- a/tests/routes/explorer/facets/test.ts +++ b/tests/routes/explorer/facets/test.ts @@ -498,6 +498,61 @@ test.describe('Facet & search', () => { // Then await expect(spanInInput).toContainText(facetsResponse[0].facets[0].count.toString()); }); + test('Selected facet is not disabled when 0 count', async ({ page }) => { + // Given + await page.route(searchResultPath, async (route: Route) => + route.fulfill({ json: searchResults }), + ); + await page.route(facetResultPath, async (route: Route) => + route.fulfill({ + json: [ + { + ...facetsResponse[0], + facets: [facetsResponse[0].facets[0], facetsResponse[0].facets[1]], + }, + facetsResponse[1], + ], + }), + ); + await page.goto('/explorer'); + await page.route(searchResultPath, async (route: Route) => + route.fulfill({ + json: { + ...searchResults, + totalElements: 0, + content: [], + }, + }), + ); + await page.route(facetResultPath, async (route: Route) => + route.fulfill({ + json: [ + { + ...facetsResponse[0], + facets: [ + { + ...facetsResponse[0].facets[0], + count: 0, + }, + facetsResponse[0].facets[1], + ], + }, + facetsResponse[1], + ], + }), + ); + + const firstCheckName = facetsResponse[0].facets[0].name; + const facetCheckBox = page.getByTestId(`facet-${firstCheckName}-label`); + await facetCheckBox.click(); + + // When + await page.getByTestId('search-box').fill('hsfgoisdhf'); + await page.locator('#search-button').click(); + + // Then + await expect(facetCheckBox).not.toBeDisabled(); + }); }); test.describe('Nested Facets', () => { From 32c7f5e493c977aecdf737a5f0b77faa0834e431 Mon Sep 17 00:00:00 2001 From: Samantha Piatt Date: Thu, 30 Jan 2025 11:47:54 -0500 Subject: [PATCH 2/3] Revert class change on checkbox. --- src/lib/components/explorer/FacetItem.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/explorer/FacetItem.svelte b/src/lib/components/explorer/FacetItem.svelte index 7f946a25..c7ac911b 100644 --- a/src/lib/components/explorer/FacetItem.svelte +++ b/src/lib/components/explorer/FacetItem.svelte @@ -92,7 +92,7 @@ {/if} Date: Thu, 30 Jan 2025 14:46:15 -0500 Subject: [PATCH 3/3] Update to leave disabled status when not checked but has a count of 0. --- src/lib/components/explorer/FacetItem.svelte | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/components/explorer/FacetItem.svelte b/src/lib/components/explorer/FacetItem.svelte index c7ac911b..f4e95604 100644 --- a/src/lib/components/explorer/FacetItem.svelte +++ b/src/lib/components/explorer/FacetItem.svelte @@ -97,6 +97,7 @@ name={facet.name} value={facet} {checked} + disabled={facet.count === 0 && !checked} aria-checked={checked} on:click={onClick} />