Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
130 lines
3.7 KiB
JavaScript
130 lines
3.7 KiB
JavaScript
"use strict";
|
|
|
|
const assert = require("node:assert/strict");
|
|
const path = require("node:path");
|
|
|
|
require("@date-fns/tz"); // To prevent @sinonjs/fake-timers from interfering with it
|
|
require("css.escape");
|
|
require("handlebars/runtime.js");
|
|
const {JSDOM} = require("jsdom");
|
|
|
|
const handlebars = require("./handlebars.cjs");
|
|
const namespace = require("./namespace.cjs");
|
|
const test = require("./test.cjs");
|
|
const blueslip = require("./zblueslip.cjs");
|
|
const {$} = require("./zjquery.cjs");
|
|
const zpage_billing_params = require("./zpage_billing_params.cjs");
|
|
const zpage_params = require("./zpage_params.cjs");
|
|
|
|
process.env.NODE_ENV = "test";
|
|
|
|
const dom = new JSDOM("", {url: "http://zulip.zulipdev.com/"});
|
|
global.DOMParser = dom.window.DOMParser;
|
|
global.HTMLAnchorElement = dom.window.HTMLAnchorElement;
|
|
global.HTMLElement = dom.window.HTMLElement;
|
|
global.HTMLImageElement = dom.window.HTMLImageElement;
|
|
global.Window = dom.window.Window;
|
|
Object.defineProperty(global, "navigator", {
|
|
value: {
|
|
userAgent: "node.js",
|
|
},
|
|
writable: true,
|
|
});
|
|
|
|
require("@babel/register").default({
|
|
extensions: [".cjs", ".cts", ".js", ".mjs", ".mts", ".ts"],
|
|
root: path.resolve(__dirname, "../.."),
|
|
});
|
|
|
|
// Find the files we need to run.
|
|
const files = process.argv.slice(2);
|
|
assert.notEqual(files.length, 0, "No tests found");
|
|
|
|
// Set up our namespace helpers.
|
|
const window = new Proxy(global, {
|
|
set(_obj, prop, value) {
|
|
namespace.set_global(prop, value);
|
|
return true;
|
|
},
|
|
});
|
|
|
|
const ls_container = new Map();
|
|
const localStorage = {
|
|
getItem(key) {
|
|
return ls_container.get(key);
|
|
},
|
|
setItem(key, val) {
|
|
ls_container.set(key, val);
|
|
},
|
|
/* istanbul ignore next */
|
|
removeItem(key) {
|
|
ls_container.delete(key);
|
|
},
|
|
clear() {
|
|
ls_container.clear();
|
|
},
|
|
};
|
|
|
|
// Set up Handlebars
|
|
handlebars.hook_require();
|
|
|
|
require("../../src/templates.ts"); // register Zulip extensions
|
|
|
|
async function run_one_module(file) {
|
|
$.clear_all_elements();
|
|
console.info("running test " + path.basename(file, ".test.cjs"));
|
|
test.set_current_file_name(file);
|
|
test.suite.length = 0;
|
|
require(file);
|
|
for (const f of test.suite) {
|
|
await f();
|
|
}
|
|
namespace.complain_about_unused_mocks();
|
|
}
|
|
|
|
test.set_verbose(files.length === 1);
|
|
|
|
// In case someone mistakenly vanishes the async task with something like `await
|
|
// new Promise(() => {})`, assume failure until we establish otherwise.
|
|
process.exitCode = 1;
|
|
|
|
(async () => {
|
|
let exit_code = 0;
|
|
|
|
for (const file of files) {
|
|
namespace.start();
|
|
namespace.set_global("window", window);
|
|
namespace.set_global("location", dom.window.location);
|
|
window.location.href = "http://zulip.zulipdev.com/#";
|
|
namespace.set_global("localStorage", localStorage);
|
|
ls_container.clear();
|
|
zpage_billing_params.reset();
|
|
zpage_params.reset();
|
|
|
|
namespace.mock_esm("../../src/blueslip", blueslip);
|
|
require("../../src/blueslip.ts");
|
|
namespace.mock_esm("../../src/base_page_params", zpage_params);
|
|
require("../../src/base_page_params.ts");
|
|
namespace.mock_esm("../../src/billing/page_params", zpage_billing_params);
|
|
require("../../src/billing/page_params.ts");
|
|
namespace.mock_esm("../../src/page_params", zpage_params);
|
|
require("../../src/page_params.ts");
|
|
|
|
// Make sure we re-register our Handlebars helpers.
|
|
require("../../src/templates.ts");
|
|
|
|
try {
|
|
await run_one_module(file);
|
|
blueslip.reset();
|
|
} catch (error) /* istanbul ignore next */ {
|
|
console.error(error);
|
|
exit_code = 1;
|
|
blueslip.reset(true);
|
|
}
|
|
|
|
namespace.finish();
|
|
}
|
|
|
|
process.exitCode = exit_code;
|
|
})();
|