fleet/frontend/pages/SoftwarePage/SoftwareAddPage/SoftwareCustomPackage/helpers.tests.tsx
Jonathan Katz 941c49b84e
Filter errors that start with Couldn't add (#42764)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #42572

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

## Testing

- [x] Added/updated automated tests
- [ ] Where appropriate, [automated tests simulate multiple hosts and
test for host
isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing)
(updates to one hosts's records do not affect another)

- [x] QA'd all new/changed functionality manually
2026-03-31 16:33:55 -04:00

53 lines
1.3 KiB
TypeScript

import { getErrorMessage } from "./helpers";
jest.mock("axios", () => {
const actual = jest.requireActual("axios");
return {
...actual,
isAxiosError: () => true,
};
});
describe("getErrorMessage", () => {
it("returns message for pending install/uninstall error", () => {
const err = {
response: {
status: 400,
data: {
errors: [
{
name: "Error",
reason:
"Couldn't install. Host already has a pending install/uninstall for this installer.",
},
],
},
},
};
expect(getErrorMessage(err)).toBe(
"Couldn't add. Couldn't install. Host already has a pending install/uninstall for this installer."
);
});
it("returns message for script validation error", () => {
const err = {
response: {
status: 400,
data: {
errors: [
{
name: "Error",
reason:
"Couldn't add. Script validation failed: Script is too large. It's limited to 500,000 characters (approximately 10,000 lines).",
},
],
},
},
};
expect(getErrorMessage(err)).toBe(
"Couldn't add. Script validation failed: Script is too large. It's limited to 500,000 characters (approximately 10,000 lines)."
);
});
});