Skip to content

Commit 01f6da6

Browse files
SimonBrandnert3chguyKerryrenovate[bot]Germain
authored
Merge latest develop into group calls branch (#2690)
* Update sonarcloud.yml (#2671) * Update sonarcloud.yml * test typescriptification - spec/unit/crypto/verification (#2673) * renamed: spec/unit/crypto/verification/request.spec.js -> spec/unit/crypto/verification/request.spec.ts * renamed: spec/unit/crypto/verification/qr_code.spec.js -> spec/unit/crypto/verification/qr_code.spec.ts * renamed: spec/unit/crypto/verification/InRoomChannel.spec.js -> spec/unit/crypto/verification/InRoomChannel.spec.ts * fix ts issues in InRoomChannel.spec * renamed: spec/unit/crypto/verification/util.js -> spec/unit/crypto/verification/util.ts * fix ts issues in util.t * fix strict errors in util.ts * js lint * test typescriptification - last few unit test files (#2675) * renamed: spec/unit/crypto/verification/sas.spec.js -> spec/unit/crypto/verification/sas.spec.ts * ts issues in sas.spec * renamed: spec/unit/crypto/verification/secret_request.spec.js -> spec/unit/crypto/verification/secret_request.spec.ts * ts issues in secret_request.spec * renamed: spec/unit/crypto/verification/verification_request.spec.js -> spec/unit/crypto/verification/verification_request.spec.ts * ts fix verification_req.spec * renamed: spec/browserify/sync-browserify.spec.js -> spec/browserify/sync-browserify.spec.ts * fix strict * formatting * Update babel monorepo to v7.19.1 (#2681) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update typescript-eslint monorepo to v5.38.0 (#2685) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Read receipts for threads (#2635) * Update all (#2684) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update jest monorepo to v29.0.3 (#2682) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Fix backpagination at end logic being spec non-conforming (#2680) * Support to remotely toggle push notifications (#2686) * Add unstable device_id field for MSC3881 (#2688) Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Kerry <kerrya@element.io> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Germain <germains@element.io>
1 parent 2a0ffe1 commit 01f6da6

29 files changed

+1521
-991
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@ jobs:
1010
runs-on: ubuntu-latest
1111
if: github.event.workflow_run.conclusion == 'success'
1212
steps:
13+
# We create the status here and then update it to success/failure in the `report` stage
14+
# This provides an easy link to this workflow_run from the PR before Cypress is done.
15+
- uses: Sibz/github-status-action@v1
16+
with:
17+
authToken: ${{ secrets.GITHUB_TOKEN }}
18+
state: pending
19+
context: ${{ github.workflow }} / SonarCloud (${{ github.event.workflow_run.event }} => ${{ github.event_name }})
20+
sha: ${{ github.event.workflow_run.head_sha }}
21+
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
22+
1323
- name: "🩻 SonarCloud Scan"
24+
id: sonarcloud
1425
uses: matrix-org/sonarcloud-workflow-action@v2.2
1526
with:
1627
repository: ${{ github.event.workflow_run.head_repository.full_name }}
@@ -22,3 +33,13 @@ jobs:
2233
coverage_run_id: ${{ github.event.workflow_run.id }}
2334
coverage_workflow_name: tests.yml
2435
coverage_extract_path: coverage
36+
37+
38+
- uses: Sibz/github-status-action@v1
39+
if: always()
40+
with:
41+
authToken: ${{ secrets.GITHUB_TOKEN }}
42+
state: ${{ steps.sonarcloud.outcome == 'success' && 'success' || 'failure' }}
43+
context: ${{ github.workflow }} / SonarCloud (${{ github.event.workflow_run.event }} => ${{ github.event_name }})
44+
sha: ${{ github.event.workflow_run.head_sha }}
45+
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"better-docs": "^2.4.0-beta.9",
9696
"browserify": "^17.0.0",
9797
"docdash": "^1.2.0",
98-
"eslint": "8.23.0",
98+
"eslint": "8.23.1",
9999
"eslint-config-google": "^0.14.0",
100100
"eslint-plugin-import": "^2.25.4",
101101
"eslint-plugin-matrix-org": "^0.6.0",

spec/integ/matrix-client-event-timeline.spec.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,45 @@ describe("MatrixClient event timelines", function() {
833833
]);
834834
});
835835

