Skip to content

Commit

Permalink
Update tests not to mock out an ancient server (#26796)
Browse files Browse the repository at this point in the history
The loading test, which mocks a `/versions` response, currently mocks the
response of a 2-year-old server. This will soon be incompatible with the
JS-SDK. Update the test in preparation.
  • Loading branch information
richvdh authored Jan 2, 2024
1 parent 2555ffc commit 258fc40
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
9 changes: 6 additions & 3 deletions test/app-tests/loading-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ import { cleanLocalstorage, deleteIndexedDB, waitForLoadingSpinner, waitForWelco
const DEFAULT_HS_URL = "http://my_server";
const DEFAULT_IS_URL = "http://my_is";

/** The matrix versions our mock server claims to support */
const SERVER_SUPPORTED_MATRIX_VERSIONS = ["v1.1", "v1.5", "v1.6", "v1.8", "v1.9"];

describe("loading:", function () {
let httpBackend: MockHttpBackend;

Expand Down Expand Up @@ -155,7 +158,7 @@ describe("loading:", function () {
async function expectAndAwaitSync(opts?: { isGuest?: boolean }): Promise<any> {
let syncRequest: (typeof MockHttpBackend.prototype.requests)[number] | null = null;
httpBackend.when("GET", "/_matrix/client/versions").respond(200, {
versions: ["v1.1"],
versions: SERVER_SUPPORTED_MATRIX_VERSIONS,
unstable_features: {},
});
const isGuest = opts?.isGuest;
Expand Down Expand Up @@ -215,7 +218,7 @@ describe("loading:", function () {
});

// Pass the liveliness checks
httpBackend.when("GET", "/versions").respond(200, { versions: ["v1.1"] });
httpBackend.when("GET", "/versions").respond(200, { versions: SERVER_SUPPORTED_MATRIX_VERSIONS });
httpBackend.when("GET", "/_matrix/identity/v2").respond(200, {});

return sleep(1)
Expand Down Expand Up @@ -265,7 +268,7 @@ describe("loading:", function () {
});

// Pass the liveliness checks
httpBackend.when("GET", "/versions").respond(200, { versions: ["v1.1"] });
httpBackend.when("GET", "/versions").respond(200, { versions: SERVER_SUPPORTED_MATRIX_VERSIONS });
httpBackend.when("GET", "/_matrix/identity/v2").respond(200, {});

return awaitLoginComponent(matrixChat)
Expand Down
5 changes: 4 additions & 1 deletion test/app-tests/server-config-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import fetchMock from "fetch-mock-jest";
import { loadApp } from "../../src/vector/app";
import WebPlatform from "../../src/vector/platform/WebPlatform";

/** The matrix versions our mock server claims to support */
const SERVER_SUPPORTED_MATRIX_VERSIONS = ["v1.1", "v1.5", "v1.6", "v1.8", "v1.9"];

fetchMock.config.overwriteRoutes = true;

describe("Loading server config", function () {
Expand All @@ -29,7 +32,7 @@ describe("Loading server config", function () {
PlatformPeg.set(new WebPlatform());
fetchMock.get("https://matrix-client.matrix.org/_matrix/client/versions", {
unstable_features: {},
versions: ["v1.1"],
versions: SERVER_SUPPORTED_MATRIX_VERSIONS,
});
fetchMock.get("https://matrix.org/.well-known/matrix/client", {
"m.homeserver": {
Expand Down
5 changes: 4 additions & 1 deletion test/app-tests/wrapper-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import WebPlatform from "../../src/vector/platform/WebPlatform";
import { loadApp } from "../../src/vector/app";
import { waitForLoadingSpinner, waitForWelcomeComponent } from "../test-utils";

/** The matrix versions our mock server claims to support */
const SERVER_SUPPORTED_MATRIX_VERSIONS = ["v1.1", "v1.5", "v1.6", "v1.8", "v1.9"];

fetchMock.config.overwriteRoutes = true;

describe("Wrapper", () => {
Expand All @@ -36,7 +39,7 @@ describe("Wrapper", () => {
PlatformPeg.set(new WebPlatform());
fetchMock.get("https://matrix-client.matrix.org/_matrix/client/versions", {
unstable_features: {},
versions: ["v1.1"],
versions: SERVER_SUPPORTED_MATRIX_VERSIONS,
});
fetchMock.get("https://matrix.org/.well-known/matrix/client", {
"m.homeserver": {
Expand Down

0 comments on commit 258fc40

Please sign in to comment.