diff --git a/frontend/e2e/search.spec.ts b/frontend/e2e/search.spec.ts index c2c7f30..2eab99f 100644 --- a/frontend/e2e/search.spec.ts +++ b/frontend/e2e/search.spec.ts @@ -208,3 +208,42 @@ test.describe('Semantic Search', () => { }) }) + +test.describe('Plot Sidebar', () => { + test('plot sidebar does not duplicate visible labels', async ({ page }) => { + // Mock the API calls so we don't need real ChromaDB data + await page.route('**/api/collections', async route => { + await route.fulfill({ json: [{ name: 'fashionimageUrl', count: 100 }] }) + }) + await page.route('**/api/collections/fashionimageUrl', async route => { + await route.fulfill({ + json: { name: 'fashionimageUrl', count: 100, metadata_fields: ['productDisplayName', 'imageUrl'] } + }) + }) + + // Navigate with collection param + await page.goto('/plot?collection=fashionimageUrl') + + // Wait for the collection dropdown to be populated with options + await expect( + page.locator('select option:not([value=""])').first() + ).toBeAttached({ timeout: 10_000 }) + + const sidebar = page.getByTestId('plot-sidebar') + + await expect(sidebar.getByRole('button', { name: 'Collection', exact: true })).toBeVisible({ timeout: 5_000 }) + + const displayFieldsBtn = sidebar.getByRole('button', { name: 'Display Fields', exact: true }) + const imageFieldBtn = sidebar.getByRole('button', { name: 'Image Field', exact: true }) + + await displayFieldsBtn.click() + await imageFieldBtn.click() + + await expect(sidebar.locator('label').filter({ hasText: /^Collection$/ })).toHaveCount(0) + await expect(sidebar.locator('label').filter({ hasText: /^Display Fields$/ })).toHaveCount(0) + await expect(sidebar.locator('label').filter({ hasText: /^Image Field$/ })).toHaveCount(0) + + await expect(sidebar.getByRole('combobox', { name: 'Collection' })).toBeVisible() + await expect(sidebar.getByRole('combobox', { name: 'Image Field' })).toBeVisible() + }) +}) diff --git a/frontend/src/components/plot/PlotControls.tsx b/frontend/src/components/plot/PlotControls.tsx index b4bea7a..c02d164 100644 --- a/frontend/src/components/plot/PlotControls.tsx +++ b/frontend/src/components/plot/PlotControls.tsx @@ -130,8 +130,8 @@ export default function PlotControls({ onCompute, isComputing }: PlotControlsPro {/* Collection Selection */}
- setImageField(e.target.value)} @@ -331,12 +327,13 @@ export default function PlotControls({ onCompute, isComputing }: PlotControlsPro setGptEnabled(e.target.checked)} className="mr-2" />