@access-mcp/events 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,219 @@
1
+ import { describe, it, expect, beforeEach } from "vitest";
2
+ import { EventsServer } from "../server.js";
3
+
4
+ // These are integration tests that hit the real API
5
+ // Run with: npm run test:integration
6
+ describe("EventsServer Integration Tests", () => {
7
+ let server: EventsServer;
8
+
9
+ beforeEach(() => {
10
+ server = new EventsServer();
11
+ });
12
+
13
+ describe("Real API Calls", () => {
14
+ it("should fetch real events from ACCESS-CI API", async () => {
15
+ const result = await server["handleToolCall"]({
16
+ params: {
17
+ name: "get_events",
18
+ arguments: {
19
+ beginning_date_relative: "today",
20
+ limit: 5,
21
+ },
22
+ },
23
+ });
24
+
25
+ const responseData = JSON.parse(result.content[0].text);
26
+
27
+ // Check structure of response
28
+ expect(responseData).toHaveProperty("total_events");
29
+ expect(responseData).toHaveProperty("events");
30
+ expect(responseData).toHaveProperty("event_types");
31
+ expect(responseData).toHaveProperty("popular_tags");
32
+
33
+ // If there are events, check their structure
34
+ if (responseData.events.length > 0) {
35
+ const event = responseData.events[0];
36
+ expect(event).toHaveProperty("id");
37
+ expect(event).toHaveProperty("title");
38
+ expect(event).toHaveProperty("date");
39
+ expect(event).toHaveProperty("tags"); // Our enhanced field
40
+ expect(event).toHaveProperty("duration_hours"); // Our calculated field
41
+ }
42
+ }, 10000); // Increase timeout for real API call
43
+
44
+ it("should search for Python events", async () => {
45
+ const result = await server["handleToolCall"]({
46
+ params: {
47
+ name: "search_events",
48
+ arguments: {
49
+ query: "Python",
50
+ limit: 3,
51
+ },
52
+ },
53
+ });
54
+
55
+ const responseData = JSON.parse(result.content[0].text);
56
+
57
+ expect(responseData).toHaveProperty("search_query");
58
+ expect(responseData.search_query).toBe("Python");
59
+ expect(responseData).toHaveProperty("total_matches");
60
+ expect(responseData).toHaveProperty("events");
61
+
62
+ // Check that search actually filters
63
+ if (responseData.events.length > 0) {
64
+ const hasMatch = responseData.events.some(
65
+ (event: any) =>
66
+ event.title?.toLowerCase().includes("python") ||
67
+ event.description?.toLowerCase().includes("python") ||
68
+ event.tags?.some((tag: string) =>
69
+ tag.toLowerCase().includes("python"),
70
+ ),
71
+ );
72
+ expect(hasMatch).toBe(true);
73
+ }
74
+ }, 10000);
75
+
76
+ it("should get upcoming office hours events", async () => {
77
+ const result = await server["handleToolCall"]({
78
+ params: {
79
+ name: "get_upcoming_events",
80
+ arguments: {
81
+ event_type: "Office Hours",
82
+ limit: 3,
83
+ },
84
+ },
85
+ });
86
+
87
+ const responseData = JSON.parse(result.content[0].text);
88
+
89
+ expect(responseData).toHaveProperty("events");
90
+
91
+ // Check that events are actually upcoming (starts_in_hours >= 0)
92
+ responseData.events.forEach((event: any) => {
93
+ if (event.starts_in_hours !== undefined) {
94
+ expect(event.starts_in_hours).toBeGreaterThanOrEqual(0);
95
+ }
96
+ });
97
+ }, 10000);
98
+
99
+ it("should get events by AI tag", async () => {
100
+ const result = await server["handleToolCall"]({
101
+ params: {
102
+ name: "get_events_by_tag",
103
+ arguments: {
104
+ tag: "ai",
105
+ time_range: "upcoming",
106
+ limit: 5,
107
+ },
108
+ },
109
+ });
110
+
111
+ const responseData = JSON.parse(result.content[0].text);
112
+
113
+ expect(responseData).toHaveProperty("tag");
114
+ expect(responseData.tag).toBe("ai");
115
+ expect(responseData).toHaveProperty("time_range");
116
+ expect(responseData).toHaveProperty("events");
117
+ }, 10000);
118
+
119
+ it("should handle date filtering correctly", async () => {
120
+ const result = await server["handleToolCall"]({
121
+ params: {
122
+ name: "get_events",
123
+ arguments: {
124
+ beginning_date: "2025-01-01",
125
+ end_date: "2025-12-31",
126
+ limit: 10,
127
+ },
128
+ },
129
+ });
130
+
131
+ const responseData = JSON.parse(result.content[0].text);
132
+
133
+ expect(responseData).toHaveProperty("events");
134
+
135
+ // Check that events are within the specified date range
136
+ responseData.events.forEach((event: any) => {
137
+ const eventDate = new Date(event.date);
138
+ expect(eventDate.getFullYear()).toBe(2025);
139
+ });
140
+ }, 10000);
141
+
142
+ it("should handle skill level filtering", async () => {
143
+ const result = await server["handleToolCall"]({
144
+ params: {
145
+ name: "get_events",
146
+ arguments: {
147
+ skill_level: "beginner",
148
+ beginning_date_relative: "today",
149
+ limit: 5,
150
+ },
151
+ },
152
+ });
153
+
154
+ const responseData = JSON.parse(result.content[0].text);
155
+
156
+ expect(responseData).toHaveProperty("events");
157
+
158
+ // Check skill levels if events are returned
159
+ if (responseData.events.length > 0) {
160
+ responseData.events.forEach((event: any) => {
161
+ if (event.skill_level) {
162
+ expect(event.skill_level.toLowerCase()).toContain("beginner");
163
+ }
164
+ });
165
+ }
166
+ }, 10000);
167
+ });
168
+
169
+ describe("Error Handling with Real API", () => {
170
+ it("should handle invalid date formats gracefully", async () => {
171
+ const result = await server["handleToolCall"]({
172
+ params: {
173
+ name: "get_events",
174
+ arguments: {
175
+ beginning_date: "invalid-date",
176
+ end_date: "2024-12-31",
177
+ },
178
+ },
179
+ });
180
+
181
+ // Should still return a response (API might ignore invalid params)
182
+ expect(result.content).toBeDefined();
183
+ expect(result.content[0]).toHaveProperty("text");
184
+ }, 10000);
185
+
186
+ it("should handle empty results gracefully", async () => {
187
+ const result = await server["handleToolCall"]({
188
+ params: {
189
+ name: "search_events",
190
+ arguments: {
191
+ query: "xyzabc123notfound",
192
+ limit: 10,
193
+ },
194
+ },
195
+ });
196
+
197
+ const responseData = JSON.parse(result.content[0].text);
198
+
199
+ expect(responseData).toHaveProperty("total_matches");
200
+ expect(responseData.total_matches).toBe(0);
201
+ expect(responseData.events).toHaveLength(0);
202
+ }, 10000);
203
+ });
204
+
205
+ describe("Resource Endpoints", () => {
206
+ it("should fetch data through resource endpoints", async () => {
207
+ const result = await server["handleResourceRead"]({
208
+ params: { uri: "accessci://events/upcoming" },
209
+ });
210
+
211
+ expect(result.contents).toBeDefined();
212
+ expect(result.contents[0]).toHaveProperty("text");
213
+ expect(result.contents[0].mimeType).toBe("application/json");
214
+
215
+ const data = JSON.parse(result.contents[0].text);
216
+ expect(data).toHaveProperty("events");
217
+ }, 10000);
218
+ });
219
+ });