vault/ui/tests/helpers/api/error-response.ts
Jordan Reimer 712d3338b7
[UI] Ember Data Migration - Sync Overview/Destinations (#30524)
* improves path handling in capabilities service

* converts has-capability to class helper and adds pathKey and params args

* adds api service to sync engine

* updates sync types

* improves typings in paginate-list util

* adds api client error handling to error page component

* adds api utils for sync

* updates sync overview route and page component to use api service

* updates sync destinations route and page component to use api service

* adds missing copyright header

* fixes paginate-list regression

* fixes return type for has-capability helper

* Apply suggestions from code review

Co-authored-by: Angel Garbarino <Monkeychip@users.noreply.github.com>

* fixes page error tests

* resolves suggestions from review

* fixes has-capability usage errors

* fixes comment in capabilities service

* more test fixes

---------

Co-authored-by: Angel Garbarino <Monkeychip@users.noreply.github.com>
2025-05-07 10:53:56 -06:00

20 lines
574 B
TypeScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { ResponseError } from '@hashicorp/vault-client-typescript';
export const getErrorResponse = <T>(error?: T, status?: number) => {
const e = error || {
errors: ['first error', 'second error'],
message: 'there were some errors',
};
// url is readonly on Response so mock it and cast to Response type
return new ResponseError({
status: status || 404,
url: `${document.location.origin}/v1/test/error/parsing`,
json: () => Promise.resolve(e),
} as Response);
};