Skip to content

Commit 143b6c6

Browse files
committed
Avoid deprecated classes in verification integ test
#3449 deprecated a bunch of exports from `src/crypto/verification/request/VerificationRequest`. Let's stop using them in the integration test.
1 parent 0545f6d commit 143b6c6

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

spec/integ/crypto/verification.spec.ts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ import fetchMock from "fetch-mock-jest";
1818
import { MockResponse } from "fetch-mock";
1919

2020
import { createClient, CryptoEvent, MatrixClient } from "../../../src";
21-
import { ShowQrCodeCallbacks, ShowSasCallbacks, Verifier, VerifierEvent } from "../../../src/crypto-api/verification";
21+
import {
22+
ShowQrCodeCallbacks,
23+
ShowSasCallbacks,
24+
Verifier,
25+
VerifierEvent,
26+
VerificationPhase,
27+
VerificationRequest,
28+
VerificationRequestEvent,
29+
canAcceptVerificationRequest,
30+
} from "../../../src/crypto-api/verification";
2231
import { escapeRegExp } from "../../../src/utils";
2332
import { CRYPTO_BACKENDS, emitPromise, InitCrypto } from "../../test-utils/test-utils";
2433
import { SyncResponder } from "../../test-utils/SyncResponder";
@@ -31,11 +40,6 @@ import {
3140
TEST_USER_ID,
3241
} from "../../test-utils/test-data";
3342
import { mockInitialApiRequests } from "../../test-utils/mockEndpoints";
34-
import {
35-
Phase,
36-
VerificationRequest,
37-
VerificationRequestEvent,
38-
} from "../../../src/crypto/verification/request/VerificationRequest";
3943

4044
// The verification flows use javascript timers to set timeouts. We tell jest to use mock timer implementations
4145
// to ensure that we don't end up with dangling timeouts.
@@ -130,7 +134,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("verification (%s)", (backend: st
130134
]);
131135
const transactionId = request.transactionId;
132136
expect(transactionId).toBeDefined();
133-
expect(request.phase).toEqual(Phase.Requested);
137+
expect(request.phase).toEqual(VerificationPhase.Requested);
134138
expect(request.roomId).toBeUndefined();
135139

136140
let toDeviceMessage = requestBody.messages[TEST_USER_ID][TEST_DEVICE_ID];
@@ -148,7 +152,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("verification (%s)", (backend: st
148152
},
149153
});
150154
await waitForVerificationRequestChanged(request);
151-
expect(request.phase).toEqual(Phase.Ready);
155+
expect(request.phase).toEqual(VerificationPhase.Ready);
152156
expect(request.otherDeviceId).toEqual(TEST_DEVICE_ID);
153157

154158
// ... and picks a method with m.key.verification.start
@@ -165,7 +169,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("verification (%s)", (backend: st
165169
},
166170
});
167171
await waitForVerificationRequestChanged(request);
168-
expect(request.phase).toEqual(Phase.Started);
172+
expect(request.phase).toEqual(VerificationPhase.Started);
169173
expect(request.chosenMethod).toEqual("m.sas.v1");
170174

171175
// there should now be a verifier
@@ -238,7 +242,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("verification (%s)", (backend: st
238242

239243
// ... and the whole thing should be done!
240244
await verificationPromise;
241-
expect(request.phase).toEqual(Phase.Done);
245+
expect(request.phase).toEqual(VerificationPhase.Done);
242246

243247
// we're done with the temporary keypair
244248
olmSAS.free();
@@ -290,7 +294,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("verification (%s)", (backend: st
290294
},
291295
});
292296
await waitForVerificationRequestChanged(request);
293-
expect(request.phase).toEqual(Phase.Ready);
297+
expect(request.phase).toEqual(VerificationPhase.Ready);
294298

295299
// we should now have QR data we can display
296300
const qrCodeBuffer = request.getQRCodeBytes()!;
@@ -320,7 +324,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("verification (%s)", (backend: st
320324
},
321325
});
322326
await waitForVerificationRequestChanged(request);
323-
expect(request.phase).toEqual(Phase.Started);
327+
expect(request.phase).toEqual(VerificationPhase.Started);
324328
expect(request.chosenMethod).toEqual("m.reciprocate.v1");
325329

326330
// there should now be a verifier
@@ -346,7 +350,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("verification (%s)", (backend: st
346350

347351
// ... and the whole thing should be done!
348352
await verificationPromise;
349-
expect(request.phase).toEqual(Phase.Done);
353+
expect(request.phase).toEqual(VerificationPhase.Done);
350354
},
351355
);
352356

@@ -374,18 +378,18 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("verification (%s)", (backend: st
374378
});
375379
const request: VerificationRequest = await emitPromise(aliceClient, CryptoEvent.VerificationRequest);
376380
expect(request.transactionId).toEqual(TRANSACTION_ID);
377-
expect(request.phase).toEqual(Phase.Requested);
381+
expect(request.phase).toEqual(VerificationPhase.Requested);
378382
expect(request.roomId).toBeUndefined();
379-
expect(request.canAccept).toBe(true);
383+
expect(canAcceptVerificationRequest(request)).toBe(true);
380384

381385
// Alice accepts, by sending a to-device message
382386
const sendToDevicePromise = expectSendToDeviceMessage("m.key.verification.ready");
383387
const acceptPromise = request.accept();
384-
expect(request.canAccept).toBe(false);
385-
expect(request.phase).toEqual(Phase.Requested);
388+
expect(canAcceptVerificationRequest(request)).toBe(false);
389+
expect(request.phase).toEqual(VerificationPhase.Requested);
386390
await acceptPromise;
387391
const requestBody = await sendToDevicePromise;
388-
expect(request.phase).toEqual(Phase.Ready);
392+
expect(request.phase).toEqual(VerificationPhase.Ready);
389393

390394
const toDeviceMessage = requestBody.messages[TEST_USER_ID][TEST_DEVICE_ID];
391395
expect(toDeviceMessage.methods).toContain("m.sas.v1");

0 commit comments

Comments
 (0)