Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Move from browser-request to fetch #9345

Merged
merged 44 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
60585c2
Update to new js-sdk upload signatures
t3chguy Oct 4, 2022
dbedcfb
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Oct 4, 2022
bb3c760
Merge branch 'develop' into t3chguy/fetch
t3chguy Oct 4, 2022
1647901
Iterate
t3chguy Oct 4, 2022
94e204a
Merge remote-tracking branch 'origin/t3chguy/fetch' into t3chguy/fetch
t3chguy Oct 4, 2022
9f0d1e9
Remove browser-request some more
t3chguy Oct 5, 2022
73bc3ec
Stash
t3chguy Oct 5, 2022
04a3127
Merge branch 'develop' into t3chguy/fetch
t3chguy Oct 5, 2022
2d5a19c
Merge branch 'develop' into t3chguy/fetch
t3chguy Oct 6, 2022
f0a7478
Fix login method
t3chguy Oct 6, 2022
debee74
Merge remote-tracking branch 'origin/t3chguy/fetch' into t3chguy/fetch
t3chguy Oct 6, 2022
12f4e20
Merge branch 'develop' into t3chguy/fetch
t3chguy Oct 6, 2022
2045511
Iterate everything
t3chguy Oct 6, 2022
127c3d6
Merge remote-tracking branch 'origin/t3chguy/fetch' into t3chguy/fetch
t3chguy Oct 6, 2022
9f62c84
Merge branch 'develop' into t3chguy/fetch
t3chguy Oct 7, 2022
fabd45e
Update InviteDialog tests
t3chguy Oct 7, 2022
c271631
Update createRoom tests
t3chguy Oct 7, 2022
ea8018b
Add tests for ContentMessages uploadFile
t3chguy Oct 7, 2022
2cf5f0a
Merge remote-tracking branch 'origin/t3chguy/fetch' into t3chguy/fetch
t3chguy Oct 7, 2022
58ee10c
Iterate uploadContent signature
t3chguy Oct 7, 2022
88406e4
Fix tests
t3chguy Oct 7, 2022
e242be7
Fix uploadContent type
t3chguy Oct 7, 2022
5d94720
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Oct 10, 2022
0bbcb69
More tests
t3chguy Oct 10, 2022
592eb79
Increase test coverage
t3chguy Oct 10, 2022
5ac6e5f
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Oct 10, 2022
6243625
Fix test
t3chguy Oct 10, 2022
38aa3e5
Improve coverage
t3chguy Oct 10, 2022
e914817
Improve coverage s'more
t3chguy Oct 10, 2022
4ebf587
Fix test parallelism
t3chguy Oct 10, 2022
66e8008
Add tests
t3chguy Oct 10, 2022
0d706f9
Add tests
t3chguy Oct 11, 2022
f54ad04
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Oct 11, 2022
231f8ea
Increase spotlight wait
t3chguy Oct 11, 2022
5d7d0b2
Add tests
t3chguy Oct 11, 2022
1319e03
Increase timeouts
t3chguy Oct 11, 2022
a86553d
Merge branch 'develop' into t3chguy/fetch
t3chguy Oct 11, 2022
c82088a
Merge branch 'develop' into t3chguy/fetch
t3chguy Oct 12, 2022
50a34ed
Fix types
t3chguy Oct 12, 2022
5c4f48f
Merge branch 'develop' into t3chguy/fetch
t3chguy Oct 12, 2022
9ff7671
Remove unused field
t3chguy Oct 12, 2022
fc5beb5
Merge remote-tracking branch 'origin/t3chguy/fetch' into t3chguy/fetch
t3chguy Oct 12, 2022
c45729b
Whoops, turns out the field was used
t3chguy Oct 12, 2022
c87196c
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Oct 12, 2022
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
81 changes: 0 additions & 81 deletions __mocks__/browser-request.js

This file was deleted.

23 changes: 12 additions & 11 deletions cypress/e2e/spotlight/spotlight.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ Cypress.Commands.add("startDM", (name: string) => {
cy.get(".mx_BasicMessageComposer_input")
.should("have.focus")
.type("Hey!{enter}");
cy.contains(".mx_EventTile_body", "Hey!");
// The DM room is created at this point, this can take a little bit of time
cy.contains(".mx_EventTile_body", "Hey!", { timeout: 30000 });
cy.contains(".mx_RoomSublist[aria-label=People]", name);
});

