@@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
22import { ref } from 'vue'
33import { mountSuspended } from '@nuxt/test-utils/runtime'
44import FacetSelector from '~/components/compare/FacetSelector.vue'
5+ import type { ComparisonFacet } from '../../../../shared/types/comparison'
56import { CATEGORY_ORDER , FACET_INFO , FACETS_BY_CATEGORY } from '../../../../shared/types/comparison'
67
78// Mock useFacetSelection
@@ -88,7 +89,7 @@ describe('FacetSelector', () => {
8889
8990 const component = await mountSuspended ( FacetSelector )
9091
91- expect ( component . find ( '.i-carbon- checkmark' ) . exists ( ) ) . toBe ( true )
92+ expect ( component . find ( '.i-carbon\\: checkmark' ) . exists ( ) ) . toBe ( true )
9293 } )
9394
9495 it ( 'shows add icon for unselected facets' , async ( ) => {
@@ -97,7 +98,7 @@ describe('FacetSelector', () => {
9798
9899 const component = await mountSuspended ( FacetSelector )
99100
100- expect ( component . find ( '.i-carbon- add' ) . exists ( ) ) . toBe ( true )
101+ expect ( component . find ( '.i-carbon\\: add' ) . exists ( ) ) . toBe ( true )
101102 } )
102103
103104 it ( 'applies aria-pressed for selected state' , async ( ) => {
@@ -147,8 +148,8 @@ describe('FacetSelector', () => {
147148 const comingSoonButton = buttons . find ( b => b . text ( ) . includes ( 'Total Dependencies' ) )
148149
149150 // Should not have checkmark or add icon
150- expect ( comingSoonButton ?. find ( '.i-carbon- checkmark' ) . exists ( ) ) . toBe ( false )
151- expect ( comingSoonButton ?. find ( '.i-carbon- add' ) . exists ( ) ) . toBe ( false )
151+ expect ( comingSoonButton ?. find ( '.i-carbon\\: checkmark' ) . exists ( ) ) . toBe ( false )
152+ expect ( comingSoonButton ?. find ( '.i-carbon\\: add' ) . exists ( ) ) . toBe ( false )
152153 } )
153154
154155 it ( 'does not call toggleFacet when comingSoon facet is clicked' , async ( ) => {
@@ -168,8 +169,8 @@ describe('FacetSelector', () => {
168169 const component = await mountSuspended ( FacetSelector )
169170
170171 // Find the first 'all' button (for performance category)
171- const allButtons = component . findAll ( 'button' ) . filter ( b => b . text ( ) === 'all' )
172- await allButtons [ 0 ] . trigger ( 'click' )
172+ const allButton = component . findAll ( 'button' ) . find ( b => b . text ( ) === 'all' )
173+ await allButton ! . trigger ( 'click' )
173174
174175 expect ( mockSelectCategory ) . toHaveBeenCalledWith ( 'performance' )
175176 } )
@@ -178,8 +179,8 @@ describe('FacetSelector', () => {
178179 const component = await mountSuspended ( FacetSelector )
179180
180181 // Find the first 'none' button (for performance category)
181- const noneButtons = component . findAll ( 'button' ) . filter ( b => b . text ( ) === 'none' )
182- await noneButtons [ 0 ] . trigger ( 'click' )
182+ const noneButton = component . findAll ( 'button' ) . find ( b => b . text ( ) === 'none' )
183+ await noneButton ! . trigger ( 'click' )
183184
184185 expect ( mockDeselectCategory ) . toHaveBeenCalledWith ( 'performance' )
185186 } )
@@ -190,13 +191,15 @@ describe('FacetSelector', () => {
190191 f => ! FACET_INFO [ f ] . comingSoon ,
191192 )
192193 mockSelectedFacets . value = performanceFacets
193- mockIsFacetSelected . mockImplementation ( ( f : string ) => performanceFacets . includes ( f ) )
194+ mockIsFacetSelected . mockImplementation ( ( f : string ) =>
195+ performanceFacets . includes ( f as ComparisonFacet ) ,
196+ )
194197
195198 const component = await mountSuspended ( FacetSelector )
196199
197- const allButtons = component . findAll ( 'button' ) . filter ( b => b . text ( ) === 'all' )
200+ const allButton = component . findAll ( 'button' ) . find ( b => b . text ( ) === 'all' )
198201 // First all button (performance) should be disabled
199- expect ( allButtons [ 0 ] . attributes ( 'disabled' ) ) . toBeDefined ( )
202+ expect ( allButton ! . attributes ( 'disabled' ) ) . toBeDefined ( )
200203 } )
201204
202205 it ( 'disables none button when no facets in category are selected' , async ( ) => {
@@ -206,9 +209,9 @@ describe('FacetSelector', () => {
206209
207210 const component = await mountSuspended ( FacetSelector )
208211
209- const noneButtons = component . findAll ( 'button' ) . filter ( b => b . text ( ) === 'none' )
212+ const noneButton = component . findAll ( 'button' ) . find ( b => b . text ( ) === 'none' )
210213 // First none button (performance) should be disabled
211- expect ( noneButtons [ 0 ] . attributes ( 'disabled' ) ) . toBeDefined ( )
214+ expect ( noneButton ! . attributes ( 'disabled' ) ) . toBeDefined ( )
212215 } )
213216 } )
214217
0 commit comments