From 377b8b22c027997f3101db3aac92234559669ed8 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 22 Feb 2023 14:04:11 -0800 Subject: [PATCH] puppeteer_tests: Move to web/e2e-tests. Signed-off-by: Anders Kaseorg --- .eslintrc.json | 4 ++-- docs/overview/directory-structure.md | 2 +- docs/testing/testing-with-puppeteer.md | 6 +++--- docs/tutorials/new-feature-tutorial.md | 4 ++-- tools/message-screenshot.js | 2 +- tools/release-tarball-exclude.txt | 1 - tools/test-js-with-puppeteer | 10 +++++----- .../admin.ts => web/e2e-tests/admin.test.ts | 2 +- .../compose.ts => web/e2e-tests/compose.test.ts | 2 +- .../e2e-tests/copy-and-paste.test.ts | 2 +- .../e2e-tests/custom-profile.test.ts | 2 +- .../e2e-tests/delete-message.test.ts | 2 +- .../drafts.ts => web/e2e-tests/drafts.test.ts | 2 +- .../edit.ts => web/e2e-tests/edit.test.ts | 2 +- .../puppeteer_lib => web/e2e-tests/lib}/common.ts | 4 ++-- .../mention.ts => web/e2e-tests/mention.test.ts | 2 +- .../e2e-tests/message-basics.test.ts | 2 +- .../navigation.ts => web/e2e-tests/navigation.test.ts | 2 +- .../e2e-tests/realm-creation.test.ts | 2 +- .../e2e-tests/realm-linkifier.test.ts | 2 +- .../e2e-tests/realm-playground.test.ts | 2 +- .../settings.ts => web/e2e-tests/settings.test.ts | 3 ++- .../stars.ts => web/e2e-tests/stars.test.ts | 2 +- .../e2e-tests/stream_create.test.ts | 2 +- .../e2e-tests/subscribe_toggle.test.ts | 2 +- .../e2e-tests/user-deactivation.test.ts | 2 +- .../e2e-tests/user-status.test.ts | 2 +- 27 files changed, 36 insertions(+), 36 deletions(-) rename frontend_tests/puppeteer_tests/admin.ts => web/e2e-tests/admin.test.ts (99%) rename frontend_tests/puppeteer_tests/compose.ts => web/e2e-tests/compose.test.ts (99%) rename frontend_tests/puppeteer_tests/copy-and-paste.ts => web/e2e-tests/copy-and-paste.test.ts (99%) rename frontend_tests/puppeteer_tests/custom-profile.ts => web/e2e-tests/custom-profile.test.ts (98%) rename frontend_tests/puppeteer_tests/delete-message.ts => web/e2e-tests/delete-message.test.ts (96%) rename frontend_tests/puppeteer_tests/drafts.ts => web/e2e-tests/drafts.test.ts (99%) rename frontend_tests/puppeteer_tests/edit.ts => web/e2e-tests/edit.test.ts (98%) rename {frontend_tests/puppeteer_lib => web/e2e-tests/lib}/common.ts (99%) rename frontend_tests/puppeteer_tests/mention.ts => web/e2e-tests/mention.test.ts (96%) rename frontend_tests/puppeteer_tests/message-basics.ts => web/e2e-tests/message-basics.test.ts (99%) rename frontend_tests/puppeteer_tests/navigation.ts => web/e2e-tests/navigation.test.ts (98%) rename frontend_tests/puppeteer_tests/realm-creation.ts => web/e2e-tests/realm-creation.test.ts (98%) rename frontend_tests/puppeteer_tests/realm-linkifier.ts => web/e2e-tests/realm-linkifier.test.ts (99%) rename frontend_tests/puppeteer_tests/realm-playground.ts => web/e2e-tests/realm-playground.test.ts (98%) rename frontend_tests/puppeteer_tests/settings.ts => web/e2e-tests/settings.test.ts (99%) rename frontend_tests/puppeteer_tests/stars.ts => web/e2e-tests/stars.test.ts (97%) rename frontend_tests/puppeteer_tests/stream_create.ts => web/e2e-tests/stream_create.test.ts (99%) rename frontend_tests/puppeteer_tests/subscribe_toggle.ts => web/e2e-tests/subscribe_toggle.test.ts (97%) rename frontend_tests/puppeteer_tests/user-deactivation.ts => web/e2e-tests/user-deactivation.test.ts (99%) rename frontend_tests/puppeteer_tests/user-status.ts => web/e2e-tests/user-status.test.ts (98%) diff --git a/.eslintrc.json b/.eslintrc.json index 0d133150ba..bd4a848517 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -131,7 +131,7 @@ } }, { - "files": ["frontend_tests/puppeteer_lib/**", "frontend_tests/puppeteer_tests/**"], + "files": ["web/e2e-tests/**"], "globals": { "zulip_test": false } @@ -202,7 +202,7 @@ } }, { - "files": ["frontend_tests/**", "web/tests/**"], + "files": ["web/e2e-tests/**", "web/tests/**"], "globals": { "CSS": false, "document": false, diff --git a/docs/overview/directory-structure.md b/docs/overview/directory-structure.md index e53b863c53..7708ef3f62 100644 --- a/docs/overview/directory-structure.md +++ b/docs/overview/directory-structure.md @@ -79,7 +79,7 @@ templating systems. - `web/tests/` Node Frontend unit tests. -- `frontend_tests/puppeteer_tests/` Puppeteer frontend integration tests. +- `web/e2e-tests/` Puppeteer frontend integration tests. - `tools/test-*` Developer-facing test runner scripts. diff --git a/docs/testing/testing-with-puppeteer.md b/docs/testing/testing-with-puppeteer.md index 6750388efe..c18845b833 100644 --- a/docs/testing/testing-with-puppeteer.md +++ b/docs/testing/testing-with-puppeteer.md @@ -19,9 +19,9 @@ See `tools/test-js-with-puppeteer --help` for useful options, especially running specific subsets of the tests to save time when debugging. -The test files live in `frontend_tests/puppeteer_tests` and make use +The test files live in `web/e2e-tests` and make use of various useful helper functions defined in -`frontend_tests/puppeteer_lib/common.ts`. +`web/e2e-tests/lib/common.ts`. ## How Puppeteer tests work @@ -123,7 +123,7 @@ These tools/features are often useful when debugging: See also [Puppeteer upstream's debugging tips](https://github.com/puppeteer/puppeteer#debugging-tips); some tips may require temporary patches to functions like `run_test` or -`ensure_browser` in `frontend_tests/puppeteer_lib/common.ts`. +`ensure_browser` in `web/e2e-tests/lib/common.ts`. ## Writing Puppeteer tests diff --git a/docs/tutorials/new-feature-tutorial.md b/docs/tutorials/new-feature-tutorial.md index 2a1e805001..919b6362b0 100644 --- a/docs/tutorials/new-feature-tutorial.md +++ b/docs/tutorials/new-feature-tutorial.md @@ -60,7 +60,7 @@ organization in Zulip). The following files are involved in the process: **Frontend testing** -- `frontend_tests/puppeteer_tests/admin.ts`: end-to-end tests for the organization +- `web/e2e-tests/admin.test.ts`: end-to-end tests for the organization admin settings pages. - `web/tests/dispatch.test.js` @@ -144,7 +144,7 @@ or JavaScript/TypeScript/Python code that generates user-facing strings, be sure **Testing:** There are two types of frontend tests: node-based unit tests and blackbox end-to-end tests. The blackbox tests are run in a headless Chromium browser using Puppeteer and are located in -`frontend_tests/puppeteer_tests/`. The unit tests use Node's `assert` +`web/e2e-tests/`. The unit tests use Node's `assert` module are located in `web/tests/`. For more information on writing and running tests, see the [testing documentation](../testing/testing.md). diff --git a/tools/message-screenshot.js b/tools/message-screenshot.js index 8b24e44b54..639daf62f2 100644 --- a/tools/message-screenshot.js +++ b/tools/message-screenshot.js @@ -26,7 +26,7 @@ if (options.messageId === undefined) { process.exit(1); } -// TODO: Refactor to share code with frontend_tests/puppeteer_tests/realm-creation.ts +// TODO: Refactor to share code with web/e2e-tests/realm-creation.test.ts async function run() { const browser = await puppeteer.launch({ args: [ diff --git a/tools/release-tarball-exclude.txt b/tools/release-tarball-exclude.txt index cda0ccbf54..03e6b8b879 100644 --- a/tools/release-tarball-exclude.txt +++ b/tools/release-tarball-exclude.txt @@ -11,4 +11,3 @@ puppet/zulip_ops zproject/dev_settings.py zproject/test_settings.py zerver/tests -frontend_tests diff --git a/tools/test-js-with-puppeteer b/tools/test-js-with-puppeteer index 1aae323df1..3fca983ddf 100755 --- a/tools/test-js-with-puppeteer +++ b/tools/test-js-with-puppeteer @@ -27,10 +27,10 @@ os.environ.pop("https_proxy", "") usage = """test-js-with-puppeteer [options] test-js-with-puppeteer # Run all test files - test-js-with-puppeteer navigation.ts # Run a single test file - test-js-with-puppeteer navi # Run a single test file navigation.ts - test-js-with-puppeteer login.ts compose.ts # Run a few test files - test-js-with-puppeteer login compose # Run a few test files, login.ts and compose.ts here""" + test-js-with-puppeteer navigation.test.ts # Run a single test file + test-js-with-puppeteer navi # Run a single test file navigation.test.ts + test-js-with-puppeteer login.test.ts compose.test.ts # Run a few test files + test-js-with-puppeteer login compose # Run a few test files, login.test.ts and compose.test.ts here""" sys.path.insert(0, ZULIP_PATH) @@ -92,7 +92,7 @@ def run_single_test(test_file: str, test_number: int, total_tests: int) -> int: def run_tests(files: Iterable[str], external_host: str, loop: int = 1) -> None: - test_dir = os.path.join(ZULIP_PATH, "frontend_tests/puppeteer_tests") + test_dir = os.path.join(ZULIP_PATH, "web/e2e-tests") test_files = find_js_test_files(test_dir, files) total_tests = len(test_files) diff --git a/frontend_tests/puppeteer_tests/admin.ts b/web/e2e-tests/admin.test.ts similarity index 99% rename from frontend_tests/puppeteer_tests/admin.ts rename to web/e2e-tests/admin.test.ts index 85fa12e490..9eb19de8a8 100644 --- a/frontend_tests/puppeteer_tests/admin.ts +++ b/web/e2e-tests/admin.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {ElementHandle, Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; async function submit_notifications_stream_settings(page: Page): Promise { await page.waitForSelector('#org-notifications .save-button[data-status="unsaved"]', { diff --git a/frontend_tests/puppeteer_tests/compose.ts b/web/e2e-tests/compose.test.ts similarity index 99% rename from frontend_tests/puppeteer_tests/compose.ts rename to web/e2e-tests/compose.test.ts index 0e77775580..e01a5dba7a 100644 --- a/frontend_tests/puppeteer_tests/compose.ts +++ b/web/e2e-tests/compose.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; async function check_compose_form_empty(page: Page): Promise { await common.check_compose_state(page, { diff --git a/frontend_tests/puppeteer_tests/copy-and-paste.ts b/web/e2e-tests/copy-and-paste.test.ts similarity index 99% rename from frontend_tests/puppeteer_tests/copy-and-paste.ts rename to web/e2e-tests/copy-and-paste.test.ts index 0d0e5e5d62..40a73c4959 100644 --- a/frontend_tests/puppeteer_tests/copy-and-paste.ts +++ b/web/e2e-tests/copy-and-paste.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; async function copy_messages( page: Page, diff --git a/frontend_tests/puppeteer_tests/custom-profile.ts b/web/e2e-tests/custom-profile.test.ts similarity index 98% rename from frontend_tests/puppeteer_tests/custom-profile.ts rename to web/e2e-tests/custom-profile.test.ts index 6a7d2992c1..e2e882b68a 100644 --- a/frontend_tests/puppeteer_tests/custom-profile.ts +++ b/web/e2e-tests/custom-profile.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; // This will be the row of the the custom profile field we add. const profile_field_row = "#admin_profile_fields_table tr:nth-last-child(1)"; diff --git a/frontend_tests/puppeteer_tests/delete-message.ts b/web/e2e-tests/delete-message.test.ts similarity index 96% rename from frontend_tests/puppeteer_tests/delete-message.ts rename to web/e2e-tests/delete-message.test.ts index 027b30b0bf..e1fc893f23 100644 --- a/frontend_tests/puppeteer_tests/delete-message.ts +++ b/web/e2e-tests/delete-message.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; async function click_delete_and_return_last_msg_id(page: Page): Promise { const msg = (await page.$$("#zhome .message_row")).at(-1); diff --git a/frontend_tests/puppeteer_tests/drafts.ts b/web/e2e-tests/drafts.test.ts similarity index 99% rename from frontend_tests/puppeteer_tests/drafts.ts rename to web/e2e-tests/drafts.test.ts index df5859e64c..3263c3afb3 100644 --- a/frontend_tests/puppeteer_tests/drafts.ts +++ b/web/e2e-tests/drafts.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; async function wait_for_drafts_to_disappear(page: Page): Promise { await page.waitForSelector("#draft_overlay.show", {hidden: true}); diff --git a/frontend_tests/puppeteer_tests/edit.ts b/web/e2e-tests/edit.test.ts similarity index 98% rename from frontend_tests/puppeteer_tests/edit.ts rename to web/e2e-tests/edit.test.ts index 482d1019bd..26847c03b9 100644 --- a/frontend_tests/puppeteer_tests/edit.ts +++ b/web/e2e-tests/edit.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; async function trigger_edit_last_message(page: Page): Promise { const msg = (await page.$$("#zhome .message_row")).at(-1); diff --git a/frontend_tests/puppeteer_lib/common.ts b/web/e2e-tests/lib/common.ts similarity index 99% rename from frontend_tests/puppeteer_lib/common.ts rename to web/e2e-tests/lib/common.ts index d723a6d0bc..357fefee80 100644 --- a/frontend_tests/puppeteer_lib/common.ts +++ b/web/e2e-tests/lib/common.ts @@ -8,9 +8,9 @@ import puppeteer from "puppeteer"; import StackFrame from "stackframe"; import StackTraceGPS from "stacktrace-gps"; -import {test_credentials} from "../../var/puppeteer/test_credentials"; +import {test_credentials} from "../../../var/puppeteer/test_credentials"; -const root_dir = path.resolve(__dirname, "../../"); +const root_dir = path.resolve(__dirname, "../../.."); const puppeteer_dir = path.join(root_dir, "var/puppeteer"); type Message = Record & {recipient?: string; content: string}; diff --git a/frontend_tests/puppeteer_tests/mention.ts b/web/e2e-tests/mention.test.ts similarity index 96% rename from frontend_tests/puppeteer_tests/mention.ts rename to web/e2e-tests/mention.test.ts index 7a4561f183..b4ff8aa966 100644 --- a/frontend_tests/puppeteer_tests/mention.ts +++ b/web/e2e-tests/mention.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; async function test_mention(page: Page): Promise { await common.log_in(page); diff --git a/frontend_tests/puppeteer_tests/message-basics.ts b/web/e2e-tests/message-basics.test.ts similarity index 99% rename from frontend_tests/puppeteer_tests/message-basics.ts rename to web/e2e-tests/message-basics.test.ts index 423fd9d5c2..eac4a34e58 100644 --- a/frontend_tests/puppeteer_tests/message-basics.ts +++ b/web/e2e-tests/message-basics.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; async function get_stream_li(page: Page, stream_name: string): Promise { const stream_id = await common.get_stream_id(page, stream_name); diff --git a/frontend_tests/puppeteer_tests/navigation.ts b/web/e2e-tests/navigation.test.ts similarity index 98% rename from frontend_tests/puppeteer_tests/navigation.ts rename to web/e2e-tests/navigation.test.ts index 527c651384..bf7ee6ea04 100644 --- a/frontend_tests/puppeteer_tests/navigation.ts +++ b/web/e2e-tests/navigation.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; async function navigate_using_left_sidebar(page: Page, click_target: string): Promise { console.log("Visiting #" + click_target); diff --git a/frontend_tests/puppeteer_tests/realm-creation.ts b/web/e2e-tests/realm-creation.test.ts similarity index 98% rename from frontend_tests/puppeteer_tests/realm-creation.ts rename to web/e2e-tests/realm-creation.test.ts index 2529ac03f3..24225dfb6d 100644 --- a/frontend_tests/puppeteer_tests/realm-creation.ts +++ b/web/e2e-tests/realm-creation.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; const email = "alice@test.example.com"; const subdomain = "testsubdomain"; diff --git a/frontend_tests/puppeteer_tests/realm-linkifier.ts b/web/e2e-tests/realm-linkifier.test.ts similarity index 99% rename from frontend_tests/puppeteer_tests/realm-linkifier.ts rename to web/e2e-tests/realm-linkifier.test.ts index 713d89faed..5c7951cf0a 100644 --- a/frontend_tests/puppeteer_tests/realm-linkifier.ts +++ b/web/e2e-tests/realm-linkifier.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; async function test_add_linkifier(page: Page): Promise { await page.waitForSelector(".admin-linkifier-form", {visible: true}); diff --git a/frontend_tests/puppeteer_tests/realm-playground.ts b/web/e2e-tests/realm-playground.test.ts similarity index 98% rename from frontend_tests/puppeteer_tests/realm-playground.ts rename to web/e2e-tests/realm-playground.test.ts index d5168837d0..fbec9d30a5 100644 --- a/frontend_tests/puppeteer_tests/realm-playground.ts +++ b/web/e2e-tests/realm-playground.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; type Playground = { playground_name: string; diff --git a/frontend_tests/puppeteer_tests/settings.ts b/web/e2e-tests/settings.test.ts similarity index 99% rename from frontend_tests/puppeteer_tests/settings.ts rename to web/e2e-tests/settings.test.ts index 77258f3398..ed8792cd46 100644 --- a/frontend_tests/puppeteer_tests/settings.ts +++ b/web/e2e-tests/settings.test.ts @@ -3,7 +3,8 @@ import {strict as assert} from "assert"; import type {ElementHandle, Page} from "puppeteer"; import {test_credentials} from "../../var/puppeteer/test_credentials"; -import * as common from "../puppeteer_lib/common"; + +import * as common from "./lib/common"; const OUTGOING_WEBHOOK_BOT_TYPE = "3"; const GENERIC_BOT_TYPE = "1"; diff --git a/frontend_tests/puppeteer_tests/stars.ts b/web/e2e-tests/stars.test.ts similarity index 97% rename from frontend_tests/puppeteer_tests/stars.ts rename to web/e2e-tests/stars.test.ts index 388180010d..740bde70b8 100644 --- a/frontend_tests/puppeteer_tests/stars.ts +++ b/web/e2e-tests/stars.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; const message = "test star"; diff --git a/frontend_tests/puppeteer_tests/stream_create.ts b/web/e2e-tests/stream_create.test.ts similarity index 99% rename from frontend_tests/puppeteer_tests/stream_create.ts rename to web/e2e-tests/stream_create.test.ts index 2245b80303..14e8fd1e89 100644 --- a/frontend_tests/puppeteer_tests/stream_create.ts +++ b/web/e2e-tests/stream_create.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; async function user_row_selector(page: Page, name: string): Promise { const user_id = await common.get_user_id_from_name(page, name); diff --git a/frontend_tests/puppeteer_tests/subscribe_toggle.ts b/web/e2e-tests/subscribe_toggle.test.ts similarity index 97% rename from frontend_tests/puppeteer_tests/subscribe_toggle.ts rename to web/e2e-tests/subscribe_toggle.test.ts index 88bf65524c..0075a2d6c5 100644 --- a/frontend_tests/puppeteer_tests/subscribe_toggle.ts +++ b/web/e2e-tests/subscribe_toggle.test.ts @@ -1,6 +1,6 @@ import type {ElementHandle, Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; async function test_subscription_button(page: Page): Promise { const stream_selector = "[data-stream-name='Venice']"; diff --git a/frontend_tests/puppeteer_tests/user-deactivation.ts b/web/e2e-tests/user-deactivation.test.ts similarity index 99% rename from frontend_tests/puppeteer_tests/user-deactivation.ts rename to web/e2e-tests/user-deactivation.test.ts index 4244ab25cf..e949247a36 100644 --- a/frontend_tests/puppeteer_tests/user-deactivation.ts +++ b/web/e2e-tests/user-deactivation.test.ts @@ -2,7 +2,7 @@ import {strict as assert} from "assert"; import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; async function navigate_to_user_list(page: Page): Promise { const menu_selector = "#settings-dropdown"; diff --git a/frontend_tests/puppeteer_tests/user-status.ts b/web/e2e-tests/user-status.test.ts similarity index 98% rename from frontend_tests/puppeteer_tests/user-status.ts rename to web/e2e-tests/user-status.test.ts index 2541742423..9d5df5f6de 100644 --- a/frontend_tests/puppeteer_tests/user-status.ts +++ b/web/e2e-tests/user-status.test.ts @@ -1,6 +1,6 @@ import type {Page} from "puppeteer"; -import * as common from "../puppeteer_lib/common"; +import * as common from "./lib/common"; async function open_set_user_status_modal(page: Page): Promise { const menu_icon_selector = ".user_sidebar_entry:first-child .user-list-sidebar-menu-icon";