836+
it("should stop paginating when it encounters no `end` token", () => {
837+
const room = client.getRoom(roomId);
838+
const timelineSet = room.getTimelineSets()[0];
839+
840+
httpBackend.when("GET", "/rooms/!foo%3Abar/context/" +
841+
encodeURIComponent(EVENTS[0].event_id))
842+
.respond(200, () => ({
843+
start: "start_token0",
844+
events_before: [],
845+
event: EVENTS[0],
846+
events_after: [],
847+
end: "end_token0",
848+
state: [],
849+
}));
850+
851+
httpBackend.when("GET", "/rooms/!foo%3Abar/messages")
852+
.check(function(req) {
853+
const params = req.queryParams;
854+
expect(params.dir).toEqual("b");
855+
expect(params.from).toEqual("start_token0");
856+
expect(params.limit).toEqual("30");
857+
}).respond(200, () => ({
858+
start: "start_token0",
859+
chunk: [],
860+
}));
861+
862+
return Promise.all([
863+
(async () => {
864+
const tl = await client.getEventTimeline(timelineSet, EVENTS[0].event_id);
865+
const success = await client.paginateEventTimeline(tl, { backwards: true });
866+
expect(success).toBeFalsy();
867+
expect(tl.getEvents().length).toEqual(1);
868+
expect(tl.getPaginationToken(EventTimeline.BACKWARDS)).toEqual(null);
869+
expect(tl.getPaginationToken(EventTimeline.FORWARDS)).toEqual("end_token0");
870+
})(),
871+
httpBackend.flushAllExpected(),
872+
]);
873+
});
874+
836875
it("should allow you to paginate forwards", function() {
837876
const room = client.getRoom(roomId);
838877
const timelineSet = room.getTimelineSets()[0];

spec/integ/matrix-client-methods.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,7 @@ describe("MatrixClient", function() {
889889
};
890890

891891
const prom = client.getPushers();
892+
httpBackend.when("GET", "/_matrix/client/versions").respond(200, {});
892893
httpBackend.when("GET", "/pushers").respond(200, response);
893894
await httpBackend.flush();
894895
expect(await prom).toStrictEqual(response);

spec/test-utils/test-utils.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import '../olm-loader';
66

77
import { logger } from '../../src/logger';
88
import { IContent, IEvent, IUnsigned, MatrixEvent, MatrixEventEvent } from "../../src/models/event";
9-
import { ClientEvent, EventType, MatrixClient, MsgType } from "../../src";
9+
import { ClientEvent, EventType, IPusher, MatrixClient, MsgType } from "../../src";
1010
import { SyncState } from "../../src/sync";
1111
import { eventMapperFor } from "../../src/event-mapper";
1212

@@ -371,3 +371,14 @@ export async function awaitDecryption(event: MatrixEvent): Promise<MatrixEvent>
371371
}
372372

373373
export const emitPromise = (e: EventEmitter, k: string): Promise<any> => new Promise(r => e.once(k, r));
374+
375+
export const mkPusher = (extra: Partial<IPusher> = {}): IPusher => ({
376+
app_display_name: "app",
377+
app_id: "123",
378+
data: {},
379+
device_display_name: "name",
380+
kind: "http",
381+
lang: "en",
382+
pushkey: "pushpush",
383+
...extra,
384+
});

spec/unit/crypto/secrets.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ describe("Secrets", function() {
250250

251251
osborne2.client.crypto.deviceList.storeDevicesForUser("@alice:example.com", {
252252
"VAX": {
253-
user_id: "@alice:example.com",
254-
device_id: "VAX",
253+
verified: 0,
254+
known: false,
255255
algorithms: [olmlib.OLM_ALGORITHM, olmlib.MEGOLM_ALGORITHM],
256256
keys: {
257257
"ed25519:VAX": vaxDevice.deviceEd25519Key,
@@ -261,9 +261,9 @@ describe("Secrets", function() {
261261
});
262262
vax.client.crypto.deviceList.storeDevicesForUser("@alice:example.com", {
263263
"Osborne2": {
264-
user_id: "@alice:example.com",
265-
device_id: "Osborne2",
266264
algorithms: [olmlib.OLM_ALGORITHM, olmlib.MEGOLM_ALGORITHM],
265+
verified: 0,
266+
known: false,
267267
keys: {
268268
"ed25519:Osborne2": osborne2Device.deviceEd25519Key,
269269
"curve25519:Osborne2": osborne2Device.deviceCurve25519Key,

spec/unit/crypto/verification/InRoomChannel.spec.js renamed to spec/unit/crypto/verification/InRoomChannel.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
import { MatrixClient } from "../../../../src/client";
1617
import { InRoomChannel } from "../../../../src/crypto/verification/request/InRoomChannel";
1718
import { MatrixEvent } from "../../../../src/models/event";
18-
"../../../../src/crypto/verification/request/ToDeviceChannel";
1919

2020
describe("InRoomChannel tests", function() {
2121
const ALICE = "@alice:hs.tld";
2222
const BOB = "@bob:hs.tld";
2323
const MALORY = "@malory:hs.tld";
2424
const client = {
2525
getUserId() { return ALICE; },
26-
};
26+
} as unknown as MatrixClient;
2727

2828
it("getEventType only returns .request for a message with a msgtype", function() {
2929
const invalidEvent = new MatrixEvent({
File renamed without changes.

spec/unit/crypto/verification/request.spec.js renamed to spec/unit/crypto/verification/request.spec.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717
import "../../../olm-loader";
18-
import { verificationMethods } from "../../../../src/crypto";
18+
import { CryptoEvent, verificationMethods } from "../../../../src/crypto";
1919
import { logger } from "../../../../src/logger";
2020
import { SAS } from "../../../../src/crypto/verification/SAS";
2121
import { makeTestClients, setupWebcrypto, teardownWebcrypto } from './util';
@@ -52,31 +52,30 @@ describe("verification request integration tests with crypto layer", function()
5252
alice.client.crypto.deviceList.getRawStoredDevicesForUser = function() {
5353
return {
5454
Dynabook: {
55+
algorithms: [],
56+
verified: 0,
57+
known: false,
5558
keys: {
5659
"ed25519:Dynabook": "bob+base64+ed25519+key",
5760
},
5861
},
5962
};
6063
};
61-
alice.client.downloadKeys = () => {
62-
return Promise.resolve();
63-
};
64-
bob.client.downloadKeys = () => {
65-
return Promise.resolve();
66-
};
67-
bob.client.on("crypto.verification.request", (request) => {
64+
alice.client.downloadKeys = jest.fn().mockResolvedValue({});
65+
bob.client.downloadKeys = jest.fn().mockResolvedValue({});
66+
bob.client.on(CryptoEvent.VerificationRequest, (request) => {
6867
const bobVerifier = request.beginKeyVerification(verificationMethods.SAS);
6968
bobVerifier.verify();
7069

71-
// XXX: Private function access (but it's a test, so we're okay)
70+
// @ts-ignore Private function access (but it's a test, so we're okay)
7271
bobVerifier.endTimer();
7372
});
7473
const aliceRequest = await alice.client.requestVerification("@bob:example.com");
7574
await aliceRequest.waitFor(r => r.started);
7675
const aliceVerifier = aliceRequest.verifier;
7776
expect(aliceVerifier).toBeInstanceOf(SAS);
7877

79-
// XXX: Private function access (but it's a test, so we're okay)
78+
// @ts-ignore Private function access (but it's a test, so we're okay)
8079
aliceVerifier.endTimer();
8180

8281
alice.stop();

0 commit comments

Comments
 (0)