Skip to content

Commit 6cf7948

Browse files
committed
test: reduce e2ee tests flakiness
1 parent b34ba25 commit 6cf7948

3 files changed

Lines changed: 22 additions & 14 deletions

File tree

apps/meteor/tests/e2e/e2e-encryption/e2ee-encryption-decryption.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ test.describe('E2EE Encryption and Decryption - Basic Features', () => {
6161

6262
// Log out
6363
await navbar.logout();
64+
await loginPage.waitForIt();
6465

6566
// Login again
6667
await loginPage.loginByUserState(Users.admin);
@@ -129,6 +130,7 @@ test.describe('E2EE Encryption and Decryption - Basic Features', () => {
129130

130131
// Log out
131132
await navbar.logout();
133+
await loginPage.waitForIt();
132134

133135
// Login again
134136
await loginPage.loginByUserState(Users.admin);

apps/meteor/tests/e2e/e2e-encryption/e2ee-key-reset.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createAuxContext } from '../fixtures/createAuxContext';
44
import injectInitialData from '../fixtures/inject-initial-data';
55
import { Users } from '../fixtures/userStates';
66
import { AccountSecurity } from '../page-objects';
7+
import { LoginPage } from '../page-objects/login';
78
import { preserveSettings } from '../utils/preserveSettings';
89
import { test, expect } from '../utils/test';
910

@@ -41,13 +42,14 @@ test.describe('E2EE Key Reset', () => {
4142

4243
test('expect force logout on e2e keys reset', async ({ page }) => {
4344
const poAccountSecurity = new AccountSecurity(page);
45+
const loginPage = new LoginPage(page);
4446

4547
await page.goto('/account/security');
4648

4749
await poAccountSecurity.securityE2EEncryptionSection.click();
4850
await poAccountSecurity.securityE2EEncryptionResetKeyButton.click();
4951

50-
await expect(page.locator('role=button[name="Login"]')).toBeVisible();
52+
await loginPage.waitForIt();
5153
await expect(anotherClientPage.locator('role=button[name="Login"]')).toBeVisible();
5254
});
5355
});

apps/meteor/tests/e2e/e2e-encryption/e2ee-passphrase-management.spec.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ test.describe('E2EE Passphrase Management - Initial Setup', () => {
3838
});
3939

4040
test.describe('Generate', () => {
41-
test.beforeEach(async ({ page, api }) => {
42-
const loginPage = new LoginPage(page);
41+
let loginPage: LoginPage;
4342

43+
test.beforeEach(async ({ page, api }) => {
44+
loginPage = new LoginPage(page);
4445
await api.post('/method.call/e2e.resetOwnE2EKey', {
4546
message: JSON.stringify({ msg: 'method', id: '1', method: 'e2e.resetOwnE2EKey', params: [] }),
4647
});
@@ -51,7 +52,6 @@ test.describe('E2EE Passphrase Management - Initial Setup', () => {
5152
});
5253

5354
test('expect the randomly generated password to work', async ({ page }) => {
54-
const loginPage = new LoginPage(page);
5555
const enterE2EEPasswordBanner = new EnterE2EEPasswordBanner(page);
5656
const enterE2EEPasswordModal = new EnterE2EEPasswordModal(page);
5757
const e2EEKeyDecodeFailureBanner = new E2EEKeyDecodeFailureBanner(page);
@@ -61,6 +61,7 @@ test.describe('E2EE Passphrase Management - Initial Setup', () => {
6161

6262
// Log out
6363
await navbar.logout();
64+
await loginPage.waitForIt();
6465

6566
// Login again
6667
await loginPage.loginByUserState(Users.admin);
@@ -75,18 +76,17 @@ test.describe('E2EE Passphrase Management - Initial Setup', () => {
7576

7677
test('expect to manually reset the password', async ({ page }) => {
7778
const accountSecurityPage = new AccountSecurity(page);
78-
const loginPage = new LoginPage(page);
7979

8080
// Reset the E2EE key to start the flow from the beginning
8181
await accountSecurityPage.goto();
8282
await accountSecurityPage.resetE2EEPassword();
8383

8484
await loginPage.loginByUserState(Users.admin);
85+
await loginPage.waitForIt();
8586
});
8687

8788
test('should reset e2e password from the modal', async ({ page }) => {
8889
const navbar = new Navbar(page);
89-
const loginPage = new LoginPage(page);
9090
const enterE2EEPasswordBanner = new EnterE2EEPasswordBanner(page);
9191
const enterE2EEPasswordModal = new EnterE2EEPasswordModal(page);
9292
const resetE2EEPasswordModal = new ResetE2EEPasswordModal(page);
@@ -95,6 +95,7 @@ test.describe('E2EE Passphrase Management - Initial Setup', () => {
9595

9696
// Logout
9797
await navbar.logout();
98+
await loginPage.waitForIt();
9899

99100
// Login again
100101
await loginPage.loginByUserState(Users.admin);
@@ -103,14 +104,10 @@ test.describe('E2EE Passphrase Management - Initial Setup', () => {
103104
await enterE2EEPasswordBanner.click();
104105
await enterE2EEPasswordModal.forgotPassword();
105106
await resetE2EEPasswordModal.confirmReset();
106-
107-
// restore login
108-
await loginPage.loginByUserState(Users.admin);
109107
});
110108

111109
test('expect to manually set a new password', async ({ page }) => {
112110
const accountSecurityPage = new AccountSecurity(page);
113-
const loginPage = new LoginPage(page);
114111
const enterE2EEPasswordBanner = new EnterE2EEPasswordBanner(page);
115112
const enterE2EEPasswordModal = new EnterE2EEPasswordModal(page);
116113
const e2EEKeyDecodeFailureBanner = new E2EEKeyDecodeFailureBanner(page);
@@ -125,6 +122,7 @@ test.describe('E2EE Passphrase Management - Initial Setup', () => {
125122
faker.string.symbol(),
126123
});
127124

125+
await loginPage.loginByUserState(Users.admin);
128126
await setupE2EEPassword(page);
129127

130128
// Set a new password
@@ -134,6 +132,7 @@ test.describe('E2EE Passphrase Management - Initial Setup', () => {
134132

135133
// Log out
136134
await navbar.logout();
135+
await loginPage.waitForIt();
137136

138137
// Login again
139138
await loginPage.loginByUserState(Users.admin);
@@ -151,15 +150,17 @@ test.describe('E2EE Passphrase Management - Initial Setup', () => {
151150
test.use({ storageState: Users.userE2EE.state });
152151

153152
test('expect to recover the keys using the recovery key', async ({ page }) => {
153+
const loginPage = new LoginPage(page);
154+
154155
await test.step('Recover the keys', async () => {
155156
await page.goto('/home');
156157
await injectInitialData();
157158
await restoreState(page, Users.userE2EE);
158159
const navbar = new Navbar(page);
159160

160161
await navbar.logout();
162+
await loginPage.waitForIt();
161163

162-
const loginPage = new LoginPage(page);
163164
await loginPage.loginByUserState(Users.userE2EE, { except: ['private_key', 'public_key'] });
164165

165166
const enterE2EEPasswordBanner = new EnterE2EEPasswordBanner(page);
@@ -174,12 +175,13 @@ test.describe('E2EE Passphrase Management - Initial Setup', () => {
174175
});
175176
});
176177

177-
test.use({ storageState: Users.admin.state });
178-
179178
const roomSetupSettingsList = ['E2E_Enable', 'E2E_Allow_Unencrypted_Messages'];
180179

181180
test.describe.serial('E2EE Passphrase Management - Room Setup States', () => {
181+
test.use({ storageState: Users.admin.state });
182+
182183
let poAccountSecurity: AccountSecurity;
184+
let loginPage: LoginPage;
183185
let poHomeChannel: HomeChannel;
184186
let e2eePassword: string;
185187

@@ -188,6 +190,7 @@ test.describe.serial('E2EE Passphrase Management - Room Setup States', () => {
188190
test.beforeEach(async ({ page }) => {
189191
poAccountSecurity = new AccountSecurity(page);
190192
poHomeChannel = new HomeChannel(page);
193+
loginPage = new LoginPage(page);
191194
});
192195

193196
test.beforeAll(async ({ api }) => {
@@ -204,7 +207,7 @@ test.describe.serial('E2EE Passphrase Management - Room Setup States', () => {
204207
await poAccountSecurity.securityE2EEncryptionSection.click();
205208
await poAccountSecurity.securityE2EEncryptionResetKeyButton.click();
206209

207-
await page.locator('role=button[name="Login"]').waitFor();
210+
await loginPage.waitForIt();
208211

209212
await injectInitialData();
210213
await restoreState(page, Users.admin);
@@ -252,6 +255,7 @@ test.describe.serial('E2EE Passphrase Management - Room Setup States', () => {
252255

253256
// Logout to remove e2ee keys
254257
await poHomeChannel.navbar.logout();
258+
await loginPage.waitForIt();
255259

256260
await injectInitialData();
257261
await restoreState(page, Users.admin, { except: ['private_key', 'public_key'] });

0 commit comments

Comments
 (0)