Skip to content

Commit

Permalink
test(e2e): renaming and improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Jan 24, 2025
1 parent 44c6d1d commit 944f661
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions playwright/e2e/crypto/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ export async function checkDeviceIsCrossSigned(app: ElementAppPage): Promise<voi
* Check that the current device is connected to the expected key backup.
* Also checks that the decryption key is known and cached locally.
*
* @param app - app page
* @param app -` ElementAppPage` wrapper for the playwright `Page`.
* @param expectedBackupVersion - the version of the backup we expect to be connected to.
* @param checkBackupKeyInCache - whether to check that the backup key is cached locally.
* @param checkBackupPrivateKeyInCache - whether to check that the backup decryption key is cached locally
*/
export async function checkDeviceIsConnectedKeyBackup(
app: ElementAppPage,
expectedBackupVersion: string,
checkBackupKeyInCache: boolean,
checkBackupPrivateKeyInCache: boolean,
): Promise<void> {
// Sanity check the given backup version: if it's null, something went wrong earlier in the test.
if (!expectedBackupVersion) {
Expand All @@ -160,20 +160,18 @@ export async function checkDeviceIsConnectedKeyBackup(
if (!crypto) return;

const backupInfo = await crypto.getKeyBackupInfo();
const backupKeyStored = Boolean(await client.isKeyBackupKeyStored());
const backupKeyFromCache = await crypto.getSessionBackupPrivateKey();
const backupKeyCached = Boolean(backupKeyFromCache);
const backupKeyWellFormed = backupKeyFromCache instanceof Uint8Array;
const backupKeyIn4S = Boolean(await client.isKeyBackupKeyStored());
const backupPrivateKeyFromCache = await crypto.getSessionBackupPrivateKey();
const activeBackupVersion = await crypto.getActiveSessionBackupVersion();

return { backupInfo, backupKeyStored, backupKeyCached, backupKeyWellFormed, activeBackupVersion };
return { backupInfo, backupPrivateKeyFromCache, backupKeyIn4S, activeBackupVersion };
});

if (!backupData) {
throw new Error("Crypo module is not available");
throw new Error("Crypto module is not available");
}

const { backupInfo, backupKeyStored, backupKeyCached, backupKeyWellFormed, activeBackupVersion } = backupData;
const { backupInfo, backupKeyIn4S, backupPrivateKeyFromCache, activeBackupVersion } = backupData;

// We have a key backup
expect(backupInfo).toBeDefined();
Expand All @@ -182,13 +180,13 @@ export async function checkDeviceIsConnectedKeyBackup(
// The active backup version is as expected
expect(activeBackupVersion).toBe(expectedBackupVersion);
// The backup key is stored in 4S
expect(backupKeyStored).toBe(true);
expect(backupKeyIn4S).toBe(true);

if (checkBackupKeyInCache) {
if (checkBackupPrivateKeyInCache) {
// The backup key is available locally
expect(backupKeyCached).toBe(true);
expect(Boolean(backupPrivateKeyFromCache)).toBe(true);
// The backup key is well-formed
expect(backupKeyWellFormed).toBe(true);
expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true);

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 4/6

[Chrome] › settings/encryption-user-tab/recovery.spec.ts:33:9 › Recovery section in Encryption tab › should verify the device @screenshot

1) [Chrome] › settings/encryption-user-tab/recovery.spec.ts:33:9 › Recovery section in Encryption tab › should verify the device @screenshot Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/settings/encryption-user-tab/recovery.spec.ts:54:9

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 4/6

[Chrome] › settings/encryption-user-tab/recovery.spec.ts:33:9 › Recovery section in Encryption tab › should verify the device @screenshot

1) [Chrome] › settings/encryption-user-tab/recovery.spec.ts:33:9 › Recovery section in Encryption tab › should verify the device @screenshot Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/settings/encryption-user-tab/recovery.spec.ts:54:9

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 4/6

[Chrome] › settings/encryption-user-tab/recovery.spec.ts:33:9 › Recovery section in Encryption tab › should verify the device @screenshot

1) [Chrome] › settings/encryption-user-tab/recovery.spec.ts:33:9 › Recovery section in Encryption tab › should verify the device @screenshot Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/settings/encryption-user-tab/recovery.spec.ts:54:9

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 4/6

[Chrome] › settings/encryption-user-tab/recovery.spec.ts:87:9 › Recovery section in Encryption tab › should setup the recovery key @screenshot @no-webkit

2) [Chrome] › settings/encryption-user-tab/recovery.spec.ts:87:9 › Recovery section in Encryption tab › should setup the recovery key @screenshot @no-webkit Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/settings/encryption-user-tab/recovery.spec.ts:122:9

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 4/6

[Chrome] › settings/encryption-user-tab/recovery.spec.ts:87:9 › Recovery section in Encryption tab › should setup the recovery key @screenshot @no-webkit

2) [Chrome] › settings/encryption-user-tab/recovery.spec.ts:87:9 › Recovery section in Encryption tab › should setup the recovery key @screenshot @no-webkit Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/settings/encryption-user-tab/recovery.spec.ts:122:9

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 4/6

