-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: jamshale <jamiehalebc@gmail.com>
- Loading branch information
Showing
22 changed files
with
383 additions
and
870 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 17 additions & 15 deletions
32
services/tenant-ui/frontend/test/__mocks__/api/routes/acapy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,29 @@ | ||
import { rest } from 'msw'; | ||
import { http, HttpResponse } from 'msw'; | ||
|
||
import { API_PATH } from '@/helpers/constants'; | ||
import { acapyResponse } from '../responses'; | ||
|
||
export const successHandlers = [ | ||
rest.all(API_PATH.TEST_TENANT_PROXY, (req, res, ctx) => { | ||
return res(ctx.status(200), ctx.json(acapyResponse.basic)); | ||
}), | ||
http.all(API_PATH.TEST_TENANT_PROXY, () => | ||
HttpResponse.json(acapyResponse.basic) | ||
), | ||
]; | ||
|
||
export const authErrorHandlers = [ | ||
rest.all(API_PATH.TEST_TENANT_PROXY, (req, res, ctx) => { | ||
return res( | ||
ctx.status(401), | ||
ctx.json({ | ||
reason: `Test: ${req.headers.get('Authorization')}`, | ||
}) | ||
); | ||
}), | ||
http.all(API_PATH.TEST_TENANT_PROXY, ({ request }) => | ||
HttpResponse.json( | ||
{ | ||
reason: `Test: ${request.headers.get('Authorization')}`, | ||
}, | ||
{ | ||
status: 401, | ||
} | ||
) | ||
), | ||
]; | ||
|
||
export const unknownErrorHandlers = [ | ||
rest.all(API_PATH.TEST_TENANT_PROXY, (req, res, ctx) => { | ||
return res(ctx.status(500), ctx.json({})); | ||
}), | ||
http.all(API_PATH.TEST_TENANT_PROXY, () => | ||
HttpResponse.json({}, { status: 500 }) | ||
), | ||
]; |
17 changes: 5 additions & 12 deletions
17
services/tenant-ui/frontend/test/__mocks__/api/routes/config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,16 @@ | ||
import { rest } from 'msw'; | ||
import { http, HttpResponse } from 'msw'; | ||
|
||
import { API_PATH } from '@/helpers/constants'; | ||
import { configResponse } from '../responses'; | ||
import { fullPathWithProxyTenant } from './utils/utils'; | ||
|
||
export const successHandlers = [ | ||
rest.get(API_PATH.CONFIG, (req, res, ctx) => { | ||
return res(ctx.status(200), ctx.json(configResponse.config)); | ||
}), | ||
rest.get( | ||
fullPathWithProxyTenant(API_PATH.SERVER_PLUGINS), | ||
(req, res, ctx) => { | ||
return res(ctx.status(200), ctx.json(configResponse.plugins)); | ||
} | ||
http.get(API_PATH.CONFIG, () => HttpResponse.json(configResponse.config)), | ||
http.get(fullPathWithProxyTenant(API_PATH.SERVER_PLUGINS), () => | ||
HttpResponse.json(configResponse.plugins) | ||
), | ||
]; | ||
|
||
export const unknownErrorHandlers = [ | ||
rest.get(API_PATH.CONFIG, (req, res, ctx) => { | ||
return res(ctx.status(500), ctx.json({})); | ||
}), | ||
http.get(API_PATH.CONFIG, () => HttpResponse.json({}, { status: 500 })), | ||
]; |
88 changes: 37 additions & 51 deletions
88
services/tenant-ui/frontend/test/__mocks__/api/routes/connection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,69 @@ | ||
import { rest } from 'msw'; | ||
import { HttpResponse, http } from 'msw'; | ||
|
||
import { API_PATH } from '@/helpers/constants'; | ||
import { connectionResponse } from '../responses'; | ||
import { fullPathWithProxyTenant } from './utils/utils'; | ||
|
||
export const successHandlers = [ | ||
rest.get(fullPathWithProxyTenant(API_PATH.CONNECTIONS), (req, res, ctx) => | ||
res(ctx.status(200), ctx.json(connectionResponse.listConnections)) | ||
http.get(fullPathWithProxyTenant(API_PATH.CONNECTIONS), () => | ||
HttpResponse.json(connectionResponse.listConnections) | ||
), | ||
rest.get( | ||
fullPathWithProxyTenant(API_PATH.CONNECTIONS) + '/:id', | ||
(req, res, ctx) => | ||
res(ctx.status(200), ctx.json(connectionResponse.getConnection)) | ||
http.get(fullPathWithProxyTenant(API_PATH.CONNECTIONS) + '/:id', () => | ||
HttpResponse.json(connectionResponse.getConnection) | ||
), | ||
rest.get( | ||
http.get( | ||
fullPathWithProxyTenant(API_PATH.CONNECTIONS_INVITATION('test-uuid')), | ||
(req, res, ctx) => | ||
res(ctx.status(200), ctx.json(connectionResponse.getConnectionInvitation)) | ||
() => HttpResponse.json(connectionResponse.getConnectionInvitation) | ||
), | ||
rest.post( | ||
http.post( | ||
fullPathWithProxyTenant(API_PATH.CONNECTIONS_CREATE_INVITATION), | ||
(req, res, ctx) => | ||
res(ctx.status(200), ctx.json(connectionResponse.createConnection)) | ||
() => HttpResponse.json(connectionResponse.createConnection) | ||
), | ||
rest.post( | ||
http.post( | ||
fullPathWithProxyTenant(API_PATH.CONNECTIONS_RECEIVE_INVITATION), | ||
(req, res, ctx) => | ||
res(ctx.status(200), ctx.json(connectionResponse.receiveInvitation)) | ||
() => HttpResponse.json(connectionResponse.receiveInvitation) | ||
), | ||
rest.post( | ||
fullPathWithProxyTenant(API_PATH.DID_EXCHANGE_CREATE_REQUEST), | ||
(req, res, ctx) => | ||
res(ctx.status(200), ctx.json(connectionResponse.didExchange)) | ||
http.post(fullPathWithProxyTenant(API_PATH.DID_EXCHANGE_CREATE_REQUEST), () => | ||
HttpResponse.json(connectionResponse.didExchange) | ||
), | ||
rest.put( | ||
fullPathWithProxyTenant(API_PATH.CONNECTION('test-uuid')), | ||
(req, res, ctx) => | ||
res(ctx.status(200), ctx.json(connectionResponse.getConnection)) | ||
http.put(fullPathWithProxyTenant(API_PATH.CONNECTION('test-uuid')), () => | ||
HttpResponse.json(connectionResponse.getConnection) | ||
), | ||
rest.delete( | ||
fullPathWithProxyTenant(API_PATH.CONNECTION('test-uuid')), | ||
(req, res, ctx) => res(ctx.status(200), ctx.json({})) | ||
http.delete(fullPathWithProxyTenant(API_PATH.CONNECTION('test-uuid')), () => | ||
HttpResponse.json({}) | ||
), | ||
]; | ||
|
||
export const unknownErrorHandlers = [ | ||
rest.get(fullPathWithProxyTenant(API_PATH.CONNECTIONS), (req, res, ctx) => { | ||
return res(ctx.status(500), ctx.json({})); | ||
}), | ||
rest.get( | ||
fullPathWithProxyTenant(API_PATH.CONNECTIONS) + '/:id', | ||
(req, res, ctx) => res(ctx.status(500), ctx.json({})) | ||
), | ||
rest.get( | ||
http.get(fullPathWithProxyTenant(API_PATH.CONNECTIONS), () => | ||
HttpResponse.json({}, { status: 500 }) | ||
), | ||
http.get(fullPathWithProxyTenant(API_PATH.CONNECTIONS) + '/:id', () => | ||
HttpResponse.json({}, { status: 500 }) | ||
), | ||
http.get( | ||
fullPathWithProxyTenant(API_PATH.CONNECTIONS_INVITATION('test-uuid')), | ||
(req, res, ctx) => res(ctx.status(500), ctx.json({})) | ||
() => HttpResponse.json({}, { status: 500 }) | ||
), | ||
rest.post( | ||
http.post( | ||
fullPathWithProxyTenant(API_PATH.CONNECTIONS_CREATE_INVITATION), | ||
(req, res, ctx) => { | ||
return res(ctx.status(500), ctx.json({})); | ||
() => { | ||
return HttpResponse.json({}, { status: 500 }); | ||
} | ||
), | ||
rest.post( | ||
http.post( | ||
fullPathWithProxyTenant(API_PATH.CONNECTIONS_RECEIVE_INVITATION), | ||
(req, res, ctx) => { | ||
return res(ctx.status(500), ctx.json({})); | ||
() => { | ||
return HttpResponse.json({}, { status: 500 }); | ||
} | ||
), | ||
rest.post( | ||
fullPathWithProxyTenant(API_PATH.DID_EXCHANGE_CREATE_REQUEST), | ||
(req, res, ctx) => res(ctx.status(500), ctx.json({})) | ||
http.post(fullPathWithProxyTenant(API_PATH.DID_EXCHANGE_CREATE_REQUEST), () => | ||
HttpResponse.json({}, { status: 500 }) | ||
), | ||
rest.put( | ||
fullPathWithProxyTenant(API_PATH.CONNECTION('test-uuid')), | ||
(req, res, ctx) => res(ctx.status(500), ctx.json({})) | ||
http.put(fullPathWithProxyTenant(API_PATH.CONNECTION('test-uuid')), () => | ||
HttpResponse.json({}, { status: 500 }) | ||
), | ||
rest.delete( | ||
fullPathWithProxyTenant(API_PATH.CONNECTION('test-uuid')), | ||
(req, res, ctx) => res(ctx.status(500), ctx.json({})) | ||
http.delete(fullPathWithProxyTenant(API_PATH.CONNECTION('test-uuid')), () => | ||
HttpResponse.json({}, { status: 500 }) | ||
), | ||
]; |
Oops, something went wrong.