Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
filter: Add more asserts for `has_exactly_channel_topic_operators`.
Aman Agrawalc5425a6dab55
diff --git a/web/tests/filter.test.cjs b/web/tests/filter.test.cjsindex d66760ad6df..18bf3eca94a 100644--- a/web/tests/filter.test.cjs+++ b/web/tests/filter.test.cjs@@ -161,6 +161,7 @@ test("basics", () => {assert.ok(filter.can_bucket_by("channel"));assert.ok(filter.can_bucket_by("channel", "topic"));+ assert.ok(!filter.has_exactly_channel_topic_operators());// "stream" was renamed to "channel"terms = [{operator: "stream", operand: foo_stream_id.toString()}];@@ -171,6 +172,7 @@ test("basics", () => {assert.ok(filter.can_apply_locally());assert.ok(filter.can_show_next_unread_topic_conversation_button());assert.ok(!filter.can_show_next_unread_dm_conversation_button());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "channel", operand: foo_stream_id.toString()},@@ -198,6 +200,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view());assert.ok(!filter.is_channel_view());assert.ok(!filter.may_contain_multiple_conversations());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "channel", operand: foo_stream_id.toString()},@@ -218,6 +221,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view());assert.ok(!filter.is_channel_view());assert.ok(!filter.may_contain_multiple_conversations());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "channel", operand: foo_stream_id.toString()},@@ -241,6 +245,7 @@ test("basics", () => {assert.ok(!filter.may_contain_multiple_conversations());assert.ok(filter.can_show_next_unread_topic_conversation_button());assert.ok(!filter.can_show_next_unread_dm_conversation_button());+ assert.ok(!filter.has_exactly_channel_topic_operators());// If our only channel operator is negated, then for all intents and purposes,// we don't consider ourselves to have a channel operator, because we don't@@ -255,6 +260,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view());assert.ok(!filter.is_channel_view());assert.ok(filter.may_contain_multiple_conversations());+ assert.ok(!filter.has_exactly_channel_topic_operators());// Negated searches are just like positive searches for our purposes, since// the search logic happens on the backend and we need to have can_apply_locally()@@ -272,6 +278,7 @@ test("basics", () => {assert.ok(filter.may_contain_multiple_conversations());assert.ok(!filter.can_show_next_unread_topic_conversation_button());assert.ok(!filter.can_show_next_unread_dm_conversation_button());+ assert.ok(!filter.has_exactly_channel_topic_operators());// Similar logic applies to negated "has" searches.terms = [{operator: "has", operand: "images", negated: true}];@@ -286,6 +293,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view());assert.ok(!filter.is_channel_view());assert.ok(filter.may_contain_multiple_conversations());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "channels", operand: "public", negated: true}];filter = new Filter(terms);@@ -299,6 +307,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view());assert.ok(!filter.is_channel_view());assert.ok(filter.may_contain_multiple_conversations());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "channels", operand: "public"}];filter = new Filter(terms);@@ -313,6 +322,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view());assert.ok(!filter.is_channel_view());assert.ok(filter.may_contain_multiple_conversations());+ assert.ok(!filter.has_exactly_channel_topic_operators());// "streams" was renamed to "channels"terms = [{operator: "streams", operand: "public"}];@@ -320,6 +330,7 @@ test("basics", () => {assert.ok(filter.has_operator("channels"));assert.ok(filter.supports_collapsing_recipients());assert.ok(filter.includes_full_stream_history());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "is", operand: "dm"}];filter = new Filter(terms);@@ -334,6 +345,7 @@ test("basics", () => {assert.ok(filter.may_contain_multiple_conversations());assert.ok(!filter.can_show_next_unread_topic_conversation_button());assert.ok(filter.can_show_next_unread_dm_conversation_button());+ assert.ok(!filter.has_exactly_channel_topic_operators());// "is:private" was renamed to "is:dm"terms = [{operator: "is", operand: "private"}];@@ -343,6 +355,7 @@ test("basics", () => {assert.ok(!filter.can_show_next_unread_topic_conversation_button());assert.ok(filter.can_show_next_unread_dm_conversation_button());assert.ok(!filter.is_channel_view());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "is", operand: "mentioned"}];filter = new Filter(terms);@@ -357,6 +370,7 @@ test("basics", () => {assert.ok(!filter.can_show_next_unread_topic_conversation_button());assert.ok(!filter.can_show_next_unread_dm_conversation_button());assert.ok(!filter.is_channel_view());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "is", operand: "starred"}];filter = new Filter(terms);@@ -369,6 +383,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view());assert.ok(filter.may_contain_multiple_conversations());assert.ok(!filter.is_channel_view());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "dm", operand: "[email protected]"}];filter = new Filter(terms);@@ -383,6 +398,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view_with_near());assert.ok(!filter.may_contain_multiple_conversations());assert.ok(!filter.is_channel_view());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "dm", operand: "[email protected]"},@@ -400,6 +416,7 @@ test("basics", () => {assert.ok(filter.is_conversation_view_with_near());assert.ok(!filter.may_contain_multiple_conversations());assert.ok(!filter.is_channel_view());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "dm", operand: "[email protected],[email protected]"}];filter = new Filter(terms);@@ -413,6 +430,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view_with_near());assert.ok(!filter.may_contain_multiple_conversations());assert.ok(!filter.is_channel_view());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "dm", operand: "[email protected],[email protected]"},@@ -428,6 +446,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view_with_near());assert.ok(!filter.may_contain_multiple_conversations());assert.ok(!filter.is_channel_view());+ assert.ok(!filter.has_exactly_channel_topic_operators());// "pm-with" was renamed to "dm"terms = [{operator: "pm-with", operand: "[email protected]"}];@@ -435,6 +454,7 @@ test("basics", () => {assert.ok(filter.has_operator("dm"));assert.ok(!filter.has_operator(" pm-with"));assert.ok(!filter.is_channel_view());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "dm-including", operand: "[email protected]"}];filter = new Filter(terms);@@ -448,6 +468,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view());assert.ok(filter.may_contain_multiple_conversations());assert.ok(!filter.is_channel_view());+ assert.ok(!filter.has_exactly_channel_topic_operators());// "group-pm-with" was replaced with "dm-including"terms = [{operator: "group-pm-with", operand: "[email protected]"}];@@ -455,6 +476,7 @@ test("basics", () => {assert.ok(filter.has_operator("dm-including"));assert.ok(!filter.has_operator("group-pm-with"));assert.ok(!filter.is_channel_view());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "is", operand: "resolved"}];filter = new Filter(terms);@@ -467,6 +489,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view());assert.ok(filter.may_contain_multiple_conversations());assert.ok(!filter.is_channel_view());+ assert.ok(!filter.has_exactly_channel_topic_operators());// Highly complex query to exercise// filter.supports_collapsing_recipients loop.@@ -492,6 +515,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view());assert.ok(filter.may_contain_multiple_conversations());assert.ok(!filter.is_channel_view());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "channel", operand: foo_stream_id.toString()},@@ -511,6 +535,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view_with_near());assert.ok(!filter.may_contain_multiple_conversations());assert.ok(!filter.is_channel_view());+ assert.ok(filter.has_exactly_channel_topic_operators());terms = [{operator: "channel", operand: foo_stream_id.toString()},@@ -532,6 +557,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view_with_near());assert.ok(!filter.may_contain_multiple_conversations());assert.ok(!filter.is_channel_view());+ assert.ok(!filter.has_exactly_channel_topic_operators());// "stream" was renamed to "channel"terms = [@@ -551,6 +577,7 @@ test("basics", () => {assert.ok(filter.is_conversation_view());assert.ok(!filter.is_conversation_view_with_near());assert.ok(!filter.is_channel_view());+ assert.ok(filter.has_exactly_channel_topic_operators());terms = [{operator: "channel", operand: "channel_name"},@@ -569,6 +596,7 @@ test("basics", () => {assert.ok(!filter.is_conversation_view());assert.ok(!filter.may_contain_multiple_conversations());assert.ok(!filter.is_channel_view());+ assert.ok(!filter.has_exactly_channel_topic_operators());terms = [{operator: "channel", operand: "foo", negated: false},