[Chrome] › settings/encryption-user-tab/recovery.spec.ts:87:9 › Recovery section in Encryption tab › should setup the recovery key @screenshot @no-webkit

2) [Chrome] › settings/encryption-user-tab/recovery.spec.ts:87:9 › Recovery section in Encryption tab › should setup the recovery key @screenshot @no-webkit Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/settings/encryption-user-tab/recovery.spec.ts:122:9

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 4/6

[Chrome] › settings/encryption-user-tab/recovery.spec.ts:129:9 › Recovery section in Encryption tab › should enter the recovery key when the secrets are not cached @screenshot

3) [Chrome] › settings/encryption-user-tab/recovery.spec.ts:129:9 › Recovery section in Encryption tab › should enter the recovery key when the secrets are not cached @screenshot Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/settings/encryption-user-tab/recovery.spec.ts:154:13

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 4/6

[Chrome] › settings/encryption-user-tab/recovery.spec.ts:129:9 › Recovery section in Encryption tab › should enter the recovery key when the secrets are not cached @screenshot

3) [Chrome] › settings/encryption-user-tab/recovery.spec.ts:129:9 › Recovery section in Encryption tab › should enter the recovery key when the secrets are not cached @screenshot Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/settings/encryption-user-tab/recovery.spec.ts:154:13

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 4/6

[Chrome] › settings/encryption-user-tab/recovery.spec.ts:129:9 › Recovery section in Encryption tab › should enter the recovery key when the secrets are not cached @screenshot

3) [Chrome] › settings/encryption-user-tab/recovery.spec.ts:129:9 › Recovery section in Encryption tab › should enter the recovery key when the secrets are not cached @screenshot Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/settings/encryption-user-tab/recovery.spec.ts:154:13

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 1/6

[Chrome] › crypto/device-verification.spec.ts:75:9 › Device verification › Verify device with QR code during login @no-webkit

1) [Chrome] › crypto/device-verification.spec.ts:75:9 › Device verification › Verify device with QR code during login @no-webkit Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/crypto/device-verification.spec.ts:115:9

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 1/6

[Chrome] › crypto/device-verification.spec.ts:75:9 › Device verification › Verify device with QR code during login @no-webkit

1) [Chrome] › crypto/device-verification.spec.ts:75:9 › Device verification › Verify device with QR code during login @no-webkit Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/crypto/device-verification.spec.ts:115:9

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 1/6

[Chrome] › crypto/device-verification.spec.ts:75:9 › Device verification › Verify device with QR code during login @no-webkit

1) [Chrome] › crypto/device-verification.spec.ts:75:9 › Device verification › Verify device with QR code during login @no-webkit Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/crypto/device-verification.spec.ts:115:9

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 1/6

[Chrome] › crypto/device-verification.spec.ts:118:9 › Device verification › Verify device with Security Phrase during login @no-webkit

2) [Chrome] › crypto/device-verification.spec.ts:118:9 › Device verification › Verify device with Security Phrase during login @no-webkit Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/crypto/device-verification.spec.ts:136:9

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 1/6

[Chrome] › crypto/device-verification.spec.ts:118:9 › Device verification › Verify device with Security Phrase during login @no-webkit

2) [Chrome] › crypto/device-verification.spec.ts:118:9 › Device verification › Verify device with Security Phrase during login @no-webkit Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/crypto/device-verification.spec.ts:136:9

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 1/6

[Chrome] › crypto/device-verification.spec.ts:118:9 › Device verification › Verify device with Security Phrase during login @no-webkit

2) [Chrome] › crypto/device-verification.spec.ts:118:9 › Device verification › Verify device with Security Phrase during login @no-webkit Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/crypto/device-verification.spec.ts:136:9

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 1/6

[Chrome] › crypto/device-verification.spec.ts:139:9 › Device verification › Verify device with Security Key during login @no-webkit

3) [Chrome] › crypto/device-verification.spec.ts:139:9 › Device verification › Verify device with Security Key during login @no-webkit Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/crypto/device-verification.spec.ts:159:9

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 1/6

[Chrome] › crypto/device-verification.spec.ts:139:9 › Device verification › Verify device with Security Key during login @no-webkit

3) [Chrome] › crypto/device-verification.spec.ts:139:9 › Device verification › Verify device with Security Key during login @no-webkit Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/crypto/device-verification.spec.ts:159:9

Check failure on line 189 in playwright/e2e/crypto/utils.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 1/6

[Chrome] › crypto/device-verification.spec.ts:139:9 › Device verification › Verify device with Security Key during login @no-webkit

3) [Chrome] › crypto/device-verification.spec.ts:139:9 › Device verification › Verify device with Security Key during login @no-webkit Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false at crypto/utils.ts:189 187 | expect(Boolean(backupPrivateKeyFromCache)).toBe(true); 188 | // The backup key is well-formed > 189 | expect(backupPrivateKeyFromCache instanceof Uint8Array).toBe(true); | ^ 190 | } 191 | } 192 | at checkDeviceIsConnectedKeyBackup (/home/runner/work/element-web/element-web/playwright/e2e/crypto/utils.ts:189:65) at /home/runner/work/element-web/element-web/playwright/e2e/crypto/device-verification.spec.ts:159:9
}
}

Expand Down

0 comments on commit 944f661

Please sign in to comment.