Skip to content

Commit c74aa48

Browse files
committed
fix tests
1 parent 7d92cd1 commit c74aa48

File tree

1 file changed

+3
-54
lines changed
  • exercises/05.changes/02.problem.resources-list-changed/src

1 file changed

+3
-54
lines changed

exercises/05.changes/02.problem.resources-list-changed/src/index.test.ts

Lines changed: 3 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -599,13 +599,6 @@ test('ListChanged notification: resources', async () => {
599599
},
600600
)
601601

602-
// Initially resources should be disabled/empty
603-
const initialResources = await client.listResources()
604-
expect(
605-
initialResources.resources,
606-
'🚨 Resources should initially be empty when no entries/tags exist',
607-
).toHaveLength(0)
608-
609602
// Trigger a DB change that should enable resources
610603
await client.callTool({
611604
name: 'create_tag',
@@ -622,7 +615,6 @@ test('ListChanged notification: resources', async () => {
622615
},
623616
})
624617

625-
// Should receive resource listChanged notification
626618
let resourceNotif
627619
try {
628620
resourceNotif = await Promise.race([
@@ -633,31 +625,13 @@ test('ListChanged notification: resources', async () => {
633625
])
634626
} catch {
635627
throw new Error(
636-
'🚨 Did not receive resources/listChanged notification when expected. Make sure your server calls sendResourceListChanged when resources are enabled/disabled.',
628+
'🚨 Did not receive resources/listChanged notification when expected. Make sure your server calls sendResourceListChanged when resources change.',
637629
)
638630
}
639631
expect(
640632
resourceNotif,
641-
'🚨 Did not receive resources/listChanged notification when expected. Make sure your server calls sendResourceListChanged when resources are enabled/disabled.',
633+
'🚨 Did not receive resources/listChanged notification when expected. Make sure your server calls sendResourceListChanged when resources change.',
642634
).toBeDefined()
643-
644-
// After notification, resources should now be available
645-
const enabledResources = await client.listResources()
646-
expect(
647-
enabledResources.resources.length,
648-
'🚨 Resources should be enabled after creating entries/tags. The server must dynamically enable/disable resources based on content.',
649-
).toBeGreaterThan(0)
650-
651-
// Verify that resources are properly available
652-
const resourceUris = enabledResources.resources.map((r) => r.uri)
653-
expect(
654-
resourceUris.some((uri) => uri.includes('entries')),
655-
'🚨 Should have entry resources available after creating entries',
656-
).toBe(true)
657-
expect(
658-
resourceUris.some((uri) => uri.includes('tags')),
659-
'🚨 Should have tag resources available after creating tags',
660-
).toBe(true)
661635
})
662636

663637
test('ListChanged notification: tools', async () => {
@@ -672,17 +646,7 @@ test('ListChanged notification: tools', async () => {
672646
},
673647
)
674648

675-
// Get initial tool list
676-
const initialTools = await client.listTools()
677-
const initialToolNames = initialTools.tools.map((t) => t.name)
678-
679-
// Should not have advanced tools initially
680-
expect(
681-
initialToolNames,
682-
'🚨 Advanced tools like create_wrapped_video should not be available initially',
683-
).not.toContain('create_wrapped_video')
684-
685-
// Trigger a DB change that should enable additional tools
649+
// Trigger a DB change that should enable tools
686650
await client.callTool({
687651
name: 'create_tag',
688652
arguments: {
@@ -698,7 +662,6 @@ test('ListChanged notification: tools', async () => {
698662
},
699663
})
700664

701-
// Should receive tool listChanged notification
702665
let toolNotif
703666
try {
704667
toolNotif = await Promise.race([
@@ -716,18 +679,4 @@ test('ListChanged notification: tools', async () => {
716679
toolNotif,
717680
'🚨 Did not receive tools/listChanged notification when expected. Make sure your server notifies clients when tools are enabled/disabled.',
718681
).toBeDefined()
719-
720-
// After notification, additional tools should be available
721-
const enabledTools = await client.listTools()
722-
const enabledToolNames = enabledTools.tools.map((t) => t.name)
723-
expect(
724-
enabledToolNames,
725-
'🚨 Advanced tools like create_wrapped_video should be enabled after creating entries/tags. The server must dynamically enable/disable tools based on content.',
726-
).toContain('create_wrapped_video')
727-
728-
// Verify that tools are properly enabled with correct count
729-
expect(
730-
enabledTools.tools.length,
731-
'🚨 Should have more tools available after creating content',
732-
).toBeGreaterThan(initialTools.tools.length)
733682
})

0 commit comments

Comments
 (0)