@@ -194,7 +194,7 @@ describe('CourseOptimizerPage', () => {
194194 } ) ;
195195 } ) ;
196196
197- it ( 'should show only manual links when manualLinks filter is selected' , async ( ) => {
197+ it ( 'should show only manual links when manualLinks filter is selected and show all links when clicked again ' , async ( ) => {
198198 const {
199199 getByText,
200200 getByLabelText,
@@ -215,6 +215,16 @@ describe('CourseOptimizerPage', () => {
215215 expect ( queryByText ( 'Test Broken Links' ) ) . not . toBeInTheDocument ( ) ;
216216 expect ( queryByText ( 'Test Locked Links' ) ) . not . toBeInTheDocument ( ) ;
217217 } ) ;
218+
219+ // Click the manual links checkbox again to clear the filter
220+ fireEvent . click ( getByLabelText ( scanResultsMessages . manualLabel . defaultMessage ) ) ;
221+
222+ // Assert that all links are displayed after clearing the filter
223+ await waitFor ( ( ) => {
224+ expect ( getByText ( 'Test Broken Links' ) ) . toBeInTheDocument ( ) ;
225+ expect ( getByText ( 'Test Manual Links' ) ) . toBeInTheDocument ( ) ;
226+ expect ( getByText ( 'Test Locked Links' ) ) . toBeInTheDocument ( ) ;
227+ } ) ;
218228 } ) ;
219229
220230 it ( 'should show only manual & locked links when manual & locked Links filters are selected, ignore broken links' , async ( ) => {
@@ -267,5 +277,51 @@ describe('CourseOptimizerPage', () => {
267277 expect ( getByText ( 'Test Locked Links' ) ) . toBeInTheDocument ( ) ;
268278 } ) ;
269279 } ) ;
280+
281+ it ( 'should show only manual links when the broken chip is clicked and show all links when clear filters button is clicked' , async ( ) => {
282+ const {
283+ getByText,
284+ getByLabelText,
285+ getByTestId,
286+ queryByText,
287+ container,
288+ } = await setupOptimizerPage ( ) ;
289+ // Select broken & manual link checkboxes
290+ fireEvent . click ( getByLabelText ( scanResultsMessages . brokenLabel . defaultMessage ) ) ;
291+ fireEvent . click ( getByLabelText ( scanResultsMessages . manualLabel . defaultMessage ) ) ;
292+
293+ const collapsibleTrigger = container . querySelector ( '.collapsible-trigger' ) ;
294+ expect ( collapsibleTrigger ) . toBeInTheDocument ( ) ;
295+ fireEvent . click ( collapsibleTrigger ) ;
296+
297+ // Assert that all links are displayed
298+ await waitFor ( ( ) => {
299+ expect ( getByText ( 'Test Broken Links' ) ) . toBeInTheDocument ( ) ;
300+ expect ( getByText ( 'Test Manual Links' ) ) . toBeInTheDocument ( ) ;
301+ expect ( queryByText ( 'Test Locked Links' ) ) . not . toBeInTheDocument ( ) ;
302+ } ) ;
303+
304+ // Click on the "Broken" chip to filter the results
305+ const brokenChip = getByTestId ( 'chip-brokenLinks' ) ;
306+ fireEvent . click ( brokenChip ) ;
307+
308+ // Assert that only manual links are displayed
309+ await waitFor ( ( ) => {
310+ expect ( queryByText ( 'Test Broken Links' ) ) . not . toBeInTheDocument ( ) ;
311+ expect ( getByText ( 'Test Manual Links' ) ) . toBeInTheDocument ( ) ;
312+ expect ( queryByText ( 'Test Locked Links' ) ) . not . toBeInTheDocument ( ) ;
313+ } ) ;
314+
315+ // Click the "Clear filters" button
316+ const clearFiltersButton = getByText ( scanResultsMessages . clearFilters . defaultMessage ) ;
317+ fireEvent . click ( clearFiltersButton ) ;
318+
319+ // Assert that all links are displayed after clearing filters
320+ await waitFor ( ( ) => {
321+ expect ( getByText ( 'Test Broken Links' ) ) . toBeInTheDocument ( ) ;
322+ expect ( getByText ( 'Test Manual Links' ) ) . toBeInTheDocument ( ) ;
323+ expect ( getByText ( 'Test Locked Links' ) ) . toBeInTheDocument ( ) ;
324+ } ) ;
325+ } ) ;
270326 } ) ;
271327} ) ;
0 commit comments