2020-08-01 03:43:15 +02:00
|
|
|
"use strict";
|
|
|
|
|
2024-10-09 00:25:41 +02:00
|
|
|
const assert = require("node:assert/strict");
|
2020-11-30 23:46:45 +01:00
|
|
|
|
2024-11-12 03:59:37 +01:00
|
|
|
const {mock_esm, set_global, zrequire} = require("./lib/namespace.js");
|
|
|
|
const {run_test, noop} = require("./lib/test.js");
|
|
|
|
const $ = require("./lib/zjquery.js");
|
2018-07-14 12:46:02 +02:00
|
|
|
|
2024-03-15 20:18:37 +01:00
|
|
|
const bootstrap_typeahead = mock_esm("../src/bootstrap_typeahead");
|
2023-02-22 23:04:10 +01:00
|
|
|
const search_suggestion = mock_esm("../src/search_suggestion");
|
2021-03-06 17:37:51 +01:00
|
|
|
|
2020-12-01 23:21:38 +01:00
|
|
|
const search = zrequire("search");
|
2024-01-25 22:11:22 +01:00
|
|
|
const search_pill = zrequire("search_pill");
|
2024-06-05 06:34:04 +02:00
|
|
|
const stream_data = zrequire("stream_data");
|
2024-01-25 22:11:22 +01:00
|
|
|
|
|
|
|
function stub_pills() {
|
|
|
|
const $pill_container = $("#searchbox-input-container.pill-container");
|
|
|
|
const $pill_input = $.create("pill_input");
|
|
|
|
$pill_container.set_find_results(".input", $pill_input);
|
|
|
|
$pill_input.before = noop;
|
|
|
|
}
|
2020-12-01 23:21:38 +01:00
|
|
|
|
2024-01-24 22:20:39 +01:00
|
|
|
set_global("getSelection", () => ({
|
|
|
|
modify: noop,
|
|
|
|
}));
|
|
|
|
|
2024-05-06 22:31:24 +02:00
|
|
|
let typeahead_forced_open = false;
|
|
|
|
|
2024-06-05 06:34:04 +02:00
|
|
|
const verona = {
|
|
|
|
subscribed: true,
|
|
|
|
color: "blue",
|
|
|
|
name: "Verona",
|
|
|
|
stream_id: 1,
|
|
|
|
};
|
|
|
|
stream_data.add_sub(verona);
|
|
|
|
|
2024-03-15 20:18:37 +01:00
|
|
|
run_test("initialize", ({override, override_rewire, mock_template}) => {
|
2022-01-25 11:36:19 +01:00
|
|
|
const $search_query_box = $("#search_query");
|
|
|
|
const $searchbox_form = $("#searchbox_form");
|
2024-01-25 22:11:22 +01:00
|
|
|
stub_pills();
|
2018-07-14 12:46:02 +02:00
|
|
|
|
2021-12-06 23:44:26 +01:00
|
|
|
mock_template("search_list_item.hbs", true, (data, html) => {
|
|
|
|
assert.equal(typeof data.description_html, "string");
|
2024-04-29 21:55:42 +02:00
|
|
|
if (data.is_people) {
|
|
|
|
for (const user of data.users) {
|
|
|
|
assert.equal(typeof user.user_pill_context.id, "number");
|
|
|
|
assert.equal(typeof user.user_pill_context.display_value, "string");
|
|
|
|
assert.equal(typeof user.user_pill_context.has_image, "boolean");
|
|
|
|
assert.equal(typeof user.user_pill_context.img_src, "string");
|
|
|
|
}
|
2021-12-06 23:44:26 +01:00
|
|
|
}
|
|
|
|
return html;
|
|
|
|
});
|
|
|
|
|
2024-01-25 22:11:22 +01:00
|
|
|
let expected_pill_display_value = "";
|
|
|
|
let input_pill_displayed = false;
|
|
|
|
mock_template("input_pill.hbs", true, (data, html) => {
|
|
|
|
assert.equal(data.display_value, expected_pill_display_value);
|
|
|
|
input_pill_displayed = true;
|
|
|
|
return html;
|
|
|
|
});
|
|
|
|
|
2019-12-25 16:58:11 +01:00
|
|
|
search_suggestion.max_num_of_search_results = 999;
|
2023-12-22 00:26:14 +01:00
|
|
|
let terms;
|
2023-06-22 11:16:16 +02:00
|
|
|
|
2024-01-25 22:11:22 +01:00
|
|
|
function mock_pill_removes(widget) {
|
|
|
|
const pills = widget._get_pills_for_testing();
|
|
|
|
for (const pill of pills) {
|
|
|
|
pill.$element.remove = noop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-06 22:31:24 +02:00
|
|
|
override(bootstrap_typeahead, "Typeahead", (input_element, opts) => {
|
2024-03-18 06:14:23 +01:00
|
|
|
assert.equal(input_element.$element, $search_query_box);
|
2019-12-25 16:58:11 +01:00
|
|
|
assert.equal(opts.items, 999);
|
2018-07-14 12:46:02 +02:00
|
|
|
assert.equal(opts.helpOnEmptyStrings, true);
|
|
|
|
assert.equal(opts.matcher(), true);
|
|
|
|
|
|
|
|
{
|
|
|
|
const search_suggestions = {
|
2020-02-12 06:58:20 +01:00
|
|
|
lookup_table: new Map([
|
2020-07-15 00:34:28 +02:00
|
|
|
[
|
|
|
|
"stream:Verona",
|
|
|
|
{
|
2022-08-18 14:54:00 +02:00
|
|
|
description_html: "Stream <strong>Ver</strong>ona",
|
2020-07-15 00:34:28 +02:00
|
|
|
search_string: "stream:Verona",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"ver",
|
|
|
|
{
|
2022-06-19 07:17:16 +02:00
|
|
|
description_html: "Search for ver",
|
2020-07-15 00:34:28 +02:00
|
|
|
search_string: "ver",
|
|
|
|
},
|
|
|
|
],
|
2020-02-12 06:58:20 +01:00
|
|
|
]),
|
2020-07-15 01:29:15 +02:00
|
|
|
strings: ["ver", "stream:Verona"],
|
2018-07-14 12:46:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Test source */
|
2020-06-01 15:00:42 +02:00
|
|
|
search_suggestion.get_suggestions = () => search_suggestions;
|
2018-07-14 12:46:02 +02:00
|
|
|
const expected_source_value = search_suggestions.strings;
|
2020-07-15 01:29:15 +02:00
|
|
|
const source = opts.source("ver");
|
2024-01-25 22:11:22 +01:00
|
|
|
assert.deepStrictEqual(source, expected_source_value);
|
2018-07-14 12:46:02 +02:00
|
|
|
|
|
|
|
/* Test highlighter */
|
2022-08-18 14:54:00 +02:00
|
|
|
let expected_value = `<div class="search_list_item">\n <span>Search for ver</span>\n</div>\n`;
|
2024-03-10 19:53:52 +01:00
|
|
|
assert.equal(opts.highlighter_html(source[0]), expected_value);
|
2021-12-06 23:44:26 +01:00
|
|
|
|
2022-08-18 14:54:00 +02:00
|
|
|
expected_value = `<div class="search_list_item">\n <span>Stream <strong>Ver</strong>ona</span>\n</div>\n`;
|
2024-03-10 19:53:52 +01:00
|
|
|
assert.equal(opts.highlighter_html(source[1]), expected_value);
|
2021-12-06 23:44:26 +01:00
|
|
|
|
|
|
|
/* Test sorter */
|
|
|
|
assert.equal(opts.sorter(search_suggestions.strings), search_suggestions.strings);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const search_suggestions = {
|
|
|
|
lookup_table: new Map([
|
|
|
|
[
|
2023-04-19 20:25:55 +02:00
|
|
|
"dm-including:zo",
|
2021-12-06 23:44:26 +01:00
|
|
|
{
|
2023-01-24 19:49:56 +01:00
|
|
|
description_html: "group direct messages including",
|
2024-04-29 21:55:42 +02:00
|
|
|
is_people: true,
|
2023-04-19 20:25:55 +02:00
|
|
|
search_string: "dm-including:user7@zulipdev.com",
|
2024-04-29 21:55:42 +02:00
|
|
|
users: [
|
|
|
|
{
|
|
|
|
user_pill_context: {
|
|
|
|
display_value: "<strong>Zo</strong>e",
|
|
|
|
has_image: true,
|
|
|
|
id: 7,
|
|
|
|
img_src:
|
2024-08-02 20:00:55 +02:00
|
|
|
"https://secure.gravatar.com/avatar/0f030c97ab51312c7bbffd3966198ced?d=identicon&version=1",
|
2024-04-29 21:55:42 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2021-12-06 23:44:26 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
2023-04-11 21:04:33 +02:00
|
|
|
"dm:zo",
|
2021-12-06 23:44:26 +01:00
|
|
|
{
|
2023-01-24 19:49:56 +01:00
|
|
|
description_html: "direct messages with",
|
2024-04-29 21:55:42 +02:00
|
|
|
is_people: true,
|
2023-04-11 21:04:33 +02:00
|
|
|
search_string: "dm:user7@zulipdev.com",
|
2024-04-29 21:55:42 +02:00
|
|
|
users: [
|
|
|
|
{
|
|
|
|
user_pill_context: {
|
|
|
|
display_value: "<strong>Zo</strong>e",
|
|
|
|
has_image: true,
|
|
|
|
id: 7,
|
|
|
|
img_src:
|
2024-08-02 20:00:55 +02:00
|
|
|
"https://secure.gravatar.com/avatar/0f030c97ab51312c7bbffd3966198ced?d=identicon&version=1",
|
2024-04-29 21:55:42 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2021-12-06 23:44:26 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"sender:zo",
|
|
|
|
{
|
|
|
|
description_html: "sent by",
|
2024-04-29 21:55:42 +02:00
|
|
|
is_people: true,
|
2021-12-06 23:44:26 +01:00
|
|
|
search_string: "sender:user7@zulipdev.com",
|
2024-04-29 21:55:42 +02:00
|
|
|
users: [
|
|
|
|
{
|
|
|
|
user_pill_context: {
|
|
|
|
display_value: "<strong>Zo</strong>e",
|
|
|
|
has_image: true,
|
|
|
|
id: 7,
|
|
|
|
img_src:
|
2024-08-02 20:00:55 +02:00
|
|
|
"https://secure.gravatar.com/avatar/0f030c97ab51312c7bbffd3966198ced?d=identicon&version=1",
|
2024-04-29 21:55:42 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2021-12-06 23:44:26 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"zo",
|
|
|
|
{
|
|
|
|
description_html: "Search for zo",
|
|
|
|
search_string: "zo",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
]),
|
2023-04-19 20:25:55 +02:00
|
|
|
strings: ["zo", "sender:zo", "dm:zo", "dm-including:zo"],
|
2021-12-06 23:44:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Test source */
|
|
|
|
search_suggestion.get_suggestions = () => search_suggestions;
|
|
|
|
const expected_source_value = search_suggestions.strings;
|
|
|
|
const source = opts.source("zo");
|
2024-01-25 22:11:22 +01:00
|
|
|
assert.deepStrictEqual(source, expected_source_value);
|
2021-12-06 23:44:26 +01:00
|
|
|
|
|
|
|
/* Test highlighter */
|
2022-08-18 14:54:00 +02:00
|
|
|
let expected_value = `<div class="search_list_item">\n <span>Search for zo</span>\n</div>\n`;
|
2024-03-10 19:53:52 +01:00
|
|
|
assert.equal(opts.highlighter_html(source[0]), expected_value);
|
2018-07-14 12:46:02 +02:00
|
|
|
|
2024-08-02 20:00:55 +02:00
|
|
|
expected_value = `<div class="search_list_item">\n <span>sent by</span>\n <span class="pill-container">\n <div class='pill ' tabindex=0>\n <img class="pill-image" src="https://secure.gravatar.com/avatar/0f030c97ab51312c7bbffd3966198ced?d=identicon&version=1" />\n <span class="pill-label">\n <span class="pill-value">\n <strong>Zo</strong>e\n </span></span>\n <div class="exit">\n <a role="button" class="zulip-icon zulip-icon-close pill-close-button"></a>\n </div>\n</div>\n </span>\n</div>\n`;
|
2024-03-10 19:53:52 +01:00
|
|
|
assert.equal(opts.highlighter_html(source[1]), expected_value);
|
2018-07-14 12:46:02 +02:00
|
|
|
|
2024-08-02 20:00:55 +02:00
|
|
|
expected_value = `<div class="search_list_item">\n <span>direct messages with</span>\n <span class="pill-container">\n <div class='pill ' tabindex=0>\n <img class="pill-image" src="https://secure.gravatar.com/avatar/0f030c97ab51312c7bbffd3966198ced?d=identicon&version=1" />\n <span class="pill-label">\n <span class="pill-value">\n <strong>Zo</strong>e\n </span></span>\n <div class="exit">\n <a role="button" class="zulip-icon zulip-icon-close pill-close-button"></a>\n </div>\n</div>\n </span>\n</div>\n`;
|
2024-03-10 19:53:52 +01:00
|
|
|
assert.equal(opts.highlighter_html(source[2]), expected_value);
|
2021-12-06 23:44:26 +01:00
|
|
|
|
2024-08-02 20:00:55 +02:00
|
|
|
expected_value = `<div class="search_list_item">\n <span>group direct messages including</span>\n <span class="pill-container">\n <div class='pill ' tabindex=0>\n <img class="pill-image" src="https://secure.gravatar.com/avatar/0f030c97ab51312c7bbffd3966198ced?d=identicon&version=1" />\n <span class="pill-label">\n <span class="pill-value">\n <strong>Zo</strong>e\n </span></span>\n <div class="exit">\n <a role="button" class="zulip-icon zulip-icon-close pill-close-button"></a>\n </div>\n</div>\n </span>\n</div>\n`;
|
2024-03-10 19:53:52 +01:00
|
|
|
assert.equal(opts.highlighter_html(source[3]), expected_value);
|
2021-12-06 23:44:26 +01:00
|
|
|
|
2018-07-14 12:46:02 +02:00
|
|
|
/* Test sorter */
|
|
|
|
assert.equal(opts.sorter(search_suggestions.strings), search_suggestions.strings);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
/* Test updater */
|
2024-01-25 22:11:22 +01:00
|
|
|
const _setup = (terms) => {
|
|
|
|
const pills = search.search_pill_widget._get_pills_for_testing();
|
|
|
|
for (const pill of pills) {
|
|
|
|
pill.$element.remove = noop;
|
|
|
|
}
|
2024-06-05 06:34:04 +02:00
|
|
|
search_pill.set_search_bar_contents(
|
|
|
|
terms,
|
|
|
|
search.search_pill_widget,
|
|
|
|
$search_query_box.text,
|
|
|
|
);
|
2018-07-14 12:46:02 +02:00
|
|
|
};
|
|
|
|
|
2023-12-22 00:26:14 +01:00
|
|
|
terms = [
|
2020-07-15 00:34:28 +02:00
|
|
|
{
|
|
|
|
negated: false,
|
|
|
|
operator: "search",
|
|
|
|
operand: "ver",
|
|
|
|
},
|
|
|
|
];
|
2024-06-20 23:02:57 +02:00
|
|
|
expected_pill_display_value = null;
|
2024-01-25 22:11:22 +01:00
|
|
|
_setup(terms);
|
|
|
|
input_pill_displayed = false;
|
|
|
|
mock_pill_removes(search.search_pill_widget);
|
2024-07-16 07:17:10 +02:00
|
|
|
$(".navbar-search.expanded").length = 1;
|
2024-06-20 23:02:57 +02:00
|
|
|
assert.equal(opts.updater("ver"), "ver");
|
|
|
|
assert.ok(!input_pill_displayed);
|
2018-07-14 12:46:02 +02:00
|
|
|
|
2024-08-03 03:05:34 +02:00
|
|
|
const verona_stream_id = verona.stream_id.toString();
|
2023-12-22 00:26:14 +01:00
|
|
|
terms = [
|
2020-07-15 00:34:28 +02:00
|
|
|
{
|
|
|
|
negated: false,
|
2024-01-25 22:11:22 +01:00
|
|
|
operator: "channel",
|
2024-08-03 03:05:34 +02:00
|
|
|
operand: verona_stream_id,
|
2024-01-25 22:11:22 +01:00
|
|
|
},
|
|
|
|
];
|
2024-05-23 23:06:21 +02:00
|
|
|
expected_pill_display_value = "channel: Verona";
|
2024-01-25 22:11:22 +01:00
|
|
|
_setup(terms);
|
|
|
|
input_pill_displayed = false;
|
|
|
|
mock_pill_removes(search.search_pill_widget);
|
2024-08-03 03:05:34 +02:00
|
|
|
assert.equal(opts.updater(`channel:${verona_stream_id}`), "");
|
2024-01-25 22:11:22 +01:00
|
|
|
assert.ok(input_pill_displayed);
|
2018-07-14 12:46:02 +02:00
|
|
|
|
2024-11-08 11:44:54 +01:00
|
|
|
search.rewire_is_using_input_method(true);
|
2024-01-25 22:11:22 +01:00
|
|
|
_setup(terms);
|
|
|
|
input_pill_displayed = false;
|
|
|
|
mock_pill_removes(search.search_pill_widget);
|
2024-08-03 03:05:34 +02:00
|
|
|
assert.equal(opts.updater(`channel:${verona_stream_id}`), "");
|
2024-01-25 22:11:22 +01:00
|
|
|
assert.ok(input_pill_displayed);
|
2018-07-14 12:46:02 +02:00
|
|
|
}
|
2024-05-06 22:31:24 +02:00
|
|
|
return {
|
|
|
|
lookup() {
|
|
|
|
typeahead_forced_open = true;
|
|
|
|
},
|
|
|
|
};
|
2024-03-13 01:21:10 +01:00
|
|
|
});
|
2018-07-14 12:46:02 +02:00
|
|
|
|
2023-06-22 11:16:16 +02:00
|
|
|
search.initialize({
|
2024-01-25 22:11:22 +01:00
|
|
|
on_narrow_search() {},
|
2023-06-22 11:16:16 +02:00
|
|
|
});
|
2018-07-14 12:46:02 +02:00
|
|
|
|
2023-09-21 11:50:42 +02:00
|
|
|
$search_query_box.text("test string");
|
2018-07-14 12:46:02 +02:00
|
|
|
|
2024-11-08 11:44:54 +01:00
|
|
|
search.rewire_is_using_input_method(false);
|
2022-01-25 11:36:19 +01:00
|
|
|
$searchbox_form.trigger("compositionend");
|
2021-06-10 08:32:54 +02:00
|
|
|
assert.ok(search.is_using_input_method);
|
2020-07-21 00:23:06 +02:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
const keydown = $searchbox_form.get_on_handler("keydown");
|
2020-09-24 07:50:36 +02:00
|
|
|
let default_prevented = false;
|
2020-07-21 00:23:06 +02:00
|
|
|
let ev = {
|
|
|
|
type: "keydown",
|
|
|
|
which: 15,
|
2020-09-24 07:50:36 +02:00
|
|
|
preventDefault() {
|
|
|
|
default_prevented = true;
|
|
|
|
},
|
2018-07-14 12:46:02 +02:00
|
|
|
};
|
2022-01-25 11:36:19 +01:00
|
|
|
$search_query_box.is = () => false;
|
2020-07-21 00:23:06 +02:00
|
|
|
assert.equal(keydown(ev), undefined);
|
2021-06-10 08:32:54 +02:00
|
|
|
assert.ok(!default_prevented);
|
2018-07-14 12:46:02 +02:00
|
|
|
|
2021-05-31 18:38:57 +02:00
|
|
|
ev.key = "Enter";
|
2020-07-21 00:23:06 +02:00
|
|
|
assert.equal(keydown(ev), undefined);
|
2021-06-10 08:32:54 +02:00
|
|
|
assert.ok(!default_prevented);
|
2018-07-14 12:46:02 +02:00
|
|
|
|
2021-05-31 18:38:57 +02:00
|
|
|
ev.key = "Enter";
|
2022-01-25 11:36:19 +01:00
|
|
|
$search_query_box.is = () => true;
|
2020-09-24 07:50:36 +02:00
|
|
|
assert.equal(keydown(ev), undefined);
|
2021-06-10 08:32:54 +02:00
|
|
|
assert.ok(default_prevented);
|
2018-07-14 12:46:02 +02:00
|
|
|
|
2020-07-21 00:23:06 +02:00
|
|
|
ev = {
|
|
|
|
type: "keyup",
|
2018-07-14 12:46:02 +02:00
|
|
|
};
|
2020-07-21 00:23:06 +02:00
|
|
|
|
2024-01-25 22:11:22 +01:00
|
|
|
const _setup = (terms) => {
|
|
|
|
const pills = search.search_pill_widget._get_pills_for_testing();
|
|
|
|
for (const pill of pills) {
|
|
|
|
pill.$element.remove = noop;
|
|
|
|
}
|
2024-01-24 22:20:39 +01:00
|
|
|
search_pill.set_search_bar_contents(
|
|
|
|
terms,
|
|
|
|
search.search_pill_widget,
|
|
|
|
$search_query_box.text,
|
|
|
|
);
|
2018-07-14 12:46:02 +02:00
|
|
|
};
|
|
|
|
|
2023-12-22 00:26:14 +01:00
|
|
|
terms = [
|
2020-07-21 00:23:06 +02:00
|
|
|
{
|
|
|
|
negated: false,
|
|
|
|
operator: "search",
|
|
|
|
operand: "",
|
|
|
|
},
|
|
|
|
];
|
2024-01-25 22:11:22 +01:00
|
|
|
_setup(terms);
|
2020-07-21 00:23:06 +02:00
|
|
|
|
2021-05-31 18:38:57 +02:00
|
|
|
ev.key = "a";
|
2022-04-09 23:44:38 +02:00
|
|
|
/* istanbul ignore next */
|
2022-01-25 11:36:19 +01:00
|
|
|
$search_query_box.is = () => false;
|
|
|
|
$searchbox_form.trigger(ev);
|
2020-07-21 00:23:06 +02:00
|
|
|
|
2024-01-25 22:11:22 +01:00
|
|
|
let search_exited = false;
|
|
|
|
override_rewire(search, "exit_search", () => {
|
|
|
|
search_exited = true;
|
|
|
|
});
|
2020-07-21 00:23:06 +02:00
|
|
|
|
2021-05-31 18:38:57 +02:00
|
|
|
ev.key = "Enter";
|
2022-01-25 11:36:19 +01:00
|
|
|
$search_query_box.is = () => false;
|
|
|
|
$searchbox_form.trigger(ev);
|
2024-01-25 22:11:22 +01:00
|
|
|
assert.ok(!search_exited);
|
2020-07-21 00:23:06 +02:00
|
|
|
|
2021-05-31 18:38:57 +02:00
|
|
|
ev.key = "Enter";
|
2022-01-25 11:36:19 +01:00
|
|
|
$search_query_box.is = () => true;
|
|
|
|
$searchbox_form.trigger(ev);
|
2024-01-25 22:11:22 +01:00
|
|
|
assert.ok(search_exited);
|
2020-07-21 00:23:06 +02:00
|
|
|
|
2024-01-25 22:11:22 +01:00
|
|
|
let is_blurred = false;
|
|
|
|
$search_query_box.on("blur", () => {
|
|
|
|
is_blurred = true;
|
|
|
|
});
|
|
|
|
terms = [
|
|
|
|
{
|
|
|
|
negated: false,
|
|
|
|
operator: "search",
|
|
|
|
operand: "ver",
|
|
|
|
},
|
|
|
|
];
|
|
|
|
expected_pill_display_value = "ver";
|
|
|
|
_setup(terms);
|
2022-05-16 19:24:49 +02:00
|
|
|
ev.key = "Enter";
|
2024-11-08 11:44:54 +01:00
|
|
|
search.rewire_is_using_input_method(true);
|
2022-01-25 11:36:19 +01:00
|
|
|
$searchbox_form.trigger(ev);
|
2024-01-25 22:11:22 +01:00
|
|
|
// No change on first Enter keyup event
|
2021-06-10 08:32:54 +02:00
|
|
|
assert.ok(!is_blurred);
|
2022-01-25 11:36:19 +01:00
|
|
|
$searchbox_form.trigger(ev);
|
2021-06-10 08:32:54 +02:00
|
|
|
assert.ok(is_blurred);
|
2018-07-14 12:46:02 +02:00
|
|
|
});
|
|
|
|
|
2024-01-25 22:11:22 +01:00
|
|
|
run_test("initiate_search", ({override_rewire}) => {
|
|
|
|
let search_bar_opened = false;
|
|
|
|
override_rewire(search, "open_search_bar_and_close_narrow_description", () => {
|
|
|
|
search_bar_opened = true;
|
2020-07-22 04:50:11 +02:00
|
|
|
});
|
2022-05-16 19:24:49 +02:00
|
|
|
$(".navbar-search.expanded").length = 0;
|
2023-09-21 11:50:42 +02:00
|
|
|
$("#search_query").text("");
|
2018-07-14 12:46:02 +02:00
|
|
|
search.initiate_search();
|
2021-06-10 08:32:54 +02:00
|
|
|
assert.ok(typeahead_forced_open);
|
2024-01-25 22:11:22 +01:00
|
|
|
assert.ok(search_bar_opened);
|
|
|
|
assert.equal($("#search_query").text(), "");
|
2018-07-14 12:46:02 +02:00
|
|
|
});
|