Disable playwright tests for legacy crypto (#12662)

* Disable "legacy crypto" playwright project

* playwight: Remove crypto stack conditions

We only ever run under the rust stack now, so these conditions are
redundant.

* playwright: remove `cryptoBackend` test option

* playwright: remove redundant `projects`

We don't need this any more

* playwright: remove redundant `TestOptions`
pull/28217/head
Richard van der Hoff 2024-06-24 11:30:59 +01:00 committed by GitHub
parent 9c862907f9
commit efd309f5f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 62 additions and 116 deletions

View File

@ -16,11 +16,9 @@ limitations under the License.
import { defineConfig } from "@playwright/test"; import { defineConfig } from "@playwright/test";
import { TestOptions } from "./playwright/element-web-test";
const baseURL = process.env["BASE_URL"] ?? "http://localhost:8080"; const baseURL = process.env["BASE_URL"] ?? "http://localhost:8080";
export default defineConfig<TestOptions>({ export default defineConfig({
use: { use: {
viewport: { width: 1280, height: 720 }, viewport: { width: 1280, height: 720 },
ignoreHTTPSErrors: true, ignoreHTTPSErrors: true,
@ -42,16 +40,6 @@ export default defineConfig<TestOptions>({
workers: 1, workers: 1,
retries: process.env.CI ? 2 : 0, retries: process.env.CI ? 2 : 0,
reporter: process.env.CI ? [["blob"], ["github"]] : [["html", { outputFolder: "playwright/html-report" }]], reporter: process.env.CI ? [["blob"], ["github"]] : [["html", { outputFolder: "playwright/html-report" }]],
projects: [
{
name: "Legacy Crypto",
use: { cryptoBackend: "legacy" },
},
{
name: "Rust Crypto",
use: { cryptoBackend: "rust" },
},
],
snapshotDir: "playwright/snapshots", snapshotDir: "playwright/snapshots",
snapshotPathTemplate: "{snapshotDir}/{testFilePath}/{arg}-{platform}{ext}", snapshotPathTemplate: "{snapshotDir}/{testFilePath}/{arg}-{platform}{ext}",
}); });

View File

@ -322,13 +322,7 @@ test.describe("Cryptography", function () {
}); });
}); });
test("should show the correct shield on e2e events", async ({ test("should show the correct shield on e2e events", async ({ page, app, bot: bob, homeserver }) => {
page,
app,
bot: bob,
homeserver,
cryptoBackend,
}) => {
// Bob has a second, not cross-signed, device // Bob has a second, not cross-signed, device
const bobSecondDevice = new Bot(page, homeserver, { const bobSecondDevice = new Bot(page, homeserver, {
bootstrapSecretStorage: false, bootstrapSecretStorage: false,
@ -432,16 +426,8 @@ test.describe("Cryptography", function () {
await app.viewRoomByName("Bob"); await app.viewRoomByName("Bob");
await app.viewRoomByName("TestRoom"); await app.viewRoomByName("TestRoom");
// some debate over whether this should have a red or a grey shield. Legacy crypto shows a grey shield,
// Rust crypto a red one.
await expect(last).toContainText("test encrypted from unverified"); await expect(last).toContainText("test encrypted from unverified");
if (cryptoBackend === "rust") { await expect(lastE2eIcon).toHaveClass(/mx_EventTile_e2eIcon_warning/);
await expect(lastE2eIcon).toHaveClass(/mx_EventTile_e2eIcon_warning/);
} else {
// skip this for now: the legacy option no longer actually gives us a legacy stack.
// We'll sort this out properly in https://github.com/matrix-org/matrix-react-sdk/pull/12662
// await expect(lastE2eIcon).toHaveClass(/mx_EventTile_e2eIcon_normal/);
}
await lastE2eIcon.focus(); await lastE2eIcon.focus();
await expect(page.getByRole("tooltip")).toContainText("Encrypted by an unknown or deleted device."); await expect(page.getByRole("tooltip")).toContainText("Encrypted by an unknown or deleted device.");
}); });
@ -561,9 +547,7 @@ test.describe("Cryptography", function () {
app, app,
credentials, credentials,
user, user,
cryptoBackend,
}) => { }) => {
test.skip(cryptoBackend === "legacy", "Not implemented for legacy crypto");
test.setTimeout(60000); test.setTimeout(60000);
// Start with a logged-in session, without key backup, and send a message. // Start with a logged-in session, without key backup, and send a message.
@ -627,11 +611,8 @@ test.describe("Cryptography", function () {
app, app,
credentials: aliceCredentials, credentials: aliceCredentials,
user: alice, user: alice,
cryptoBackend,
bot: bob, bot: bob,
}) => { }) => {
test.skip(cryptoBackend === "legacy", "Not implemented for legacy crypto");
// Bob creates an encrypted room and sends a message to it. He then invites Alice // Bob creates an encrypted room and sends a message to it. He then invites Alice
const roomId = await bob.evaluate( const roomId = await bob.evaluate(
async (client, { alice }) => { async (client, { alice }) => {
@ -735,15 +716,8 @@ test.describe("Cryptography", function () {
app, app,
credentials: aliceCredentials, credentials: aliceCredentials,
user: alice, user: alice,
cryptoBackend,
bot: bob, bot: bob,
}) => { }) => {
// The old pre-join UTD hiding code would hide events sent
// before our latest join event, even if the event that we're
// jumping to was decryptable. We test that this no longer happens.
test.skip(cryptoBackend === "legacy", "Not implemented for legacy crypto");
// Bob: // Bob:
// - creates an encrypted room, // - creates an encrypted room,
// - invites Alice, // - invites Alice,

View File

@ -305,10 +305,7 @@ test.describe("User verification", () => {
user: aliceCredentials, user: aliceCredentials,
toasts, toasts,
room: { roomId: dmRoomId }, room: { roomId: dmRoomId },
cryptoBackend,
}) => { }) => {
test.skip(cryptoBackend === "legacy", "Not implemented for legacy crypto");
// once Alice has joined, Bob starts the verification // once Alice has joined, Bob starts the verification
const bobVerificationRequest = await bob.evaluateHandle( const bobVerificationRequest = await bob.evaluateHandle(
async (client, { dmRoomId, aliceCredentials }) => { async (client, { dmRoomId, aliceCredentials }) => {

View File

@ -249,7 +249,6 @@ test.describe("Read receipts", () => {
}); });
test("Paging up to find old threads that were never read keeps the room unread", async ({ test("Paging up to find old threads that were never read keeps the room unread", async ({
cryptoBackend,
roomAlpha: room1, roomAlpha: room1,
roomBeta: room2, roomBeta: room2,
util, util,
@ -338,7 +337,6 @@ test.describe("Read receipts", () => {
}); });
test("After marking room as read, paging up to find old threads that were never read leaves the room read", async ({ test("After marking room as read, paging up to find old threads that were never read leaves the room read", async ({
cryptoBackend,
roomAlpha: room1, roomAlpha: room1,
roomBeta: room2, roomBeta: room2,
util, util,

View File

@ -568,9 +568,9 @@ test.describe("Timeline", () => {
); );
}); });
test("should set inline start padding to a hidden event line", async ({ page, app, room, cryptoBackend }) => { test("should set inline start padding to a hidden event line", async ({ page, app, room }) => {
test.skip( test.skip(
cryptoBackend === "rust", true,
"Disabled due to screenshot test being flaky - https://github.com/element-hq/element-web/issues/26890", "Disabled due to screenshot test being flaky - https://github.com/element-hq/element-web/issues/26890",
); );
await sendEvent(app.client, room.roomId); await sendEvent(app.client, room.roomId);

View File

@ -63,84 +63,77 @@ const CONFIG_JSON: Partial<IConfigOptions> = {
}, },
}; };
export type TestOptions = {
cryptoBackend: "legacy" | "rust";
};
interface CredentialsWithDisplayName extends Credentials { interface CredentialsWithDisplayName extends Credentials {
displayName: string; displayName: string;
} }
export const test = base.extend< export const test = base.extend<{
TestOptions & { axe: AxeBuilder;
axe: AxeBuilder; checkA11y: () => Promise<void>;
checkA11y: () => Promise<void>;
/** /**
* The contents of the config.json to send when the client requests it. * The contents of the config.json to send when the client requests it.
*/ */
config: typeof CONFIG_JSON; config: typeof CONFIG_JSON;
/** /**
* The options with which to run the {@link #homeserver} fixture. * The options with which to run the {@link #homeserver} fixture.
*/ */
startHomeserverOpts: StartHomeserverOpts | string; startHomeserverOpts: StartHomeserverOpts | string;
homeserver: HomeserverInstance; homeserver: HomeserverInstance;
oAuthServer: { port: number }; oAuthServer: { port: number };
/** /**
* The displayname to use for the user registered in {@link #credentials}. * The displayname to use for the user registered in {@link #credentials}.
* *
* To set it, call `test.use({ displayName: "myDisplayName" })` in the test file or `describe` block. * To set it, call `test.use({ displayName: "myDisplayName" })` in the test file or `describe` block.
* See {@link https://playwright.dev/docs/api/class-test#test-use}. * See {@link https://playwright.dev/docs/api/class-test#test-use}.
*/ */
displayName?: string; displayName?: string;
/** /**
* A test fixture which registers a test user on the {@link #homeserver} and supplies the details * A test fixture which registers a test user on the {@link #homeserver} and supplies the details
* of the registered user. * of the registered user.
*/ */
credentials: CredentialsWithDisplayName; credentials: CredentialsWithDisplayName;
/** /**
* The same as {@link https://playwright.dev/docs/api/class-fixtures#fixtures-page|`page`}, * The same as {@link https://playwright.dev/docs/api/class-fixtures#fixtures-page|`page`},
* but adds an initScript which will populate localStorage with the user's details from * but adds an initScript which will populate localStorage with the user's details from
* {@link #credentials} and {@link #homeserver}. * {@link #credentials} and {@link #homeserver}.
* *
* Similar to {@link #user}, but doesn't load the app. * Similar to {@link #user}, but doesn't load the app.
*/ */
pageWithCredentials: Page; pageWithCredentials: Page;
/** /**
* A (rather poorly-named) test fixture which registers a user per {@link #credentials}, stores * A (rather poorly-named) test fixture which registers a user per {@link #credentials}, stores
* the credentials into localStorage per {@link #homeserver}, and then loads the front page of the * the credentials into localStorage per {@link #homeserver}, and then loads the front page of the
* app. * app.
*/ */
user: CredentialsWithDisplayName; user: CredentialsWithDisplayName;
/** /**
* The same as {@link https://playwright.dev/docs/api/class-fixtures#fixtures-page|`page`}, * The same as {@link https://playwright.dev/docs/api/class-fixtures#fixtures-page|`page`},
* but wraps the returned `Page` in a class of utilities for interacting with the Element-Web UI, * but wraps the returned `Page` in a class of utilities for interacting with the Element-Web UI,
* {@link ElementAppPage}. * {@link ElementAppPage}.
*/ */
app: ElementAppPage; app: ElementAppPage;
mailhog: { api: mailhog.API; instance: Instance }; mailhog: { api: mailhog.API; instance: Instance };
crypto: Crypto; crypto: Crypto;
room?: { roomId: string }; room?: { roomId: string };
toasts: Toasts; toasts: Toasts;
uut?: Locator; // Unit Under Test, useful place to refer a prepared locator uut?: Locator; // Unit Under Test, useful place to refer a prepared locator
botCreateOpts: CreateBotOpts; botCreateOpts: CreateBotOpts;
bot: Bot; bot: Bot;
slidingSyncProxy: ProxyInstance; slidingSyncProxy: ProxyInstance;
labsFlags: string[]; labsFlags: string[];
webserver: Webserver; webserver: Webserver;
} }>({
>({
cryptoBackend: ["legacy", { option: true }],
config: CONFIG_JSON, config: CONFIG_JSON,
page: async ({ context, page, config, cryptoBackend, labsFlags }, use) => { page: async ({ context, page, config, labsFlags }, use) => {
await context.route(`http://localhost:8080/config.json*`, async (route) => { await context.route(`http://localhost:8080/config.json*`, async (route) => {
const json = { ...CONFIG_JSON, ...config }; const json = { ...CONFIG_JSON, ...config };
json["features"] = { json["features"] = {
@ -151,10 +144,6 @@ export const test = base.extend<
return obj; return obj;
}, {}), }, {}),
}; };
// the default is to use rust now, so set to `false` if on legacy backend
if (cryptoBackend === "legacy") {
json.features.feature_rust_crypto = false;
}
await route.fulfill({ json }); await route.fulfill({ json });
}); });
await use(page); await use(page);