Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2e86553
[CI-3134] Filters Components
Mudaafi May 9, 2024
ccdc528
Update mocks
Mudaafi May 17, 2024
4fdf1e8
Checkpoint 2 - Ranged Slider
Mudaafi May 31, 2024
eb0069a
Update to styles
Mudaafi May 31, 2024
99e2537
CSS Updates - Options List
Mudaafi May 31, 2024
aa5f00a
Filter Group Header css
Mudaafi Jun 3, 2024
8a2c382
Add tests
Mudaafi Jun 3, 2024
fcba345
Merge branch 'main' into ci-3134-mvp-create-a-filters-component
Mudaafi Jun 3, 2024
5973fd2
Fix Merge conflicts and update story
Mudaafi Jun 3, 2024
2b26874
Add Documentation
Mudaafi Jun 3, 2024
47a6de6
lint
Mudaafi Jun 3, 2024
c8997ae
lint 2
Mudaafi Jun 3, 2024
69e33e1
Only update filter-range after onMouseUp event
Mudaafi Jun 10, 2024
9aaf067
Increased debounced time, bugfix rerender calls
Mudaafi Jun 11, 2024
61725d3
Fixes based on comments
Mudaafi Jun 17, 2024
6e6dc18
Add Classnames
Mudaafi Jun 20, 2024
a2cb74d
lint: remove unnecessary else statement
Mudaafi Jun 20, 2024
f6a2fb5
bugfixes to remove console errors
Mudaafi Jun 20, 2024
073ecb5
Update styles
Mudaafi Jun 24, 2024
cd46155
Update inputs to only update on blur
Mudaafi Jun 24, 2024
31f4cea
Add more tests
Mudaafi Jun 24, 2024
b40648b
Add new test
Mudaafi Jun 24, 2024
468a268
Show invalid state if slider range inputs are empty
Mudaafi Jun 24, 2024
ee483b9
Fix input resizing on num digits increase
Mudaafi Jun 25, 2024
b9fa20b
Change callback fn name, fix trackClick
Mudaafi Jun 25, 2024
54db633
CSS updates
Mudaafi Jun 26, 2024
2a90e89
Updates placeholders and naming
Mudaafi Jun 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,8 @@
"vite": "^4.5.3",
"vite-plugin-css-injected-by-js": "^3.1.0",
"webpack": "^5.75.0"
},
"dependencies": {
"classnames": "^2.5.1"
}
}
54 changes: 54 additions & 0 deletions spec/Filters.server.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react';
import { renderToString } from 'react-dom/server';
import '@testing-library/jest-dom';
import { DEMO_API_KEY } from '../src/constants';
import CioPlp from '../src/components/CioPlp';
import Filters from '../src/components/Filters';
import mockTransformedFacets from './local_examples/sampleFacets.json';

const mockSearchOrBrowseResponse = { facets: mockTransformedFacets };

describe('Testing Component on the server: Filters', () => {
beforeEach(() => {
// Mock console error to de-clutter the console for expected errors
const spy = jest.spyOn(console, 'error');
spy.mockImplementation(() => {});
});

afterAll(() => {
jest.resetAllMocks(); // This will reset all mocks after each test
});

it('Should throw error if used outside the CioPlp', () => {
expect(() => renderToString(<Filters facets={mockTransformedFacets} />)).toThrow();
});

it('Should render filters based on search or browse response', async () => {
const html = renderToString(
<CioPlp apiKey={DEMO_API_KEY}>
<Filters response={mockSearchOrBrowseResponse} />
</CioPlp>,
);

mockTransformedFacets.forEach((facetGroup) => {
expect(html).toContain(facetGroup.displayName);
});
});

it('Should render correctly with render props', () => {
const mockChildren = jest.fn().mockReturnValue(<div>Custom Filters</div>);

const filterProps = {
response: mockSearchOrBrowseResponse,
children: mockChildren,
};

const html = renderToString(
<CioPlp apiKey={DEMO_API_KEY}>
<Filters {...filterProps} />
</CioPlp>,
);
expect(mockChildren).toHaveBeenCalled();
expect(html).toContain('Custom Filters');
});
});
Loading