From cea1119423556359a5031982cb6304dea893eb08 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 22 Feb 2023 14:04:10 -0800 Subject: [PATCH] node_tests: Move to web/tests. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This lets us simplify the long-ish ‘../../static/js’ paths, and will remove the need for the ‘zrequire’ wrapper. Signed-off-by: Anders Kaseorg --- .eslintrc.json | 4 +- docs/overview/directory-structure.md | 2 +- docs/subsystems/events-system.md | 4 +- docs/subsystems/markdown.md | 2 +- docs/testing/testing-with-node.md | 18 +-- docs/tutorials/new-feature-tutorial.md | 8 +- package.json | 5 + tools/check-schemas | 2 +- tools/linter_lib/custom_check.py | 10 +- tools/node_lib/dump_fixtures.js | 2 +- tools/test-js-with-node | 26 ++-- .../activity.js => web/tests/activity.test.js | 28 ++-- .../tests/alert_words.test.js | 4 +- .../tests/alert_words_ui.test.js | 12 +- .../billing.js => web/tests/billing.test.js | 8 +- .../tests/billing_helpers.test.js | 12 +- .../tests/blueslip_stacktrace.test.js | 4 +- .../bot_data.js => web/tests/bot_data.test.js | 4 +- .../tests/browser_history.test.js | 8 +- .../tests/buddy_data.test.js | 12 +- .../tests/buddy_list.test.js | 12 +- .../channel.js => web/tests/channel.test.js | 10 +- .../tests/color_data.test.js | 4 +- .../tests/colorspace.test.js | 4 +- .../common.js => web/tests/common.test.js | 6 +- .../tests/components.test.js | 8 +- .../compose.js => web/tests/compose.test.js | 39 +++--- .../tests/compose_actions.test.js | 33 +++-- .../tests/compose_closed_ui.test.js | 12 +- .../tests/compose_fade.test.js | 4 +- .../tests/compose_pm_pill.test.js | 10 +- .../tests/compose_state.test.js | 6 +- .../tests/compose_ui.test.js | 14 +- .../tests/compose_validate.test.js | 19 ++- .../tests/compose_video.test.js | 17 ++- .../tests/composebox_typeahead.test.js | 20 +-- .../tests/copy_and_paste.test.js | 10 +- .../tests/deprecated_feature_notice.test.js | 4 +- .../dispatch.js => web/tests/dispatch.test.js | 129 +++++++++--------- .../tests/dispatch_subs.test.js | 29 ++-- .../drafts.js => web/tests/drafts.test.js | 12 +- .../tests/dropdown_list_widget.test.js | 12 +- .../echo.js => web/tests/echo.test.js | 20 +-- .../emoji.js => web/tests/emoji.test.js | 7 +- .../tests/emoji_picker.test.js | 4 +- .../tests/event_status.test.js | 8 +- .../example1.js => web/tests/example1.test.js | 8 +- .../example2.js => web/tests/example2.test.js | 4 +- .../example3.js => web/tests/example3.test.js | 6 +- .../example4.js => web/tests/example4.test.js | 14 +- .../example5.js => web/tests/example5.test.js | 22 +-- .../example6.js => web/tests/example6.test.js | 4 +- .../example7.js => web/tests/example7.test.js | 14 +- .../example8.js => web/tests/example8.test.js | 8 +- .../tests/fenced_code.test.js | 4 +- .../tests/fetch_status.test.js | 6 +- .../filter.js => web/tests/filter.test.js | 12 +- .../tests/fold_dict.test.js | 4 +- .../tests/gear_menu.test.js | 6 +- .../tests/hash_util.test.js | 4 +- .../tests/hashchange.test.js | 36 ++--- .../hotkey.js => web/tests/hotkey.test.js | 54 ++++---- .../i18n.js => web/tests/i18n.test.js | 14 +- .../tests/input_pill.test.js | 12 +- .../tests/internal_url.test.js | 4 +- .../tests/keydown_util.test.js | 6 +- .../lazy_set.js => web/tests/lazy_set.test.js | 6 +- .../tests}/lib/compose_banner.js | 5 +- .../node_tests => web/tests}/lib/events.js | 0 .../zjsunit => web/tests/lib}/handlebars.js | 0 .../zjsunit => web/tests/lib}/i18n.js | 0 .../zjsunit => web/tests/lib}/index.js | 30 ++-- .../tests/lib}/markdown_assert.js | 0 .../zjsunit => web/tests/lib}/mdiff.js | 0 .../zjsunit => web/tests/lib}/namespace.js | 11 +- .../zjsunit => web/tests/lib}/real_jquery.js | 0 .../zjsunit => web/tests/lib}/stub.js | 0 .../zjsunit => web/tests/lib}/test.js | 0 .../zjsunit => web/tests/lib}/zblueslip.js | 0 .../zjsunit => web/tests/lib}/zjquery.js | 0 .../tests/lib}/zjquery_element.js | 0 .../tests/lib}/zjquery_event.js | 0 .../zjsunit => web/tests/lib}/zpage_params.js | 0 .../lightbox.js => web/tests/lightbox.test.js | 14 +- .../tests/linkifiers.test.js | 6 +- .../tests/list_cursor.test.js | 8 +- .../tests/list_widget.test.js | 8 +- .../markdown.js => web/tests/markdown.test.js | 9 +- .../tests/markdown_parse.test.js | 4 +- .../tests/message_edit.test.js | 8 +- .../tests/message_events.test.js | 22 +-- .../tests/message_fetch.test.js | 26 ++-- .../tests/message_flags.test.js | 10 +- .../tests/message_list.test.js | 18 +-- .../tests/message_list_data.test.js | 6 +- .../tests/message_list_view.test.js | 12 +- .../tests/message_store.test.js | 12 +- .../tests/muted_users.test.js | 4 +- .../narrow.js => web/tests/narrow.test.js | 18 +-- .../tests/narrow_activate.test.js | 46 +++---- .../tests/narrow_local.test.js | 6 +- .../tests/narrow_state.test.js | 4 +- .../tests/narrow_unread.test.js | 8 +- .../tests/navbar_alerts.test.js | 6 +- .../tests/notifications.test.js | 8 +- .../password.js => web/tests/password.test.js | 4 +- .../tests/peer_data.test.js | 8 +- .../people.js => web/tests/people.test.js | 12 +- .../tests/people_errors.test.js | 8 +- .../tests/pill_typeahead.test.js | 10 +- .../tests/pm_conversations.test.js | 4 +- .../pm_list.js => web/tests/pm_list.test.js | 6 +- .../tests/pm_list_data.test.js | 8 +- .../tests/poll_widget.test.js | 10 +- .../popovers.js => web/tests/popovers.test.js | 20 +-- .../presence.js => web/tests/presence.test.js | 10 +- .../tests/reactions.test.js | 22 +-- .../tests/recent_senders.test.js | 8 +- .../tests/recent_topics.test.js | 42 +++--- .../reload.js => web/tests/reload.test.js | 4 +- .../tests/reload_state.test.js | 4 +- .../tests/rendered_markdown.test.js | 12 +- .../tests/resolved_topic.test.js | 4 +- .../rtl.js => web/tests/rtl.test.js | 6 +- .../schema.js => web/tests/schema.test.js | 4 +- .../tests/scroll_util.test.js | 6 +- .../tests/search_future.test.js | 18 +-- .../tests/search_now.test.js | 16 +-- .../tests/search_pill.test.js | 6 +- .../tests/search_suggestion_future.test.js | 10 +- .../tests/search_suggestion_now.test.js | 10 +- .../tests/server_events.test.js | 20 +-- .../tests/settings_bots.test.js | 8 +- .../tests/settings_config.test.js | 6 +- .../tests/settings_data.test.js | 6 +- .../tests/settings_emoji.test.js | 8 +- .../tests/settings_muted_topics.test.js | 10 +- .../tests/settings_muted_users.test.js | 10 +- .../tests/settings_org.test.js | 22 +-- .../tests/settings_profile_fields.test.js | 10 +- .../tests/settings_realm_domains.test.js | 10 +- .../tests/settings_user_groups_legacy.test.js | 26 ++-- .../spoilers.js => web/tests/spoilers.test.js | 6 +- .../tests/starred_messages.test.js | 12 +- .../stream_create_subscribers_data.test.js | 6 +- .../tests/stream_data.test.js | 8 +- .../tests/stream_edit.test.js | 5 +- .../tests/stream_events.test.js | 32 ++--- .../tests/stream_list.test.js | 20 +-- .../tests/stream_pill.test.js | 4 +- .../tests/stream_search.test.js | 12 +- .../tests/stream_settings_ui.test.js | 10 +- .../tests/stream_sort.test.js | 4 +- .../tests/stream_topic_history.test.js | 8 +- .../tests/submessage.test.js | 12 +- .../support.js => web/tests/support.test.js | 6 +- .../tests/templates.test.js | 2 +- .../tests}/templates/and.hbs | 0 .../tests}/templates/numberFormat.hbs | 0 .../node_tests => web/tests}/templates/or.hbs | 0 .../tests}/templates/rendered_markdown.hbs | 0 .../tests}/templates/tooltip_hotkey_hints.hbs | 0 .../tests/timerender.test.js | 10 +- .../tests/top_left_corner.test.js | 8 +- .../tests/topic_generator.test.js | 12 +- .../tests/topic_list_data.test.js | 12 +- .../transmit.js => web/tests/transmit.test.js | 16 +-- .../tests/typeahead.test.js | 4 +- .../tests/typeahead_helper.test.js | 8 +- .../tests/typing_data.test.js | 4 +- .../tests/typing_events.test.js | 8 +- .../tests/typing_status.test.js | 6 +- .../unread.js => web/tests/unread.test.js | 6 +- .../upgrade.js => web/tests/upgrade.test.js | 8 +- .../upload.js => web/tests/upload.test.js | 12 +- .../tests/user_events.test.js | 32 ++--- .../tests/user_group_pill.test.js | 4 +- .../tests/user_groups.test.js | 6 +- .../tests/user_pill.test.js | 6 +- .../tests/user_search.test.js | 18 +-- .../tests/user_status.test.js | 6 +- .../tests/user_topics.test.js | 11 +- .../util.js => web/tests/util.test.js | 4 +- .../vdom.js => web/tests/vdom.test.js | 6 +- .../watchdog.js => web/tests/watchdog.test.js | 4 +- .../tests/widgetize.test.js | 14 +- .../tests/zblueslip.test.js | 8 +- .../zjquery.js => web/tests/zjquery.test.js | 6 +- zerver/lib/mdiff.py | 2 +- zerver/tests/test_markdown.py | 2 +- 190 files changed, 990 insertions(+), 993 deletions(-) rename frontend_tests/node_tests/activity.js => web/tests/activity.test.js (96%) rename frontend_tests/node_tests/alert_words.js => web/tests/alert_words.test.js (98%) rename frontend_tests/node_tests/alert_words_ui.js => web/tests/alert_words_ui.test.js (92%) rename frontend_tests/node_tests/billing.js => web/tests/billing.test.js (96%) rename frontend_tests/node_tests/billing_helpers.js => web/tests/billing_helpers.test.js (96%) rename frontend_tests/node_tests/blueslip_stacktrace.js => web/tests/blueslip_stacktrace.test.js (94%) rename frontend_tests/node_tests/bot_data.js => web/tests/bot_data.test.js (98%) rename frontend_tests/node_tests/browser_history.js => web/tests/browser_history.test.js (91%) rename frontend_tests/node_tests/buddy_data.js => web/tests/buddy_data.test.js (97%) rename frontend_tests/node_tests/buddy_list.js => web/tests/buddy_list.test.js (94%) rename frontend_tests/node_tests/channel.js => web/tests/channel.test.js (97%) rename frontend_tests/node_tests/color_data.js => web/tests/color_data.test.js (89%) rename frontend_tests/node_tests/colorspace.js => web/tests/colorspace.test.js (91%) rename frontend_tests/node_tests/common.js => web/tests/common.test.js (97%) rename frontend_tests/node_tests/components.js => web/tests/components.test.js (97%) rename frontend_tests/node_tests/compose.js => web/tests/compose.test.js (96%) rename frontend_tests/node_tests/compose_actions.js => web/tests/compose_actions.test.js (94%) rename frontend_tests/node_tests/compose_closed_ui.js => web/tests/compose_closed_ui.test.js (90%) rename frontend_tests/node_tests/compose_fade.js => web/tests/compose_fade.test.js (95%) rename frontend_tests/node_tests/compose_pm_pill.js => web/tests/compose_pm_pill.test.js (95%) rename frontend_tests/node_tests/compose_state.js => web/tests/compose_state.test.js (88%) rename frontend_tests/node_tests/compose_ui.js => web/tests/compose_ui.test.js (98%) rename frontend_tests/node_tests/compose_validate.js => web/tests/compose_validate.test.js (98%) rename frontend_tests/node_tests/compose_video.js => web/tests/compose_video.test.js (95%) rename frontend_tests/node_tests/composebox_typeahead.js => web/tests/composebox_typeahead.test.js (99%) rename frontend_tests/node_tests/copy_and_paste.js => web/tests/copy_and_paste.test.js (97%) rename frontend_tests/node_tests/deprecated_feature_notice.js => web/tests/deprecated_feature_notice.test.js (90%) rename frontend_tests/node_tests/dispatch.js => web/tests/dispatch.test.js (91%) rename frontend_tests/node_tests/dispatch_subs.js => web/tests/dispatch_subs.test.js (90%) rename frontend_tests/node_tests/drafts.js => web/tests/drafts.test.js (98%) rename frontend_tests/node_tests/dropdown_list_widget.js => web/tests/dropdown_list_widget.test.js (95%) rename frontend_tests/node_tests/echo.js => web/tests/echo.test.js (94%) rename frontend_tests/node_tests/emoji.js => web/tests/emoji.test.js (97%) rename frontend_tests/node_tests/emoji_picker.js => web/tests/emoji_picker.test.js (97%) rename frontend_tests/node_tests/event_status.js => web/tests/event_status.test.js (98%) rename frontend_tests/node_tests/example1.js => web/tests/example1.test.js (91%) rename frontend_tests/node_tests/example2.js => web/tests/example2.test.js (96%) rename frontend_tests/node_tests/example3.js => web/tests/example3.test.js (94%) rename frontend_tests/node_tests/example4.js => web/tests/example4.test.js (91%) rename frontend_tests/node_tests/example5.js => web/tests/example5.test.js (85%) rename frontend_tests/node_tests/example6.js => web/tests/example6.test.js (95%) rename frontend_tests/node_tests/example7.js => web/tests/example7.test.js (92%) rename frontend_tests/node_tests/example8.js => web/tests/example8.test.js (96%) rename frontend_tests/node_tests/fenced_code.js => web/tests/fenced_code.test.js (94%) rename frontend_tests/node_tests/fetch_status.js => web/tests/fetch_status.test.js (96%) rename frontend_tests/node_tests/filter.js => web/tests/filter.test.js (99%) rename frontend_tests/node_tests/fold_dict.js => web/tests/fold_dict.test.js (95%) rename frontend_tests/node_tests/gear_menu.js => web/tests/gear_menu.test.js (95%) rename frontend_tests/node_tests/hash_util.js => web/tests/hash_util.test.js (98%) rename frontend_tests/node_tests/hashchange.js => web/tests/hashchange.test.js (90%) rename frontend_tests/node_tests/hotkey.js => web/tests/hotkey.test.js (92%) rename frontend_tests/node_tests/i18n.js => web/tests/i18n.test.js (93%) rename frontend_tests/node_tests/input_pill.js => web/tests/input_pill.test.js (98%) rename frontend_tests/node_tests/internal_url.js => web/tests/internal_url.test.js (94%) rename frontend_tests/node_tests/keydown_util.js => web/tests/keydown_util.test.js (92%) rename frontend_tests/node_tests/lazy_set.js => web/tests/lazy_set.test.js (79%) rename {frontend_tests/node_tests => web/tests}/lib/compose_banner.js (80%) rename {frontend_tests/node_tests => web/tests}/lib/events.js (100%) rename {frontend_tests/zjsunit => web/tests/lib}/handlebars.js (100%) rename {frontend_tests/zjsunit => web/tests/lib}/i18n.js (100%) rename {frontend_tests/zjsunit => web/tests/lib}/index.js (79%) rename {frontend_tests/zjsunit => web/tests/lib}/markdown_assert.js (100%) rename {frontend_tests/zjsunit => web/tests/lib}/mdiff.js (100%) rename {frontend_tests/zjsunit => web/tests/lib}/namespace.js (97%) rename {frontend_tests/zjsunit => web/tests/lib}/real_jquery.js (100%) rename {frontend_tests/zjsunit => web/tests/lib}/stub.js (100%) rename {frontend_tests/zjsunit => web/tests/lib}/test.js (100%) rename {frontend_tests/zjsunit => web/tests/lib}/zblueslip.js (100%) rename {frontend_tests/zjsunit => web/tests/lib}/zjquery.js (100%) rename {frontend_tests/zjsunit => web/tests/lib}/zjquery_element.js (100%) rename {frontend_tests/zjsunit => web/tests/lib}/zjquery_event.js (100%) rename {frontend_tests/zjsunit => web/tests/lib}/zpage_params.js (100%) rename frontend_tests/node_tests/lightbox.js => web/tests/lightbox.test.js (85%) rename frontend_tests/node_tests/linkifiers.js => web/tests/linkifiers.test.js (92%) rename frontend_tests/node_tests/list_cursor.js => web/tests/list_cursor.test.js (94%) rename frontend_tests/node_tests/list_widget.js => web/tests/list_widget.test.js (99%) rename frontend_tests/node_tests/markdown.js => web/tests/markdown.test.js (99%) rename frontend_tests/node_tests/markdown_parse.js => web/tests/markdown_parse.test.js (99%) rename frontend_tests/node_tests/message_edit.js => web/tests/message_edit.test.js (97%) rename frontend_tests/node_tests/message_events.js => web/tests/message_events.test.js (86%) rename frontend_tests/node_tests/message_fetch.js => web/tests/message_fetch.test.js (94%) rename frontend_tests/node_tests/message_flags.js => web/tests/message_flags.test.js (97%) rename frontend_tests/node_tests/message_list.js => web/tests/message_list.test.js (95%) rename frontend_tests/node_tests/message_list_data.js => web/tests/message_list_data.test.js (98%) rename frontend_tests/node_tests/message_list_view.js => web/tests/message_list_view.test.js (99%) rename frontend_tests/node_tests/message_store.js => web/tests/message_store.test.js (96%) rename frontend_tests/node_tests/muted_users.js => web/tests/muted_users.test.js (96%) rename frontend_tests/node_tests/narrow.js => web/tests/narrow.test.js (98%) rename frontend_tests/node_tests/narrow_activate.js => web/tests/narrow_activate.test.js (79%) rename frontend_tests/node_tests/narrow_local.js => web/tests/narrow_local.test.js (98%) rename frontend_tests/node_tests/narrow_state.js => web/tests/narrow_state.test.js (99%) rename frontend_tests/node_tests/narrow_unread.js => web/tests/narrow_unread.test.js (96%) rename frontend_tests/node_tests/navbar_alerts.js => web/tests/navbar_alerts.test.js (96%) rename frontend_tests/node_tests/notifications.js => web/tests/notifications.test.js (98%) rename frontend_tests/node_tests/password.js => web/tests/password.test.js (95%) rename frontend_tests/node_tests/peer_data.js => web/tests/peer_data.test.js (97%) rename frontend_tests/node_tests/people.js => web/tests/people.test.js (99%) rename frontend_tests/node_tests/people_errors.js => web/tests/people_errors.test.js (94%) rename frontend_tests/node_tests/pill_typeahead.js => web/tests/pill_typeahead.test.js (97%) rename frontend_tests/node_tests/pm_conversations.js => web/tests/pm_conversations.test.js (97%) rename frontend_tests/node_tests/pm_list.js => web/tests/pm_list.test.js (87%) rename frontend_tests/node_tests/pm_list_data.js => web/tests/pm_list_data.test.js (98%) rename frontend_tests/node_tests/poll_widget.js => web/tests/poll_widget.test.js (97%) rename frontend_tests/node_tests/popovers.js => web/tests/popovers.test.js (91%) rename frontend_tests/node_tests/presence.js => web/tests/presence.test.js (96%) rename frontend_tests/node_tests/reactions.js => web/tests/reactions.test.js (98%) rename frontend_tests/node_tests/recent_senders.js => web/tests/recent_senders.test.js (98%) rename frontend_tests/node_tests/recent_topics.js => web/tests/recent_topics.test.js (96%) rename frontend_tests/node_tests/reload.js => web/tests/reload.test.js (90%) rename frontend_tests/node_tests/reload_state.js => web/tests/reload_state.test.js (85%) rename frontend_tests/node_tests/rendered_markdown.js => web/tests/rendered_markdown.test.js (97%) rename frontend_tests/node_tests/resolved_topic.js => web/tests/resolved_topic.test.js (95%) rename frontend_tests/node_tests/rtl.js => web/tests/rtl.test.js (98%) rename frontend_tests/node_tests/schema.js => web/tests/schema.test.js (91%) rename frontend_tests/node_tests/scroll_util.js => web/tests/scroll_util.test.js (94%) rename frontend_tests/node_tests/search_future.js => web/tests/search_future.test.js (97%) rename frontend_tests/node_tests/search_now.js => web/tests/search_now.test.js (97%) rename frontend_tests/node_tests/search_pill.js => web/tests/search_pill.test.js (92%) rename frontend_tests/node_tests/search_suggestion_future.js => web/tests/search_suggestion_future.test.js (99%) rename frontend_tests/node_tests/search_suggestion_now.js => web/tests/search_suggestion_now.test.js (99%) rename frontend_tests/node_tests/server_events.js => web/tests/server_events.test.js (84%) rename frontend_tests/node_tests/settings_bots.js => web/tests/settings_bots.test.js (94%) rename frontend_tests/node_tests/settings_config.js => web/tests/settings_config.test.js (95%) rename frontend_tests/node_tests/settings_data.js => web/tests/settings_data.test.js (98%) rename frontend_tests/node_tests/settings_emoji.js => web/tests/settings_emoji.test.js (79%) rename frontend_tests/node_tests/settings_muted_topics.js => web/tests/settings_muted_topics.test.js (89%) rename frontend_tests/node_tests/settings_muted_users.js => web/tests/settings_muted_users.test.js (87%) rename frontend_tests/node_tests/settings_org.js => web/tests/settings_org.test.js (98%) rename frontend_tests/node_tests/settings_profile_fields.js => web/tests/settings_profile_fields.test.js (96%) rename frontend_tests/node_tests/settings_realm_domains.js => web/tests/settings_realm_domains.test.js (92%) rename frontend_tests/node_tests/settings_user_groups_legacy.js => web/tests/settings_user_groups_legacy.test.js (97%) rename frontend_tests/node_tests/spoilers.js => web/tests/spoilers.test.js (89%) rename frontend_tests/node_tests/starred_messages.js => web/tests/starred_messages.test.js (90%) rename frontend_tests/node_tests/stream_create_subscribers_data.js => web/tests/stream_create_subscribers_data.test.js (94%) rename frontend_tests/node_tests/stream_data.js => web/tests/stream_data.test.js (99%) rename frontend_tests/node_tests/stream_edit.js => web/tests/stream_edit.test.js (88%) rename frontend_tests/node_tests/stream_events.js => web/tests/stream_events.test.js (93%) rename frontend_tests/node_tests/stream_list.js => web/tests/stream_list.test.js (97%) rename frontend_tests/node_tests/stream_pill.js => web/tests/stream_pill.test.js (95%) rename frontend_tests/node_tests/stream_search.js => web/tests/stream_search.test.js (93%) rename frontend_tests/node_tests/stream_settings_ui.js => web/tests/stream_settings_ui.test.js (96%) rename frontend_tests/node_tests/stream_sort.js => web/tests/stream_sort.test.js (98%) rename frontend_tests/node_tests/stream_topic_history.js => web/tests/stream_topic_history.test.js (98%) rename frontend_tests/node_tests/submessage.js => web/tests/submessage.test.js (88%) rename frontend_tests/node_tests/support.js => web/tests/support.test.js (90%) rename frontend_tests/node_tests/templates.js => web/tests/templates.test.js (96%) rename {frontend_tests/node_tests => web/tests}/templates/and.hbs (100%) rename {frontend_tests/node_tests => web/tests}/templates/numberFormat.hbs (100%) rename {frontend_tests/node_tests => web/tests}/templates/or.hbs (100%) rename {frontend_tests/node_tests => web/tests}/templates/rendered_markdown.hbs (100%) rename {frontend_tests/node_tests => web/tests}/templates/tooltip_hotkey_hints.hbs (100%) rename frontend_tests/node_tests/timerender.js => web/tests/timerender.test.js (98%) rename frontend_tests/node_tests/top_left_corner.js => web/tests/top_left_corner.test.js (93%) rename frontend_tests/node_tests/topic_generator.js => web/tests/topic_generator.test.js (92%) rename frontend_tests/node_tests/topic_list_data.js => web/tests/topic_list_data.test.js (95%) rename frontend_tests/node_tests/transmit.js => web/tests/transmit.test.js (90%) rename frontend_tests/node_tests/typeahead.js => web/tests/typeahead.test.js (98%) rename frontend_tests/node_tests/typeahead_helper.js => web/tests/typeahead_helper.test.js (98%) rename frontend_tests/node_tests/typing_data.js => web/tests/typing_data.test.js (97%) rename frontend_tests/node_tests/typing_events.js => web/tests/typing_events.test.js (94%) rename frontend_tests/node_tests/typing_status.js => web/tests/typing_status.test.js (97%) rename frontend_tests/node_tests/unread.js => web/tests/unread.test.js (99%) rename frontend_tests/node_tests/upgrade.js => web/tests/upgrade.test.js (97%) rename frontend_tests/node_tests/upload.js => web/tests/upload.test.js (98%) rename frontend_tests/node_tests/user_events.js => web/tests/user_events.test.js (91%) rename frontend_tests/node_tests/user_group_pill.js => web/tests/user_group_pill.test.js (95%) rename frontend_tests/node_tests/user_groups.js => web/tests/user_groups.test.js (98%) rename frontend_tests/node_tests/user_pill.js => web/tests/user_pill.test.js (95%) rename frontend_tests/node_tests/user_search.js => web/tests/user_search.test.js (93%) rename frontend_tests/node_tests/user_status.js => web/tests/user_status.test.js (96%) rename frontend_tests/node_tests/user_topics.js => web/tests/user_topics.test.js (94%) rename frontend_tests/node_tests/util.js => web/tests/util.test.js (98%) rename frontend_tests/node_tests/vdom.js => web/tests/vdom.test.js (97%) rename frontend_tests/node_tests/watchdog.js => web/tests/watchdog.test.js (93%) rename frontend_tests/node_tests/widgetize.js => web/tests/widgetize.test.js (92%) rename frontend_tests/node_tests/zblueslip.js => web/tests/zblueslip.test.js (92%) rename frontend_tests/node_tests/zjquery.js => web/tests/zjquery.test.js (97%) diff --git a/.eslintrc.json b/.eslintrc.json index 015961eb0f..0d133150ba 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -125,7 +125,7 @@ }, "overrides": [ { - "files": ["frontend_tests/node_tests/**", "frontend_tests/zjsunit/**"], + "files": ["web/tests/**"], "rules": { "no-jquery/no-selector-prop": "off" } @@ -202,7 +202,7 @@ } }, { - "files": ["frontend_tests/**"], + "files": ["frontend_tests/**", "web/tests/**"], "globals": { "CSS": false, "document": false, diff --git a/docs/overview/directory-structure.md b/docs/overview/directory-structure.md index a902196f54..e53b863c53 100644 --- a/docs/overview/directory-structure.md +++ b/docs/overview/directory-structure.md @@ -77,7 +77,7 @@ templating systems. - `zerver/tests/` Backend tests. -- `frontend_tests/node_tests/` Node Frontend unit tests. +- `web/tests/` Node Frontend unit tests. - `frontend_tests/puppeteer_tests/` Puppeteer frontend integration tests. diff --git a/docs/subsystems/events-system.md b/docs/subsystems/events-system.md index 9574a041e5..d024ca159d 100644 --- a/docs/subsystems/events-system.md +++ b/docs/subsystems/events-system.md @@ -376,9 +376,9 @@ node test fixtures and our OpenAPI documentation. #### Node testing Once you've completed backend testing, be sure to add an example event -in `frontend_tests/node_tests/lib/events.js`, a test of the +in `web/tests/lib/events.js`, a test of the `server_events_dispatch.js` code for that event in -`frontend_tests/node_tests/dispatch.js`, and verify your example +`web/tests/dispatch.test.js`, and verify your example against the two versions of the schema that you declared above using `tools/check-schemas`. diff --git a/docs/subsystems/markdown.md b/docs/subsystems/markdown.md index 2b69522d96..92effadd0c 100644 --- a/docs/subsystems/markdown.md +++ b/docs/subsystems/markdown.md @@ -41,7 +41,7 @@ message is sent). As a result, we try to make sure that The Python-Markdown implementation is tested by `zerver/tests/test_markdown.py`, and the marked.js implementation and `markdown.contains_backend_only_syntax` are tested by -`frontend_tests/node_tests/markdown.js`. +`web/tests/markdown.test.js`. A shared set of fixed test data ("test fixtures") is present in `zerver/tests/fixtures/markdown_test_cases.json`, and is automatically used diff --git a/docs/testing/testing-with-node.md b/docs/testing/testing-with-node.md index 558733c345..23f077a761 100644 --- a/docs/testing/testing-with-node.md +++ b/docs/testing/testing-with-node.md @@ -17,8 +17,8 @@ whole suite is quite fast, it still saves time to run a single test by name when debugging something. The JS unit tests are written to work with node. You can find them -in `frontend_tests/node_tests`. Here is an example test from -`frontend_tests/node_tests/stream_data.js`: +in `web/tests`. Here is an example test from +`web/tests/stream_data.test.js`: ```js (function test_get_by_id() { @@ -40,12 +40,12 @@ in `frontend_tests/node_tests`. Here is an example test from The names of the node tests generally align with the names of the modules they test. If you modify a JS module in `web/src` you should -see if there are corresponding test in `frontend_tests/node_tests`. If +see if there are corresponding test in `web/tests`. If there are, you should strive to follow the patterns of the existing tests and add your own tests. A good first test to read is -[example1.js](https://github.com/zulip/zulip/blob/main/frontend_tests/node_tests/example1.js). +[example1.js](https://github.com/zulip/zulip/blob/main/web/tests/example1.test.js). (And then there are several other example files.) ## How the node tests work @@ -60,10 +60,10 @@ those slow down the tests a lot, and often don't add much value. Instead, the preferred model for our unit tests is to mock DOM manipulations (which in Zulip are almost exclusively done via `jQuery`) using a custom library -[zjquery](https://github.com/zulip/zulip/blob/main/frontend_tests/zjsunit/zjquery.js). +[zjquery](https://github.com/zulip/zulip/blob/main/web/tests/lib/zjquery.js). The -[unit test file](https://github.com/zulip/zulip/blob/main/frontend_tests/node_tests/zjquery.js) +[unit test file](https://github.com/zulip/zulip/blob/main/web/tests/zjquery.test.js) for `zjquery` is designed to be also serve as nice documentation for how to use `zjquery`, and is **highly recommended reading** for anyone working on or debugging the Zulip node tests. @@ -150,7 +150,7 @@ narrow_state.stream = function () { ## Creating new test modules The test runner (`index.js`) automatically runs all .js files in the -`frontend_tests/node_tests` directory, so you can simply start editing a file +`web/tests` directory, so you can simply start editing a file in that directory to create a new test. ## Coverage reports @@ -216,7 +216,7 @@ These instructions assume you're using the Vagrant development environment. 1. **Set the `Node.js interpreter path` to `/usr/local/bin/node`** 1. Hit `OK` 2 times to get back to the `Run/Debug Configurations` window. 1. Under `Working Directory` select the root `zulip` directory. - 1. Under `JavaScript file`, enter `frontend_tests/zjsunit/index.js` + 1. Under `JavaScript file`, enter `web/tests/lib/index.js` -- this is the root script for Zulip's node unit tests. Congratulations! You've now set up the integration. @@ -226,7 +226,7 @@ Congratulations! You've now set up the integration. To use Webstorm to debug a given node test file, do the following: 1. Under `Application parameters` choose the node test file that you - are trying to test (e.g. `frontend_tests/node_tests/message_store.js`). + are trying to test (e.g. `web/tests/message_store.test.js`). 1. Under `Path Mappings`, set `Project Root` to `/srv/zulip` (i.e. where the `zulip` Git repository is mounted in the Vagrant guest). 1. Use the WebStorm debugger; see [this overview][webstorm-debugging] diff --git a/docs/tutorials/new-feature-tutorial.md b/docs/tutorials/new-feature-tutorial.md index 27bb15db43..2a1e805001 100644 --- a/docs/tutorials/new-feature-tutorial.md +++ b/docs/tutorials/new-feature-tutorial.md @@ -62,7 +62,7 @@ organization in Zulip). The following files are involved in the process: - `frontend_tests/puppeteer_tests/admin.ts`: end-to-end tests for the organization admin settings pages. -- `frontend_tests/node_tests/dispatch.js` +- `web/tests/dispatch.test.js` **Documentation** @@ -145,7 +145,7 @@ or JavaScript/TypeScript/Python code that generates user-facing strings, be sure 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` -module are located in `frontend_tests/node_tests/`. For more +module are located in `web/tests/`. For more information on writing and running tests, see the [testing documentation](../testing/testing.md). @@ -668,11 +668,11 @@ frontend tests: [node-based unit tests](../testing/testing-with-node.md) and At the minimum, if you created a new function to update UI in `settings_org.js`, you will need to mock that function in -`frontend_tests/node_tests/dispatch.js`. Add the name of the UI +`web/tests/dispatch.test.js`. Add the name of the UI function you created to the following object with `noop` as the value: ```js -// frontend_tests/node_tests/dispatch.js +// web/tests/dispatch.test.js set_global('settings_org', { update_email_change_display: noop, diff --git a/package.json b/package.json index 8db4d3745e..70e53499fa 100644 --- a/package.json +++ b/package.json @@ -139,5 +139,10 @@ "repository": { "type": "git", "url": "https://github.com/zulip/zulip.git" + }, + "nyc": { + "exclude": [ + "**/node_modules/**" + ] } } diff --git a/tools/check-schemas b/tools/check-schemas index 21ad6dc657..9e954b1912 100755 --- a/tools/check-schemas +++ b/tools/check-schemas @@ -22,7 +22,7 @@ TOOLS_DIR = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.dirname(TOOLS_DIR)) ROOT_DIR = os.path.dirname(TOOLS_DIR) -EVENTS_JS = "frontend_tests/node_tests/lib/events.js" +EVENTS_JS = "web/tests/lib/events.js" # check for the venv from tools.lib import sanity_check diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py index e0888c4661..815ab3cdea 100644 --- a/tools/linter_lib/custom_check.py +++ b/tools/linter_lib/custom_check.py @@ -84,7 +84,7 @@ whitespace_rules: List["Rule"] = [ comma_whitespace_rule: List["Rule"] = [ { "pattern": ", {2,}[^#/ ]", - "exclude": {"zerver/tests", "frontend_tests/node_tests", "corporate/tests"}, + "exclude": {"zerver/tests", "web/tests", "corporate/tests"}, "description": "Remove multiple whitespaces after ','", "good_lines": ["foo(1, 2, 3)", "foo = bar # some inline comment"], "bad_lines": ["foo(1, 2, 3)", "foo(1, 2, 3)"], @@ -116,7 +116,7 @@ js_rules = RuleList( rules=[ { "pattern": "subject|SUBJECT", - "exclude": {"web/src/types.ts", "web/src/util.ts", "frontend_tests/"}, + "exclude": {"web/src/types.ts", "web/src/util.ts", "web/tests/"}, "exclude_pattern": "emails", "description": "avoid subject in JS code", "good_lines": ["topic_name"], @@ -139,7 +139,7 @@ js_rules = RuleList( "web/src/lightbox.js", "web/src/ui_report.ts", "web/src/dialog_widget.js", - "frontend_tests/", + "web/tests/", }, "description": "Setting HTML content with jQuery .html() can lead to XSS security bugs. Consider .text() or using rendered_foo as a variable name if content comes from Handlebars and thus is already sanitized.", }, @@ -150,7 +150,7 @@ js_rules = RuleList( { "pattern": r"""[.]text\(["'][a-zA-Z]""", "description": "Strings passed to $().text should be wrapped in $t() for internationalization", - "exclude": {"frontend_tests/node_tests/"}, + "exclude": {"web/tests/"}, }, { "pattern": r"ui.report_success\(", @@ -205,7 +205,7 @@ js_rules = RuleList( "exclude_pattern": r"(const |\S)style ?=", "description": "Avoid using the `style=` attribute; we prefer styling in CSS files", "exclude": { - "frontend_tests/node_tests/copy_and_paste.js", + "web/tests/copy_and_paste.test.js", }, "good_lines": ["#my-style {color: blue;}", "const style =", 'some_style = "test"'], "bad_lines": ['

Foo

', 'style = "color: blue;"'], diff --git a/tools/node_lib/dump_fixtures.js b/tools/node_lib/dump_fixtures.js index 9f620036bd..7f33a82e01 100644 --- a/tools/node_lib/dump_fixtures.js +++ b/tools/node_lib/dump_fixtures.js @@ -1,5 +1,5 @@ "use strict"; -const events = require("../../frontend_tests/node_tests/lib/events"); +const events = require("../../web/tests/lib/events"); console.info(JSON.stringify(events.fixtures, null, 4)); diff --git a/tools/test-js-with-node b/tools/test-js-with-node index e9eda08b7a..bb5ccec977 100755 --- a/tools/test-js-with-node +++ b/tools/test-js-with-node @@ -20,7 +20,7 @@ sanity_check.check_venv(__file__) import orjson from zulint.printer import BOLDRED, CYAN, ENDC, GREEN -INDEX_JS = os.path.join(ROOT_DIR, "frontend_tests/zjsunit/index.js") +INDEX_JS = os.path.join(ROOT_DIR, "web/tests/lib/index.js") NODE_COVERAGE_PATH = os.path.join(ROOT_DIR, "var/node-coverage/coverage-final.json") # Ideally, we wouldn't need this line, but it seems to be required to @@ -28,9 +28,9 @@ NODE_COVERAGE_PATH = os.path.join(ROOT_DIR, "var/node-coverage/coverage-final.js os.chdir(ROOT_DIR) USAGE = """ - tools/test-js-with-node - to run all tests - tools/test-js-with-node util.js activity.js - to run just a couple tests - tools/test-js-with-node --coverage - to generate coverage report + tools/test-js-with-node - to run all tests + tools/test-js-with-node util.test.js activity.test.js - to run just a couple tests + tools/test-js-with-node --coverage - to generate coverage report """ @@ -44,8 +44,6 @@ def make_set(files: List[str]) -> Set[str]: # We do not yet require 100% line coverage for these files: EXEMPT_FILES = make_set( [ - "frontend_tests/zjsunit/mdiff.js", - "frontend_tests/zjsunit/zjquery_element.js", "web/shared/src/poll_data.js", "web/src/about_zulip.js", "web/src/add_subscribers_pill.js", @@ -225,6 +223,8 @@ EXEMPT_FILES = make_set( "web/src/zform.js", "web/src/zulip.js", "web/src/zulip_test.js", + "web/tests/lib/mdiff.js", + "web/tests/lib/zjquery_element.js", ] ) @@ -288,10 +288,10 @@ def print_error(msg: str) -> None: def clean_file(orig_fn: str) -> str: fn = orig_fn - if not fn.endswith(".js"): - fn += ".js" - if "frontend_tests/" not in fn: - fn = os.path.join(ROOT_DIR, "frontend_tests", "node_tests", fn) + if not fn.endswith(".test.js"): + fn += ".test.js" + if "web/tests/" not in fn: + fn = os.path.join(ROOT_DIR, "web", "tests", fn) fn = os.path.abspath(fn) if not os.path.exists(fn): print(f"Cannot find {orig_fn} ({fn})") @@ -319,7 +319,7 @@ def run_tests_via_node_js() -> int: parallel = 1 files = individual_files else: - files = sorted(glob.glob(os.path.join(ROOT_DIR, "frontend_tests/node_tests/*.js"))) + files = sorted(glob.glob(os.path.join(ROOT_DIR, "web/tests/*.test.js"))) test_files = clean_files(files) @@ -394,13 +394,13 @@ def read_coverage() -> Any: def enforce_proper_coverage(coverage_json: Any) -> bool: all_js_files = { - *glob.glob("frontend_tests/node_tests/*.js"), - *glob.glob("frontend_tests/zjsunit/*.js"), *glob.glob("web/shared/src/*.js"), *glob.glob("web/shared/src/*.ts"), *glob.glob("web/src/*.js"), *glob.glob("web/src/*.ts"), *glob.glob("web/src/billing/*.js"), + *glob.glob("web/tests/*.js"), + *glob.glob("web/tests/lib/*.js"), } enforce_fully_covered = sorted(all_js_files - EXEMPT_FILES) diff --git a/frontend_tests/node_tests/activity.js b/web/tests/activity.test.js similarity index 96% rename from frontend_tests/node_tests/activity.js rename to web/tests/activity.test.js index 984e8c80a0..9a64d7557f 100644 --- a/frontend_tests/node_tests/activity.js +++ b/web/tests/activity.test.js @@ -2,11 +2,11 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, with_overrides, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); -const {page_params, user_settings} = require("../zjsunit/zpage_params"); +const {mock_esm, set_global, with_overrides, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); +const {page_params, user_settings} = require("./lib/zpage_params"); const $window_stub = $.create("window-stub"); set_global("to_$", () => $window_stub); @@ -18,15 +18,15 @@ const _document = { }, }; -const channel = mock_esm("../../web/src/channel"); -const compose_state = mock_esm("../../web/src/compose_state"); -const narrow = mock_esm("../../web/src/narrow"); -const padded_widget = mock_esm("../../web/src/padded_widget"); -const pm_list = mock_esm("../../web/src/pm_list"); -const popovers = mock_esm("../../web/src/popovers"); -const resize = mock_esm("../../web/src/resize"); -const scroll_util = mock_esm("../../web/src/scroll_util"); -const watchdog = mock_esm("../../web/src/watchdog"); +const channel = mock_esm("../src/channel"); +const compose_state = mock_esm("../src/compose_state"); +const narrow = mock_esm("../src/narrow"); +const padded_widget = mock_esm("../src/padded_widget"); +const pm_list = mock_esm("../src/pm_list"); +const popovers = mock_esm("../src/popovers"); +const resize = mock_esm("../src/resize"); +const scroll_util = mock_esm("../src/scroll_util"); +const watchdog = mock_esm("../src/watchdog"); set_global("document", _document); diff --git a/frontend_tests/node_tests/alert_words.js b/web/tests/alert_words.test.js similarity index 98% rename from frontend_tests/node_tests/alert_words.js rename to web/tests/alert_words.test.js index b5ee49fc9c..094124bb03 100644 --- a/frontend_tests/node_tests/alert_words.js +++ b/web/tests/alert_words.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); set_global("page_params", { is_spectator: false, diff --git a/frontend_tests/node_tests/alert_words_ui.js b/web/tests/alert_words_ui.test.js similarity index 92% rename from frontend_tests/node_tests/alert_words_ui.js rename to web/tests/alert_words_ui.test.js index d61a163d55..c62966272d 100644 --- a/frontend_tests/node_tests/alert_words_ui.js +++ b/web/tests/alert_words_ui.test.js @@ -2,12 +2,12 @@ const {strict: assert} = require("assert"); -const {$t} = require("../zjsunit/i18n"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {$t} = require("./lib/i18n"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); -const channel = mock_esm("../../web/src/channel"); +const channel = mock_esm("../src/channel"); const alert_words = zrequire("alert_words"); const alert_words_ui = zrequire("alert_words_ui"); @@ -20,7 +20,7 @@ const noop = () => {}; run_test("rerender_alert_words_ui", ({mock_template}) => { let list_widget_create_called = false; alert_words_ui.reset(); - const ListWidget = mock_esm("../../web/src/list_widget", { + const ListWidget = mock_esm("../src/list_widget", { modifier: noop, create(container, words, opts) { const alert_words = []; diff --git a/frontend_tests/node_tests/billing.js b/web/tests/billing.test.js similarity index 96% rename from frontend_tests/node_tests/billing.js rename to web/tests/billing.test.js index db3fd96046..ea2744cb2f 100644 --- a/frontend_tests/node_tests/billing.js +++ b/web/tests/billing.test.js @@ -5,16 +5,16 @@ const fs = require("fs"); const {JSDOM} = require("jsdom"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); const template = fs.readFileSync("templates/corporate/billing.html", "utf8"); const dom = new JSDOM(template, {pretendToBeVisual: true}); const document = dom.window.document; const location = set_global("location", {}); -const helpers = mock_esm("../../web/src/billing/helpers", { +const helpers = mock_esm("../src/billing/helpers", { set_tab() {}, }); diff --git a/frontend_tests/node_tests/billing_helpers.js b/web/tests/billing_helpers.test.js similarity index 96% rename from frontend_tests/node_tests/billing_helpers.js rename to web/tests/billing_helpers.test.js index 8ab378e4ea..e02012a0ba 100644 --- a/frontend_tests/node_tests/billing_helpers.js +++ b/web/tests/billing_helpers.test.js @@ -5,11 +5,11 @@ const fs = require("fs"); const {JSDOM} = require("jsdom"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const jQueryFactory = require("../zjsunit/real_jquery"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const jQueryFactory = require("./lib/real_jquery"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); const template = fs.readFileSync("templates/corporate/upgrade.html", "utf8"); const dom = new JSDOM(template, { @@ -19,7 +19,7 @@ const dom = new JSDOM(template, { const jquery = jQueryFactory(dom.window); const history = set_global("history", {}); -const loading = mock_esm("../../web/src/loading"); +const loading = mock_esm("../src/loading"); set_global("document", { title: "Zulip", }); diff --git a/frontend_tests/node_tests/blueslip_stacktrace.js b/web/tests/blueslip_stacktrace.test.js similarity index 94% rename from frontend_tests/node_tests/blueslip_stacktrace.js rename to web/tests/blueslip_stacktrace.test.js index 3192929728..81f22f521a 100644 --- a/frontend_tests/node_tests/blueslip_stacktrace.js +++ b/web/tests/blueslip_stacktrace.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const blueslip_stacktrace = zrequire("blueslip_stacktrace"); diff --git a/frontend_tests/node_tests/bot_data.js b/web/tests/bot_data.test.js similarity index 98% rename from frontend_tests/node_tests/bot_data.js rename to web/tests/bot_data.test.js index 6dc1105e01..857c55f588 100644 --- a/frontend_tests/node_tests/bot_data.js +++ b/web/tests/bot_data.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const bot_data = zrequire("bot_data"); diff --git a/frontend_tests/node_tests/browser_history.js b/web/tests/browser_history.test.js similarity index 91% rename from frontend_tests/node_tests/browser_history.js rename to web/tests/browser_history.test.js index d5a5f547b3..19dc8936c4 100644 --- a/frontend_tests/node_tests/browser_history.js +++ b/web/tests/browser_history.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {make_stub} = require("../zjsunit/stub"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); +const {zrequire} = require("./lib/namespace"); +const {make_stub} = require("./lib/stub"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); window.location.hash = "#bogus"; diff --git a/frontend_tests/node_tests/buddy_data.js b/web/tests/buddy_data.test.js similarity index 97% rename from frontend_tests/node_tests/buddy_data.js rename to web/tests/buddy_data.test.js index 95d886f11d..d26a932efa 100644 --- a/frontend_tests/node_tests/buddy_data.js +++ b/web/tests/buddy_data.test.js @@ -4,12 +4,12 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const {page_params, user_settings} = require("../zjsunit/zpage_params"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const {page_params, user_settings} = require("./lib/zpage_params"); -const timerender = mock_esm("../../web/src/timerender"); +const timerender = mock_esm("../src/timerender"); const compose_fade_helper = zrequire("compose_fade_helper"); const muted_users = zrequire("muted_users"); @@ -22,7 +22,7 @@ const user_status = zrequire("user_status"); const buddy_data = zrequire("buddy_data"); // The buddy_data module is mostly tested indirectly through -// activity.js, but we should feel free to add direct tests +// activity.test.js, but we should feel free to add direct tests // here. const selma = { diff --git a/frontend_tests/node_tests/buddy_list.js b/web/tests/buddy_list.test.js similarity index 94% rename from frontend_tests/node_tests/buddy_list.js rename to web/tests/buddy_list.test.js index 316d91301b..cce8d4f7e0 100644 --- a/frontend_tests/node_tests/buddy_list.js +++ b/web/tests/buddy_list.test.js @@ -4,13 +4,13 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); -const padded_widget = mock_esm("../../web/src/padded_widget"); -const message_viewport = mock_esm("../../web/src/message_viewport"); +const padded_widget = mock_esm("../src/padded_widget"); +const message_viewport = mock_esm("../src/message_viewport"); const people = zrequire("people"); const {BuddyList} = zrequire("buddy_list"); diff --git a/frontend_tests/node_tests/channel.js b/web/tests/channel.test.js similarity index 97% rename from frontend_tests/node_tests/channel.js rename to web/tests/channel.test.js index c39317aac1..428a7f094a 100644 --- a/frontend_tests/node_tests/channel.js +++ b/web/tests/channel.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_jquery, mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_jquery, mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const {page_params} = require("./lib/zpage_params"); const xhr_401 = { status: 401, @@ -13,7 +13,7 @@ const xhr_401 = { }; let login_to_access_shown = false; -mock_esm("../../web/src/spectators", { +mock_esm("../src/spectators", { login_to_access() { login_to_access_shown = true; }, diff --git a/frontend_tests/node_tests/color_data.js b/web/tests/color_data.test.js similarity index 89% rename from frontend_tests/node_tests/color_data.js rename to web/tests/color_data.test.js index b8595dd97b..61e18b222d 100644 --- a/frontend_tests/node_tests/color_data.js +++ b/web/tests/color_data.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const color_data = zrequire("color_data"); diff --git a/frontend_tests/node_tests/colorspace.js b/web/tests/colorspace.test.js similarity index 91% rename from frontend_tests/node_tests/colorspace.js rename to web/tests/colorspace.test.js index 91ac62f9bc..c4e79988e8 100644 --- a/frontend_tests/node_tests/colorspace.js +++ b/web/tests/colorspace.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const colorspace = zrequire("colorspace"); diff --git a/frontend_tests/node_tests/common.js b/web/tests/common.test.js similarity index 97% rename from frontend_tests/node_tests/common.js rename to web/tests/common.test.js index 54929b418f..e65999a30e 100644 --- a/frontend_tests/node_tests/common.js +++ b/web/tests/common.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); const noop = () => {}; diff --git a/frontend_tests/node_tests/components.js b/web/tests/components.test.js similarity index 97% rename from frontend_tests/node_tests/components.js rename to web/tests/components.test.js index f1ee25299b..4b6726fee2 100644 --- a/frontend_tests/node_tests/components.js +++ b/web/tests/components.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {$t} = require("../zjsunit/i18n"); -const {mock_jquery, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); +const {$t} = require("./lib/i18n"); +const {mock_jquery, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); let env; diff --git a/frontend_tests/node_tests/compose.js b/web/tests/compose.test.js similarity index 96% rename from frontend_tests/node_tests/compose.js rename to web/tests/compose.test.js index f33a7c6bcf..10297ad5a9 100644 --- a/frontend_tests/node_tests/compose.js +++ b/web/tests/compose.test.js @@ -4,14 +4,13 @@ const {strict: assert} = require("assert"); const MockDate = require("mockdate"); -const {$t} = require("../zjsunit/i18n"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); -const {page_params, user_settings} = require("../zjsunit/zpage_params"); - const {mock_banners} = require("./lib/compose_banner"); +const {$t} = require("./lib/i18n"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); +const {page_params, user_settings} = require("./lib/zpage_params"); const noop = () => {}; @@ -28,19 +27,19 @@ set_global( const fake_now = 555; -const channel = mock_esm("../../web/src/channel"); -const compose_actions = mock_esm("../../web/src/compose_actions"); -const compose_fade = mock_esm("../../web/src/compose_fade"); -const compose_pm_pill = mock_esm("../../web/src/compose_pm_pill"); -const loading = mock_esm("../../web/src/loading"); -const markdown = mock_esm("../../web/src/markdown"); -const reminder = mock_esm("../../web/src/reminder"); -const rendered_markdown = mock_esm("../../web/src/rendered_markdown"); -const resize = mock_esm("../../web/src/resize"); -const sent_messages = mock_esm("../../web/src/sent_messages"); -const server_events = mock_esm("../../web/src/server_events"); -const transmit = mock_esm("../../web/src/transmit"); -const upload = mock_esm("../../web/src/upload"); +const channel = mock_esm("../src/channel"); +const compose_actions = mock_esm("../src/compose_actions"); +const compose_fade = mock_esm("../src/compose_fade"); +const compose_pm_pill = mock_esm("../src/compose_pm_pill"); +const loading = mock_esm("../src/loading"); +const markdown = mock_esm("../src/markdown"); +const reminder = mock_esm("../src/reminder"); +const rendered_markdown = mock_esm("../src/rendered_markdown"); +const resize = mock_esm("../src/resize"); +const sent_messages = mock_esm("../src/sent_messages"); +const server_events = mock_esm("../src/server_events"); +const transmit = mock_esm("../src/transmit"); +const upload = mock_esm("../src/upload"); const compose_ui = zrequire("compose_ui"); const compose_banner = zrequire("compose_banner"); diff --git a/frontend_tests/node_tests/compose_actions.js b/web/tests/compose_actions.test.js similarity index 94% rename from frontend_tests/node_tests/compose_actions.js rename to web/tests/compose_actions.test.js index 132e1a8b08..428bc6cceb 100644 --- a/frontend_tests/node_tests/compose_actions.js +++ b/web/tests/compose_actions.test.js @@ -2,12 +2,11 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); - const {mock_banners} = require("./lib/compose_banner"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); const settings_config = zrequire("settings_config"); @@ -17,38 +16,38 @@ set_global("document", { to_$: () => $("document-stub"), }); -const channel = mock_esm("../../web/src/channel"); -const compose_fade = mock_esm("../../web/src/compose_fade", { +const channel = mock_esm("../src/channel"); +const compose_fade = mock_esm("../src/compose_fade", { clear_compose: noop, }); -const compose_pm_pill = mock_esm("../../web/src/compose_pm_pill"); -const compose_ui = mock_esm("../../web/src/compose_ui", { +const compose_pm_pill = mock_esm("../src/compose_pm_pill"); +const compose_ui = mock_esm("../src/compose_ui", { autosize_textarea: noop, is_full_size: () => false, }); -const hash_util = mock_esm("../../web/src/hash_util"); -const narrow_state = mock_esm("../../web/src/narrow_state", { +const hash_util = mock_esm("../src/hash_util"); +const narrow_state = mock_esm("../src/narrow_state", { set_compose_defaults: noop, }); -mock_esm("../../web/src/reload_state", { +mock_esm("../src/reload_state", { is_in_progress: () => false, }); -mock_esm("../../web/src/recent_topics_util", { +mock_esm("../src/recent_topics_util", { is_visible: noop, }); -mock_esm("../../web/src/drafts", { +mock_esm("../src/drafts", { update_draft: noop, }); -mock_esm("../../web/src/unread_ops", { +mock_esm("../src/unread_ops", { notify_server_message_read: noop, }); -mock_esm("../../web/src/message_lists", { +mock_esm("../src/message_lists", { current: { can_mark_messages_read: () => true, }, }); -mock_esm("../../web/src/resize", { +mock_esm("../src/resize", { reset_compose_message_max_height: noop, }); diff --git a/frontend_tests/node_tests/compose_closed_ui.js b/web/tests/compose_closed_ui.test.js similarity index 90% rename from frontend_tests/node_tests/compose_closed_ui.js rename to web/tests/compose_closed_ui.test.js index c5d1107e36..bd0e8cf068 100644 --- a/frontend_tests/node_tests/compose_closed_ui.js +++ b/web/tests/compose_closed_ui.test.js @@ -3,17 +3,17 @@ // Setup const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); -mock_esm("../../web/src/recent_topics_util", { +mock_esm("../src/recent_topics_util", { is_visible: () => false, }); const noop = () => {}; // Mocking and stubbing things set_global("document", "document-stub"); -const message_lists = mock_esm("../../web/src/message_lists"); +const message_lists = mock_esm("../src/message_lists"); function MessageListView() { return { maybe_rerender: noop, @@ -21,7 +21,7 @@ function MessageListView() { prepend: noop, }; } -mock_esm("../../web/src/message_list_view", { +mock_esm("../src/message_list_view", { MessageListView, }); // Code we're actually using/testing diff --git a/frontend_tests/node_tests/compose_fade.js b/web/tests/compose_fade.test.js similarity index 95% rename from frontend_tests/node_tests/compose_fade.js rename to web/tests/compose_fade.test.js index a08831a80c..3c01ea3907 100644 --- a/frontend_tests/node_tests/compose_fade.js +++ b/web/tests/compose_fade.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {mock_jquery, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_jquery, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); mock_jquery((selector) => { switch (selector) { diff --git a/frontend_tests/node_tests/compose_pm_pill.js b/web/tests/compose_pm_pill.test.js similarity index 95% rename from frontend_tests/node_tests/compose_pm_pill.js rename to web/tests/compose_pm_pill.test.js index 0b77e85ccc..252e466f94 100644 --- a/frontend_tests/node_tests/compose_pm_pill.js +++ b/web/tests/compose_pm_pill.test.js @@ -2,12 +2,12 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); -const compose_actions = mock_esm("../../web/src/compose_actions"); -const input_pill = mock_esm("../../web/src/input_pill"); +const compose_actions = mock_esm("../src/compose_actions"); +const input_pill = mock_esm("../src/input_pill"); const people = zrequire("people"); const compose_pm_pill = zrequire("compose_pm_pill"); diff --git a/frontend_tests/node_tests/compose_state.js b/web/tests/compose_state.test.js similarity index 88% rename from frontend_tests/node_tests/compose_state.js rename to web/tests/compose_state.test.js index f84c881911..c0d41394ea 100644 --- a/frontend_tests/node_tests/compose_state.js +++ b/web/tests/compose_state.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); -const compose_pm_pill = mock_esm("../../web/src/compose_pm_pill"); +const compose_pm_pill = mock_esm("../src/compose_pm_pill"); const compose_state = zrequire("compose_state"); diff --git a/frontend_tests/node_tests/compose_ui.js b/web/tests/compose_ui.test.js similarity index 98% rename from frontend_tests/node_tests/compose_ui.js rename to web/tests/compose_ui.test.js index 502f8b2d0e..d5cd9937e7 100644 --- a/frontend_tests/node_tests/compose_ui.js +++ b/web/tests/compose_ui.test.js @@ -4,24 +4,24 @@ const {strict: assert} = require("assert"); const autosize = require("autosize"); -const {$t} = require("../zjsunit/i18n"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {$t} = require("./lib/i18n"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); const noop = () => {}; set_global("navigator", {}); -mock_esm("../../web/src/message_lists", { +mock_esm("../src/message_lists", { current: {}, }); const compose_ui = zrequire("compose_ui"); const people = zrequire("people"); const user_status = zrequire("user_status"); -const hash_util = mock_esm("../../web/src/hash_util"); -const channel = mock_esm("../../web/src/channel"); +const hash_util = mock_esm("../src/hash_util"); +const channel = mock_esm("../src/channel"); const compose_actions = zrequire("compose_actions"); const message_lists = zrequire("message_lists"); const text_field_edit = mock_esm("text-field-edit"); diff --git a/frontend_tests/node_tests/compose_validate.js b/web/tests/compose_validate.test.js similarity index 98% rename from frontend_tests/node_tests/compose_validate.js rename to web/tests/compose_validate.test.js index bb682ea6c1..1debfc5308 100644 --- a/frontend_tests/node_tests/compose_validate.js +++ b/web/tests/compose_validate.test.js @@ -2,17 +2,16 @@ const {strict: assert} = require("assert"); -const {$t} = require("../zjsunit/i18n"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); - const {mock_banners} = require("./lib/compose_banner"); +const {$t} = require("./lib/i18n"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); -const channel = mock_esm("../../web/src/channel"); -const compose_actions = mock_esm("../../web/src/compose_actions"); +const channel = mock_esm("../src/channel"); +const compose_actions = mock_esm("../src/compose_actions"); const compose_banner = zrequire("compose_banner"); const compose_pm_pill = zrequire("compose_pm_pill"); @@ -22,7 +21,7 @@ const peer_data = zrequire("peer_data"); const people = zrequire("people"); const resolved_topic = zrequire("../shared/src/resolved_topic"); const settings_config = zrequire("settings_config"); -const settings_data = mock_esm("../../web/src/settings_data"); +const settings_data = mock_esm("../src/settings_data"); const stream_data = zrequire("stream_data"); const me = { diff --git a/frontend_tests/node_tests/compose_video.js b/web/tests/compose_video.test.js similarity index 95% rename from frontend_tests/node_tests/compose_video.js rename to web/tests/compose_video.test.js index 4798167fc3..73c4408c69 100644 --- a/frontend_tests/node_tests/compose_video.js +++ b/web/tests/compose_video.test.js @@ -2,17 +2,16 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, with_overrides, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); - const events = require("./lib/events"); +const {mock_esm, set_global, with_overrides, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); -const channel = mock_esm("../../web/src/channel"); -const compose_ui = mock_esm("../../web/src/compose_ui"); -const upload = mock_esm("../../web/src/upload"); -mock_esm("../../web/src/resize", { +const channel = mock_esm("../src/channel"); +const compose_ui = mock_esm("../src/compose_ui"); +const upload = mock_esm("../src/upload"); +mock_esm("../src/resize", { watch_manual_resize() {}, }); set_global("document", { diff --git a/frontend_tests/node_tests/composebox_typeahead.js b/web/tests/composebox_typeahead.test.js similarity index 99% rename from frontend_tests/node_tests/composebox_typeahead.js rename to web/tests/composebox_typeahead.test.js index bae794afc7..5ec2726367 100644 --- a/frontend_tests/node_tests/composebox_typeahead.js +++ b/web/tests/composebox_typeahead.test.js @@ -2,27 +2,27 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, with_overrides, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {user_settings} = require("../zjsunit/zpage_params"); +const {mock_esm, set_global, with_overrides, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {user_settings} = require("./lib/zpage_params"); const noop = () => {}; -const compose = mock_esm("../../web/src/compose", { +const compose = mock_esm("../src/compose", { finish: noop, }); -const compose_validate = mock_esm("../../web/src/compose_validate", { +const compose_validate = mock_esm("../src/compose_validate", { warn_for_text_overflow_when_tries_to_send: () => true, }); -const input_pill = mock_esm("../../web/src/input_pill"); -const message_user_ids = mock_esm("../../web/src/message_user_ids", { +const input_pill = mock_esm("../src/input_pill"); +const message_user_ids = mock_esm("../src/message_user_ids", { user_ids: () => [], }); -const stream_topic_history = mock_esm("../../web/src/stream_topic_history", { +const stream_topic_history = mock_esm("../src/stream_topic_history", { stream_has_topics: () => false, }); -const stream_topic_history_util = mock_esm("../../web/src/stream_topic_history_util"); +const stream_topic_history_util = mock_esm("../src/stream_topic_history_util"); let autosize_called; diff --git a/frontend_tests/node_tests/copy_and_paste.js b/web/tests/copy_and_paste.test.js similarity index 97% rename from frontend_tests/node_tests/copy_and_paste.js rename to web/tests/copy_and_paste.test.js index 71c54bffdb..85c16e37dd 100644 --- a/frontend_tests/node_tests/copy_and_paste.js +++ b/web/tests/copy_and_paste.test.js @@ -4,17 +4,17 @@ const {strict: assert} = require("assert"); const {JSDOM} = require("jsdom"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const jquery = require("../zjsunit/real_jquery"); -const {run_test} = require("../zjsunit/test"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const jquery = require("./lib/real_jquery"); +const {run_test} = require("./lib/test"); +const {page_params} = require("./lib/zpage_params"); const {window} = new JSDOM("

Hello world

"); const {document} = window; const $ = jquery(window); -const compose_ui = mock_esm("../../web/src/compose_ui"); +const compose_ui = mock_esm("../src/compose_ui"); set_global("document", document); const copy_and_paste = zrequire("copy_and_paste"); diff --git a/frontend_tests/node_tests/deprecated_feature_notice.js b/web/tests/deprecated_feature_notice.test.js similarity index 90% rename from frontend_tests/node_tests/deprecated_feature_notice.js rename to web/tests/deprecated_feature_notice.test.js index 03cc32b3f0..82f8978b55 100644 --- a/frontend_tests/node_tests/deprecated_feature_notice.js +++ b/web/tests/deprecated_feature_notice.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); set_global("navigator", { userAgent: "", diff --git a/frontend_tests/node_tests/dispatch.js b/web/tests/dispatch.test.js similarity index 91% rename from frontend_tests/node_tests/dispatch.js rename to web/tests/dispatch.test.js index d3ec47a118..a75e35dcdd 100644 --- a/frontend_tests/node_tests/dispatch.js +++ b/web/tests/dispatch.test.js @@ -2,21 +2,16 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, with_overrides, zrequire} = require("../zjsunit/namespace"); -const {make_stub} = require("../zjsunit/stub"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); -const { - page_params, - realm_user_settings_defaults, - user_settings, -} = require("../zjsunit/zpage_params"); +const events = require("./lib/events"); +const {mock_esm, set_global, with_overrides, zrequire} = require("./lib/namespace"); +const {make_stub} = require("./lib/stub"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); +const {page_params, realm_user_settings_defaults, user_settings} = require("./lib/zpage_params"); const noop = () => {}; -const events = require("./lib/events"); - const event_fixtures = events.fixtures; const test_message = events.test_message; const test_user = events.test_user; @@ -24,64 +19,64 @@ const typing_person1 = events.typing_person1; set_global("setTimeout", (func) => func()); -const activity = mock_esm("../../web/src/activity"); -const alert_words_ui = mock_esm("../../web/src/alert_words_ui"); -const attachments_ui = mock_esm("../../web/src/attachments_ui"); -const bot_data = mock_esm("../../web/src/bot_data"); -const compose_pm_pill = mock_esm("../../web/src/compose_pm_pill"); -const composebox_typeahead = mock_esm("../../web/src/composebox_typeahead"); -const dark_theme = mock_esm("../../web/src/dark_theme"); -const emoji_picker = mock_esm("../../web/src/emoji_picker"); -const hotspots = mock_esm("../../web/src/hotspots"); -const linkifiers = mock_esm("../../web/src/linkifiers"); -const message_events = mock_esm("../../web/src/message_events"); -const message_lists = mock_esm("../../web/src/message_lists"); -const muted_topics_ui = mock_esm("../../web/src/muted_topics_ui"); -const muted_users_ui = mock_esm("../../web/src/muted_users_ui"); -const notifications = mock_esm("../../web/src/notifications"); -const pm_list = mock_esm("../../web/src/pm_list"); -const reactions = mock_esm("../../web/src/reactions"); -const realm_icon = mock_esm("../../web/src/realm_icon"); -const realm_logo = mock_esm("../../web/src/realm_logo"); -const realm_playground = mock_esm("../../web/src/realm_playground"); -const reload = mock_esm("../../web/src/reload"); -const scroll_bar = mock_esm("../../web/src/scroll_bar"); -const settings_account = mock_esm("../../web/src/settings_account"); -const settings_bots = mock_esm("../../web/src/settings_bots"); -const settings_display = mock_esm("../../web/src/settings_display"); -const settings_emoji = mock_esm("../../web/src/settings_emoji"); -const settings_exports = mock_esm("../../web/src/settings_exports"); -const settings_invites = mock_esm("../../web/src/settings_invites"); -const settings_linkifiers = mock_esm("../../web/src/settings_linkifiers"); -const settings_playgrounds = mock_esm("../../web/src/settings_playgrounds"); -const settings_notifications = mock_esm("../../web/src/settings_notifications"); -const settings_org = mock_esm("../../web/src/settings_org"); -const settings_profile_fields = mock_esm("../../web/src/settings_profile_fields"); +const activity = mock_esm("../src/activity"); +const alert_words_ui = mock_esm("../src/alert_words_ui"); +const attachments_ui = mock_esm("../src/attachments_ui"); +const bot_data = mock_esm("../src/bot_data"); +const compose_pm_pill = mock_esm("../src/compose_pm_pill"); +const composebox_typeahead = mock_esm("../src/composebox_typeahead"); +const dark_theme = mock_esm("../src/dark_theme"); +const emoji_picker = mock_esm("../src/emoji_picker"); +const hotspots = mock_esm("../src/hotspots"); +const linkifiers = mock_esm("../src/linkifiers"); +const message_events = mock_esm("../src/message_events"); +const message_lists = mock_esm("../src/message_lists"); +const muted_topics_ui = mock_esm("../src/muted_topics_ui"); +const muted_users_ui = mock_esm("../src/muted_users_ui"); +const notifications = mock_esm("../src/notifications"); +const pm_list = mock_esm("../src/pm_list"); +const reactions = mock_esm("../src/reactions"); +const realm_icon = mock_esm("../src/realm_icon"); +const realm_logo = mock_esm("../src/realm_logo"); +const realm_playground = mock_esm("../src/realm_playground"); +const reload = mock_esm("../src/reload"); +const scroll_bar = mock_esm("../src/scroll_bar"); +const settings_account = mock_esm("../src/settings_account"); +const settings_bots = mock_esm("../src/settings_bots"); +const settings_display = mock_esm("../src/settings_display"); +const settings_emoji = mock_esm("../src/settings_emoji"); +const settings_exports = mock_esm("../src/settings_exports"); +const settings_invites = mock_esm("../src/settings_invites"); +const settings_linkifiers = mock_esm("../src/settings_linkifiers"); +const settings_playgrounds = mock_esm("../src/settings_playgrounds"); +const settings_notifications = mock_esm("../src/settings_notifications"); +const settings_org = mock_esm("../src/settings_org"); +const settings_profile_fields = mock_esm("../src/settings_profile_fields"); const settings_realm_user_settings_defaults = mock_esm( - "../../web/src/settings_realm_user_settings_defaults", + "../src/settings_realm_user_settings_defaults", ); -const settings_realm_domains = mock_esm("../../web/src/settings_realm_domains"); -const settings_streams = mock_esm("../../web/src/settings_streams"); -const settings_user_groups_legacy = mock_esm("../../web/src/settings_user_groups_legacy"); -const settings_users = mock_esm("../../web/src/settings_users"); -const stream_data = mock_esm("../../web/src/stream_data"); -const stream_events = mock_esm("../../web/src/stream_events"); -const stream_list = mock_esm("../../web/src/stream_list"); -const stream_settings_ui = mock_esm("../../web/src/stream_settings_ui"); -const stream_topic_history = mock_esm("../../web/src/stream_topic_history"); -const submessage = mock_esm("../../web/src/submessage"); -mock_esm("../../web/src/top_left_corner", { +const settings_realm_domains = mock_esm("../src/settings_realm_domains"); +const settings_streams = mock_esm("../src/settings_streams"); +const settings_user_groups_legacy = mock_esm("../src/settings_user_groups_legacy"); +const settings_users = mock_esm("../src/settings_users"); +const stream_data = mock_esm("../src/stream_data"); +const stream_events = mock_esm("../src/stream_events"); +const stream_list = mock_esm("../src/stream_list"); +const stream_settings_ui = mock_esm("../src/stream_settings_ui"); +const stream_topic_history = mock_esm("../src/stream_topic_history"); +const submessage = mock_esm("../src/submessage"); +mock_esm("../src/top_left_corner", { update_starred_count() {}, }); -const typing_events = mock_esm("../../web/src/typing_events"); -const ui = mock_esm("../../web/src/ui"); -const unread_ops = mock_esm("../../web/src/unread_ops"); -const user_events = mock_esm("../../web/src/user_events"); -const user_groups = mock_esm("../../web/src/user_groups"); -const user_group_edit = mock_esm("../../web/src/user_group_edit"); -const overlays = mock_esm("../../web/src/overlays"); -const user_groups_settings_ui = mock_esm("../../web/src/user_groups_settings_ui"); -mock_esm("../../web/src/giphy"); +const typing_events = mock_esm("../src/typing_events"); +const ui = mock_esm("../src/ui"); +const unread_ops = mock_esm("../src/unread_ops"); +const user_events = mock_esm("../src/user_events"); +const user_groups = mock_esm("../src/user_groups"); +const user_group_edit = mock_esm("../src/user_group_edit"); +const overlays = mock_esm("../src/overlays"); +const user_groups_settings_ui = mock_esm("../src/user_groups_settings_ui"); +mock_esm("../src/giphy"); const electron_bridge = set_global("electron_bridge", {}); @@ -735,7 +730,7 @@ run_test("submessage", ({override}) => { }); }); -// For subscriptions, see dispatch_subs.js +// For subscriptions, see dispatch_subs.test.js run_test("typing", ({override}) => { // Simulate that we are not typing. diff --git a/frontend_tests/node_tests/dispatch_subs.js b/web/tests/dispatch_subs.test.js similarity index 90% rename from frontend_tests/node_tests/dispatch_subs.js rename to web/tests/dispatch_subs.test.js index 43cdb2698d..98599f44e8 100644 --- a/frontend_tests/node_tests/dispatch_subs.js +++ b/web/tests/dispatch_subs.test.js @@ -2,26 +2,25 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {make_stub} = require("../zjsunit/stub"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const {page_params} = require("../zjsunit/zpage_params"); - const events = require("./lib/events"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {make_stub} = require("./lib/stub"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const {page_params} = require("./lib/zpage_params"); const event_fixtures = events.fixtures; const test_user = events.test_user; -const compose_fade = mock_esm("../../web/src/compose_fade"); -const message_lists = mock_esm("../../web/src/message_lists"); -const narrow_state = mock_esm("../../web/src/narrow_state"); -const overlays = mock_esm("../../web/src/overlays"); -const settings_org = mock_esm("../../web/src/settings_org"); -const settings_streams = mock_esm("../../web/src/settings_streams"); -const stream_events = mock_esm("../../web/src/stream_events"); -const stream_list = mock_esm("../../web/src/stream_list"); -const stream_settings_ui = mock_esm("../../web/src/stream_settings_ui"); +const compose_fade = mock_esm("../src/compose_fade"); +const message_lists = mock_esm("../src/message_lists"); +const narrow_state = mock_esm("../src/narrow_state"); +const overlays = mock_esm("../src/overlays"); +const settings_org = mock_esm("../src/settings_org"); +const settings_streams = mock_esm("../src/settings_streams"); +const stream_events = mock_esm("../src/stream_events"); +const stream_list = mock_esm("../src/stream_list"); +const stream_settings_ui = mock_esm("../src/stream_settings_ui"); message_lists.current = {}; const peer_data = zrequire("peer_data"); diff --git a/frontend_tests/node_tests/drafts.js b/web/tests/drafts.test.js similarity index 98% rename from frontend_tests/node_tests/drafts.js rename to web/tests/drafts.test.js index 512c8b72d2..d237b14028 100644 --- a/frontend_tests/node_tests/drafts.js +++ b/web/tests/drafts.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire, with_overrides} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {user_settings} = require("../zjsunit/zpage_params"); +const {mock_esm, set_global, zrequire, with_overrides} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {user_settings} = require("./lib/zpage_params"); const blueslip = zrequire("blueslip"); const compose_pm_pill = zrequire("compose_pm_pill"); @@ -29,10 +29,10 @@ set_global("setTimeout", (f, delay) => { assert.equal(delay, setTimeout_delay); f(); }); -mock_esm("../../web/src/markdown", { +mock_esm("../src/markdown", { apply_markdown: noop, }); -mock_esm("../../web/src/overlays", { +mock_esm("../src/overlays", { open_overlay: noop, }); diff --git a/frontend_tests/node_tests/dropdown_list_widget.js b/web/tests/dropdown_list_widget.test.js similarity index 95% rename from frontend_tests/node_tests/dropdown_list_widget.js rename to web/tests/dropdown_list_widget.test.js index 66a38e88a6..b9330d1c8e 100644 --- a/frontend_tests/node_tests/dropdown_list_widget.js +++ b/web/tests/dropdown_list_widget.test.js @@ -2,14 +2,14 @@ const {strict: assert} = require("assert"); -const {$t} = require("../zjsunit/i18n"); -const {mock_esm, zrequire, set_global} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); +const {$t} = require("./lib/i18n"); +const {mock_esm, zrequire, set_global} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); const noop = () => {}; -mock_esm("../../web/src/list_widget", { +mock_esm("../src/list_widget", { create: () => ({init: noop}), }); diff --git a/frontend_tests/node_tests/echo.js b/web/tests/echo.test.js similarity index 94% rename from frontend_tests/node_tests/echo.js rename to web/tests/echo.test.js index 49b910aba3..a033b048b7 100644 --- a/frontend_tests/node_tests/echo.js +++ b/web/tests/echo.test.js @@ -4,28 +4,28 @@ const {strict: assert} = require("assert"); const MockDate = require("mockdate"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {make_stub} = require("../zjsunit/stub"); -const {run_test} = require("../zjsunit/test"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {make_stub} = require("./lib/stub"); +const {run_test} = require("./lib/test"); +const {page_params} = require("./lib/zpage_params"); -const markdown = mock_esm("../../web/src/markdown"); -const message_lists = mock_esm("../../web/src/message_lists"); -const notifications = mock_esm("../../web/src/notifications"); +const markdown = mock_esm("../src/markdown"); +const message_lists = mock_esm("../src/message_lists"); +const notifications = mock_esm("../src/notifications"); let disparities = []; -mock_esm("../../web/src/ui", { +mock_esm("../src/ui", { show_failed_message_success() {}, }); -mock_esm("../../web/src/sent_messages", { +mock_esm("../src/sent_messages", { mark_disparity(local_id) { disparities.push(local_id); }, }); -const message_store = mock_esm("../../web/src/message_store", { +const message_store = mock_esm("../src/message_store", { get: () => ({failed_request: true}), update_booleans() {}, diff --git a/frontend_tests/node_tests/emoji.js b/web/tests/emoji.test.js similarity index 97% rename from frontend_tests/node_tests/emoji.js rename to web/tests/emoji.test.js index e6aa9eb84e..9186d480c8 100644 --- a/frontend_tests/node_tests/emoji.js +++ b/web/tests/emoji.test.js @@ -2,13 +2,12 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const events = require("./lib/events"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const emoji_codes = zrequire("../../static/generated/emoji/emoji_codes.json"); -const events = require("./lib/events"); - const emoji = zrequire("emoji"); const realm_emoji = events.test_realm_emojis; diff --git a/frontend_tests/node_tests/emoji_picker.js b/web/tests/emoji_picker.test.js similarity index 97% rename from frontend_tests/node_tests/emoji_picker.js rename to web/tests/emoji_picker.test.js index f915cbf2e7..5680590217 100644 --- a/frontend_tests/node_tests/emoji_picker.js +++ b/web/tests/emoji_picker.test.js @@ -4,8 +4,8 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const emoji = zrequire("emoji"); const emoji_picker = zrequire("emoji_picker"); diff --git a/frontend_tests/node_tests/event_status.js b/web/tests/event_status.test.js similarity index 98% rename from frontend_tests/node_tests/event_status.js rename to web/tests/event_status.test.js index bf080e7ae3..a3f5e33edf 100644 --- a/frontend_tests/node_tests/event_status.js +++ b/web/tests/event_status.test.js @@ -2,12 +2,12 @@ const {strict: assert} = require("assert"); -const {set_global, zrequire, mock_esm} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {set_global, zrequire, mock_esm} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); const event_status = zrequire("billing/event_status"); -const helpers = mock_esm("../../web/src/billing/helpers"); +const helpers = mock_esm("../src/billing/helpers"); run_test("initialize_retry_with_another_card_link_click_handler", ({override}) => { override(helpers, "create_ajax_request", (url, form_name, ignored_inputs, method, callback) => { diff --git a/frontend_tests/node_tests/example1.js b/web/tests/example1.test.js similarity index 91% rename from frontend_tests/node_tests/example1.js rename to web/tests/example1.test.js index 7e5171e2a2..d794fd22e8 100644 --- a/frontend_tests/node_tests/example1.js +++ b/web/tests/example1.test.js @@ -9,8 +9,8 @@ // become clear as you keep reading. const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); // We will use our special zrequire helper to import the // Zulip code. We use zrequire instead of require, @@ -41,7 +41,7 @@ const isaac = { // The `people`object is a very fundamental object in the // Zulip app. You can learn a lot more about it by reading -// the tests in people.js in the same directory as this file. +// the tests in people.test.js in the same directory as this file. // Let's exercise the code and use assert to verify it works! assert.ok(!people.is_known_user_id(isaac.user_id)); @@ -70,4 +70,4 @@ run_test("verify stream_data persists stream color", () => { const sub = stream_data.get_sub_by_name("Denmark"); assert.equal(sub.color, "blue"); }); -// See example2.js in this directory. +// See example2.test.js in this directory. diff --git a/frontend_tests/node_tests/example2.js b/web/tests/example2.test.js similarity index 96% rename from frontend_tests/node_tests/example2.js rename to web/tests/example2.test.js index 05d0154052..c304130849 100644 --- a/frontend_tests/node_tests/example2.js +++ b/web/tests/example2.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); // Hopefully the basic patterns for testing data-oriented modules // are starting to become apparent. To reinforce that, we will present diff --git a/frontend_tests/node_tests/example3.js b/web/tests/example3.test.js similarity index 94% rename from frontend_tests/node_tests/example3.js rename to web/tests/example3.test.js index 3452370c68..50365c1c2c 100644 --- a/frontend_tests/node_tests/example3.js +++ b/web/tests/example3.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const {page_params} = require("../zjsunit/zpage_params"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const {page_params} = require("./lib/zpage_params"); // In the Zulip app you can narrow your message stream by topic, by // sender, by PM recipient, by search keywords, etc. We will discuss diff --git a/frontend_tests/node_tests/example4.js b/web/tests/example4.test.js similarity index 91% rename from frontend_tests/node_tests/example4.js rename to web/tests/example4.test.js index 9c744e1e5e..cee4d695a1 100644 --- a/frontend_tests/node_tests/example4.js +++ b/web/tests/example4.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); /* @@ -23,7 +23,7 @@ const {run_test} = require("../zjsunit/test"); you are interested, all of these objects have test suites that have 100% line coverage on the modules that implement those objects. For example, you can look - at people.js in this directory for more tests on the + at people.test.js in this directory for more tests on the people object. We can quickly review some testing concepts: @@ -55,10 +55,10 @@ const {run_test} = require("../zjsunit/test"); */ // We are going to use mock versions of some of our libraries. -const activity = mock_esm("../../web/src/activity"); -const message_live_update = mock_esm("../../web/src/message_live_update"); -const pm_list = mock_esm("../../web/src/pm_list"); -const settings_users = mock_esm("../../web/src/settings_users"); +const activity = mock_esm("../src/activity"); +const message_live_update = mock_esm("../src/message_live_update"); +const pm_list = mock_esm("../src/pm_list"); +const settings_users = mock_esm("../src/settings_users"); // Use real versions of these modules. const people = zrequire("people"); diff --git a/frontend_tests/node_tests/example5.js b/web/tests/example5.test.js similarity index 85% rename from frontend_tests/node_tests/example5.js rename to web/tests/example5.test.js index 14ff97d0ec..acfeb84a83 100644 --- a/frontend_tests/node_tests/example5.js +++ b/web/tests/example5.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); /* Our test from an earlier example verifies that the update events @@ -20,15 +20,15 @@ const {run_test} = require("../zjsunit/test"); // First we tell the compiler to skip certain modules and just // replace them with {}. -const huddle_data = mock_esm("../../web/src/huddle_data"); -const message_lists = mock_esm("../../web/src/message_lists"); -const message_util = mock_esm("../../web/src/message_util"); -const notifications = mock_esm("../../web/src/notifications"); -const pm_list = mock_esm("../../web/src/pm_list"); -const recent_topics_data = mock_esm("../../web/src/recent_topics_data"); -const stream_list = mock_esm("../../web/src/stream_list"); -const unread_ops = mock_esm("../../web/src/unread_ops"); -const unread_ui = mock_esm("../../web/src/unread_ui"); +const huddle_data = mock_esm("../src/huddle_data"); +const message_lists = mock_esm("../src/message_lists"); +const message_util = mock_esm("../src/message_util"); +const notifications = mock_esm("../src/notifications"); +const pm_list = mock_esm("../src/pm_list"); +const recent_topics_data = mock_esm("../src/recent_topics_data"); +const stream_list = mock_esm("../src/stream_list"); +const unread_ops = mock_esm("../src/unread_ops"); +const unread_ui = mock_esm("../src/unread_ui"); message_lists.home = {}; diff --git a/frontend_tests/node_tests/example6.js b/web/tests/example6.test.js similarity index 95% rename from frontend_tests/node_tests/example6.js rename to web/tests/example6.test.js index a73d781d8d..ec8ef0b940 100644 --- a/frontend_tests/node_tests/example6.js +++ b/web/tests/example6.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {make_stub} = require("../zjsunit/stub"); -const {run_test} = require("../zjsunit/test"); +const {make_stub} = require("./lib/stub"); +const {run_test} = require("./lib/test"); /* The previous example was a bit extreme. Generally we just diff --git a/frontend_tests/node_tests/example7.js b/web/tests/example7.test.js similarity index 92% rename from frontend_tests/node_tests/example7.js rename to web/tests/example7.test.js index d94e3519e2..9e7c18697a 100644 --- a/frontend_tests/node_tests/example7.js +++ b/web/tests/example7.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); /* @@ -49,11 +49,11 @@ const {run_test} = require("../zjsunit/test"); value.) */ -const channel = mock_esm("../../web/src/channel"); -const message_lists = mock_esm("../../web/src/message_lists"); -const message_viewport = mock_esm("../../web/src/message_viewport"); -const notifications = mock_esm("../../web/src/notifications"); -const unread_ui = mock_esm("../../web/src/unread_ui"); +const channel = mock_esm("../src/channel"); +const message_lists = mock_esm("../src/message_lists"); +const message_viewport = mock_esm("../src/message_viewport"); +const notifications = mock_esm("../src/notifications"); +const unread_ui = mock_esm("../src/unread_ui"); message_lists.current = {}; message_lists.home = {}; diff --git a/frontend_tests/node_tests/example8.js b/web/tests/example8.test.js similarity index 96% rename from frontend_tests/node_tests/example8.js rename to web/tests/example8.test.js index 68a7e41063..7b2057b619 100644 --- a/frontend_tests/node_tests/example8.js +++ b/web/tests/example8.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); /* Until now, we had seen various testing techniques, learned diff --git a/frontend_tests/node_tests/fenced_code.js b/web/tests/fenced_code.test.js similarity index 94% rename from frontend_tests/node_tests/fenced_code.js rename to web/tests/fenced_code.test.js index dbd42db3de..35ceecc854 100644 --- a/frontend_tests/node_tests/fenced_code.js +++ b/web/tests/fenced_code.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const fenced_code = zrequire("../shared/src/fenced_code"); diff --git a/frontend_tests/node_tests/fetch_status.js b/web/tests/fetch_status.test.js similarity index 96% rename from frontend_tests/node_tests/fetch_status.js rename to web/tests/fetch_status.test.js index 8984254e2c..7c4bc8746f 100644 --- a/frontend_tests/node_tests/fetch_status.js +++ b/web/tests/fetch_status.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); -mock_esm("../../web/src/message_scroll", { +mock_esm("../src/message_scroll", { hide_loading_older() {}, show_loading_older() {}, diff --git a/frontend_tests/node_tests/filter.js b/web/tests/filter.test.js similarity index 99% rename from frontend_tests/node_tests/filter.js rename to web/tests/filter.test.js index 03f43719a5..9af76f8d1a 100644 --- a/frontend_tests/node_tests/filter.js +++ b/web/tests/filter.test.js @@ -4,13 +4,13 @@ const {strict: assert} = require("assert"); const {parseOneAddress} = require("email-addresses"); -const {mock_esm, with_overrides, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, with_overrides, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); -const message_store = mock_esm("../../web/src/message_store"); +const message_store = mock_esm("../src/message_store"); const resolved_topic = zrequire("../shared/src/resolved_topic"); const stream_data = zrequire("stream_data"); diff --git a/frontend_tests/node_tests/fold_dict.js b/web/tests/fold_dict.test.js similarity index 95% rename from frontend_tests/node_tests/fold_dict.js rename to web/tests/fold_dict.test.js index 8e2ec4528a..ea23dc216c 100644 --- a/frontend_tests/node_tests/fold_dict.js +++ b/web/tests/fold_dict.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const {FoldDict} = zrequire("fold_dict"); diff --git a/frontend_tests/node_tests/gear_menu.js b/web/tests/gear_menu.test.js similarity index 95% rename from frontend_tests/node_tests/gear_menu.js rename to web/tests/gear_menu.test.js index d6c1f6ea5a..9213661ca3 100644 --- a/frontend_tests/node_tests/gear_menu.js +++ b/web/tests/gear_menu.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const {page_params} = require("../zjsunit/zpage_params"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const {page_params} = require("./lib/zpage_params"); const gear_menu = zrequire("gear_menu"); diff --git a/frontend_tests/node_tests/hash_util.js b/web/tests/hash_util.test.js similarity index 98% rename from frontend_tests/node_tests/hash_util.js rename to web/tests/hash_util.test.js index a2cb7506df..aaa7d36dff 100644 --- a/frontend_tests/node_tests/hash_util.js +++ b/web/tests/hash_util.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const hash_util = zrequire("hash_util"); const stream_data = zrequire("stream_data"); diff --git a/frontend_tests/node_tests/hashchange.js b/web/tests/hashchange.test.js similarity index 90% rename from frontend_tests/node_tests/hashchange.js rename to web/tests/hashchange.test.js index e173952fbc..c33cee784a 100644 --- a/frontend_tests/node_tests/hashchange.js +++ b/web/tests/hashchange.test.js @@ -2,33 +2,33 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); -const {user_settings} = require("../zjsunit/zpage_params"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); +const {user_settings} = require("./lib/zpage_params"); let $window_stub; set_global("to_$", () => $window_stub); -mock_esm("../../web/src/search", { +mock_esm("../src/search", { update_button_visibility() {}, }); set_global("document", "document-stub"); const history = set_global("history", {}); -const admin = mock_esm("../../web/src/admin"); -const drafts = mock_esm("../../web/src/drafts"); -const info_overlay = mock_esm("../../web/src/info_overlay"); -const message_viewport = mock_esm("../../web/src/message_viewport"); -const narrow = mock_esm("../../web/src/narrow"); -const overlays = mock_esm("../../web/src/overlays"); -const recent_topics_ui = mock_esm("../../web/src/recent_topics_ui"); -const settings = mock_esm("../../web/src/settings"); -const stream_settings_ui = mock_esm("../../web/src/stream_settings_ui"); -const ui_util = mock_esm("../../web/src/ui_util"); -const ui_report = mock_esm("../../web/src/ui_report"); -mock_esm("../../web/src/top_left_corner", { +const admin = mock_esm("../src/admin"); +const drafts = mock_esm("../src/drafts"); +const info_overlay = mock_esm("../src/info_overlay"); +const message_viewport = mock_esm("../src/message_viewport"); +const narrow = mock_esm("../src/narrow"); +const overlays = mock_esm("../src/overlays"); +const recent_topics_ui = mock_esm("../src/recent_topics_ui"); +const settings = mock_esm("../src/settings"); +const stream_settings_ui = mock_esm("../src/stream_settings_ui"); +const ui_util = mock_esm("../src/ui_util"); +const ui_report = mock_esm("../src/ui_report"); +mock_esm("../src/top_left_corner", { handle_narrow_deactivated() {}, }); set_global("favicon", {}); diff --git a/frontend_tests/node_tests/hotkey.js b/web/tests/hotkey.test.js similarity index 92% rename from frontend_tests/node_tests/hotkey.js rename to web/tests/hotkey.test.js index bed835fe32..f694bffd82 100644 --- a/frontend_tests/node_tests/hotkey.js +++ b/web/tests/hotkey.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, with_overrides, zrequire} = require("../zjsunit/namespace"); -const {make_stub} = require("../zjsunit/stub"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, set_global, with_overrides, zrequire} = require("./lib/namespace"); +const {make_stub} = require("./lib/stub"); +const {run_test} = require("./lib/test"); // Important note on these tests: @@ -31,24 +31,24 @@ set_global("navigator", { // jQuery stuff should go away if we make an initialize() method. set_global("document", "document-stub"); -const browser_history = mock_esm("../../web/src/browser_history"); -const compose_actions = mock_esm("../../web/src/compose_actions"); -const condense = mock_esm("../../web/src/condense"); -const drafts = mock_esm("../../web/src/drafts"); -const emoji_picker = mock_esm("../../web/src/emoji_picker", { +const browser_history = mock_esm("../src/browser_history"); +const compose_actions = mock_esm("../src/compose_actions"); +const condense = mock_esm("../src/condense"); +const drafts = mock_esm("../src/drafts"); +const emoji_picker = mock_esm("../src/emoji_picker", { reactions_popped: () => false, }); -const gear_menu = mock_esm("../../web/src/gear_menu", { +const gear_menu = mock_esm("../src/gear_menu", { is_open: () => false, }); -const lightbox = mock_esm("../../web/src/lightbox"); -const list_util = mock_esm("../../web/src/list_util"); -const message_edit = mock_esm("../../web/src/message_edit"); -const message_lists = mock_esm("../../web/src/message_lists"); -const muted_topics_ui = mock_esm("../../web/src/muted_topics_ui"); -const narrow = mock_esm("../../web/src/narrow"); -const navigate = mock_esm("../../web/src/navigate"); -const overlays = mock_esm("../../web/src/overlays", { +const lightbox = mock_esm("../src/lightbox"); +const list_util = mock_esm("../src/list_util"); +const message_edit = mock_esm("../src/message_edit"); +const message_lists = mock_esm("../src/message_lists"); +const muted_topics_ui = mock_esm("../src/muted_topics_ui"); +const narrow = mock_esm("../src/narrow"); +const navigate = mock_esm("../src/navigate"); +const overlays = mock_esm("../src/overlays", { is_active: () => false, settings_open: () => false, streams_open: () => false, @@ -58,31 +58,31 @@ const overlays = mock_esm("../../web/src/overlays", { is_modal_open: () => false, is_overlay_or_modal_open: () => overlays.is_modal_open() || overlays.is_active(), }); -const popovers = mock_esm("../../web/src/popovers", { +const popovers = mock_esm("../src/popovers", { user_info_manage_menu_popped: () => false, message_info_popped: () => false, user_sidebar_popped: () => false, user_info_popped: () => false, }); -const popover_menus = mock_esm("../../web/src/popover_menus", { +const popover_menus = mock_esm("../src/popover_menus", { actions_popped: () => false, }); -const reactions = mock_esm("../../web/src/reactions"); -const search = mock_esm("../../web/src/search"); -const settings_data = mock_esm("../../web/src/settings_data"); -const stream_list = mock_esm("../../web/src/stream_list"); -const stream_settings_ui = mock_esm("../../web/src/stream_settings_ui"); +const reactions = mock_esm("../src/reactions"); +const search = mock_esm("../src/search"); +const settings_data = mock_esm("../src/settings_data"); +const stream_list = mock_esm("../src/stream_list"); +const stream_settings_ui = mock_esm("../src/stream_settings_ui"); -mock_esm("../../web/src/hotspots", { +mock_esm("../src/hotspots", { is_open: () => false, }); -mock_esm("../../web/src/recent_topics_util", { +mock_esm("../src/recent_topics_util", { is_visible: () => false, is_in_focus: () => false, }); -const stream_popover = mock_esm("../../web/src/stream_popover", { +const stream_popover = mock_esm("../src/stream_popover", { stream_popped: () => false, topic_popped: () => false, all_messages_popped: () => false, diff --git a/frontend_tests/node_tests/i18n.js b/web/tests/i18n.test.js similarity index 93% rename from frontend_tests/node_tests/i18n.js rename to web/tests/i18n.test.js index d0361993d1..6e4507acbc 100644 --- a/frontend_tests/node_tests/i18n.js +++ b/web/tests/i18n.test.js @@ -4,9 +4,9 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const {unmock_module, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const {page_params} = require("../zjsunit/zpage_params"); +const {unmock_module, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const {page_params} = require("./lib/zpage_params"); // We download our translations in `page_params` (which // are for the user's chosen language), so we simulate @@ -22,13 +22,13 @@ page_params.translation_data = { // Re-register Zulip extensions so extensions registered previously with // mocked i18n.ts do not interfere with following tests. -require("../../web/src/templates"); +require("../src/templates"); // All of our other tests stub out i18n activity; // here we do a quick sanity check on the engine itself. // `i18n.js` initializes FormatJS and is imported by // `templates.js`. -unmock_module("../../web/src/i18n"); +unmock_module("../src/i18n"); const {$t, $t_html, get_language_name, get_language_list_columns, initialize} = zrequire("i18n"); run_test("$t", () => { @@ -89,7 +89,7 @@ run_test("t_tag", ({mock_template}) => { assert.ok(html.indexOf("Citer et répondre ou transférer") > 0); }); - require("../../web/templates/actions_popover_content.hbs")(args); + require("../templates/actions_popover_content.hbs")(args); }); run_test("tr_tag", ({mock_template}) => { @@ -117,7 +117,7 @@ run_test("tr_tag", ({mock_template}) => { assert.equal(data, args); assert.ok(html.indexOf("Déclencheurs de notification") > 0); }); - require("../../web/templates/settings_tab.hbs")(args); + require("../templates/settings_tab.hbs")(args); }); run_test("language_list", () => { diff --git a/frontend_tests/node_tests/input_pill.js b/web/tests/input_pill.test.js similarity index 98% rename from frontend_tests/node_tests/input_pill.js rename to web/tests/input_pill.test.js index a21d6ae4c6..c984b26a8f 100644 --- a/frontend_tests/node_tests/input_pill.js +++ b/web/tests/input_pill.test.js @@ -2,17 +2,17 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); set_global("document", {}); const noop = () => {}; const example_img_link = "http://example.com/example.png"; -mock_esm("../../web/src/ui_util", { +mock_esm("../src/ui_util", { place_caret_at_end: noop, }); @@ -40,7 +40,7 @@ function pill_html(value, img_src, status_emoji_info) { opts.status_emoji_info = status_emoji_info; } - return require("../../web/templates/input_pill.hbs")(opts); + return require("../templates/input_pill.hbs")(opts); } run_test("basics", ({mock_template}) => { diff --git a/frontend_tests/node_tests/internal_url.js b/web/tests/internal_url.test.js similarity index 94% rename from frontend_tests/node_tests/internal_url.js rename to web/tests/internal_url.test.js index 88ffd75b49..a35578d92d 100644 --- a/frontend_tests/node_tests/internal_url.js +++ b/web/tests/internal_url.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const internal_url = zrequire("../shared/src/internal_url"); diff --git a/frontend_tests/node_tests/keydown_util.js b/web/tests/keydown_util.test.js similarity index 92% rename from frontend_tests/node_tests/keydown_util.js rename to web/tests/keydown_util.test.js index b32d28f307..d3a27b7010 100644 --- a/frontend_tests/node_tests/keydown_util.js +++ b/web/tests/keydown_util.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); const keydown_util = zrequire("keydown_util"); diff --git a/frontend_tests/node_tests/lazy_set.js b/web/tests/lazy_set.test.js similarity index 79% rename from frontend_tests/node_tests/lazy_set.js rename to web/tests/lazy_set.test.js index 86cd825cf5..cc0b72c2b6 100644 --- a/frontend_tests/node_tests/lazy_set.js +++ b/web/tests/lazy_set.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); const {LazySet} = zrequire("lazy_set"); diff --git a/frontend_tests/node_tests/lib/compose_banner.js b/web/tests/lib/compose_banner.js similarity index 80% rename from frontend_tests/node_tests/lib/compose_banner.js rename to web/tests/lib/compose_banner.js index 0055e768b1..a009a86f0c 100644 --- a/frontend_tests/node_tests/lib/compose_banner.js +++ b/web/tests/lib/compose_banner.js @@ -1,7 +1,8 @@ "use strict"; -const compose_banner = require("../../../web/src/compose_banner"); -const $ = require("../../zjsunit/zjquery"); +const compose_banner = require("../../src/compose_banner"); + +const $ = require("./zjquery"); exports.mock_banners = () => { // zjquery doesn't support `remove`, which is used when clearing the compose box. diff --git a/frontend_tests/node_tests/lib/events.js b/web/tests/lib/events.js similarity index 100% rename from frontend_tests/node_tests/lib/events.js rename to web/tests/lib/events.js diff --git a/frontend_tests/zjsunit/handlebars.js b/web/tests/lib/handlebars.js similarity index 100% rename from frontend_tests/zjsunit/handlebars.js rename to web/tests/lib/handlebars.js diff --git a/frontend_tests/zjsunit/i18n.js b/web/tests/lib/i18n.js similarity index 100% rename from frontend_tests/zjsunit/i18n.js rename to web/tests/lib/i18n.js diff --git a/frontend_tests/zjsunit/index.js b/web/tests/lib/index.js similarity index 79% rename from frontend_tests/zjsunit/index.js rename to web/tests/lib/index.js index 788e0e915c..1dbe9ebeba 100644 --- a/frontend_tests/zjsunit/index.js +++ b/web/tests/lib/index.js @@ -27,10 +27,8 @@ global.navigator = { require("@babel/register")({ extensions: [".es6", ".es", ".jsx", ".js", ".mjs", ".ts"], only: [ - new RegExp("^" + _.escapeRegExp(path.resolve(__dirname, "../../web/src") + path.sep)), - new RegExp( - "^" + _.escapeRegExp(path.resolve(__dirname, "../../web/shared/src") + path.sep), - ), + new RegExp("^" + _.escapeRegExp(path.resolve(__dirname, "../../shared/src") + path.sep)), + new RegExp("^" + _.escapeRegExp(path.resolve(__dirname, "../../src") + path.sep)), ], plugins: [ "babel-plugin-rewire-ts", @@ -90,12 +88,12 @@ function short_tb(tb) { return lines.splice(0, i + 1).join("\n") + "\n(...)\n"; } -require("../../web/src/templates"); // register Zulip extensions +require("../../src/templates"); // register Zulip extensions async function run_one_module(file) { zjquery.clear_initialize_function(); zjquery.clear_all_elements(); - console.info("running test " + path.basename(file, ".js")); + console.info("running test " + path.basename(file, ".test.js")); test.set_current_file_name(file); test.suite.length = 0; require(file); @@ -121,16 +119,16 @@ test.set_verbose(files.length === 1); _.debounce = immediate; zpage_params.reset(); - namespace.mock_esm("../../web/src/blueslip", blueslip); - require("../../web/src/blueslip"); - namespace.mock_esm("../../web/src/i18n", stub_i18n); - require("../../web/src/i18n"); - namespace.mock_esm("../../web/src/page_params", zpage_params); - require("../../web/src/page_params"); - namespace.mock_esm("../../web/src/user_settings", zpage_params); - require("../../web/src/user_settings"); - namespace.mock_esm("../../web/src/realm_user_settings_defaults", zpage_params); - require("../../web/src/realm_user_settings_defaults"); + namespace.mock_esm("../../src/blueslip", blueslip); + require("../../src/blueslip"); + namespace.mock_esm("../../src/i18n", stub_i18n); + require("../../src/i18n"); + namespace.mock_esm("../../src/page_params", zpage_params); + require("../../src/page_params"); + namespace.mock_esm("../../src/user_settings", zpage_params); + require("../../src/user_settings"); + namespace.mock_esm("../../src/realm_user_settings_defaults", zpage_params); + require("../../src/realm_user_settings_defaults"); await run_one_module(file); diff --git a/frontend_tests/zjsunit/markdown_assert.js b/web/tests/lib/markdown_assert.js similarity index 100% rename from frontend_tests/zjsunit/markdown_assert.js rename to web/tests/lib/markdown_assert.js diff --git a/frontend_tests/zjsunit/mdiff.js b/web/tests/lib/mdiff.js similarity index 100% rename from frontend_tests/zjsunit/mdiff.js rename to web/tests/lib/mdiff.js diff --git a/frontend_tests/zjsunit/namespace.js b/web/tests/lib/namespace.js similarity index 97% rename from frontend_tests/zjsunit/namespace.js rename to web/tests/lib/namespace.js index bde3369a54..f767398b28 100644 --- a/frontend_tests/zjsunit/namespace.js +++ b/web/tests/lib/namespace.js @@ -6,7 +6,7 @@ const path = require("path"); const callsites = require("callsites"); -const $ = require("../zjsunit/zjquery"); +const $ = require("./zjquery"); const new_globals = new Set(); let old_globals = {}; @@ -18,7 +18,7 @@ const used_module_mocks = new Set(); const used_templates = new Set(); const jquery_path = require.resolve("jquery"); -const real_jquery_path = require.resolve("../zjsunit/real_jquery.js"); +const real_jquery_path = require.resolve("./real_jquery.js"); let in_mid_render = false; let jquery_function; @@ -268,10 +268,11 @@ exports.zrequire = function (short_fn) { `, ); - return require(`../../web/src/${short_fn}`); + return require(`../../src/${short_fn}`); }; -const webPath = path.resolve(__dirname, "../../web") + path.sep; +const webPath = path.resolve(__dirname, "../..") + path.sep; +const testsLibPath = __dirname + path.sep; exports.complain_about_unused_mocks = function () { for (const filename of module_mocks.keys()) { @@ -301,7 +302,7 @@ exports.finish = function () { used_module_mocks.clear(); for (const path of Object.keys(require.cache)) { - if (path.startsWith(webPath)) { + if (path.startsWith(webPath) && !path.startsWith(testsLibPath)) { delete require.cache[path]; } } diff --git a/frontend_tests/zjsunit/real_jquery.js b/web/tests/lib/real_jquery.js similarity index 100% rename from frontend_tests/zjsunit/real_jquery.js rename to web/tests/lib/real_jquery.js diff --git a/frontend_tests/zjsunit/stub.js b/web/tests/lib/stub.js similarity index 100% rename from frontend_tests/zjsunit/stub.js rename to web/tests/lib/stub.js diff --git a/frontend_tests/zjsunit/test.js b/web/tests/lib/test.js similarity index 100% rename from frontend_tests/zjsunit/test.js rename to web/tests/lib/test.js diff --git a/frontend_tests/zjsunit/zblueslip.js b/web/tests/lib/zblueslip.js similarity index 100% rename from frontend_tests/zjsunit/zblueslip.js rename to web/tests/lib/zblueslip.js diff --git a/frontend_tests/zjsunit/zjquery.js b/web/tests/lib/zjquery.js similarity index 100% rename from frontend_tests/zjsunit/zjquery.js rename to web/tests/lib/zjquery.js diff --git a/frontend_tests/zjsunit/zjquery_element.js b/web/tests/lib/zjquery_element.js similarity index 100% rename from frontend_tests/zjsunit/zjquery_element.js rename to web/tests/lib/zjquery_element.js diff --git a/frontend_tests/zjsunit/zjquery_event.js b/web/tests/lib/zjquery_event.js similarity index 100% rename from frontend_tests/zjsunit/zjquery_event.js rename to web/tests/lib/zjquery_event.js diff --git a/frontend_tests/zjsunit/zpage_params.js b/web/tests/lib/zpage_params.js similarity index 100% rename from frontend_tests/zjsunit/zpage_params.js rename to web/tests/lib/zpage_params.js diff --git a/frontend_tests/node_tests/lightbox.js b/web/tests/lightbox.test.js similarity index 85% rename from frontend_tests/node_tests/lightbox.js rename to web/tests/lightbox.test.js index 87405b5114..db82a1288b 100644 --- a/frontend_tests/node_tests/lightbox.js +++ b/web/tests/lightbox.test.js @@ -2,23 +2,23 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); set_global("Image", class Image {}); -mock_esm("../../web/src/overlays", { +mock_esm("../src/overlays", { close_overlay() {}, close_active() {}, open_overlay() {}, }); -mock_esm("../../web/src/popovers", { +mock_esm("../src/popovers", { hide_all() {}, }); -const rows = mock_esm("../../web/src/rows"); +const rows = mock_esm("../src/rows"); -const message_store = mock_esm("../../web/src/message_store"); +const message_store = mock_esm("../src/message_store"); const lightbox = zrequire("lightbox"); diff --git a/frontend_tests/node_tests/linkifiers.js b/web/tests/linkifiers.test.js similarity index 92% rename from frontend_tests/node_tests/linkifiers.js rename to web/tests/linkifiers.test.js index c620e81dc5..0b34ab762e 100644 --- a/frontend_tests/node_tests/linkifiers.js +++ b/web/tests/linkifiers.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); const linkifiers = zrequire("linkifiers"); diff --git a/frontend_tests/node_tests/list_cursor.js b/web/tests/list_cursor.test.js similarity index 94% rename from frontend_tests/node_tests/list_cursor.js rename to web/tests/list_cursor.test.js index 0871ac3002..9c494d4cae 100644 --- a/frontend_tests/node_tests/list_cursor.js +++ b/web/tests/list_cursor.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); const {ListCursor} = zrequire("list_cursor"); diff --git a/frontend_tests/node_tests/list_widget.js b/web/tests/list_widget.test.js similarity index 99% rename from frontend_tests/node_tests/list_widget.js rename to web/tests/list_widget.test.js index 41cb63fced..750ec2204f 100644 --- a/frontend_tests/node_tests/list_widget.js +++ b/web/tests/list_widget.test.js @@ -2,15 +2,15 @@ const {strict: assert} = require("assert"); -const {mock_esm, mock_jquery, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); +const {mock_esm, mock_jquery, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); // We need these stubs to get by instanceof checks. // The ListWidget library allows you to insert objects // that are either jQuery, Element, or just raw HTML // strings. We initially test with raw strings. -const ui = mock_esm("../../web/src/ui"); +const ui = mock_esm("../src/ui"); // We only need very simple jQuery wrappers for when the diff --git a/frontend_tests/node_tests/markdown.js b/web/tests/markdown.test.js similarity index 99% rename from frontend_tests/node_tests/markdown.js rename to web/tests/markdown.test.js index d9ec9ce834..40ce529c27 100644 --- a/frontend_tests/node_tests/markdown.js +++ b/web/tests/markdown.test.js @@ -3,10 +3,11 @@ const {strict: assert} = require("assert"); const markdown_test_cases = require("../../zerver/tests/fixtures/markdown_test_cases"); -const markdown_assert = require("../zjsunit/markdown_assert"); -const {set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const {page_params, user_settings} = require("../zjsunit/zpage_params"); + +const markdown_assert = require("./lib/markdown_assert"); +const {set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const {page_params, user_settings} = require("./lib/zpage_params"); const example_realm_linkifiers = [ { diff --git a/frontend_tests/node_tests/markdown_parse.js b/web/tests/markdown_parse.test.js similarity index 99% rename from frontend_tests/node_tests/markdown_parse.js rename to web/tests/markdown_parse.test.js index 27ddc93b58..2c3c8ee8ff 100644 --- a/frontend_tests/node_tests/markdown_parse.js +++ b/web/tests/markdown_parse.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const markdown = zrequire("markdown"); const linkifiers = zrequire("linkifiers"); diff --git a/frontend_tests/node_tests/message_edit.js b/web/tests/message_edit.test.js similarity index 97% rename from frontend_tests/node_tests/message_edit.js rename to web/tests/message_edit.test.js index f3f5d80c98..1fcd599cf9 100644 --- a/frontend_tests/node_tests/message_edit.js +++ b/web/tests/message_edit.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const {page_params} = require("./lib/zpage_params"); page_params.realm_move_messages_within_stream_limit_seconds = 259200; @@ -12,7 +12,7 @@ const message_edit = zrequire("message_edit"); const is_content_editable = message_edit.is_content_editable; -const settings_data = mock_esm("../../web/src/settings_data"); +const settings_data = mock_esm("../src/settings_data"); run_test("is_content_editable", () => { // You can't edit a null message diff --git a/frontend_tests/node_tests/message_events.js b/web/tests/message_events.test.js similarity index 86% rename from frontend_tests/node_tests/message_events.js rename to web/tests/message_events.test.js index 3a84c28bb1..3ce5b3a339 100644 --- a/frontend_tests/node_tests/message_events.js +++ b/web/tests/message_events.test.js @@ -2,18 +2,18 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); -const condense = mock_esm("../../web/src/condense"); -const message_edit = mock_esm("../../web/src/message_edit"); -const message_lists = mock_esm("../../web/src/message_lists"); -const notifications = mock_esm("../../web/src/notifications"); -const pm_list = mock_esm("../../web/src/pm_list"); -const stream_list = mock_esm("../../web/src/stream_list"); -const unread_ui = mock_esm("../../web/src/unread_ui"); +const condense = mock_esm("../src/condense"); +const message_edit = mock_esm("../src/message_edit"); +const message_lists = mock_esm("../src/message_lists"); +const notifications = mock_esm("../src/notifications"); +const pm_list = mock_esm("../src/pm_list"); +const stream_list = mock_esm("../src/stream_list"); +const unread_ui = mock_esm("../src/unread_ui"); message_lists.current = {}; message_lists.all_rendered_message_lists = () => [message_lists.home, message_lists.current]; diff --git a/frontend_tests/node_tests/message_fetch.js b/web/tests/message_fetch.test.js similarity index 94% rename from frontend_tests/node_tests/message_fetch.js rename to web/tests/message_fetch.test.js index 5e8c4a17a7..9cf5b9e9e6 100644 --- a/frontend_tests/node_tests/message_fetch.js +++ b/web/tests/message_fetch.test.js @@ -4,10 +4,10 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); set_global("document", "document-stub"); @@ -20,27 +20,27 @@ function MessageListView() { prepend: noop, }; } -mock_esm("../../web/src/message_list_view", { +mock_esm("../src/message_list_view", { MessageListView, }); -mock_esm("../../web/src/recent_topics_ui", { +mock_esm("../src/recent_topics_ui", { process_messages: noop, show_loading_indicator: noop, hide_loading_indicator: noop, }); -mock_esm("../../web/src/ui_report", { +mock_esm("../src/ui_report", { hide_error: noop, }); -const channel = mock_esm("../../web/src/channel"); -const message_helper = mock_esm("../../web/src/message_helper"); -const message_lists = mock_esm("../../web/src/message_lists"); -const message_util = mock_esm("../../web/src/message_util"); -const stream_list = mock_esm("../../web/src/stream_list", { +const channel = mock_esm("../src/channel"); +const message_helper = mock_esm("../src/message_helper"); +const message_lists = mock_esm("../src/message_lists"); +const message_util = mock_esm("../src/message_util"); +const stream_list = mock_esm("../src/stream_list", { maybe_scroll_narrow_into_view() {}, }); -mock_esm("../../web/src/message_scroll", { +mock_esm("../src/message_scroll", { show_loading_older: noop, hide_loading_older: noop, show_loading_newer: noop, diff --git a/frontend_tests/node_tests/message_flags.js b/web/tests/message_flags.test.js similarity index 97% rename from frontend_tests/node_tests/message_flags.js rename to web/tests/message_flags.test.js index 73d391108b..1c77de0904 100644 --- a/frontend_tests/node_tests/message_flags.js +++ b/web/tests/message_flags.test.js @@ -2,13 +2,13 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, with_overrides, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, set_global, with_overrides, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); -const channel = mock_esm("../../web/src/channel"); -const ui = mock_esm("../../web/src/ui"); +const channel = mock_esm("../src/channel"); +const ui = mock_esm("../src/ui"); -mock_esm("../../web/src/starred_messages", { +mock_esm("../src/starred_messages", { add() {}, get_starred_msg_ids: () => [1, 2, 3, 4, 5], remove() {}, diff --git a/frontend_tests/node_tests/message_list.js b/web/tests/message_list.test.js similarity index 95% rename from frontend_tests/node_tests/message_list.js rename to web/tests/message_list.test.js index 99efd69fd0..a35a83a476 100644 --- a/frontend_tests/node_tests/message_list.js +++ b/web/tests/message_list.test.js @@ -2,12 +2,12 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {make_stub} = require("../zjsunit/stub"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {make_stub} = require("./lib/stub"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); // These unit tests for web/src/message_list.js emphasize the model-ish // aspects of the MessageList class. We have to stub out a few functions @@ -23,8 +23,8 @@ set_global("document", { }, }); -const narrow_state = mock_esm("../../web/src/narrow_state"); -const stream_data = mock_esm("../../web/src/stream_data"); +const narrow_state = mock_esm("../src/narrow_state"); +const stream_data = mock_esm("../src/stream_data"); const {MessageList} = zrequire("message_list"); function MessageListView() { @@ -35,7 +35,7 @@ function MessageListView() { clear_rendering_state: noop, }; } -mock_esm("../../web/src/message_list_view", { +mock_esm("../src/message_list_view", { MessageListView, }); const {Filter} = zrequire("filter"); diff --git a/frontend_tests/node_tests/message_list_data.js b/web/tests/message_list_data.test.js similarity index 98% rename from frontend_tests/node_tests/message_list_data.js rename to web/tests/message_list_data.test.js index 9df7f505e4..6cda52f8ab 100644 --- a/frontend_tests/node_tests/message_list_data.js +++ b/web/tests/message_list_data.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); const user_topics = zrequire("user_topics"); const muted_users = zrequire("muted_users"); diff --git a/frontend_tests/node_tests/message_list_view.js b/web/tests/message_list_view.test.js similarity index 99% rename from frontend_tests/node_tests/message_list_view.js rename to web/tests/message_list_view.test.js index 41e3a44de1..ff0676702b 100644 --- a/frontend_tests/node_tests/message_list_view.js +++ b/web/tests/message_list_view.test.js @@ -4,16 +4,16 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); set_global("document", "document-stub"); const noop = () => {}; // timerender calls setInterval when imported -mock_esm("../../web/src/timerender", { +mock_esm("../src/timerender", { render_date(time) { return [{outerHTML: String(time.getTime())}]; }, @@ -22,7 +22,7 @@ mock_esm("../../web/src/timerender", { }, }); -mock_esm("../../web/src/rows", { +mock_esm("../src/rows", { get_table() { return { children() { @@ -34,7 +34,7 @@ mock_esm("../../web/src/rows", { }, }); -mock_esm("../../web/src/people", { +mock_esm("../src/people", { sender_is_bot: () => false, sender_is_guest: () => false, small_avatar_url: () => "fake/small/avatar/url", diff --git a/frontend_tests/node_tests/message_store.js b/web/tests/message_store.test.js similarity index 96% rename from frontend_tests/node_tests/message_store.js rename to web/tests/message_store.test.js index dbf12d6ba0..e34d37f548 100644 --- a/frontend_tests/node_tests/message_store.js +++ b/web/tests/message_store.test.js @@ -2,18 +2,18 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const {page_params} = require("./lib/zpage_params"); const noop = () => {}; -mock_esm("../../web/src/stream_topic_history", { +mock_esm("../src/stream_topic_history", { add_message: noop, }); -mock_esm("../../web/src/recent_senders", { +mock_esm("../src/recent_senders", { process_stream_message: noop, process_private_message: noop, }); diff --git a/frontend_tests/node_tests/muted_users.js b/web/tests/muted_users.test.js similarity index 96% rename from frontend_tests/node_tests/muted_users.js rename to web/tests/muted_users.test.js index 2f700fbb89..3471099bfd 100644 --- a/frontend_tests/node_tests/muted_users.js +++ b/web/tests/muted_users.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const muted_users = zrequire("muted_users"); diff --git a/frontend_tests/node_tests/narrow.js b/web/tests/narrow.test.js similarity index 98% rename from frontend_tests/node_tests/narrow.js rename to web/tests/narrow.test.js index 554c62e8c3..3324ae4467 100644 --- a/frontend_tests/node_tests/narrow.js +++ b/web/tests/narrow.test.js @@ -2,11 +2,11 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); const hash_util = zrequire("hash_util"); const compose_state = zrequire("compose_state"); @@ -18,11 +18,11 @@ const {Filter} = zrequire("../src/filter"); const narrow = zrequire("narrow"); const settings_config = zrequire("settings_config"); -const compose_pm_pill = mock_esm("../../web/src/compose_pm_pill"); -mock_esm("../../web/src/spectators", { +const compose_pm_pill = mock_esm("../src/compose_pm_pill"); +mock_esm("../src/spectators", { login_to_access() {}, }); -const recent_topics_util = mock_esm("../../web/src/recent_topics_util", { +const recent_topics_util = mock_esm("../src/recent_topics_util", { is_visible() {}, }); @@ -32,7 +32,7 @@ function empty_narrow_html(title, html, search_data) { html, search_data, }; - return require("../../web/templates/empty_feed_notice.hbs")(opts); + return require("../templates/empty_feed_notice.hbs")(opts); } function set_filter(operators) { diff --git a/frontend_tests/node_tests/narrow_activate.js b/web/tests/narrow_activate.test.js similarity index 79% rename from frontend_tests/node_tests/narrow_activate.js rename to web/tests/narrow_activate.test.js index fe9904b605..6935b2c933 100644 --- a/frontend_tests/node_tests/narrow_activate.js +++ b/web/tests/narrow_activate.test.js @@ -2,38 +2,38 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); -mock_esm("../../web/src/resize", { +mock_esm("../src/resize", { resize_stream_filters_container() {}, }); -const all_messages_data = mock_esm("../../web/src/all_messages_data"); -const channel = mock_esm("../../web/src/channel"); -const compose_actions = mock_esm("../../web/src/compose_actions"); -const compose_banner = mock_esm("../../web/src/compose_banner"); -const compose_closed_ui = mock_esm("../../web/src/compose_closed_ui"); -const hashchange = mock_esm("../../web/src/hashchange"); -const message_fetch = mock_esm("../../web/src/message_fetch"); -const message_list = mock_esm("../../web/src/message_list"); -const message_lists = mock_esm("../../web/src/message_lists", { +const all_messages_data = mock_esm("../src/all_messages_data"); +const channel = mock_esm("../src/channel"); +const compose_actions = mock_esm("../src/compose_actions"); +const compose_banner = mock_esm("../src/compose_banner"); +const compose_closed_ui = mock_esm("../src/compose_closed_ui"); +const hashchange = mock_esm("../src/hashchange"); +const message_fetch = mock_esm("../src/message_fetch"); +const message_list = mock_esm("../src/message_list"); +const message_lists = mock_esm("../src/message_lists", { home: {}, current: {}, set_current(msg_list) { message_lists.current = msg_list; }, }); -const message_scroll = mock_esm("../../web/src/message_scroll"); -const message_view_header = mock_esm("../../web/src/message_view_header"); -const notifications = mock_esm("../../web/src/notifications"); -const search = mock_esm("../../web/src/search"); -const stream_list = mock_esm("../../web/src/stream_list"); -const top_left_corner = mock_esm("../../web/src/top_left_corner"); -const typing_events = mock_esm("../../web/src/typing_events"); -const unread_ops = mock_esm("../../web/src/unread_ops"); -mock_esm("../../web/src/recent_topics_util", { +const message_scroll = mock_esm("../src/message_scroll"); +const message_view_header = mock_esm("../src/message_view_header"); +const notifications = mock_esm("../src/notifications"); +const search = mock_esm("../src/search"); +const stream_list = mock_esm("../src/stream_list"); +const top_left_corner = mock_esm("../src/top_left_corner"); +const typing_events = mock_esm("../src/typing_events"); +const unread_ops = mock_esm("../src/unread_ops"); +mock_esm("../src/recent_topics_util", { is_visible() {}, }); @@ -45,7 +45,7 @@ set_global("setTimeout", (f, t) => { f(); }); -mock_esm("../../web/src/user_topics", { +mock_esm("../src/user_topics", { is_topic_muted: () => false, }); diff --git a/frontend_tests/node_tests/narrow_local.js b/web/tests/narrow_local.test.js similarity index 98% rename from frontend_tests/node_tests/narrow_local.js rename to web/tests/narrow_local.test.js index 42a62b5c0b..0a6b9dbcb2 100644 --- a/frontend_tests/node_tests/narrow_local.js +++ b/web/tests/narrow_local.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); -const all_messages_data = mock_esm("../../web/src/all_messages_data"); +const all_messages_data = mock_esm("../src/all_messages_data"); const {Filter} = zrequire("../src/filter"); const {MessageListData} = zrequire("../src/message_list_data"); diff --git a/frontend_tests/node_tests/narrow_state.js b/web/tests/narrow_state.test.js similarity index 99% rename from frontend_tests/node_tests/narrow_state.js rename to web/tests/narrow_state.test.js index b3d520a33f..72d0a2a2b2 100644 --- a/frontend_tests/node_tests/narrow_state.js +++ b/web/tests/narrow_state.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const people = zrequire("people"); const {Filter} = zrequire("../src/filter"); diff --git a/frontend_tests/node_tests/narrow_unread.js b/web/tests/narrow_unread.test.js similarity index 96% rename from frontend_tests/node_tests/narrow_unread.js rename to web/tests/narrow_unread.test.js index dc61774475..2dac8925bc 100644 --- a/frontend_tests/node_tests/narrow_unread.js +++ b/web/tests/narrow_unread.test.js @@ -2,11 +2,11 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); -mock_esm("../../web/src/user_topics", { +mock_esm("../src/user_topics", { is_topic_muted: () => false, }); diff --git a/frontend_tests/node_tests/navbar_alerts.js b/web/tests/navbar_alerts.test.js similarity index 96% rename from frontend_tests/node_tests/navbar_alerts.js rename to web/tests/navbar_alerts.test.js index 29287baca8..43214fac12 100644 --- a/frontend_tests/node_tests/navbar_alerts.js +++ b/web/tests/navbar_alerts.test.js @@ -4,9 +4,9 @@ const {strict: assert} = require("assert"); const {addDays} = require("date-fns"); -const {set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const {page_params} = require("../zjsunit/zpage_params"); +const {set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const {page_params} = require("./lib/zpage_params"); page_params.is_spectator = false; diff --git a/frontend_tests/node_tests/notifications.js b/web/tests/notifications.test.js similarity index 98% rename from frontend_tests/node_tests/notifications.js rename to web/tests/notifications.test.js index b385fafb38..40b72f8cd0 100644 --- a/frontend_tests/node_tests/notifications.js +++ b/web/tests/notifications.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params, user_settings} = require("../zjsunit/zpage_params"); +const {set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params, user_settings} = require("./lib/zpage_params"); // Dependencies diff --git a/frontend_tests/node_tests/password.js b/web/tests/password.test.js similarity index 95% rename from frontend_tests/node_tests/password.js rename to web/tests/password.test.js index 4f7b1e460a..fa9c529e9f 100644 --- a/frontend_tests/node_tests/password.js +++ b/web/tests/password.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const {password_quality, password_warning} = zrequire("password_quality"); diff --git a/frontend_tests/node_tests/peer_data.js b/web/tests/peer_data.test.js similarity index 97% rename from frontend_tests/node_tests/peer_data.js rename to web/tests/peer_data.test.js index 1e25403563..4069af691c 100644 --- a/frontend_tests/node_tests/peer_data.js +++ b/web/tests/peer_data.test.js @@ -8,10 +8,10 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const {page_params} = require("../zjsunit/zpage_params"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const {page_params} = require("./lib/zpage_params"); const peer_data = zrequire("peer_data"); const people = zrequire("people"); diff --git a/frontend_tests/node_tests/people.js b/web/tests/people.test.js similarity index 99% rename from frontend_tests/node_tests/people.js rename to web/tests/people.test.js index cebcacca2d..020b4ea4dc 100644 --- a/frontend_tests/node_tests/people.js +++ b/web/tests/people.test.js @@ -6,13 +6,13 @@ const {parseISO} = require("date-fns"); const _ = require("lodash"); const MockDate = require("mockdate"); -const {$t} = require("../zjsunit/i18n"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const {page_params, user_settings} = require("../zjsunit/zpage_params"); +const {$t} = require("./lib/i18n"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const {page_params, user_settings} = require("./lib/zpage_params"); -const message_user_ids = mock_esm("../../web/src/message_user_ids"); +const message_user_ids = mock_esm("../src/message_user_ids"); const muted_users = zrequire("muted_users"); const people = zrequire("people"); diff --git a/frontend_tests/node_tests/people_errors.js b/web/tests/people_errors.test.js similarity index 94% rename from frontend_tests/node_tests/people_errors.js rename to web/tests/people_errors.test.js index 180a5a5472..9ab6ac98da 100644 --- a/frontend_tests/node_tests/people_errors.js +++ b/web/tests/people_errors.test.js @@ -2,11 +2,11 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); -const reload_state = mock_esm("../../web/src/reload_state", { +const reload_state = mock_esm("../src/reload_state", { is_in_progress: () => false, }); diff --git a/frontend_tests/node_tests/pill_typeahead.js b/web/tests/pill_typeahead.test.js similarity index 97% rename from frontend_tests/node_tests/pill_typeahead.js rename to web/tests/pill_typeahead.test.js index 5be6a8bdb0..51eadce21d 100644 --- a/frontend_tests/node_tests/pill_typeahead.js +++ b/web/tests/pill_typeahead.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {zrequire, mock_esm} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); +const {zrequire, mock_esm} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); const input_pill = zrequire("input_pill"); const pill_typeahead = zrequire("pill_typeahead"); @@ -23,7 +23,7 @@ const $fake_rendered_person = $.create("fake-rendered-person"); const $fake_rendered_stream = $.create("fake-rendered-stream"); const $fake_rendered_group = $.create("fake-rendered-group"); -mock_esm("../../web/src/typeahead_helper", { +mock_esm("../src/typeahead_helper", { render_person() { return $fake_rendered_person; }, diff --git a/frontend_tests/node_tests/pm_conversations.js b/web/tests/pm_conversations.test.js similarity index 97% rename from frontend_tests/node_tests/pm_conversations.js rename to web/tests/pm_conversations.test.js index bbe4df1a2e..924dcbaf86 100644 --- a/frontend_tests/node_tests/pm_conversations.js +++ b/web/tests/pm_conversations.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const user_topics = zrequire("user_topics"); const muted_users = zrequire("muted_users"); diff --git a/frontend_tests/node_tests/pm_list.js b/web/tests/pm_list.test.js similarity index 87% rename from frontend_tests/node_tests/pm_list.js rename to web/tests/pm_list.test.js index 68aba53f7b..0cf00a37a2 100644 --- a/frontend_tests/node_tests/pm_list.js +++ b/web/tests/pm_list.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); const narrow_state = zrequire("narrow_state"); const pm_list = zrequire("pm_list"); diff --git a/frontend_tests/node_tests/pm_list_data.js b/web/tests/pm_list_data.test.js similarity index 98% rename from frontend_tests/node_tests/pm_list_data.js rename to web/tests/pm_list_data.test.js index f233d84296..6b6d5f0110 100644 --- a/frontend_tests/node_tests/pm_list_data.js +++ b/web/tests/pm_list_data.test.js @@ -2,12 +2,12 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); -const unread = mock_esm("../../web/src/unread"); +const unread = mock_esm("../src/unread"); -mock_esm("../../web/src/user_status", { +mock_esm("../src/user_status", { get_status_emoji: () => ({ emoji_code: 20, }), diff --git a/frontend_tests/node_tests/poll_widget.js b/web/tests/poll_widget.test.js similarity index 97% rename from frontend_tests/node_tests/poll_widget.js rename to web/tests/poll_widget.test.js index fd921569e3..fc50a2678e 100644 --- a/frontend_tests/node_tests/poll_widget.js +++ b/web/tests/poll_widget.test.js @@ -2,12 +2,12 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); -const {PollData} = zrequire("../../web/shared/src/poll_data"); +const {PollData} = zrequire("../shared/src/poll_data"); const poll_widget = zrequire("poll_widget"); diff --git a/frontend_tests/node_tests/popovers.js b/web/tests/popovers.test.js similarity index 91% rename from frontend_tests/node_tests/popovers.js rename to web/tests/popovers.test.js index 9f015a4a29..42d2c80e50 100644 --- a/frontend_tests/node_tests/popovers.js +++ b/web/tests/popovers.test.js @@ -2,11 +2,11 @@ const {strict: assert} = require("assert"); -const {$t} = require("../zjsunit/i18n"); -const {mock_cjs, mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {$t} = require("./lib/i18n"); +const {mock_cjs, mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); const noop = function () {}; @@ -15,21 +15,21 @@ class Clipboard { } mock_cjs("clipboard", Clipboard); -const rows = mock_esm("../../web/src/rows"); -mock_esm("../../web/src/emoji_picker", { +const rows = mock_esm("../src/rows"); +mock_esm("../src/emoji_picker", { hide_emoji_popover: noop, }); -mock_esm("../../web/src/giphy", { +mock_esm("../src/giphy", { hide_giphy_popover: noop, }); -const message_lists = mock_esm("../../web/src/message_lists", { +const message_lists = mock_esm("../src/message_lists", { current: { view: { message_containers: {}, }, }, }); -mock_esm("../../web/src/stream_popover", { +mock_esm("../src/stream_popover", { hide_stream_popover: noop, hide_topic_popover: noop, hide_all_messages_popover: noop, diff --git a/frontend_tests/node_tests/presence.js b/web/tests/presence.test.js similarity index 96% rename from frontend_tests/node_tests/presence.js rename to web/tests/presence.test.js index e525ba2468..fd7ff7b05e 100644 --- a/frontend_tests/node_tests/presence.js +++ b/web/tests/presence.test.js @@ -2,12 +2,12 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const {page_params, user_settings} = require("../zjsunit/zpage_params"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const {page_params, user_settings} = require("./lib/zpage_params"); -const reload_state = mock_esm("../../web/src/reload_state", { +const reload_state = mock_esm("../src/reload_state", { is_in_progress: () => false, }); diff --git a/frontend_tests/node_tests/reactions.js b/web/tests/reactions.test.js similarity index 98% rename from frontend_tests/node_tests/reactions.js rename to web/tests/reactions.test.js index f717f22fdc..c4935000da 100644 --- a/frontend_tests/node_tests/reactions.js +++ b/web/tests/reactions.test.js @@ -2,12 +2,12 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {make_stub} = require("../zjsunit/stub"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); -const {page_params, user_settings} = require("../zjsunit/zpage_params"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {make_stub} = require("./lib/stub"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); +const {page_params, user_settings} = require("./lib/zpage_params"); const alice_user_id = 5; @@ -38,13 +38,13 @@ const sample_message = { ], }; -const channel = mock_esm("../../web/src/channel"); -const emoji_picker = mock_esm("../../web/src/emoji_picker", { +const channel = mock_esm("../src/channel"); +const emoji_picker = mock_esm("../src/emoji_picker", { hide_emoji_popover() {}, }); -const message_lists = mock_esm("../../web/src/message_lists"); -const message_store = mock_esm("../../web/src/message_store"); -const spectators = mock_esm("../../web/src/spectators", { +const message_lists = mock_esm("../src/message_lists"); +const message_store = mock_esm("../src/message_store"); +const spectators = mock_esm("../src/spectators", { login_to_access() {}, }); diff --git a/frontend_tests/node_tests/recent_senders.js b/web/tests/recent_senders.test.js similarity index 98% rename from frontend_tests/node_tests/recent_senders.js rename to web/tests/recent_senders.test.js index 87ccdc1a73..0036bf512a 100644 --- a/frontend_tests/node_tests/recent_senders.js +++ b/web/tests/recent_senders.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); let next_id = 0; const messages = new Map(); @@ -23,10 +23,10 @@ function make_stream_message({stream_id, topic, sender_id}) { return message; } -mock_esm("../../web/src/message_store", { +mock_esm("../src/message_store", { get: (message_id) => messages.get(message_id), }); -mock_esm("../../web/src/people", { +mock_esm("../src/people", { my_current_user_id: () => 1, }); diff --git a/frontend_tests/node_tests/recent_topics.js b/web/tests/recent_topics.test.js similarity index 96% rename from frontend_tests/node_tests/recent_topics.js rename to web/tests/recent_topics.test.js index 7a38579387..57bb728c12 100644 --- a/frontend_tests/node_tests/recent_topics.js +++ b/web/tests/recent_topics.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); const noop = () => {}; const test_url = () => "https://www.example.com"; @@ -39,7 +39,7 @@ const topic10 = "topic-10"; let expected_data_to_replace_in_list_widget; -const ListWidget = mock_esm("../../web/src/list_widget", { +const ListWidget = mock_esm("../src/list_widget", { modifier: noop, create(container, mapped_topic_values, opts) { @@ -50,7 +50,7 @@ const ListWidget = mock_esm("../../web/src/list_widget", { opts.filter.predicate(item); } // Just for coverage, the mechanisms - // are tested in list_widget.js + // are tested in list_widget.test.js if (mapped_topic_values.length >= 2) { opts.sort_fields.stream_sort(mapped_topic_values[0], mapped_topic_values[1]); opts.sort_fields.stream_sort(mapped_topic_values[1], mapped_topic_values[0]); @@ -75,25 +75,25 @@ const ListWidget = mock_esm("../../web/src/list_widget", { }, }); -mock_esm("../../web/src/compose_closed_ui", { +mock_esm("../src/compose_closed_ui", { set_standard_text_for_reply_button: noop, update_buttons_for_recent_topics: noop, }); -mock_esm("../../web/src/hash_util", { +mock_esm("../src/hash_util", { by_stream_url: test_url, by_stream_topic_url: test_url, by_conversation_and_time_url: test_url, }); -mock_esm("../../web/src/message_list_data", { +mock_esm("../src/message_list_data", { MessageListData: class {}, }); -mock_esm("../../web/src/message_store", { +mock_esm("../src/message_store", { get: (msg_id) => messages[msg_id - 1], }); -mock_esm("../../web/src/message_view_header", { +mock_esm("../src/message_view_header", { render_title_area: noop, }); -mock_esm("../../web/src/user_topics", { +mock_esm("../src/user_topics", { is_topic_muted(stream_id, topic) { if (stream_id === stream1 && topic === topic7) { return true; @@ -101,33 +101,33 @@ mock_esm("../../web/src/user_topics", { return false; }, }); -const narrow = mock_esm("../../web/src/narrow", { +const narrow = mock_esm("../src/narrow", { update_narrow_title: noop, hide_mark_as_read_turned_off_banner: noop, handle_middle_pane_transition: noop, has_shown_message_list_view: true, }); -mock_esm("../../web/src/pm_list", { +mock_esm("../src/pm_list", { update_private_messages: noop, handle_narrow_deactivated: noop, }); -mock_esm("../../web/src/recent_senders", { +mock_esm("../src/recent_senders", { get_topic_recent_senders: () => [2, 1], }); -mock_esm("../../web/src/stream_data", { +mock_esm("../src/stream_data", { is_muted: () => // We only test via muted topics for now. // TODO: Make muted streams and test them. false, }); -mock_esm("../../web/src/stream_list", { +mock_esm("../src/stream_list", { handle_narrow_deactivated: noop, }); -mock_esm("../../web/src/timerender", { +mock_esm("../src/timerender", { last_seen_status_from_date: () => "Just now", get_full_datetime: () => "date at time", }); -mock_esm("../../web/src/sub_store", { +mock_esm("../src/sub_store", { get(stream) { if (stream === stream5) { // No data is available for deactivated streams @@ -142,10 +142,10 @@ mock_esm("../../web/src/sub_store", { }; }, }); -mock_esm("../../web/src/top_left_corner", { +mock_esm("../src/top_left_corner", { narrow_to_recent_topics: noop, }); -mock_esm("../../web/src/unread", { +mock_esm("../src/unread", { num_unread_for_topic(stream_id, topic) { if (stream_id === 1 && topic === "topic-1") { return 0; diff --git a/frontend_tests/node_tests/reload.js b/web/tests/reload.test.js similarity index 90% rename from frontend_tests/node_tests/reload.js rename to web/tests/reload.test.js index 68d5c6077c..44389cadc0 100644 --- a/frontend_tests/node_tests/reload.js +++ b/web/tests/reload.test.js @@ -2,11 +2,11 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); +const {zrequire} = require("./lib/namespace"); // override file-level function call in reload.js window.addEventListener = () => {}; const reload = zrequire("reload"); -const {run_test} = require("../zjsunit/test"); +const {run_test} = require("./lib/test"); run_test("old_metadata_string_is_stale", () => { assert.ok(reload.is_stale_refresh_token("1663886962834", "1663883954033"), true); diff --git a/frontend_tests/node_tests/reload_state.js b/web/tests/reload_state.test.js similarity index 85% rename from frontend_tests/node_tests/reload_state.js rename to web/tests/reload_state.test.js index 35840f8e75..f8d64cfec1 100644 --- a/frontend_tests/node_tests/reload_state.js +++ b/web/tests/reload_state.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const reload_state = zrequire("reload_state"); diff --git a/frontend_tests/node_tests/rendered_markdown.js b/web/tests/rendered_markdown.test.js similarity index 97% rename from frontend_tests/node_tests/rendered_markdown.js rename to web/tests/rendered_markdown.test.js index a9c8f49d52..9d8ca96290 100644 --- a/frontend_tests/node_tests/rendered_markdown.js +++ b/web/tests/rendered_markdown.test.js @@ -2,11 +2,11 @@ const {strict: assert} = require("assert"); -const {mock_cjs, mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); -const {user_settings} = require("../zjsunit/zpage_params"); +const {mock_cjs, mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); +const {user_settings} = require("./lib/zpage_params"); let clipboard_args; class Clipboard { @@ -17,7 +17,7 @@ class Clipboard { mock_cjs("clipboard", Clipboard); -const realm_playground = mock_esm("../../web/src/realm_playground"); +const realm_playground = mock_esm("../src/realm_playground"); user_settings.emojiset = "apple"; const rm = zrequire("rendered_markdown"); diff --git a/frontend_tests/node_tests/resolved_topic.js b/web/tests/resolved_topic.test.js similarity index 95% rename from frontend_tests/node_tests/resolved_topic.js rename to web/tests/resolved_topic.test.js index b74708d171..3b8fe4730c 100644 --- a/frontend_tests/node_tests/resolved_topic.js +++ b/web/tests/resolved_topic.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const resolved_topic = zrequire("../shared/src/resolved_topic"); diff --git a/frontend_tests/node_tests/rtl.js b/web/tests/rtl.test.js similarity index 98% rename from frontend_tests/node_tests/rtl.js rename to web/tests/rtl.test.js index 7bf3055907..0478607acf 100644 --- a/frontend_tests/node_tests/rtl.js +++ b/web/tests/rtl.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); const rtl = zrequire("rtl"); diff --git a/frontend_tests/node_tests/schema.js b/web/tests/schema.test.js similarity index 91% rename from frontend_tests/node_tests/schema.js rename to web/tests/schema.test.js index 5b8f3f6dac..439a044a53 100644 --- a/frontend_tests/node_tests/schema.js +++ b/web/tests/schema.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const schema = zrequire("schema"); diff --git a/frontend_tests/node_tests/scroll_util.js b/web/tests/scroll_util.test.js similarity index 94% rename from frontend_tests/node_tests/scroll_util.js rename to web/tests/scroll_util.test.js index b88fd5ca0b..c42ec45317 100644 --- a/frontend_tests/node_tests/scroll_util.js +++ b/web/tests/scroll_util.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); -mock_esm("../../web/src/ui", { +mock_esm("../src/ui", { get_scroll_element: (element) => element, }); diff --git a/frontend_tests/node_tests/search_future.js b/web/tests/search_future.test.js similarity index 97% rename from frontend_tests/node_tests/search_future.js rename to web/tests/search_future.test.js index 559f6f004a..167eeab8c4 100644 --- a/frontend_tests/node_tests/search_future.js +++ b/web/tests/search_future.test.js @@ -2,25 +2,25 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); const noop = () => {}; -const narrow = mock_esm("../../web/src/narrow"); -const narrow_state = mock_esm("../../web/src/narrow_state", { +const narrow = mock_esm("../src/narrow"); +const narrow_state = mock_esm("../src/narrow_state", { filter: () => false, }); -const search_suggestion = mock_esm("../../web/src/search_suggestion"); +const search_suggestion = mock_esm("../src/search_suggestion"); -mock_esm("../../web/src/search_pill_widget", { +mock_esm("../src/search_pill_widget", { widget: { getByElement: () => true, }, }); -mock_esm("../../web/src/ui_util", { +mock_esm("../src/ui_util", { place_caret_at_end: noop, }); diff --git a/frontend_tests/node_tests/search_now.js b/web/tests/search_now.test.js similarity index 97% rename from frontend_tests/node_tests/search_now.js rename to web/tests/search_now.test.js index 69b4fce50a..68e7cede92 100644 --- a/frontend_tests/node_tests/search_now.js +++ b/web/tests/search_now.test.js @@ -2,20 +2,20 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); page_params.search_pills_enabled = false; -const narrow = mock_esm("../../web/src/narrow"); -const narrow_state = mock_esm("../../web/src/narrow_state"); -const search_suggestion = mock_esm("../../web/src/search_suggestion"); +const narrow = mock_esm("../src/narrow"); +const narrow_state = mock_esm("../src/narrow_state"); +const search_suggestion = mock_esm("../src/search_suggestion"); const Filter = {}; -mock_esm("../../web/src/filter", { +mock_esm("../src/filter", { Filter, }); diff --git a/frontend_tests/node_tests/search_pill.js b/web/tests/search_pill.test.js similarity index 92% rename from frontend_tests/node_tests/search_pill.js rename to web/tests/search_pill.test.js index 7c1a4a72da..5d6a11f811 100644 --- a/frontend_tests/node_tests/search_pill.js +++ b/web/tests/search_pill.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); -const input_pill = mock_esm("../../web/src/input_pill"); +const input_pill = mock_esm("../src/input_pill"); const search_pill = zrequire("search_pill"); diff --git a/frontend_tests/node_tests/search_suggestion_future.js b/web/tests/search_suggestion_future.test.js similarity index 99% rename from frontend_tests/node_tests/search_suggestion_future.js rename to web/tests/search_suggestion_future.test.js index 84fd99c395..23cba7a854 100644 --- a/frontend_tests/node_tests/search_suggestion_future.js +++ b/web/tests/search_suggestion_future.test.js @@ -2,12 +2,12 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const {page_params} = require("./lib/zpage_params"); -const narrow_state = mock_esm("../../web/src/narrow_state"); -const stream_topic_history_util = mock_esm("../../web/src/stream_topic_history_util"); +const narrow_state = mock_esm("../src/narrow_state"); +const stream_topic_history_util = mock_esm("../src/stream_topic_history_util"); const huddle_data = zrequire("huddle_data"); diff --git a/frontend_tests/node_tests/search_suggestion_now.js b/web/tests/search_suggestion_now.test.js similarity index 99% rename from frontend_tests/node_tests/search_suggestion_now.js rename to web/tests/search_suggestion_now.test.js index c34d0e3e60..1b6e9f320e 100644 --- a/frontend_tests/node_tests/search_suggestion_now.js +++ b/web/tests/search_suggestion_now.test.js @@ -2,12 +2,12 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const {page_params} = require("./lib/zpage_params"); -const narrow_state = mock_esm("../../web/src/narrow_state"); -const stream_topic_history_util = mock_esm("../../web/src/stream_topic_history_util"); +const narrow_state = mock_esm("../src/narrow_state"); +const stream_topic_history_util = mock_esm("../src/stream_topic_history_util"); const huddle_data = zrequire("huddle_data"); diff --git a/frontend_tests/node_tests/server_events.js b/web/tests/server_events.test.js similarity index 84% rename from frontend_tests/node_tests/server_events.js rename to web/tests/server_events.test.js index 1e6633c76f..6ce67e68cb 100644 --- a/frontend_tests/node_tests/server_events.js +++ b/web/tests/server_events.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const {page_params} = require("./lib/zpage_params"); const noop = () => {}; @@ -18,9 +18,9 @@ set_global("document", { }); set_global("addEventListener", noop); -const channel = mock_esm("../../web/src/channel"); -const message_lists = mock_esm("../../web/src/message_lists"); -mock_esm("../../web/src/reload_state", { +const channel = mock_esm("../src/channel"); +const message_lists = mock_esm("../src/message_lists"); +mock_esm("../src/reload_state", { is_in_progress() { return false; }, @@ -36,19 +36,19 @@ page_params.test_suite = false; // we also directly write to pointer set_global("pointer", {}); -mock_esm("../../web/src/ui_report", { +mock_esm("../src/ui_report", { hide_error() { return false; }, }); -mock_esm("../../web/src/stream_events", { +mock_esm("../src/stream_events", { update_property() { throw new Error("subs update error"); }, }); -const message_events = mock_esm("../../web/src/message_events", { +const message_events = mock_esm("../src/message_events", { insert_new_messages() { throw new Error("insert error"); }, diff --git a/frontend_tests/node_tests/settings_bots.js b/web/tests/settings_bots.test.js similarity index 94% rename from frontend_tests/node_tests/settings_bots.js rename to web/tests/settings_bots.test.js index f472c00810..4ad0e1c976 100644 --- a/frontend_tests/node_tests/settings_bots.js +++ b/web/tests/settings_bots.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_cjs, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_cjs, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); const bot_data_params = { realm_bots: [ diff --git a/frontend_tests/node_tests/settings_config.js b/web/tests/settings_config.test.js similarity index 95% rename from frontend_tests/node_tests/settings_config.js rename to web/tests/settings_config.test.js index 2563578a5e..892061b930 100644 --- a/frontend_tests/node_tests/settings_config.js +++ b/web/tests/settings_config.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const {user_settings} = require("../zjsunit/zpage_params"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const {user_settings} = require("./lib/zpage_params"); const settings_config = zrequire("settings_config"); diff --git a/frontend_tests/node_tests/settings_data.js b/web/tests/settings_data.test.js similarity index 98% rename from frontend_tests/node_tests/settings_data.js rename to web/tests/settings_data.test.js index 2faed0dd17..813d80bd13 100644 --- a/frontend_tests/node_tests/settings_data.js +++ b/web/tests/settings_data.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const {page_params, user_settings} = require("../zjsunit/zpage_params"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const {page_params, user_settings} = require("./lib/zpage_params"); const settings_data = zrequire("settings_data"); const settings_config = zrequire("settings_config"); diff --git a/frontend_tests/node_tests/settings_emoji.js b/web/tests/settings_emoji.test.js similarity index 79% rename from frontend_tests/node_tests/settings_emoji.js rename to web/tests/settings_emoji.test.js index 1656bbceb6..f47d63f409 100644 --- a/frontend_tests/node_tests/settings_emoji.js +++ b/web/tests/settings_emoji.test.js @@ -2,11 +2,11 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); -const upload_widget = mock_esm("../../web/src/upload_widget"); +const upload_widget = mock_esm("../src/upload_widget"); const settings_emoji = zrequire("settings_emoji"); run_test("add_custom_emoji_post_render", () => { diff --git a/frontend_tests/node_tests/settings_muted_topics.js b/web/tests/settings_muted_topics.test.js similarity index 89% rename from frontend_tests/node_tests/settings_muted_topics.js rename to web/tests/settings_muted_topics.test.js index 87a21c33dd..7765339c30 100644 --- a/frontend_tests/node_tests/settings_muted_topics.js +++ b/web/tests/settings_muted_topics.test.js @@ -2,12 +2,12 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); -const list_widget = mock_esm("../../web/src/list_widget"); -const muted_topics_ui = mock_esm("../../web/src/muted_topics_ui"); +const list_widget = mock_esm("../src/list_widget"); +const muted_topics_ui = mock_esm("../src/muted_topics_ui"); const settings_muted_topics = zrequire("settings_muted_topics"); const stream_data = zrequire("stream_data"); diff --git a/frontend_tests/node_tests/settings_muted_users.js b/web/tests/settings_muted_users.test.js similarity index 87% rename from frontend_tests/node_tests/settings_muted_users.js rename to web/tests/settings_muted_users.test.js index 71e3fdc617..0027621e54 100644 --- a/frontend_tests/node_tests/settings_muted_users.js +++ b/web/tests/settings_muted_users.test.js @@ -2,12 +2,12 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); -const list_widget = mock_esm("../../web/src/list_widget"); -const muted_users_ui = mock_esm("../../web/src/muted_users_ui"); +const list_widget = mock_esm("../src/list_widget"); +const muted_users_ui = mock_esm("../src/muted_users_ui"); const settings_muted_users = zrequire("settings_muted_users"); const muted_users = zrequire("muted_users"); diff --git a/frontend_tests/node_tests/settings_org.js b/web/tests/settings_org.test.js similarity index 98% rename from frontend_tests/node_tests/settings_org.js rename to web/tests/settings_org.test.js index 67cec70ea8..5fb38a288f 100644 --- a/frontend_tests/node_tests/settings_org.js +++ b/web/tests/settings_org.test.js @@ -2,24 +2,24 @@ const {strict: assert} = require("assert"); -const {$t} = require("../zjsunit/i18n"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {$t} = require("./lib/i18n"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); const noop = () => {}; -const realm_icon = mock_esm("../../web/src/realm_icon"); +const realm_icon = mock_esm("../src/realm_icon"); -const channel = mock_esm("../../web/src/channel"); +const channel = mock_esm("../src/channel"); -mock_esm("../../web/src/csrf", {csrf_token: "token-stub"}); -mock_esm("../../web/src/list_widget", { +mock_esm("../src/csrf", {csrf_token: "token-stub"}); +mock_esm("../src/list_widget", { create: () => ({init: noop}), }); -mock_esm("../../web/src/loading", { +mock_esm("../src/loading", { make_indicator: noop, destroy_indicator: noop, }); diff --git a/frontend_tests/node_tests/settings_profile_fields.js b/web/tests/settings_profile_fields.test.js similarity index 96% rename from frontend_tests/node_tests/settings_profile_fields.js rename to web/tests/settings_profile_fields.test.js index 38a2a95ee4..9c01150a71 100644 --- a/frontend_tests/node_tests/settings_profile_fields.js +++ b/web/tests/settings_profile_fields.test.js @@ -2,12 +2,12 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); -const loading = mock_esm("../../web/src/loading"); +const loading = mock_esm("../src/loading"); const SHORT_TEXT_ID = 1; diff --git a/frontend_tests/node_tests/settings_realm_domains.js b/web/tests/settings_realm_domains.test.js similarity index 92% rename from frontend_tests/node_tests/settings_realm_domains.js rename to web/tests/settings_realm_domains.test.js index bf217e88b5..868370cb10 100644 --- a/frontend_tests/node_tests/settings_realm_domains.js +++ b/web/tests/settings_realm_domains.test.js @@ -2,13 +2,13 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); -const channel = mock_esm("../../web/src/channel"); +const channel = mock_esm("../src/channel"); const noop = () => {}; -mock_esm("../../web/src/ui_report", { +mock_esm("../src/ui_report", { success(msg, elem) { elem.val(msg); }, diff --git a/frontend_tests/node_tests/settings_user_groups_legacy.js b/web/tests/settings_user_groups_legacy.test.js similarity index 97% rename from frontend_tests/node_tests/settings_user_groups_legacy.js rename to web/tests/settings_user_groups_legacy.test.js index a7724b9ac0..189b7f7fcb 100644 --- a/frontend_tests/node_tests/settings_user_groups_legacy.js +++ b/web/tests/settings_user_groups_legacy.test.js @@ -2,12 +2,12 @@ const {strict: assert} = require("assert"); -const {$t} = require("../zjsunit/i18n"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {$t} = require("./lib/i18n"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); const noop = () => {}; @@ -17,17 +17,17 @@ const pills = { let create_item_handler; -const channel = mock_esm("../../web/src/channel"); -const confirm_dialog = mock_esm("../../web/src/confirm_dialog"); -const dialog_widget = mock_esm("../../web/src/dialog_widget"); -const input_pill = mock_esm("../../web/src/input_pill"); -const typeahead_helper = mock_esm("../../web/src/typeahead_helper"); -const user_groups = mock_esm("../../web/src/user_groups", { +const channel = mock_esm("../src/channel"); +const confirm_dialog = mock_esm("../src/confirm_dialog"); +const dialog_widget = mock_esm("../src/dialog_widget"); +const input_pill = mock_esm("../src/input_pill"); +const typeahead_helper = mock_esm("../src/typeahead_helper"); +const user_groups = mock_esm("../src/user_groups", { get_user_group_from_id: noop, remove: noop, add: noop, }); -const ui_report = mock_esm("../../web/src/ui_report"); +const ui_report = mock_esm("../src/ui_report"); const people = zrequire("people"); const settings_data = zrequire("settings_data"); diff --git a/frontend_tests/node_tests/spoilers.js b/web/tests/spoilers.test.js similarity index 89% rename from frontend_tests/node_tests/spoilers.js rename to web/tests/spoilers.test.js index ce2832e895..184b051b34 100644 --- a/frontend_tests/node_tests/spoilers.js +++ b/web/tests/spoilers.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); const spoilers = zrequire("spoilers"); diff --git a/frontend_tests/node_tests/starred_messages.js b/web/tests/starred_messages.test.js similarity index 90% rename from frontend_tests/node_tests/starred_messages.js rename to web/tests/starred_messages.test.js index 4924f53fbe..e9a2f60e87 100644 --- a/frontend_tests/node_tests/starred_messages.js +++ b/web/tests/starred_messages.test.js @@ -2,15 +2,15 @@ const {strict: assert} = require("assert"); -const {mock_esm, with_overrides, zrequire} = require("../zjsunit/namespace"); -const {make_stub} = require("../zjsunit/stub"); -const {run_test} = require("../zjsunit/test"); -const {page_params, user_settings} = require("../zjsunit/zpage_params"); +const {mock_esm, with_overrides, zrequire} = require("./lib/namespace"); +const {make_stub} = require("./lib/stub"); +const {run_test} = require("./lib/test"); +const {page_params, user_settings} = require("./lib/zpage_params"); -const top_left_corner = mock_esm("../../web/src/top_left_corner", { +const top_left_corner = mock_esm("../src/top_left_corner", { update_starred_count() {}, }); -const stream_popover = mock_esm("../../web/src/stream_popover", { +const stream_popover = mock_esm("../src/stream_popover", { hide_topic_popover() {}, hide_starred_messages_popover() {}, }); diff --git a/frontend_tests/node_tests/stream_create_subscribers_data.js b/web/tests/stream_create_subscribers_data.test.js similarity index 94% rename from frontend_tests/node_tests/stream_create_subscribers_data.js rename to web/tests/stream_create_subscribers_data.test.js index 9b0be72eb8..93aa2ba468 100644 --- a/frontend_tests/node_tests/stream_create_subscribers_data.js +++ b/web/tests/stream_create_subscribers_data.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const {page_params} = require("../zjsunit/zpage_params"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const {page_params} = require("./lib/zpage_params"); const people = zrequire("people"); const stream_create_subscribers_data = zrequire("stream_create_subscribers_data"); diff --git a/frontend_tests/node_tests/stream_data.js b/web/tests/stream_data.test.js similarity index 99% rename from frontend_tests/node_tests/stream_data.js rename to web/tests/stream_data.test.js index 9b25613536..95edfb0ba2 100644 --- a/frontend_tests/node_tests/stream_data.js +++ b/web/tests/stream_data.test.js @@ -4,10 +4,10 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const {page_params, user_settings} = require("../zjsunit/zpage_params"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const {page_params, user_settings} = require("./lib/zpage_params"); // TODO: Remove after we enable support for // web_public_streams in production. diff --git a/frontend_tests/node_tests/stream_edit.js b/web/tests/stream_edit.test.js similarity index 88% rename from frontend_tests/node_tests/stream_edit.js rename to web/tests/stream_edit.test.js index 1b5ee318bd..a44008201c 100644 --- a/frontend_tests/node_tests/stream_edit.js +++ b/web/tests/stream_edit.test.js @@ -2,8 +2,9 @@ const {strict: assert} = require("assert"); -const {get_stream_email_address} = require("../../web/src/stream_edit"); -const {run_test} = require("../zjsunit/test"); +const {get_stream_email_address} = require("../src/stream_edit"); + +const {run_test} = require("./lib/test"); run_test("get_stream_email_address", () => { let address = "announce.747b04693224b5d2f0d409b66ccd3866@zulipdev.com"; diff --git a/frontend_tests/node_tests/stream_events.js b/web/tests/stream_events.test.js similarity index 93% rename from frontend_tests/node_tests/stream_events.js rename to web/tests/stream_events.test.js index da9bbb406a..c5c3652609 100644 --- a/frontend_tests/node_tests/stream_events.js +++ b/web/tests/stream_events.test.js @@ -2,37 +2,37 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {make_stub} = require("../zjsunit/stub"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {make_stub} = require("./lib/stub"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); const noop = () => {}; -const color_data = mock_esm("../../web/src/color_data"); -const stream_color = mock_esm("../../web/src/stream_color"); -const stream_list = mock_esm("../../web/src/stream_list"); -const stream_muting = mock_esm("../../web/src/stream_muting"); -const stream_settings_ui = mock_esm("../../web/src/stream_settings_ui", { +const color_data = mock_esm("../src/color_data"); +const stream_color = mock_esm("../src/stream_color"); +const stream_list = mock_esm("../src/stream_list"); +const stream_muting = mock_esm("../src/stream_muting"); +const stream_settings_ui = mock_esm("../src/stream_settings_ui", { update_settings_for_subscribed: noop, }); -const unread_ui = mock_esm("../../web/src/unread_ui"); +const unread_ui = mock_esm("../src/unread_ui"); -const message_lists = mock_esm("../../web/src/message_lists", { +const message_lists = mock_esm("../src/message_lists", { current: {}, }); -const message_view_header = mock_esm("../../web/src/message_view_header", { +const message_view_header = mock_esm("../src/message_view_header", { maybe_rerender_title_area_for_stream() {}, }); -mock_esm("../../web/src/recent_topics_ui", { +mock_esm("../src/recent_topics_ui", { complete_rerender() {}, }); -mock_esm("../../web/src/settings_notifications", { +mock_esm("../src/settings_notifications", { update_page() {}, }); -mock_esm("../../web/src/overlays", {streams_open: () => true}); +mock_esm("../src/overlays", {streams_open: () => true}); const {Filter} = zrequire("../src/filter"); const narrow_state = zrequire("narrow_state"); diff --git a/frontend_tests/node_tests/stream_list.js b/web/tests/stream_list.test.js similarity index 97% rename from frontend_tests/node_tests/stream_list.js rename to web/tests/stream_list.test.js index efee886172..68349c5351 100644 --- a/frontend_tests/node_tests/stream_list.js +++ b/web/tests/stream_list.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params, user_settings} = require("../zjsunit/zpage_params"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params, user_settings} = require("./lib/zpage_params"); set_global("document", "document-stub"); @@ -17,18 +17,18 @@ let num_unread_for_stream; let stream_has_any_unread_mentions; const noop = () => {}; -mock_esm("../../web/src/narrow_state", { +mock_esm("../src/narrow_state", { active: () => false, }); -const topic_list = mock_esm("../../web/src/topic_list"); -mock_esm("../../web/src/keydown_util", { +const topic_list = mock_esm("../src/topic_list"); +mock_esm("../src/keydown_util", { handle: noop, }); -const scroll_util = mock_esm("../../web/src/scroll_util", { +const scroll_util = mock_esm("../src/scroll_util", { scroll_element_into_container() {}, }); -mock_esm("../../web/src/ui", {get_scroll_element: ($element) => $element}); -mock_esm("../../web/src/unread", { +mock_esm("../src/ui", {get_scroll_element: ($element) => $element}); +mock_esm("../src/unread", { num_unread_for_stream: () => num_unread_for_stream, stream_has_any_unread_mentions: () => stream_has_any_unread_mentions, }); diff --git a/frontend_tests/node_tests/stream_pill.js b/web/tests/stream_pill.test.js similarity index 95% rename from frontend_tests/node_tests/stream_pill.js rename to web/tests/stream_pill.test.js index 9d64cd2b21..42774421d9 100644 --- a/frontend_tests/node_tests/stream_pill.js +++ b/web/tests/stream_pill.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const peer_data = zrequire("peer_data"); const stream_data = zrequire("stream_data"); diff --git a/frontend_tests/node_tests/stream_search.js b/web/tests/stream_search.test.js similarity index 93% rename from frontend_tests/node_tests/stream_search.js rename to web/tests/stream_search.test.js index 9a17fef6af..53248a4bbe 100644 --- a/frontend_tests/node_tests/stream_search.js +++ b/web/tests/stream_search.test.js @@ -2,23 +2,23 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); // This tests the stream searching functionality which currently // lives in stream_list.js. const noop = () => {}; -mock_esm("../../web/src/resize", { +mock_esm("../src/resize", { resize_page_components: noop, resize_stream_filters_container: noop, }); -const popovers = mock_esm("../../web/src/popovers"); -const stream_popover = mock_esm("../../web/src/stream_popover"); +const popovers = mock_esm("../src/popovers"); +const stream_popover = mock_esm("../src/stream_popover"); const stream_list = zrequire("stream_list"); diff --git a/frontend_tests/node_tests/stream_settings_ui.js b/web/tests/stream_settings_ui.test.js similarity index 96% rename from frontend_tests/node_tests/stream_settings_ui.js rename to web/tests/stream_settings_ui.test.js index 5da8cbabb9..9ae918ac00 100644 --- a/frontend_tests/node_tests/stream_settings_ui.js +++ b/web/tests/stream_settings_ui.test.js @@ -2,17 +2,17 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); const denmark_stream_id = 101; -const ui = mock_esm("../../web/src/ui", { +const ui = mock_esm("../src/ui", { get_content_element: ($element) => $element, }); -mock_esm("../../web/src/hash_util", { +mock_esm("../src/hash_util", { by_stream_url() {}, get_current_hash_section: () => denmark_stream_id, }); diff --git a/frontend_tests/node_tests/stream_sort.js b/web/tests/stream_sort.test.js similarity index 98% rename from frontend_tests/node_tests/stream_sort.js rename to web/tests/stream_sort.test.js index bddd4d6c15..92774ecd63 100644 --- a/frontend_tests/node_tests/stream_sort.js +++ b/web/tests/stream_sort.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const stream_data = zrequire("stream_data"); const stream_sort = zrequire("stream_sort"); diff --git a/frontend_tests/node_tests/stream_topic_history.js b/web/tests/stream_topic_history.test.js similarity index 98% rename from frontend_tests/node_tests/stream_topic_history.js rename to web/tests/stream_topic_history.test.js index 324bb9a206..e7ac9e9827 100644 --- a/frontend_tests/node_tests/stream_topic_history.js +++ b/web/tests/stream_topic_history.test.js @@ -2,11 +2,11 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); -const channel = mock_esm("../../web/src/channel"); -const message_util = mock_esm("../../web/src/message_util"); +const channel = mock_esm("../src/channel"); +const message_util = mock_esm("../src/message_util"); const all_messages_data = zrequire("all_messages_data"); const unread = zrequire("unread"); diff --git a/frontend_tests/node_tests/submessage.js b/web/tests/submessage.test.js similarity index 88% rename from frontend_tests/node_tests/submessage.js rename to web/tests/submessage.test.js index 25d1b30fcb..e860cff822 100644 --- a/frontend_tests/node_tests/submessage.js +++ b/web/tests/submessage.test.js @@ -2,13 +2,13 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); -const channel = mock_esm("../../web/src/channel"); -const message_store = mock_esm("../../web/src/message_store"); -const widgetize = mock_esm("../../web/src/widgetize"); +const channel = mock_esm("../src/channel"); +const message_store = mock_esm("../src/message_store"); +const widgetize = mock_esm("../src/widgetize"); const submessage = zrequire("submessage"); diff --git a/frontend_tests/node_tests/support.js b/web/tests/support.test.js similarity index 90% rename from frontend_tests/node_tests/support.js rename to web/tests/support.test.js index da1384fc4d..248c35a165 100644 --- a/frontend_tests/node_tests/support.js +++ b/web/tests/support.test.js @@ -5,9 +5,9 @@ const fs = require("fs"); const {JSDOM} = require("jsdom"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); const template = fs.readFileSync("templates/analytics/realm_details.html", "utf8"); const dom = new JSDOM(template, {pretendToBeVisual: true}); diff --git a/frontend_tests/node_tests/templates.js b/web/tests/templates.test.js similarity index 96% rename from frontend_tests/node_tests/templates.js rename to web/tests/templates.test.js index bcf015a936..a12765ad6f 100644 --- a/frontend_tests/node_tests/templates.js +++ b/web/tests/templates.test.js @@ -2,7 +2,7 @@ const {strict: assert} = require("assert"); -const {run_test} = require("../zjsunit/test"); +const {run_test} = require("./lib/test"); /* Note that the test runner automatically registers diff --git a/frontend_tests/node_tests/templates/and.hbs b/web/tests/templates/and.hbs similarity index 100% rename from frontend_tests/node_tests/templates/and.hbs rename to web/tests/templates/and.hbs diff --git a/frontend_tests/node_tests/templates/numberFormat.hbs b/web/tests/templates/numberFormat.hbs similarity index 100% rename from frontend_tests/node_tests/templates/numberFormat.hbs rename to web/tests/templates/numberFormat.hbs diff --git a/frontend_tests/node_tests/templates/or.hbs b/web/tests/templates/or.hbs similarity index 100% rename from frontend_tests/node_tests/templates/or.hbs rename to web/tests/templates/or.hbs diff --git a/frontend_tests/node_tests/templates/rendered_markdown.hbs b/web/tests/templates/rendered_markdown.hbs similarity index 100% rename from frontend_tests/node_tests/templates/rendered_markdown.hbs rename to web/tests/templates/rendered_markdown.hbs diff --git a/frontend_tests/node_tests/templates/tooltip_hotkey_hints.hbs b/web/tests/templates/tooltip_hotkey_hints.hbs similarity index 100% rename from frontend_tests/node_tests/templates/tooltip_hotkey_hints.hbs rename to web/tests/templates/tooltip_hotkey_hints.hbs diff --git a/frontend_tests/node_tests/timerender.js b/web/tests/timerender.test.js similarity index 98% rename from frontend_tests/node_tests/timerender.js rename to web/tests/timerender.test.js index 54260a63df..c6718c2677 100644 --- a/frontend_tests/node_tests/timerender.js +++ b/web/tests/timerender.test.js @@ -5,11 +5,11 @@ const {strict: assert} = require("assert"); const {add} = require("date-fns"); const MockDate = require("mockdate"); -const {$t} = require("../zjsunit/i18n"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {user_settings} = require("../zjsunit/zpage_params"); +const {$t} = require("./lib/i18n"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {user_settings} = require("./lib/zpage_params"); user_settings.twenty_four_hour_time = true; diff --git a/frontend_tests/node_tests/top_left_corner.js b/web/tests/top_left_corner.test.js similarity index 93% rename from frontend_tests/node_tests/top_left_corner.js rename to web/tests/top_left_corner.test.js index c36fa6f35d..d7ff1d2d60 100644 --- a/frontend_tests/node_tests/top_left_corner.js +++ b/web/tests/top_left_corner.test.js @@ -2,11 +2,11 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); -mock_esm("../../web/src/resize", { +mock_esm("../src/resize", { resize_stream_filters_container() {}, }); diff --git a/frontend_tests/node_tests/topic_generator.js b/web/tests/topic_generator.test.js similarity index 92% rename from frontend_tests/node_tests/topic_generator.js rename to web/tests/topic_generator.test.js index fdb3387024..8396634d98 100644 --- a/frontend_tests/node_tests/topic_generator.js +++ b/web/tests/topic_generator.test.js @@ -2,13 +2,13 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); -const user_topics = mock_esm("../../web/src/user_topics"); -const stream_data = mock_esm("../../web/src/stream_data"); -const stream_topic_history = mock_esm("../../web/src/stream_topic_history"); -const unread = mock_esm("../../web/src/unread"); +const user_topics = mock_esm("../src/user_topics"); +const stream_data = mock_esm("../src/stream_data"); +const stream_topic_history = mock_esm("../src/stream_topic_history"); +const unread = mock_esm("../src/unread"); const pm_conversations = zrequire("pm_conversations"); pm_conversations.recent = {}; diff --git a/frontend_tests/node_tests/topic_list_data.js b/web/tests/topic_list_data.test.js similarity index 95% rename from frontend_tests/node_tests/topic_list_data.js rename to web/tests/topic_list_data.test.js index 80a807ea03..2de5c9e1b5 100644 --- a/frontend_tests/node_tests/topic_list_data.js +++ b/web/tests/topic_list_data.test.js @@ -4,10 +4,10 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); -mock_esm("../../web/src/message_store", { +mock_esm("../src/message_store", { get() { return { stream_id: 556, @@ -15,16 +15,16 @@ mock_esm("../../web/src/message_store", { }; }, }); -const user_topics = mock_esm("../../web/src/user_topics", { +const user_topics = mock_esm("../src/user_topics", { is_topic_muted() { return false; }, }); -const narrow_state = mock_esm("../../web/src/narrow_state", { +const narrow_state = mock_esm("../src/narrow_state", { topic() {}, }); -const topic_list = mock_esm("../../web/src/topic_list", { +const topic_list = mock_esm("../src/topic_list", { get_topic_search_term() {}, }); diff --git a/frontend_tests/node_tests/transmit.js b/web/tests/transmit.test.js similarity index 90% rename from frontend_tests/node_tests/transmit.js rename to web/tests/transmit.test.js index 0d6c71a861..4312becb13 100644 --- a/frontend_tests/node_tests/transmit.js +++ b/web/tests/transmit.test.js @@ -2,17 +2,17 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const {page_params} = require("./lib/zpage_params"); const noop = () => {}; -const channel = mock_esm("../../web/src/channel"); -const reload = mock_esm("../../web/src/reload"); -const reload_state = mock_esm("../../web/src/reload_state"); -const sent_messages = mock_esm("../../web/src/sent_messages", { +const channel = mock_esm("../src/channel"); +const reload = mock_esm("../src/reload"); +const reload_state = mock_esm("../src/reload_state"); +const sent_messages = mock_esm("../src/sent_messages", { start_tracking_message: noop, report_server_ack: noop, }); diff --git a/frontend_tests/node_tests/typeahead.js b/web/tests/typeahead.test.js similarity index 98% rename from frontend_tests/node_tests/typeahead.js rename to web/tests/typeahead.test.js index 6cce0a631a..d927ebeddf 100644 --- a/frontend_tests/node_tests/typeahead.js +++ b/web/tests/typeahead.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const typeahead = zrequire("../shared/src/typeahead"); diff --git a/frontend_tests/node_tests/typeahead_helper.js b/web/tests/typeahead_helper.test.js similarity index 98% rename from frontend_tests/node_tests/typeahead_helper.js rename to web/tests/typeahead_helper.test.js index 9996f36c4d..c2060870fc 100644 --- a/frontend_tests/node_tests/typeahead_helper.js +++ b/web/tests/typeahead_helper.test.js @@ -2,11 +2,11 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const {page_params, user_settings} = require("../zjsunit/zpage_params"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const {page_params, user_settings} = require("./lib/zpage_params"); -const stream_topic_history = mock_esm("../../web/src/stream_topic_history"); +const stream_topic_history = mock_esm("../src/stream_topic_history"); const settings_config = zrequire("settings_config"); const pm_conversations = zrequire("pm_conversations"); diff --git a/frontend_tests/node_tests/typing_data.js b/web/tests/typing_data.test.js similarity index 97% rename from frontend_tests/node_tests/typing_data.js rename to web/tests/typing_data.test.js index 40bb55e373..c1fe37e780 100644 --- a/frontend_tests/node_tests/typing_data.js +++ b/web/tests/typing_data.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const muted_users = zrequire("muted_users"); const typing_data = zrequire("typing_data"); diff --git a/frontend_tests/node_tests/typing_events.js b/web/tests/typing_events.test.js similarity index 94% rename from frontend_tests/node_tests/typing_events.js rename to web/tests/typing_events.test.js index 1153ecd96f..11456431a0 100644 --- a/frontend_tests/node_tests/typing_events.js +++ b/web/tests/typing_events.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); const {Filter} = zrequire("filter"); const narrow_state = zrequire("narrow_state"); diff --git a/frontend_tests/node_tests/typing_status.js b/web/tests/typing_status.test.js similarity index 97% rename from frontend_tests/node_tests/typing_status.js rename to web/tests/typing_status.test.js index a2e2453342..9fea40a7f4 100644 --- a/frontend_tests/node_tests/typing_status.js +++ b/web/tests/typing_status.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); -const compose_pm_pill = mock_esm("../../web/src/compose_pm_pill"); +const compose_pm_pill = mock_esm("../src/compose_pm_pill"); const typing = zrequire("typing"); const typing_status = zrequire("../shared/src/typing_status"); diff --git a/frontend_tests/node_tests/unread.js b/web/tests/unread.test.js similarity index 99% rename from frontend_tests/node_tests/unread.js rename to web/tests/unread.test.js index 754d6179e1..9558d7ee4b 100644 --- a/frontend_tests/node_tests/unread.js +++ b/web/tests/unread.test.js @@ -4,9 +4,9 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const {zrequire, set_global} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const {page_params, user_settings} = require("../zjsunit/zpage_params"); +const {zrequire, set_global} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const {page_params, user_settings} = require("./lib/zpage_params"); page_params.realm_push_notifications_enabled = false; diff --git a/frontend_tests/node_tests/upgrade.js b/web/tests/upgrade.test.js similarity index 97% rename from frontend_tests/node_tests/upgrade.js rename to web/tests/upgrade.test.js index 141579d097..d7c2cbe930 100644 --- a/frontend_tests/node_tests/upgrade.js +++ b/web/tests/upgrade.test.js @@ -5,10 +5,10 @@ const fs = require("fs"); const {JSDOM} = require("jsdom"); -const {set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); const noop = () => {}; const template = fs.readFileSync("templates/corporate/upgrade.html", "utf8"); diff --git a/frontend_tests/node_tests/upload.js b/web/tests/upload.test.js similarity index 98% rename from frontend_tests/node_tests/upload.js rename to web/tests/upload.test.js index f720e6e779..5ed97f14b2 100644 --- a/frontend_tests/node_tests/upload.js +++ b/web/tests/upload.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); set_global("navigator", { userAgent: "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)", @@ -19,8 +19,8 @@ mock_esm("@uppy/core", { }); mock_esm("@uppy/xhr-upload", {default: class XHRUpload {}}); -const compose_actions = mock_esm("../../web/src/compose_actions"); -mock_esm("../../web/src/csrf", {csrf_token: "csrf_token"}); +const compose_actions = mock_esm("../src/compose_actions"); +mock_esm("../src/csrf", {csrf_token: "csrf_token"}); const compose_ui = zrequire("compose_ui"); const upload = zrequire("upload"); diff --git a/frontend_tests/node_tests/user_events.js b/web/tests/user_events.test.js similarity index 91% rename from frontend_tests/node_tests/user_events.js rename to web/tests/user_events.test.js index 2a29c78426..90777f68a4 100644 --- a/frontend_tests/node_tests/user_events.js +++ b/web/tests/user_events.test.js @@ -2,46 +2,46 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const {page_params} = require("./lib/zpage_params"); -const message_live_update = mock_esm("../../web/src/message_live_update"); -const settings_account = mock_esm("../../web/src/settings_account", { +const message_live_update = mock_esm("../src/message_live_update"); +const settings_account = mock_esm("../src/settings_account", { update_email() {}, update_full_name() {}, update_account_settings_display() {}, }); -mock_esm("../../web/src/activity", { +mock_esm("../src/activity", { redraw() {}, }); -mock_esm("../../web/src/compose", { +mock_esm("../src/compose", { update_email() {}, }); -mock_esm("../../web/src/narrow_state", { +mock_esm("../src/narrow_state", { update_email() {}, }); -mock_esm("../../web/src/pm_list", { +mock_esm("../src/pm_list", { update_private_messages() {}, }); -mock_esm("../../web/src/settings_linkifiers", { +mock_esm("../src/settings_linkifiers", { maybe_disable_widgets() {}, }); -mock_esm("../../web/src/settings_org", { +mock_esm("../src/settings_org", { maybe_disable_widgets() {}, }); -mock_esm("../../web/src/settings_profile_fields", { +mock_esm("../src/settings_profile_fields", { maybe_disable_widgets() {}, }); -mock_esm("../../web/src/settings_realm_user_settings_defaults", { +mock_esm("../src/settings_realm_user_settings_defaults", { maybe_disable_widgets() {}, }); -mock_esm("../../web/src/settings_streams", { +mock_esm("../src/settings_streams", { maybe_disable_widgets() {}, }); -mock_esm("../../web/src/settings_users", { +mock_esm("../src/settings_users", { update_user_data() {}, }); diff --git a/frontend_tests/node_tests/user_group_pill.js b/web/tests/user_group_pill.test.js similarity index 95% rename from frontend_tests/node_tests/user_group_pill.js rename to web/tests/user_group_pill.test.js index bd15f9be32..9df72aa0f9 100644 --- a/frontend_tests/node_tests/user_group_pill.js +++ b/web/tests/user_group_pill.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); const user_groups = zrequire("user_groups"); const user_group_pill = zrequire("user_group_pill"); diff --git a/frontend_tests/node_tests/user_groups.js b/web/tests/user_groups.test.js similarity index 98% rename from frontend_tests/node_tests/user_groups.js rename to web/tests/user_groups.test.js index a1bb29688d..2097eddc3e 100644 --- a/frontend_tests/node_tests/user_groups.js +++ b/web/tests/user_groups.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); const user_groups = zrequire("user_groups"); diff --git a/frontend_tests/node_tests/user_pill.js b/web/tests/user_pill.test.js similarity index 95% rename from frontend_tests/node_tests/user_pill.js rename to web/tests/user_pill.test.js index daa732f20c..f0dfb9dc80 100644 --- a/frontend_tests/node_tests/user_pill.js +++ b/web/tests/user_pill.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const {page_params} = require("../zjsunit/zpage_params"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const {page_params} = require("./lib/zpage_params"); const people = zrequire("people"); const user_pill = zrequire("user_pill"); diff --git a/frontend_tests/node_tests/user_search.js b/web/tests/user_search.test.js similarity index 93% rename from frontend_tests/node_tests/user_search.js rename to web/tests/user_search.test.js index cdee912782..ae48c7b2c4 100644 --- a/frontend_tests/node_tests/user_search.js +++ b/web/tests/user_search.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); -const {page_params} = require("../zjsunit/zpage_params"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); +const {page_params} = require("./lib/zpage_params"); const _document = { hasFocus() { @@ -21,14 +21,14 @@ const fake_buddy_list = { next_key() {}, }; -mock_esm("../../web/src/buddy_list", { +mock_esm("../src/buddy_list", { buddy_list: fake_buddy_list, }); -const popovers = mock_esm("../../web/src/popovers"); -const presence = mock_esm("../../web/src/presence"); -const stream_popover = mock_esm("../../web/src/stream_popover"); -const resize = mock_esm("../../web/src/resize"); +const popovers = mock_esm("../src/popovers"); +const presence = mock_esm("../src/presence"); +const stream_popover = mock_esm("../src/stream_popover"); +const resize = mock_esm("../src/resize"); set_global("document", _document); diff --git a/frontend_tests/node_tests/user_status.js b/web/tests/user_status.test.js similarity index 96% rename from frontend_tests/node_tests/user_status.js rename to web/tests/user_status.test.js index b1af8c6d09..8d5a20651c 100644 --- a/frontend_tests/node_tests/user_status.js +++ b/web/tests/user_status.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_esm, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {mock_esm, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); -const channel = mock_esm("../../web/src/channel"); +const channel = mock_esm("../src/channel"); const user_status = zrequire("user_status"); const emoji_codes = zrequire("../../static/generated/emoji/emoji_codes.json"); diff --git a/frontend_tests/node_tests/user_topics.js b/web/tests/user_topics.test.js similarity index 94% rename from frontend_tests/node_tests/user_topics.js rename to web/tests/user_topics.test.js index b21cb97f84..d6f977ee9f 100644 --- a/frontend_tests/node_tests/user_topics.js +++ b/web/tests/user_topics.test.js @@ -2,11 +2,12 @@ const {strict: assert} = require("assert"); -const {visibility_policy} = require("../../web/src/user_topics"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const {page_params} = require("../zjsunit/zpage_params"); +const {visibility_policy} = require("../src/user_topics"); + +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const {page_params} = require("./lib/zpage_params"); const user_topics = zrequire("user_topics"); const stream_data = zrequire("stream_data"); diff --git a/frontend_tests/node_tests/util.js b/web/tests/util.test.js similarity index 98% rename from frontend_tests/node_tests/util.js rename to web/tests/util.test.js index a3f59c19a5..b9cecbf041 100644 --- a/frontend_tests/node_tests/util.js +++ b/web/tests/util.test.js @@ -4,8 +4,8 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const {set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); set_global("document", {}); const util = zrequire("util"); diff --git a/frontend_tests/node_tests/vdom.js b/web/tests/vdom.test.js similarity index 97% rename from frontend_tests/node_tests/vdom.js rename to web/tests/vdom.test.js index edd281675d..a79f11d5b7 100644 --- a/frontend_tests/node_tests/vdom.js +++ b/web/tests/vdom.test.js @@ -2,9 +2,9 @@ const {strict: assert} = require("assert"); -const {zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); +const {zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); const vdom = zrequire("vdom"); diff --git a/frontend_tests/node_tests/watchdog.js b/web/tests/watchdog.test.js similarity index 93% rename from frontend_tests/node_tests/watchdog.js rename to web/tests/watchdog.test.js index e22b24cde3..662d26127c 100644 --- a/frontend_tests/node_tests/watchdog.js +++ b/web/tests/watchdog.test.js @@ -4,8 +4,8 @@ const {strict: assert} = require("assert"); const MockDate = require("mockdate"); -const {set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); +const {set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); let time = 0; let checker; diff --git a/frontend_tests/node_tests/widgetize.js b/web/tests/widgetize.test.js similarity index 92% rename from frontend_tests/node_tests/widgetize.js rename to web/tests/widgetize.test.js index 814bee417d..c9128a4f19 100644 --- a/frontend_tests/node_tests/widgetize.js +++ b/web/tests/widgetize.test.js @@ -2,10 +2,10 @@ const {strict: assert} = require("assert"); -const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); -const $ = require("../zjsunit/zjquery"); +const {mock_esm, set_global, zrequire} = require("./lib/namespace"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); +const $ = require("./lib/zjquery"); const sample_events = [ { @@ -54,9 +54,9 @@ const fake_poll_widget = { }, }; -const message_lists = mock_esm("../../web/src/message_lists", {current: {}}); -const narrow_state = mock_esm("../../web/src/narrow_state"); -mock_esm("../../web/src/poll_widget", fake_poll_widget); +const message_lists = mock_esm("../src/message_lists", {current: {}}); +const narrow_state = mock_esm("../src/narrow_state"); +mock_esm("../src/poll_widget", fake_poll_widget); set_global("document", "document-stub"); diff --git a/frontend_tests/node_tests/zblueslip.js b/web/tests/zblueslip.test.js similarity index 92% rename from frontend_tests/node_tests/zblueslip.js rename to web/tests/zblueslip.test.js index 25303f4254..32495fec55 100644 --- a/frontend_tests/node_tests/zblueslip.js +++ b/web/tests/zblueslip.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {run_test} = require("../zjsunit/test"); -const blueslip = require("../zjsunit/zblueslip"); +const {run_test} = require("./lib/test"); +const blueslip = require("./lib/zblueslip"); /* @@ -23,10 +23,10 @@ What is zblueslip? The code we are testing lives here: - https://github.com/zulip/zulip/blob/main/frontend_tests/zjsunit/zblueslip.js + https://github.com/zulip/zulip/blob/main/web/tests/lib/zblueslip.js Read the following contents for an overview of how zblueslip works. Also take a -look at `node_tests/people_errors.js` for actual usage of this module. +look at `people_errors.test.js` for actual usage of this module. */ run_test("basics", () => { diff --git a/frontend_tests/node_tests/zjquery.js b/web/tests/zjquery.test.js similarity index 97% rename from frontend_tests/node_tests/zjquery.js rename to web/tests/zjquery.test.js index 2bf865561b..022457e6c5 100644 --- a/frontend_tests/node_tests/zjquery.js +++ b/web/tests/zjquery.test.js @@ -2,8 +2,8 @@ const {strict: assert} = require("assert"); -const {run_test} = require("../zjsunit/test"); -const $ = require("../zjsunit/zjquery"); +const {run_test} = require("./lib/test"); +const $ = require("./lib/zjquery"); /* @@ -25,7 +25,7 @@ What is zjquery? The code we are testing lives here: - https://github.com/zulip/zulip/blob/main/frontend_tests/zjsunit/zjquery.js + https://github.com/zulip/zulip/blob/main/web/tests/lib/zjquery.js */ diff --git a/zerver/lib/mdiff.py b/zerver/lib/mdiff.py index e592561fdc..3cced977bf 100644 --- a/zerver/lib/mdiff.py +++ b/zerver/lib/mdiff.py @@ -8,7 +8,7 @@ class DiffError(Exception): def diff_strings(output: str, expected_output: str) -> str: - mdiff_path = "frontend_tests/zjsunit/mdiff.js" + mdiff_path = "web/tests/lib/mdiff.js" if not os.path.isfile(mdiff_path): # nocoverage msg = "Cannot find mdiff for Markdown diff rendering" logging.error(msg) diff --git a/zerver/tests/test_markdown.py b/zerver/tests/test_markdown.py index 5f5ce41c94..fda73aab66 100644 --- a/zerver/tests/test_markdown.py +++ b/zerver/tests/test_markdown.py @@ -1614,7 +1614,7 @@ class MarkdownTest(ZulipTestCase): ) def test_topic_links_ordering_by_priority(self) -> None: - # The same test case is also implemented in frontend_tests/node_tests/markdown_parse.js + # The same test case is also implemented in web/tests/markdown_parse.test.js realm = get_realm("zulip") self.check_add_linkifiers( [