Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { faker } from '@faker-js/faker';

import { Users } from '../fixtures/userStates';
import { HomeChannel } from '../page-objects';
import { CreateE2EEChannel } from '../page-objects/fragments/e2ee';
import { deleteRoom } from '../utils/create-target-channel';
import { preserveSettings } from '../utils/preserveSettings';
import { test, expect } from '../utils/test';

Expand All @@ -15,7 +17,9 @@ const settingsList = [
preserveSettings(settingsList);

test.describe('E2EE Encrypted Channels', () => {
const createdChannels: { name: string; id?: string | null }[] = [];
let poHomeChannel: HomeChannel;
let createE2EEChannel: CreateE2EEChannel;

test.use({ storageState: Users.userE2EE.state });

Expand All @@ -29,13 +33,18 @@ test.describe('E2EE Encrypted Channels', () => {

test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);
createE2EEChannel = new CreateE2EEChannel(page);
await page.goto('/home');
});

test.afterAll(async ({ api }) => {
await Promise.all(createdChannels.map(({ id }) => (id ? deleteRoom(api, id) : Promise.resolve())));
});

test('expect create a private channel encrypted and send an encrypted message', async ({ page }) => {
const channelName = faker.string.uuid();

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);

Expand Down Expand Up @@ -77,7 +86,7 @@ test.describe('E2EE Encrypted Channels', () => {
test('expect create a private encrypted channel and send a encrypted thread message', async ({ page }) => {
const channelName = faker.string.uuid();

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);

Expand Down Expand Up @@ -109,7 +118,7 @@ test.describe('E2EE Encrypted Channels', () => {
test('expect create a private encrypted channel and check disabled message menu actions on an encrypted message', async ({ page }) => {
const channelName = faker.string.uuid();

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);

Expand Down Expand Up @@ -141,6 +150,8 @@ test.describe('E2EE Encrypted Channels', () => {
await poHomeChannel.toastMessage.waitForDisplay();
await poHomeChannel.toastMessage.dismissToast();

await createE2EEChannel.resolveAndStore(channelName, createdChannels);

await poHomeChannel.tabs.kebab.click();
// TODO(@jessicaschelly/@dougfabris): fix this flaky behavior
if (!(await poHomeChannel.tabs.btnEnableE2E.isVisible())) {
Expand All @@ -162,7 +173,7 @@ test.describe('E2EE Encrypted Channels', () => {
test('expect create a encrypted private channel and mention user', async ({ page }) => {
const channelName = faker.string.uuid();

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);

Expand All @@ -180,7 +191,7 @@ test.describe('E2EE Encrypted Channels', () => {
test('expect create a encrypted private channel, mention a channel and navigate to it', async ({ page }) => {
const channelName = faker.string.uuid();

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);

Expand All @@ -202,7 +213,7 @@ test.describe('E2EE Encrypted Channels', () => {
test('expect create a encrypted private channel, mention a channel and user', async ({ page }) => {
const channelName = faker.string.uuid();

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);

Expand Down Expand Up @@ -238,6 +249,9 @@ test.describe('E2EE Encrypted Channels', () => {
await poHomeChannel.toastMessage.waitForDisplay();
await poHomeChannel.toastMessage.dismissToast();

// Track channel for cleanup
await createE2EEChannel.resolveAndStore(channelName, createdChannels);

// Send Unencrypted Messages
await poHomeChannel.content.sendMessage('first unencrypted message');
await poHomeChannel.content.sendMessage('second unencrypted message');
Expand Down Expand Up @@ -276,7 +290,7 @@ test.describe('E2EE Encrypted Channels', () => {
test('expect create a private encrypted channel and pin/star an encrypted message', async ({ page }) => {
const channelName = faker.string.uuid();

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);

Expand Down Expand Up @@ -331,7 +345,7 @@ test.describe('E2EE Encrypted Channels', () => {
const originalMessage = 'This is the original encrypted message';
const editedMessage = 'This is the edited encrypted message';

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();

Expand All @@ -356,7 +370,7 @@ test.describe('E2EE Encrypted Channels', () => {
const editedMessage = 'This is the edited encrypted message with a mention to @user1 and #general';
const displayedMessage = 'This is the edited encrypted message with a mention to user1 and general';

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);
await expect(page).toHaveURL(`/group/${channelName}`);
await expect(poHomeChannel.content.encryptedRoomHeaderIcon).toBeVisible();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { BASE_URL } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { EncryptedRoomPage } from '../page-objects/encrypted-room';
import { HomeSidenav } from '../page-objects/fragments';
import { CreateE2EEChannel } from '../page-objects/fragments/e2ee';
import { FileUploadModal } from '../page-objects/fragments/file-upload-modal';
import { LoginPage } from '../page-objects/login';
import { createTargetGroupAndReturnFullRoom, deleteChannel, deleteRoom } from '../utils';
import { createTargetGroupAndReturnFullRoom, deleteRoom } from '../utils';
import { preserveSettings } from '../utils/preserveSettings';
import { sendMessageFromUser } from '../utils/sendMessage';
import { test, expect } from '../utils/test';
Expand All @@ -17,6 +18,9 @@ const settingsList = ['E2E_Enable', 'E2E_Allow_Unencrypted_Messages'];
preserveSettings(settingsList);

test.describe('E2EE Encryption and Decryption - Basic Features', () => {
const createdChannels: { name: string; id?: string | null }[] = [];
let createE2EEChannel: CreateE2EEChannel;

test.use({ storageState: Users.admin.state });

test.beforeAll(async ({ api }) => {
Expand All @@ -34,6 +38,11 @@ test.describe('E2EE Encryption and Decryption - Basic Features', () => {
await page.goto('/home');
await loginPage.waitForIt();
await loginPage.loginByUserState(Users.admin);
createE2EEChannel = new CreateE2EEChannel(page);
});

test.afterAll(async ({ api }) => {
await Promise.all(createdChannels.map(({ id }) => (id ? deleteRoom(api, id) : Promise.resolve())));
});

test('expect placeholder text in place of encrypted message', async ({ page }) => {
Expand All @@ -46,7 +55,7 @@ test.describe('E2EE Encryption and Decryption - Basic Features', () => {

await setupE2EEPassword(page);

await sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);
await expect(encryptedRoomPage.encryptedIcon).toBeVisible();
Expand Down Expand Up @@ -87,7 +96,7 @@ test.describe('E2EE Encryption and Decryption - Basic Features', () => {
await setupE2EEPassword(page);

// Create an encrypted channel
await sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);
await expect(encryptedRoomPage.encryptedIcon).toBeVisible();
Expand Down Expand Up @@ -154,7 +163,6 @@ test.describe('E2EE Encryption and Decryption - Basic Features', () => {

test.afterAll(async ({ api }) => {
await deleteRoom(api, targetRoomId);
await deleteChannel(api, targetChannelName);
});

test('expect to not crash and not show quote message for a message_link which is not accessible to the user', async ({
Expand All @@ -163,10 +171,9 @@ test.describe('E2EE Encryption and Decryption - Basic Features', () => {
api,
}) => {
const encryptedRoomPage = new EncryptedRoomPage(page);
const sidenav = new HomeSidenav(page);
targetChannelName = faker.string.uuid();

await sidenav.createEncryptedChannel(targetChannelName);
await createE2EEChannel.createAndStore(targetChannelName, createdChannels);

await expect(page).toHaveURL(`/group/${targetChannelName}`);
await expect(encryptedRoomPage.encryptedIcon).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { faker } from '@faker-js/faker';

import { Users } from '../fixtures/userStates';
import { HomeChannel } from '../page-objects';
import { CreateE2EEChannel } from '../page-objects/fragments/e2ee';
import { deleteRoom } from '../utils/create-target-channel';
import { preserveSettings } from '../utils/preserveSettings';
import { test, expect } from '../utils/test';

Expand All @@ -16,7 +18,9 @@ const settingsList = [
const originalSettings = preserveSettings(settingsList);

test.describe('E2EE File Encryption', () => {
const createdChannels: { name: string; id?: string | null }[] = [];
let poHomeChannel: HomeChannel;
let createE2EEChannel: CreateE2EEChannel;

test.use({ storageState: Users.userE2EE.state });

Expand All @@ -29,20 +33,22 @@ test.describe('E2EE File Encryption', () => {
});

test.afterAll(async ({ api }) => {
await Promise.all(createdChannels.map(({ id }) => (id ? deleteRoom(api, id) : Promise.resolve())));
await api.post('/settings/FileUpload_MediaTypeWhiteList', { value: '' });
await api.post('/settings/FileUpload_MediaTypeBlackList', { value: 'image/svg+xml' });
});

test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);
createE2EEChannel = new CreateE2EEChannel(page);
await page.goto('/home');
});

test('File and description encryption and editing the description', async ({ page }) => {
await test.step('create an encrypted channel', async () => {
const channelName = faker.string.uuid();

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);

Expand Down Expand Up @@ -77,7 +83,7 @@ test.describe('E2EE File Encryption', () => {
await test.step('create an encrypted room', async () => {
const channelName = faker.string.uuid();

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);

Expand Down Expand Up @@ -141,7 +147,7 @@ test.describe('E2EE File Encryption', () => {
await test.step('create an encrypted channel', async () => {
const channelName = faker.string.uuid();

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import type { APIRequestContext } from '@playwright/test';
import { BASE_API_URL } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { HomeChannel } from '../page-objects';
import { CreateE2EEChannel } from '../page-objects/fragments/e2ee';
import { deleteRoom } from '../utils/create-target-channel';
import { preserveSettings } from '../utils/preserveSettings';
import { test, expect } from '../utils/test';

Expand Down Expand Up @@ -33,7 +35,9 @@ const sendEncryptedMessage = async (request: APIRequestContext, rid: string, enc
};

test.describe('E2EE Legacy Format', () => {
const createdChannels: { name: string; id?: string | null }[] = [];
let poHomeChannel: HomeChannel;
let createE2EEChannel: CreateE2EEChannel;

test.use({ storageState: Users.userE2EE.state });

Expand All @@ -47,13 +51,18 @@ test.describe('E2EE Legacy Format', () => {

test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);
createE2EEChannel = new CreateE2EEChannel(page);
await page.goto('/home');
});

test.afterAll(async ({ api }) => {
await Promise.all(createdChannels.map(({ id }) => (id ? deleteRoom(api, id) : Promise.resolve())));
});

test('legacy expect create a private channel encrypted and send an encrypted message', async ({ page, request }) => {
const channelName = faker.string.uuid();

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import { AccountSecurity, HomeChannel } from '../page-objects';
import { setupE2EEPassword } from './setupE2EEPassword';
import { HomeSidenav } from '../page-objects/fragments';
import {
CreateE2EEChannel,
E2EEKeyDecodeFailureBanner,
EnterE2EEPasswordBanner,
EnterE2EEPasswordModal,
ResetE2EEPasswordModal,
} from '../page-objects/fragments/e2ee';
import { LoginPage } from '../page-objects/login';
import { deleteRoom } from '../utils/create-target-channel';
import { preserveSettings } from '../utils/preserveSettings';
import { test, expect } from '../utils/test';

Expand Down Expand Up @@ -184,13 +186,17 @@ const roomSetupSettingsList = ['E2E_Enable', 'E2E_Allow_Unencrypted_Messages'];
test.describe.serial('E2EE Passphrase Management - Room Setup States', () => {
let poAccountSecurity: AccountSecurity;
let poHomeChannel: HomeChannel;
let createE2EEChannel: CreateE2EEChannel;
let e2eePassword: string;

const createdChannels: { name: string; id?: string | null }[] = [];

preserveSettings(roomSetupSettingsList);

test.beforeEach(async ({ page }) => {
poAccountSecurity = new AccountSecurity(page);
poHomeChannel = new HomeChannel(page);
createE2EEChannel = new CreateE2EEChannel(page);
});

test.beforeAll(async ({ api }) => {
Expand All @@ -202,6 +208,10 @@ test.describe.serial('E2EE Passphrase Management - Room Setup States', () => {
await api.recreateContext();
});

test.afterAll(async ({ api }) => {
await Promise.all(createdChannels.map(({ id }) => (id ? deleteRoom(api, id) : Promise.resolve())));
});

test('expect save password state on encrypted room', async ({ page }) => {
await page.goto('/account/security');
await poAccountSecurity.securityE2EEncryptionSection.click();
Expand All @@ -219,7 +229,7 @@ test.describe.serial('E2EE Passphrase Management - Room Setup States', () => {

const channelName = faker.string.uuid();

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);

Expand Down Expand Up @@ -261,7 +271,7 @@ test.describe.serial('E2EE Passphrase Management - Room Setup States', () => {

const channelName = faker.string.uuid();

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);

Expand Down Expand Up @@ -303,7 +313,7 @@ test.describe.serial('E2EE Passphrase Management - Room Setup States', () => {

const channelName = faker.string.uuid();

await poHomeChannel.sidenav.createEncryptedChannel(channelName);
await createE2EEChannel.createAndStore(channelName, createdChannels);

await expect(page).toHaveURL(`/group/${channelName}`);

Expand Down
Loading
Loading