You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-30 04:23:07 +03:00
Test 400, 429 and 502 responses
This commit is contained in:
@ -417,6 +417,22 @@ describe("MatrixClient", function () {
|
||||
]);
|
||||
});
|
||||
|
||||
it("should fallback to unstable endpoint when stable endpoint 400s", async () => {
|
||||
await assertRequestsMade([
|
||||
{
|
||||
prefix: ClientPrefix.V1,
|
||||
error: {
|
||||
httpStatus: 400,
|
||||
errcode: "M_UNRECOGNIZED",
|
||||
},
|
||||
},
|
||||
{
|
||||
prefix: unstableMSC3030Prefix,
|
||||
data: { event_id: eventId },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("should fallback to unstable endpoint when stable endpoint 404s", async () => {
|
||||
await assertRequestsMade([
|
||||
{
|
||||
@ -449,7 +465,7 @@ describe("MatrixClient", function () {
|
||||
]);
|
||||
});
|
||||
|
||||
it("should not fallback to unstable endpoint when stable endpoint returns an error", async () => {
|
||||
it("should not fallback to unstable endpoint when stable endpoint returns an error (500)", async () => {
|
||||
await assertRequestsMade(
|
||||
[
|
||||
{
|
||||
@ -463,6 +479,36 @@ describe("MatrixClient", function () {
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("should not fallback to unstable endpoint when stable endpoint is rate-limiting (429)", async () => {
|
||||
await assertRequestsMade(
|
||||
[
|
||||
{
|
||||
prefix: ClientPrefix.V1,
|
||||
error: {
|
||||
httpStatus: 429,
|
||||
errcode: "M_UNRECOGNIZED", // Still refuses even if the errcode claims unrecognised
|
||||
},
|
||||
},
|
||||
],
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("should not fallback to unstable endpoint when stable endpoint says bad gateway (502)", async () => {
|
||||
await assertRequestsMade(
|
||||
[
|
||||
{
|
||||
prefix: ClientPrefix.V1,
|
||||
error: {
|
||||
httpStatus: 502,
|
||||
errcode: "Fake response error",
|
||||
},
|
||||
},
|
||||
],
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getSafeUserId()", () => {
|
||||
|
Reference in New Issue
Block a user