mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
fix(ui): follow redirects when fetching alerts from the UI
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import merge from "lodash.merge";
|
||||
|
||||
const FetchWithCredentials = async (uri, options) =>
|
||||
await fetch(uri, merge({}, { credentials: "include" }, options));
|
||||
await fetch(
|
||||
uri,
|
||||
merge({}, { credentials: "include", redirect: "follow" }, options)
|
||||
);
|
||||
|
||||
export { FetchWithCredentials };
|
||||
|
||||
@@ -13,7 +13,8 @@ describe("FetchWithCredentials", () => {
|
||||
const request = FetchWithCredentials("http://example.com", {});
|
||||
await expect(request).resolves.toBeUndefined();
|
||||
expect(fetch).toHaveBeenCalledWith("http://example.com", {
|
||||
credentials: "include"
|
||||
credentials: "include",
|
||||
redirect: "follow"
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,17 +25,20 @@ describe("FetchWithCredentials", () => {
|
||||
await expect(request).resolves.toBeUndefined();
|
||||
expect(fetch).toHaveBeenCalledWith("http://example.com", {
|
||||
credentials: "include",
|
||||
redirect: "follow",
|
||||
foo: "bar"
|
||||
});
|
||||
});
|
||||
|
||||
it("custom credentials are used when passed", async () => {
|
||||
const request = FetchWithCredentials("http://example.com", {
|
||||
credentials: "none"
|
||||
credentials: "none",
|
||||
redirect: "follow"
|
||||
});
|
||||
await expect(request).resolves.toBeUndefined();
|
||||
expect(fetch).toHaveBeenCalledWith("http://example.com", {
|
||||
credentials: "none"
|
||||
credentials: "none",
|
||||
redirect: "follow"
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -89,7 +89,7 @@ describe("<SilencePreview />", () => {
|
||||
fetch
|
||||
).toHaveBeenCalledWith(
|
||||
"./alerts.json?q=foo%3Dbar&q=%40alertmanager%3D~%5E%28amValue%29%24",
|
||||
{ credentials: "include" }
|
||||
{ credentials: "include", redirect: "follow" }
|
||||
);
|
||||
});
|
||||
|
||||
@@ -105,7 +105,7 @@ describe("<SilencePreview />", () => {
|
||||
fetch
|
||||
).toHaveBeenCalledWith(
|
||||
"./alerts.json?q=foo%3Dbar&q=%40alertmanager%3D~%5E%28am1%7Cam2%29%24",
|
||||
{ credentials: "include" }
|
||||
{ credentials: "include", redirect: "follow" }
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user