Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests not to mock out an ancient server #26796

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading