Skip to content

Commit cc5a85f

Browse files
committed
test(wizard): update api endpoints
1 parent a0910d3 commit cc5a85f

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

src/wizard/internal.wizard.e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('InternalWizardController (e2e)', () => {
2323
};
2424

2525
const taskCreateResponse = await client
26-
.post('/api/v1/wizard/collect')
26+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/collect`)
2727
.send(collectData)
2828
.expect(HttpStatus.CREATED);
2929

src/wizard/wizard.e2e-spec.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('WizardController (e2e)', () => {
3333
await client.close();
3434
});
3535

36-
describe('POST /api/v1/wizard/collect', () => {
36+
describe('POST /api/v1/namespaces/:namespaceId/wizard/collect', () => {
3737
it('should collect web content successfully', async () => {
3838
const collectData = {
3939
html: '<html><body><h1>Test Page</h1><p>This is test content.</p></body></html>',
@@ -44,7 +44,7 @@ describe('WizardController (e2e)', () => {
4444
};
4545

4646
const response = await client
47-
.post('/api/v1/wizard/collect')
47+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/collect`)
4848
.send(collectData)
4949
.expect(HttpStatus.CREATED);
5050

@@ -62,7 +62,7 @@ describe('WizardController (e2e)', () => {
6262
};
6363

6464
await client
65-
.post('/api/v1/wizard/collect')
65+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/collect`)
6666
.send(incompleteData)
6767
.expect(HttpStatus.BAD_REQUEST);
6868
});
@@ -77,7 +77,7 @@ describe('WizardController (e2e)', () => {
7777
};
7878

7979
await client
80-
.post('/api/v1/wizard/collect')
80+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/collect`)
8181
.send(emptyData)
8282
.expect(HttpStatus.BAD_REQUEST);
8383
});
@@ -92,7 +92,7 @@ describe('WizardController (e2e)', () => {
9292
};
9393

9494
const response = await client
95-
.post('/api/v1/wizard/collect')
95+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/collect`)
9696
.send(collectData)
9797
.expect(HttpStatus.CREATED);
9898

@@ -101,7 +101,7 @@ describe('WizardController (e2e)', () => {
101101
});
102102
});
103103

104-
describe('POST /api/v1/wizard/ask', () => {
104+
describe('POST /api/v1/namespaces/:namespaceId/wizard/ask', () => {
105105
it('should handle ask request with valid data', async () => {
106106
const askData = {
107107
query: 'What is the meaning of life?',
@@ -117,7 +117,7 @@ describe('WizardController (e2e)', () => {
117117
};
118118

119119
const response = await client
120-
.post('/api/v1/wizard/ask')
120+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/ask`)
121121
.set('X-Request-Id', 'test-request-123')
122122
.send(askData);
123123

@@ -140,7 +140,7 @@ describe('WizardController (e2e)', () => {
140140
};
141141

142142
const response = await client
143-
.post('/api/v1/wizard/ask')
143+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/ask`)
144144
.set('X-Request-Id', 'test-request-456')
145145
.send(askData);
146146

@@ -163,7 +163,7 @@ describe('WizardController (e2e)', () => {
163163
};
164164

165165
const response = await client
166-
.post('/api/v1/wizard/ask')
166+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/ask`)
167167
.set('X-Request-Id', 'test-request-789')
168168
.send(askData);
169169