Expand Down Expand Up @@ -217,7 +218,7 @@ describe("Spotlight", () => {
it("should find joined rooms", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightSearch().clear().type(room1Name);
cy.wait(1000); // wait for the dialog code to settle
cy.wait(3000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", room1Name);
cy.spotlightResults().eq(0).click();
Expand All @@ -231,7 +232,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.PublicRooms);
cy.spotlightSearch().clear().type(room1Name);
cy.wait(1000); // wait for the dialog code to settle
cy.wait(3000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", room1Name);
cy.spotlightResults().eq(0).should("contain", "View");
Expand All @@ -246,7 +247,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.PublicRooms);
cy.spotlightSearch().clear().type(room2Name);
cy.wait(1000); // wait for the dialog code to settle
cy.wait(3000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", room2Name);
cy.spotlightResults().eq(0).should("contain", "Join");
Expand All @@ -262,7 +263,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.PublicRooms);
cy.spotlightSearch().clear().type(room3Name);
cy.wait(1000); // wait for the dialog code to settle
cy.wait(3000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", room3Name);
cy.spotlightResults().eq(0).should("contain", "View");
Expand Down Expand Up @@ -301,7 +302,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot1Name);
cy.wait(1000); // wait for the dialog code to settle
cy.wait(3000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", bot1Name);
cy.spotlightResults().eq(0).click();
Expand All @@ -314,7 +315,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot2Name);
cy.wait(1000); // wait for the dialog code to settle
cy.wait(3000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", bot2Name);
cy.spotlightResults().eq(0).click();
Expand All @@ -331,7 +332,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot2Name);
cy.wait(1000); // wait for the dialog code to settle
cy.wait(3000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", bot2Name);
cy.spotlightResults().eq(0).click();
Expand All @@ -345,7 +346,7 @@ describe("Spotlight", () => {
.type("Hey!{enter}");

// Assert DM exists by checking for the first message and the room being in the room list
cy.contains(".mx_EventTile_body", "Hey!");
cy.contains(".mx_EventTile_body", "Hey!", { timeout: 30000 });
cy.get(".mx_RoomSublist[aria-label=People]").should("contain", bot2Name);

// Invite BotBob into existing DM with ByteBot
Expand Down Expand Up @@ -409,7 +410,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot2Name);
cy.wait(1000); // wait for the dialog code to settle
cy.wait(3000); // wait for the dialog code to settle
cy.spotlightResults().should("have.length", 1);
cy.spotlightResults().eq(0).should("contain", bot2Name);
cy.get(".mx_SpotlightDialog_startGroupChat").should("contain", "Start a group chat");
Expand All @@ -431,7 +432,7 @@ describe("Spotlight", () => {
cy.openSpotlightDialog().within(() => {
cy.spotlightFilter(Filter.People);
cy.spotlightSearch().clear().type(bot1Name);
cy.wait(1000); // wait for the dialog code to settle
cy.wait(3000); // wait for the dialog code to settle
cy.get(".mx_Spinner").should("not.exist");
cy.spotlightResults().should("have.length", 1);
});
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/timeline/timeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ describe("Timeline", () => {

describe("useOnlyCurrentProfiles", () => {
beforeEach(() => {
cy.uploadContent(OLD_AVATAR).then((url) => {
cy.uploadContent(OLD_AVATAR).then(({ content_uri: url }) => {
oldAvatarUrl = url;
cy.setAvatarUrl(url);
});
cy.uploadContent(NEW_AVATAR).then((url) => {
cy.uploadContent(NEW_AVATAR).then(({ content_uri: url }) => {
newAvatarUrl = url;
});
});
Expand Down Expand Up @@ -271,7 +271,7 @@ describe("Timeline", () => {
cy.get(".mx_RoomHeader_searchButton").click();
cy.get(".mx_SearchBar_input input").type("Message{enter}");

cy.get(".mx_EventTile:not(.mx_EventTile_contextual)").find(".mx_EventTile_searchHighlight").should("exist");
cy.get(".mx_EventTile:not(.mx_EventTile_contextual) .mx_EventTile_searchHighlight").should("exist");
cy.get(".mx_RoomView_searchResultsPanel").percySnapshotElement("Highlighted search results");
});

Expand Down
3 changes: 0 additions & 3 deletions cypress/support/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ limitations under the License.

/// <reference types="cypress" />

import request from "browser-request";

import type { ISendEventResponse, MatrixClient, Room } from "matrix-js-sdk/src/matrix";
import { SynapseInstance } from "../plugins/synapsedocker";
import Chainable = Cypress.Chainable;
Expand Down Expand Up @@ -86,7 +84,6 @@ Cypress.Commands.add("getBot", (synapse: SynapseInstance, opts: CreateBotOpts):
userId: credentials.userId,
deviceId: credentials.deviceId,
accessToken: credentials.accessToken,
request,
store: new win.matrixcs.MemoryStore(),
scheduler: new win.matrixcs.MatrixScheduler(),
cryptoStore: new win.matrixcs.MemoryCryptoStore(),
Expand Down
15 changes: 7 additions & 8 deletions cypress/support/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ limitations under the License.

/// <reference types="cypress" />

import type { FileType, UploadContentResponseType } from "matrix-js-sdk/src/http-api";
import type { IAbortablePromise } from "matrix-js-sdk/src/@types/partials";
import type { ICreateRoomOpts, ISendEventResponse, IUploadOpts } from "matrix-js-sdk/src/@types/requests";
import type { FileType, Upload, UploadOpts } from "matrix-js-sdk/src/http-api";
import type { ICreateRoomOpts, ISendEventResponse } from "matrix-js-sdk/src/@types/requests";
import type { MatrixClient } from "matrix-js-sdk/src/client";
import type { Room } from "matrix-js-sdk/src/models/room";
import type { IContent } from "matrix-js-sdk/src/models/event";
Expand Down Expand Up @@ -90,10 +89,10 @@ declare global {
* can be sent to XMLHttpRequest.send (typically a File). Under node.js,
* a a Buffer, String or ReadStream.
*/
uploadContent<O extends IUploadOpts>(
uploadContent(
file: FileType,
opts?: O,
): IAbortablePromise<UploadContentResponseType<O>>;
opts?: UploadOpts,
): Chainable<Awaited<Upload["promise"]>>;
/**
* Turn an MXC URL into an HTTP one. <strong>This method is experimental and
* may change.</strong>
Expand Down Expand Up @@ -203,9 +202,9 @@ Cypress.Commands.add("setDisplayName", (name: string): Chainable<{}> => {
});
});

Cypress.Commands.add("uploadContent", (file: FileType): Chainable<{}> => {
Cypress.Commands.add("uploadContent", (file: FileType, opts?: UploadOpts): Chainable<Awaited<Upload["promise"]>> => {
return cy.getClient().then(async (cli: MatrixClient) => {
return cli.uploadContent(file);
return cli.uploadContent(file, opts);
});
});

Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"@types/ua-parser-js": "^0.7.36",
"await-lock": "^2.1.0",
"blurhash": "^1.1.3",
"browser-request": "^0.3.3",
"cheerio": "^1.0.0-rc.9",
"classnames": "^2.2.6",
"commonmark": "^0.29.3",
Expand Down Expand Up @@ -190,16 +189,16 @@
"eslint-plugin-matrix-org": "^0.6.1",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"fetch-mock-jest": "^1.5.1",
"fs-extra": "^10.0.1",
"glob": "^7.1.6",
"jest": "^27.4.0",
"jest-canvas-mock": "^2.3.0",
"jest-environment-jsdom": "^27.0.6",
"jest-fetch-mock": "^3.0.3",
"jest-mock": "^27.5.1",
"jest-raw-loader": "^1.0.1",
"jest-sonar-reporter": "^2.0.0",
"matrix-mock-request": "^2.0.0",
"matrix-mock-request": "^2.5.0",
"matrix-react-test-utils": "^0.2.3",
"matrix-web-i18n": "^1.3.0",
"postcss-scss": "^4.0.4",
Expand Down
4 changes: 2 additions & 2 deletions src/AddThreepid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default class AddThreepid {
const identityAccessToken = await authClient.getAccessToken();
return MatrixClientPeg.get().requestEmailToken(
emailAddress, this.clientSecret, 1,
undefined, undefined, identityAccessToken,
undefined, identityAccessToken,
).then((res) => {
this.sessionId = res.sid;
return res;
Expand Down Expand Up @@ -142,7 +142,7 @@ export default class AddThreepid {
const identityAccessToken = await authClient.getAccessToken();
return MatrixClientPeg.get().requestMsisdnToken(
phoneCountry, phoneNumber, this.clientSecret, 1,
undefined, undefined, identityAccessToken,
undefined, identityAccessToken,
).then((res) => {
this.sessionId = res.sid;
return res;
Expand Down
Loading