mirror of
https://github.com/zulip/zulip.git
synced 2026-06-06 21:12:33 +08:00
Fixes #23995. We try to fetch the message locally if possible. If it is not possible to fetch the message locally, only then we make a network request. We give the users common options to chose from along with a custom time option which opens up a date picker for the user to chose a custom date from.
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
"use strict";
|
|
|
|
const assert = require("node:assert/strict");
|
|
|
|
const {zrequire} = require("./lib/namespace.cjs");
|
|
const {run_test} = require("./lib/test.cjs");
|
|
const blueslip = require("./lib/zblueslip.cjs");
|
|
|
|
const {Filter} = zrequire("filter");
|
|
const {MessageListData} = zrequire("message_list_data");
|
|
const message_fetch = zrequire("message_fetch");
|
|
|
|
run_test("get_parameters_for_message_fetch_api date anchor", () => {
|
|
const msg_list_data = new MessageListData({
|
|
excludes_muted_topics: false,
|
|
filter: new Filter([]),
|
|
});
|
|
|
|
const anchor_date = new Date("2024-01-02T00:00:00.000Z").toISOString();
|
|
const params = message_fetch.get_parameters_for_message_fetch_api({
|
|
anchor: "date",
|
|
anchor_date,
|
|
num_before: 0,
|
|
num_after: 0,
|
|
cont() {},
|
|
msg_list_data,
|
|
});
|
|
assert.equal(params.anchor, "date");
|
|
assert.equal(params.anchor_date, anchor_date);
|
|
|
|
blueslip.expect("error", "Missing anchor_date for date anchor fetch");
|
|
const missing_date = message_fetch.get_parameters_for_message_fetch_api({
|
|
anchor: "date",
|
|
num_before: 0,
|
|
num_after: 0,
|
|
cont() {},
|
|
msg_list_data,
|
|
});
|
|
assert.equal(missing_date.anchor_date, undefined);
|
|
});
|