From f3133f22caf085f93f304d18179b4413f4c095d3 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 22 Nov 2023 13:20:58 +0000 Subject: [PATCH] Run both legacy & rust crypto tests in Playwright (#11919) * Install playwright Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add foundations for writing tests under Playwright Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * .gitignore juggling Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add tsconfig and fix eslint rules Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add docker & synapse plugins Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add login.spec.ts Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Wire up fixture which sets up ElementAppPage & bakes config.json Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove launch test, it has served its purpose Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove test which has been ported to Playwright Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix test not cleaning up after itself Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Move registerUser to the Homeserver interface Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove unused fixture param Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove redundant launch test Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add newline * Run both legacy & rust crypto tests in Playwright Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove redundant comment Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: R Midhun Suresh --- playwright.config.ts | 19 +++++++++++++++---- playwright/element-web-test.ts | 31 +++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 5844443427..4c5c2bdfa5 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -14,11 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -import type { PlaywrightTestConfig } 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 config: PlaywrightTestConfig = { +export default defineConfig({ use: { headless: false, viewport: { width: 1280, height: 720 }, @@ -35,5 +37,14 @@ const config: PlaywrightTestConfig = { outputDir: "playwright/test-results", workers: 1, reporter: process.env.CI ? "blob" : [["html", { outputFolder: "playwright/html-report" }]], -}; -export default config; + projects: [ + { + name: "Legacy Crypto", + use: { crypto: "legacy" }, + }, + { + name: "Rust Crypto", + use: { crypto: "rust" }, + }, + ], +}); diff --git a/playwright/element-web-test.ts b/playwright/element-web-test.ts index 28b97199dc..cd163e1072 100644 --- a/playwright/element-web-test.ts +++ b/playwright/element-web-test.ts @@ -35,15 +35,30 @@ const CONFIG_JSON = { map_style_url: "https://api.maptiler.com/maps/streets/style.json?key=fU3vlMsMn4Jb6dnEIFsx", }; -export const test = base.extend<{ - startHomeserverOpts: StartHomeserverOpts | string; - homeserver: HomeserverInstance; -}>({ - page: async ({ context, page }, use) => { - await context.route(`http://localhost:8080/config.json*`, async (route) => { - await route.fulfill({ json: CONFIG_JSON }); - }); +export type TestOptions = { + crypto: "legacy" | "rust"; +}; +export const test = base.extend< + TestOptions & { + config: typeof CONFIG_JSON; + startHomeserverOpts: StartHomeserverOpts | string; + homeserver: HomeserverInstance; + } +>({ + crypto: ["legacy", { option: true }], + config: CONFIG_JSON, + page: async ({ context, page, config, crypto }, use) => { + await context.route(`http://localhost:8080/config.json*`, async (route) => { + const json = { ...config }; + if (crypto === "rust") { + json["features"] = { + ...json["features"], + feature_rust_crypto: true, + }; + } + await route.fulfill({ json }); + }); await use(page); },