mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
* #1108 send users to manage queries if error * #1108 fixed tests and lint * #1108 fixed more tests * #1108 new clause to show different error message * #1108 fixed logic
This commit is contained in:
parent
4800856bf7
commit
42272f358f
2 changed files with 25 additions and 8 deletions
|
|
@ -7,9 +7,14 @@ import { renderFlash } from "redux/nodes/notifications/actions";
|
||||||
|
|
||||||
export const fetchQuery = (dispatch, queryID) => {
|
export const fetchQuery = (dispatch, queryID) => {
|
||||||
return dispatch(queryActions.load(queryID)).catch((errors) => {
|
return dispatch(queryActions.load(queryID)).catch((errors) => {
|
||||||
const errorMessage = join(values(omit(errors, "http_status")), ", ");
|
const { MANAGE_QUERIES } = PATHS;
|
||||||
|
let errorMessage = join(values(omit(errors, "http_status")), ", ");
|
||||||
|
|
||||||
dispatch(push(PATHS.NEW_QUERY));
|
if (errorMessage.includes("no rows in result set")) {
|
||||||
|
errorMessage = "The query you requested does not exist in Fleet.";
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatch(push(MANAGE_QUERIES));
|
||||||
dispatch(renderFlash("error", errorMessage));
|
dispatch(renderFlash("error", errorMessage));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ describe("QueryPageWrapper - helpers", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when the API call is unsuccessful", () => {
|
describe("when the API call is unsuccessful", () => {
|
||||||
it("pushes to the new query page", (done) => {
|
it("pushes to the manage queries page", (done) => {
|
||||||
queryMocks.load.invalid(bearerToken, queryID);
|
queryMocks.load.invalid(bearerToken, queryID);
|
||||||
const mockStore = reduxMockStore();
|
const mockStore = reduxMockStore();
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ describe("QueryPageWrapper - helpers", () => {
|
||||||
expect(locationChangeAction).toBeTruthy();
|
expect(locationChangeAction).toBeTruthy();
|
||||||
expect(locationChangeAction.payload).toEqual({
|
expect(locationChangeAction.payload).toEqual({
|
||||||
method: "push",
|
method: "push",
|
||||||
args: ["/queries/new"],
|
args: ["/queries/manage"],
|
||||||
});
|
});
|
||||||
|
|
||||||
done();
|
done();
|
||||||
|
|
@ -70,10 +70,22 @@ describe("QueryPageWrapper - helpers", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(flashMessageAction).toBeTruthy();
|
expect(flashMessageAction).toBeTruthy();
|
||||||
expect(flashMessageAction.payload).toMatchObject({
|
|
||||||
alertType: "error",
|
if (
|
||||||
message: "Resource not found",
|
flashMessageAction.payload.message.includes(
|
||||||
});
|
"no rows in result set"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
expect(flashMessageAction.payload).toMatchObject({
|
||||||
|
alertType: "error",
|
||||||
|
message: "The query you requested does not exist in Fleet.",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
expect(flashMessageAction.payload).toMatchObject({
|
||||||
|
alertType: "error",
|
||||||
|
message: "Resource not found",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue