Skip to content

Commit 6487612

Browse files
committed
test(e2e): renaming and improve documentation
1 parent 44c6d1d commit 6487612

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

playwright/e2e/crypto/utils.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ export async function checkDeviceIsCrossSigned(app: ElementAppPage): Promise<voi
139139
* Check that the current device is connected to the expected key backup.
140140
* Also checks that the decryption key is known and cached locally.
141141
*
142-
* @param app - app page
142+
* @param app -` ElementAppPage` wrapper for the playwright `Page`.
143143
* @param expectedBackupVersion - the version of the backup we expect to be connected to.
144-
* @param checkBackupKeyInCache - whether to check that the backup key is cached locally.
144+
* @param checkBackupPrivateKeyInCache - whether to check that the backup decryption key is cached locally
145145
*/
146146
export async function checkDeviceIsConnectedKeyBackup(
147147
app: ElementAppPage,
148148
expectedBackupVersion: string,
149-
checkBackupKeyInCache: boolean,
149+
checkBackupPrivateKeyInCache: boolean,
150150
): Promise<void> {
151151
// Sanity check the given backup version: if it's null, something went wrong earlier in the test.
152152
if (!expectedBackupVersion) {
@@ -160,20 +160,27 @@ export async function checkDeviceIsConnectedKeyBackup(
160160
if (!crypto) return;
161161

162162
const backupInfo = await crypto.getKeyBackupInfo();
163-
const backupKeyStored = Boolean(await client.isKeyBackupKeyStored());
164-
const backupKeyFromCache = await crypto.getSessionBackupPrivateKey();
165-
const backupKeyCached = Boolean(backupKeyFromCache);
166-
const backupKeyWellFormed = backupKeyFromCache instanceof Uint8Array;
163+
const backupKeyIn4S = Boolean(await client.isKeyBackupKeyStored());
164+
const backupPrivateKeyFromCache = await crypto.getSessionBackupPrivateKey();
165+
const hasBackupPrivateKeyFromCache = Boolean(backupPrivateKeyFromCache);
166+
const backupPrivateKeyWellFormed = backupPrivateKeyFromCache instanceof Uint8Array;
167167
const activeBackupVersion = await crypto.getActiveSessionBackupVersion();
168168

169-
return { backupInfo, backupKeyStored, backupKeyCached, backupKeyWellFormed, activeBackupVersion };
169+
return {
170+
backupInfo,
171+
hasBackupPrivateKeyFromCache,
172+
backupPrivateKeyWellFormed,
173+
backupKeyIn4S,
174+
activeBackupVersion,
175+
};
170176
});
171177

172178
if (!backupData) {
173-
throw new Error("Crypo module is not available");
179+
throw new Error("Crypto module is not available");
174180
}
175181

176-
const { backupInfo, backupKeyStored, backupKeyCached, backupKeyWellFormed, activeBackupVersion } = backupData;
182+
const { backupInfo, backupKeyIn4S, hasBackupPrivateKeyFromCache, backupPrivateKeyWellFormed, activeBackupVersion } =
183+
backupData;
177184

178185
// We have a key backup
179186
expect(backupInfo).toBeDefined();
@@ -182,13 +189,13 @@ export async function checkDeviceIsConnectedKeyBackup(
182189
// The active backup version is as expected
183190
expect(activeBackupVersion).toBe(expectedBackupVersion);
184191
// The backup key is stored in 4S
185-
expect(backupKeyStored).toBe(true);
192+
expect(backupKeyIn4S).toBe(true);
186193

187-
if (checkBackupKeyInCache) {
194+
if (checkBackupPrivateKeyInCache) {
188195
// The backup key is available locally
189-
expect(backupKeyCached).toBe(true);
196+
expect(hasBackupPrivateKeyFromCache).toBe(true);
190197
// The backup key is well-formed
191-
expect(backupKeyWellFormed).toBe(true);
198+
expect(backupPrivateKeyWellFormed).toBe(true);
192199
}
193200
}
194201

0 commit comments

Comments
 (0)