11import type { ComparisonFacet } from '#shared/types/comparison'
2- import { CATEGORY_ORDER , FACET_INFO , FACETS_BY_CATEGORY } from '#shared/types/comparison'
2+ import {
3+ CATEGORY_ORDER ,
4+ FACET_INFO ,
5+ FACETS_BY_CATEGORY ,
6+ comingSoonFacets ,
7+ hasComingSoonFacets ,
8+ } from '#shared/types/comparison'
39import FacetSelector from '~/components/Compare/FacetSelector.vue'
410import { beforeEach , describe , expect , it , vi } from 'vitest'
511import { computed , ref } from 'vue'
@@ -21,7 +27,7 @@ const facetLabels: Record<ComparisonFacet, { label: string; description: string
2127 license : { label : 'License' , description : 'Package license' } ,
2228 dependencies : { label : 'Direct Deps' , description : 'Number of direct dependencies' } ,
2329 totalDependencies : {
24- label : 'Total Deps ' ,
30+ label : 'Total deps ' ,
2531 description : 'Total number of dependencies including transitive' ,
2632 } ,
2733 deprecated : { label : 'Deprecated?' , description : 'Whether the package is deprecated' } ,
@@ -34,6 +40,11 @@ const categoryLabels: Record<string, string> = {
3440 security : 'Security & Compliance' ,
3541}
3642
43+ const comingSoonFacetId = comingSoonFacets [ 0 ]
44+ const comingSoonFacetLabel = hasComingSoonFacets
45+ ? ( facetLabels [ comingSoonFacetId ! ] ?. label ?? comingSoonFacetId )
46+ : ''
47+
3748// Helper to build facet info with labels
3849function buildFacetInfo ( facet : ComparisonFacet ) {
3950 return {
@@ -174,6 +185,47 @@ describe('FacetSelector', () => {
174185 } )
175186 } )
176187
188+ describe . runIf ( hasComingSoonFacets ) ( 'comingSoon facets' , ( ) => {
189+ it ( 'disables comingSoon facets' , async ( ) => {
190+ const component = await mountSuspended ( FacetSelector )
191+
192+ // totalDependencies is marked as comingSoon
193+ const buttons = component . findAll ( 'button' )
194+ const comingSoonButton = buttons . find ( b => b . text ( ) . includes ( comingSoonFacetLabel ) )
195+
196+ expect ( comingSoonButton ?. attributes ( 'disabled' ) ) . toBeDefined ( )
197+ } )
198+
199+ it ( 'shows coming soon text for comingSoon facets' , async ( ) => {
200+ const component = await mountSuspended ( FacetSelector )
201+
202+ expect ( component . text ( ) . toLowerCase ( ) ) . toContain ( 'coming soon' )
203+ } )
204+
205+ it ( 'does not show checkmark/add icon for comingSoon facets' , async ( ) => {
206+ const component = await mountSuspended ( FacetSelector )
207+
208+ // Find the comingSoon button
209+ const buttons = component . findAll ( 'button' )
210+ const comingSoonButton = buttons . find ( b => b . text ( ) . includes ( comingSoonFacetLabel ) )
211+
212+ // Should not have checkmark or add icon
213+ expect ( comingSoonButton ?. find ( '.i-carbon\\:checkmark' ) . exists ( ) ) . toBe ( false )
214+ expect ( comingSoonButton ?. find ( '.i-carbon\\:add' ) . exists ( ) ) . toBe ( false )
215+ } )
216+
217+ it ( 'does not call toggleFacet when comingSoon facet is clicked' , async ( ) => {
218+ const component = await mountSuspended ( FacetSelector )
219+
220+ const buttons = component . findAll ( 'button' )
221+ const comingSoonButton = buttons . find ( b => b . text ( ) . includes ( comingSoonFacetLabel ) )
222+ await comingSoonButton ?. trigger ( 'click' )
223+
224+ // toggleFacet should not have been called with totalDependencies
225+ expect ( mockToggleFacet ) . not . toHaveBeenCalledWith ( comingSoonFacetId )
226+ } )
227+ } )
228+
177229 describe ( 'category all/none buttons' , ( ) => {
178230 it ( 'calls selectCategory when all button is clicked' , async ( ) => {
179231 const component = await mountSuspended ( FacetSelector )
@@ -237,5 +289,11 @@ describe('FacetSelector', () => {
237289 // Selected facets have bg-bg-muted class
238290 expect ( component . find ( '.bg-bg-muted' ) . exists ( ) ) . toBe ( true )
239291 } )
292+
293+ it . runIf ( hasComingSoonFacets ) ( 'applies cursor-not-allowed to comingSoon facets' , async ( ) => {
294+ const component = await mountSuspended ( FacetSelector )
295+
296+ expect ( component . find ( '.cursor-not-allowed' ) . exists ( ) ) . toBe ( true )
297+ } )
240298 } )
241299} )
0 commit comments