snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
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
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
This commit is contained in:
81
web/tests/topic_list.test.cjs
Normal file
81
web/tests/topic_list.test.cjs
Normal file
@@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
|
||||
const assert = require("node:assert/strict");
|
||||
|
||||
const {make_realm} = require("./lib/example_realm.cjs");
|
||||
const {mock_esm, zrequire} = require("./lib/namespace.cjs");
|
||||
const {run_test, noop} = require("./lib/test.cjs");
|
||||
|
||||
const stream_topic_history_util = mock_esm("../src/stream_topic_history_util");
|
||||
mock_esm("../src/people.ts", {
|
||||
maybe_get_user_by_id: noop,
|
||||
});
|
||||
|
||||
const recent_view_messages_data = zrequire("recent_view_messages_data");
|
||||
const {set_realm} = zrequire("state_data");
|
||||
const stream_data = zrequire("stream_data");
|
||||
const stream_topic_history = zrequire("stream_topic_history");
|
||||
const topic_list = zrequire("topic_list");
|
||||
|
||||
set_realm(make_realm());
|
||||
|
||||
function test(label, f) {
|
||||
run_test(label, (helpers) => {
|
||||
f(helpers);
|
||||
});
|
||||
}
|
||||
|
||||
test("is_full_topic_history_available", ({override}) => {
|
||||
const stream_id = 21;
|
||||
const general = {
|
||||
name: "general",
|
||||
stream_id,
|
||||
first_message_id: null,
|
||||
subscriber_count: 0,
|
||||
};
|
||||
const messages = [
|
||||
{id: 1, stream_id},
|
||||
{id: 2, stream_id},
|
||||
{id: 3, stream_id},
|
||||
];
|
||||
const sub = stream_data.create_sub_from_server_data(general);
|
||||
|
||||
// Currently, recent_view_messages_data is empty.
|
||||
assert.equal(topic_list.is_full_topic_history_available(stream_id), false);
|
||||
|
||||
recent_view_messages_data.recent_view_messages_data.clear();
|
||||
recent_view_messages_data.recent_view_messages_data.add_messages(messages, true);
|
||||
|
||||
let has_found_newest = false;
|
||||
|
||||
override(
|
||||
recent_view_messages_data.recent_view_messages_data.fetch_status,
|
||||
"has_found_newest",
|
||||
() => has_found_newest,
|
||||
);
|
||||
|
||||
assert.equal(topic_list.is_full_topic_history_available(stream_id), false);
|
||||
has_found_newest = true;
|
||||
// sub.first_message_id === null
|
||||
assert.equal(topic_list.is_full_topic_history_available(stream_id), true);
|
||||
|
||||
// Note that we'll return `true` here due to
|
||||
// fetched_stream_ids having the stream_id now.
|
||||
assert.equal(topic_list.is_full_topic_history_available(stream_id), true);
|
||||
|
||||
// Clear the data, otherwise `is_full_topic_history_available`
|
||||
// will always return true due to stream_id in fetched_stream_ids.
|
||||
stream_topic_history.reset();
|
||||
|
||||
sub.first_message_id = 0;
|
||||
assert.equal(topic_list.is_full_topic_history_available(stream_id), false);
|
||||
|
||||
sub.first_message_id = 2;
|
||||
let full_topic_history_fetched_and_widget_updated = false;
|
||||
stream_topic_history_util.get_server_history = (stream_id) => {
|
||||
assert.equal(stream_id, general.stream_id);
|
||||
full_topic_history_fetched_and_widget_updated = true;
|
||||
};
|
||||
assert.equal(topic_list.is_full_topic_history_available(stream_id), true);
|
||||
assert.equal(full_topic_history_fetched_and_widget_updated, true);
|
||||
});
|
||||
Reference in New Issue
Block a user