node_tests: Move to web/tests.

This lets us simplify the long-ish ‘../../static/js’ paths, and will
remove the need for the ‘zrequire’ wrapper.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-02-22 14:04:10 -08:00
parent c1675913a2
commit cea1119423
190 changed files with 990 additions and 993 deletions

View File

@ -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,

View File

@ -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.

View File

@ -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`.

View File

@ -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

View File

@ -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]

View File

@ -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,

View File

@ -139,5 +139,10 @@
"repository": {
"type": "git",
"url": "https://github.com/zulip/zulip.git"
},
"nyc": {
"exclude": [
"**/node_modules/**"
]
}
}

View File

@ -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

View File

@ -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": ['<p style="color: blue;">Foo</p>', 'style = "color: blue;"'],

View File

@ -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));

View File

@ -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)

View File

@ -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);

View File

@ -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,

View File

@ -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 = [];

View File

@ -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() {},
});

View File

@ -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",
});

View File

@ -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");

View File

@ -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");

View File

@ -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";

View File

@ -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 = {

View File

@ -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");

View File

@ -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;
},

View File

@ -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");

View File

@ -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");

View File

@ -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 = () => {};

View File

@ -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;

View File

@ -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");

View File

@ -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,
});

View File

@ -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

View File

@ -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) {

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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 = {

View File

@ -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", {

View File

@ -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;

View File

@ -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("<!DOCTYPE html><p>Hello world</p>");
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");

View File

@ -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: "",

View File

@ -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.

View File

@ -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");

View File

@ -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,
});

View File

@ -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}),
});

View File

@ -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() {},

View File

@ -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;

View File

@ -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");

View File

@ -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) => {

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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");

View File

@ -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 = {};

View File

@ -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

View File

@ -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 = {};

View File

@ -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

View File

@ -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");

View File

@ -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() {},

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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", {});

View File

@ -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,

View File

@ -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", () => {

View File

@ -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}) => {

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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.

View File

@ -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);

View File

@ -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];
}
}

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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

View File

@ -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 = [
{

View File

@ -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");

View File

@ -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

View File

@ -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];

View File

@ -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,

View File

@ -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() {},

View File

@ -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");

View File

@ -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");

View File

@ -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",

View File

@ -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,
});

View File

@ -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");

View File

@ -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) {

View File

@ -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,
});

Some files were not shown because too many files have changed in this diff Show More