@@ -181,7 +181,7 @@ describe('WizardController (e2e)', () => {
181181

182182
// Note: The RequestId decorator returns undefined if header is missing,
183183
// but the service might handle this gracefully
184-
const response = await client.post('/api/v1/wizard/ask').send(askData);
184+
const response = await client.post(`/api/v1/namespaces/${client.namespace.id}/wizard/ask`).send(askData);
185185

186186
// The endpoint might still work without X-Request-Id
187187
expect([
@@ -192,7 +192,7 @@ describe('WizardController (e2e)', () => {
192192
});
193193
});
194194

195-
describe('POST /api/v1/wizard/write', () => {
195+
describe('POST /api/v1/namespaces/:namespaceId/wizard/write', () => {
196196
it('should handle write request with valid data', async () => {
197197
const writeData = {
198198
query: 'Write a summary of the uploaded document',
@@ -208,7 +208,7 @@ describe('WizardController (e2e)', () => {
208208
};
209209

210210
const response = await client
211-
.post('/api/v1/wizard/write')
211+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/write`)
212212
.set('X-Request-Id', 'test-write-request-123')
213213
.send(writeData);
214214

@@ -233,7 +233,7 @@ describe('WizardController (e2e)', () => {
233233
};
234234

235235
const response = await client
236-
.post('/api/v1/wizard/write')
236+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/write`)
237237
.set('X-Request-Id', 'test-write-request-456')
238238
.send(writeData);
239239

@@ -253,7 +253,7 @@ describe('WizardController (e2e)', () => {
253253

254254
await client
255255
.request()
256-
.post('/api/v1/wizard/collect')
256+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/collect`)
257257
.send(collectData)
258258
.expect(HttpStatus.UNAUTHORIZED);
259259
});
@@ -269,7 +269,7 @@ describe('WizardController (e2e)', () => {
269269

270270
await client
271271
.request()
272-
.post('/api/v1/wizard/ask')
272+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/ask`)
273273
.send(askData)
274274
.expect(HttpStatus.UNAUTHORIZED);
275275
});
@@ -285,7 +285,7 @@ describe('WizardController (e2e)', () => {
285285

286286
await client
287287
.request()
288-
.post('/api/v1/wizard/write')
288+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/write`)
289289
.send(writeData)
290290
.expect(HttpStatus.UNAUTHORIZED);
291291
});
@@ -302,7 +302,7 @@ describe('WizardController (e2e)', () => {
302302
};
303303

304304
await client
305-
.post('/api/v1/wizard/collect')
305+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/collect`)
306306
.send(invalidData)
307307
.expect(HttpStatus.BAD_REQUEST);
308308
});
@@ -317,7 +317,7 @@ describe('WizardController (e2e)', () => {
317317
};
318318

319319
const response = await client
320-
.post('/api/v1/wizard/ask')
320+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/ask`)
321321
.set('X-Request-Id', 'test-request')
322322
.send(invalidData);
323323

@@ -331,13 +331,13 @@ describe('WizardController (e2e)', () => {
331331
});
332332
});
333333

334-
describe('POST /api/v1/wizard/*path (proxy)', () => {
334+
describe('POST /api/v1/namespaces/:namespaceId/wizard/*path (proxy)', () => {
335335
it('should handle proxy requests', async () => {
336336
// Note: This test might fail if the wizard service is not running
337337
// or if the proxy path doesn't exist. In a real test environment,
338338
// you might want to mock the wizard service.
339339
const response = await client
340-
.post('/api/v1/wizard/test-proxy-path')
340+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/test-proxy-path`)
341341
.send({ test: 'data' });
342342

343343
// The response status depends on the wizard service implementation
@@ -364,7 +364,7 @@ describe('WizardController (e2e)', () => {
364364
};
365365

366366
const response = await client
367-
.post('/api/v1/wizard/collect')
367+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/collect`)
368368
.send(collectData);
369369

370370
// Should either succeed or fail gracefully
@@ -385,7 +385,7 @@ describe('WizardController (e2e)', () => {
385385
};
386386

387387
const response = await client
388-
.post('/api/v1/wizard/collect')
388+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/collect`)
389389
.send(collectData)
390390
.expect(HttpStatus.CREATED);
391391

@@ -403,7 +403,7 @@ describe('WizardController (e2e)', () => {
403403
};
404404

405405
const response = await client
406-
.post('/api/v1/wizard/ask')
406+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/ask`)
407407
.set('X-Request-Id', 'test-empty-query-request')
408408
.send(askData);
409409

@@ -420,16 +420,16 @@ describe('WizardController (e2e)', () => {
420420
html: '<html><body>Test</body></html>',
421421
url: 'https://example.com',
422422
title: 'Test',
423-
namespace_id: 'invalid-namespace-id',
423+
namespace_id: client.namespace.id,
424424
parentId: client.namespace.root_resource_id,
425425
};
426426

427427
const response = await client
428-
.post('/api/v1/wizard/collect')
428+
.post(`/api/v1/namespaces/invalid-namespace-id/wizard/collect`)
429429
.send(collectData);
430430

431-
// Invalid namespace_id results in permission error (403) rather than validation error (400)
432-
expect([HttpStatus.BAD_REQUEST, HttpStatus.FORBIDDEN]).toContain(
431+
// Invalid namespace_id in URL results in not found error (404) or forbidden error (403)
432+
expect([HttpStatus.NOT_FOUND, HttpStatus.FORBIDDEN]).toContain(
433433
response.status,
434434
);
435435
});
@@ -444,7 +444,7 @@ describe('WizardController (e2e)', () => {
444444
};
445445

446446
const response = await client
447-
.post('/api/v1/wizard/collect')
447+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/collect`)
448448
.send(collectData);
449449

450450
// Invalid parent_id results in not-found error (404) rather than validation error (400)
@@ -477,7 +477,7 @@ describe('WizardController (e2e)', () => {
477477
};
478478

479479
const response = await client
480-
.post('/api/v1/wizard/ask')
480+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/ask`)
481481
.set('X-Request-Id', 'test-specific-resources-request')
482482
.send(askData);
483483

@@ -502,7 +502,7 @@ describe('WizardController (e2e)', () => {
502502
};
503503

504504
const response = await client
505-
.post('/api/v1/wizard/ask')
505+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/ask`)
506506
.set('X-Request-Id', 'test-time-constraints-request')
507507
.send(askData);
508508

@@ -538,7 +538,7 @@ describe('WizardController (e2e)', () => {
538538
};
539539

540540
const response = await client
541-
.post('/api/v1/wizard/write')
541+
.post(`/api/v1/namespaces/${client.namespace.id}/wizard/write`)
542542
.set('X-Request-Id', 'test-mixed-tools-request')
543543
.send(writeData);
544544

0 commit comments

Comments
 (0)