mirror of https://github.com/zulip/zulip.git
test_fixtures: Add 'message_link_test_cases' test fixture.
This is a prep commit to extract out the test cases for 'test_is_same_server_message_link' in hash_util.test.js as a test fixture. This will help in reusing the same test cases in the node and backend tests. Also, it will help in making sure that the logic for 'is_same_server_message_link' is in sync, in both the web client and server code.
This commit is contained in:
parent
885957c529
commit
5fd676c4e0
|
@ -2,6 +2,8 @@
|
|||
|
||||
const {strict: assert} = require("assert");
|
||||
|
||||
const message_link_test_cases = require("../../zerver/tests/fixtures/message_link_test_cases");
|
||||
|
||||
const {zrequire} = require("./lib/namespace");
|
||||
const {run_test} = require("./lib/test");
|
||||
|
||||
|
@ -88,39 +90,12 @@ run_test("get_current_nth_hash_section", () => {
|
|||
});
|
||||
|
||||
run_test("test_is_same_server_message_link", () => {
|
||||
const dm_message_link = "#narrow/dm/9,15-dm/near/43";
|
||||
assert.equal(hash_parser.is_same_server_message_link(dm_message_link), true);
|
||||
|
||||
const group_message_link = "#narrow/dm/9,16,15-group/near/68";
|
||||
assert.equal(hash_parser.is_same_server_message_link(group_message_link), true);
|
||||
|
||||
const stream_message_link = "#narrow/stream/8-design/topic/desktop/near/82";
|
||||
assert.equal(hash_parser.is_same_server_message_link(stream_message_link), true);
|
||||
|
||||
const stream_link = "#narrow/stream/8-design";
|
||||
assert.equal(hash_parser.is_same_server_message_link(stream_link), false);
|
||||
|
||||
const topic_link = "#narrow/stream/8-design/topic/desktop";
|
||||
assert.equal(hash_parser.is_same_server_message_link(topic_link), false);
|
||||
|
||||
const dm_link = "#narrow/dm/15-John";
|
||||
assert.equal(hash_parser.is_same_server_message_link(dm_link), false);
|
||||
|
||||
const search_link = "#narrow/search/database";
|
||||
assert.equal(hash_parser.is_same_server_message_link(search_link), false);
|
||||
|
||||
const different_server_message_link =
|
||||
"https://fakechat.zulip.org/#narrow/dm/8,1848,2369-group/near/1717378";
|
||||
assert.equal(hash_parser.is_same_server_message_link(different_server_message_link), false);
|
||||
|
||||
const drafts_link = "#drafts";
|
||||
assert.equal(hash_parser.is_same_server_message_link(drafts_link), false);
|
||||
|
||||
const empty_link = "#";
|
||||
assert.equal(hash_parser.is_same_server_message_link(empty_link), false);
|
||||
|
||||
const non_zulip_link = "https://www.google.com";
|
||||
assert.equal(hash_parser.is_same_server_message_link(non_zulip_link), false);
|
||||
for (const message_link_test_case of message_link_test_cases) {
|
||||
assert.equal(
|
||||
hash_parser.is_same_server_message_link(message_link_test_case.message_link),
|
||||
message_link_test_case.expected_output,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
run_test("build_reload_url", () => {
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
[
|
||||
{
|
||||
"name": "dm_message_link",
|
||||
"message_link": "#narrow/dm/9,15-dm/near/43",
|
||||
"expected_output": true
|
||||
},
|
||||
{
|
||||
"name": "group_message_link",
|
||||
"message_link": "#narrow/dm/9,16,15-group/near/68",
|
||||
"expected_output": true
|
||||
},
|
||||
{
|
||||
"name": "stream_message_link",
|
||||
"message_link": "#narrow/stream/8-design/topic/desktop/near/82",
|
||||
"expected_output": true
|
||||
},
|
||||
{
|
||||
"name": "stream_link",
|
||||
"message_link": "#narrow/stream/8-design",
|
||||
"expected_output": false
|
||||
},
|
||||
{
|
||||
"name": "topic_link",
|
||||
"message_link": "#narrow/stream/8-design/topic/desktop",
|
||||
"expected_output": false
|
||||
},
|
||||
{
|
||||
"name": "dm_link",
|
||||
"message_link": "#narrow/dm/15-John",
|
||||
"expected_output": false
|
||||
},
|
||||
{
|
||||
"name": "search_link",
|
||||
"message_link": "#narrow/search/database",
|
||||
"expected_output": false
|
||||
},
|
||||
{
|
||||
"name": "different_server_message_link",
|
||||
"message_link": "https://fakechat.zulip.org/#narrow/dm/8,1848,2369-group/near/1717378",
|
||||
"expected_output": false
|
||||
},
|
||||
{
|
||||
"name": "drafts_link",
|
||||
"message_link": "#drafts",
|
||||
"expected_output": false
|
||||
},
|
||||
{
|
||||
"name": "empty_link",
|
||||
"message_link": "#",
|
||||
"expected_output": false
|
||||
},
|
||||
{
|
||||
"name": "non_zulip_link",
|
||||
"message_link": "https://www.google.com",
|
||||
"expected_output": false
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue