{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== 'OCR模型免费转Markdown' && linkText !== 'OCR模型免费转Markdown' ) { link.textContent = 'OCR模型免费转Markdown'; link.href = 'https://fast360.xyz'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== '模型下载攻略' ) { link.textContent = '模型下载攻略'; link.href = '/'; replacedLinks.add(link); } // 删除Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, 'OCR模型免费转Markdown'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); \n \n \"\"\"\n- parser = GenericParser(html)\n+ parser = GenericParser(html, \"text/html; charset=UTF-8\")\n result = parser.extract_data()\n self.assertEqual(result.get('title'), 'Test title')\n self.assertEqual(result.get('description'), 'Description text')\n \n def test_extract_image(self) -> None:\n- html = \"\"\"\n+ html = b\"\"\"\n \n \n

Main header

\n@@ -202,14 +223,14 @@ def test_extract_image(self) -> None:\n \n \n \"\"\"\n- parser = GenericParser(html)\n+ parser = GenericParser(html, \"text/html; charset=UTF-8\")\n result = parser.extract_data()\n self.assertEqual(result.get('title'), 'Main header')\n self.assertEqual(result.get('description'), 'Description text')\n self.assertEqual(result.get('image'), 'http://test.com/test.jpg')\n \n def test_extract_description(self) -> None:\n- html = \"\"\"\n+ html = b\"\"\"\n \n \n
\n@@ -220,22 +241,22 @@ def test_extract_description(self) -> None:\n \n \n \"\"\"\n- parser = GenericParser(html)\n+ parser = GenericParser(html, \"text/html; charset=UTF-8\")\n result = parser.extract_data()\n self.assertEqual(result.get('description'), 'Description text')\n \n- html = \"\"\"\n+ html = b\"\"\"\n \n \n \n \n \"\"\"\n- parser = GenericParser(html)\n+ parser = GenericParser(html, \"text/html; charset=UTF-8\")\n result = parser.extract_data()\n self.assertEqual(result.get('description'), 'description 123')\n \n- html = \"\"\n- parser = GenericParser(html)\n+ html = b\"\"\n+ parser = GenericParser(html, \"text/html; charset=UTF-8\")\n result = parser.extract_data()\n self.assertIsNone(result.get('description'))\n \n"},"problem_statement":{"kind":"string","value":"URL preview garbled Chinese\nVersion: Self hosted 3.3\r\n\r\n## Scenario\r\nServer with `URL Preview` enabled\r\nposting this link: https://newtalk.tw/news/view/2020-12-03/503169\r\nSite uses html lang tag `lang=“zh-Hant-TW”`\r\n\r\n## Expected Behavior\r\nA URL leading to a Chinese website should produce a Chinese preview.\r\n\r\n## Actual Behavior\r\nThe preview contains garbled characters like [mojibake](https://revealingerrors.com/mojibake).\r\n> Or here's something equivalent to \"interpreting it as if it were ISO-8859-1\" which might turn out to be a better description of what's really happening in this bug: taking the bytes of the UTF-8 encoding, and interpreting each single byte as a Unicode codepoint.\r\n\r\n![Screen Shot 2020-12-04 at 4 36 22 PM](https://user-images.githubusercontent.com/15863509/101258381-1b091b80-375d-11eb-9710-8dcba9fa3a65.png)\r\n\r\n```\r\n# Actual content of header meta title\r\n蘋果AirDrop技術爆大漏洞!駭客可遠端操控iPhone | 科技 | 新頭殼 Newtalk\r\n\r\n# Actual Content of header meta description\r\nGoogle Project Zero的網路安全研究人員Ian Beer日前揭露了iPhone過去的重大漏洞,破解蘋果應用在AirDrop的相關技術,使得有心人士得以透過特殊裝置遠段操控附近的iPhone,所幸蘋果已經在今年5月修補了這個iOS漏洞。Beer所發現的系統漏洞存在於蘋果2014年引進的\r\n\r\n# Garbled preview version in zulip\r\n蘋果AirDropæŠ€è¡“çˆ†å¤§æ¼æ´žï¼é§­å®¢å¯é ç«¯æ“æŽ§iPhone | 科技 | æ–°é ­æ®¼ Newtalk\r\nGoogle Project Zeroçš„ç¶²è·¯å®‰å…¨ç ”ç©¶äººå“¡Ian Beer日前揭露了iPhoneéŽåŽ»çš„é‡å¤§æ¼æ´žï¼Œç ´è§£è˜‹æžœæ‡‰ç”¨åœ¨AirDropçš„ç›¸é—œæŠ€è¡“ï¼Œä½¿å¾—æœ‰å¿ƒäººå£«å¾—ä»¥é€éŽç‰¹æ®Šè£ç½®é æ®µæ“æŽ§é™„è¿‘çš„iPhone,所幸蘋果已經在今年5月修補了這個iOS漏洞。Beer所發現的系統漏洞存在於蘋果2014年引進的\r\n```\r\n\r\n## Possible Issue\r\nSpot-checking just the first couple of characters here: these mojibake are consistent with getting something that's actually UTF-8 and interpreting it as if it were ISO-8859-1. Specifically:\r\n\r\n> 蘋\r\n\r\nThis first character is e8 98 8b in UTF-8:\r\n```\r\n$ unicode -s 蘋 --long\r\nU+860B CJK UNIFIED IDEOGRAPH-860B\r\nUTF-8: e8 98 8b UTF-16BE: 860b Decimal: &#34315; Octal: \\0103013\r\n蘋\r\n…\r\n```\r\nand interpreting the byte e8 in ISO-8859-1, you get è:\r\n```\r\n$ unicode u+00e8\r\nè U+00E8 LATIN SMALL LETTER E WITH GRAVE\r\n```\r\n## Related Code\r\nhttps://github.com/zulip/zulip/blob/0d6c771baf9ea0ebd8174c927e50709d59da0f64/zerver/lib/url_preview/preview.py\r\n\r\n## Related issue chat\r\nhttps://chat.zulip.org/#narrow/stream/9-issues/topic/URL.20preview.20Chinese.20Jumbled\n"},"hints_text":{"kind":"string","value":"@zulipbot add \"bug\" \"area: general UI\" \nhttps://chat.zulip.org/#narrow/stream/9-issues/topic/URL.20preview.20Chinese.20Jumbled/near/1076820 has the bug pointed out by Greg. See it before working on this issue.\nCopying here a bit of partial debugging I mentioned in the linked chat thread:\r\n\r\nThis looks like [mojibake](https://revealingerrors.com/mojibake), and specifically the kind of mojibake you get when taking some data that's actually encoded in UTF-8 and interpreting it as if it were encoded in ISO-8859-1.\r\n\r\nOr equivalently: it looks like exactly what we'd get if the data is actually encoded in UTF-8 and we interpret each single byte of it as if it were a Unicode codepoint.\r\n\r\nI took a quick look at the code involved and don't see an obvious spot where the bug might be. (I'm not familiar with this area of our code.) The next step is probably for someone to take the given reproducer and do some debugging to find out exactly where in the code the bad data (mis-decoded data) comes from.\r\n\nI wonder if this has anything to do with beautiful soup (web crawler) used to extract data from the page\r\nSpecifically Beautiful soup seems to \"guess\" the encoding of the source document. \r\nhttps://www.crummy.com/software/BeautifulSoup/bs4/doc/#encodings\nNo, the problem is the opposite: we prevent Beautiful Soup from detecting the encoding by passing `str` instead of `bytes`. The pages you’ve referenced don’t send a charset in their `Content-Type`, so we need to let Beautiful Soup detect the encoding from the `` tags in the page."},"created_at":{"kind":"timestamp","value":"2020-12-08T03:33:45","string":"2020-12-08T03:33:45"}}},{"rowIdx":632,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":16860,"string":"16,860"},"instance_id":{"kind":"string","value":"zulip__zulip-16860"},"issue_numbers":{"kind":"list like","value":["16482"],"string":"[\n \"16482\"\n]"},"base_commit":{"kind":"string","value":"417faa046582890c3d15603e90b8e0bb18fbaa5e"},"patch":{"kind":"string","value":"diff --git a/zerver/migrations/0330_linkifier_pattern_validator.py b/zerver/migrations/0330_linkifier_pattern_validator.py\nnew file mode 100644\n--- /dev/null\n+++ b/zerver/migrations/0330_linkifier_pattern_validator.py\n@@ -0,0 +1,18 @@\n+# Generated by Django 3.1.8 on 2021-04-18 15:36\n+\n+from django.db import migrations, models\n+\n+\n+class Migration(migrations.Migration):\n+\n+ dependencies = [\n+ (\"zerver\", \"0329_remove_realm_allow_community_topic_editing\"),\n+ ]\n+\n+ operations = [\n+ migrations.AlterField(\n+ model_name=\"realmfilter\",\n+ name=\"pattern\",\n+ field=models.TextField(),\n+ ),\n+ ]\ndiff --git a/zerver/models.py b/zerver/models.py\n--- a/zerver/models.py\n+++ b/zerver/models.py\n@@ -11,6 +11,7 @@\n Dict,\n List,\n Optional,\n+ Pattern,\n Sequence,\n Set,\n Tuple,\n@@ -918,7 +919,7 @@ def flush_realm_emoji(sender: Any, **kwargs: Any) -> None:\n post_delete.connect(flush_realm_emoji, sender=RealmEmoji)\n \n \n-def filter_pattern_validator(value: str) -> None:\n+def filter_pattern_validator(value: str) -> Pattern[str]:\n regex = re.compile(r\"^(?:(?:[\\w\\-#_= /:]*|[+]|[!])(\\(\\?P<\\w+>.+\\)))+$\")\n error_msg = _(\"Invalid linkifier pattern. Valid characters are {}.\").format(\n \"[ a-zA-Z_#=/:+!-]\",\n@@ -928,11 +929,13 @@ def filter_pattern_validator(value: str) -> None:\n raise ValidationError(error_msg)\n \n try:\n- re.compile(value)\n+ pattern = re.compile(value)\n except re.error:\n # Regex is invalid\n raise ValidationError(error_msg)\n \n+ return pattern\n+\n \n def filter_format_validator(value: str) -> None:\n regex = re.compile(r\"^([\\.\\/:a-zA-Z0-9#_?=&;~-]+%\\(([a-zA-Z0-9_-]+)\\)s)+[/a-zA-Z0-9#_?=&;~-]*$\")\n@@ -948,12 +951,54 @@ class RealmFilter(models.Model):\n \n id: int = models.AutoField(auto_created=True, primary_key=True, verbose_name=\"ID\")\n realm: Realm = models.ForeignKey(Realm, on_delete=CASCADE)\n- pattern: str = models.TextField(validators=[filter_pattern_validator])\n+ pattern: str = models.TextField()\n url_format_string: str = models.TextField(validators=[URLValidator(), filter_format_validator])\n \n class Meta:\n unique_together = (\"realm\", \"pattern\")\n \n+ def clean(self) -> None:\n+ \"\"\"Validate whether the set of parameters in the URL Format string\n+ match the set of parameters in the regular expression.\n+\n+ Django's `full_clean` calls `clean_fields` followed by `clean` method\n+ and stores all ValidationErrors from all stages to return as JSON.\n+ \"\"\"\n+\n+ # Extract variables present in the pattern\n+ pattern = filter_pattern_validator(self.pattern)\n+ group_set = set(pattern.groupindex.keys())\n+\n+ # Extract variables used in the URL format string. Note that\n+ # this regex will incorrectly reject patterns that attempt to\n+ # escape % using %%.\n+ found_group_set: Set[str] = set()\n+ group_match_regex = r\"%\\((?P[^()]+)\\)s\"\n+ for m in re.finditer(group_match_regex, self.url_format_string):\n+ group_name = m.group(\"group_name\")\n+ found_group_set.add(group_name)\n+\n+ # Report patterns missing in linkifier pattern.\n+ missing_in_pattern_set = found_group_set - group_set\n+ if len(missing_in_pattern_set) > 0:\n+ name = list(missing_in_pattern_set)[0]\n+ raise ValidationError(\n+ _(\"Group %(name)r in URL format string is not present in linkifier pattern.\"),\n+ params={\"name\": name},\n+ )\n+\n+ missing_in_url_set = group_set - found_group_set\n+ # Report patterns missing in URL format string.\n+ if len(missing_in_url_set) > 0:\n+ # We just report the first missing pattern here. Users can\n+ # incrementally resolve errors if there are multiple\n+ # missing patterns.\n+ name = list(missing_in_url_set)[0]\n+ raise ValidationError(\n+ _(\"Group %(name)r in linkifier pattern is not present in URL format string.\"),\n+ params={\"name\": name},\n+ )\n+\n def __str__(self) -> str:\n return f\"\"\n \n"},"test_patch":{"kind":"string","value":"diff --git a/frontend_tests/puppeteer_tests/realm-linkifier.ts b/frontend_tests/puppeteer_tests/realm-linkifier.ts\n--- a/frontend_tests/puppeteer_tests/realm-linkifier.ts\n+++ b/frontend_tests/puppeteer_tests/realm-linkifier.ts\n@@ -47,9 +47,9 @@ async function test_add_invalid_linkifier_pattern(page: Page): Promise {\n });\n await page.click(\"form.admin-linkifier-form button.button\");\n \n- await page.waitForSelector(\"div#admin-linkifier-pattern-status\", {visible: true});\n+ await page.waitForSelector(\"div#admin-linkifier-status\", {visible: true});\n assert.strictEqual(\n- await common.get_text_from_selector(page, \"div#admin-linkifier-pattern-status\"),\n+ await common.get_text_from_selector(page, \"div#admin-linkifier-status\"),\n \"Failed: Invalid linkifier pattern. Valid characters are [ a-zA-Z_#=/:+!-].\",\n );\n }\n@@ -88,7 +88,7 @@ async function test_edit_invalid_linkifier(page: Page): Promise {\n });\n await page.click(\".submit-linkifier-info-change\");\n \n- const edit_linkifier_pattern_status_selector = \"div#edit-linkifier-pattern-status\";\n+ const edit_linkifier_pattern_status_selector = \"div#edit-linkifier-status\";\n await page.waitForSelector(edit_linkifier_pattern_status_selector, {visible: true});\n const edit_linkifier_pattern_status = await common.get_text_from_selector(\n page,\ndiff --git a/zerver/tests/test_realm_linkifiers.py b/zerver/tests/test_realm_linkifiers.py\n--- a/zerver/tests/test_realm_linkifiers.py\n+++ b/zerver/tests/test_realm_linkifiers.py\n@@ -94,6 +94,41 @@ def test_create(self) -> None:\n self.assert_json_success(result)\n self.assertIsNotNone(re.match(data[\"pattern\"], \"!123\"))\n \n+ # This block of tests is for mismatches between field sets\n+ data[\"pattern\"] = r\"ZUL-(?P\\d+)\"\n+ data[\"url_format_string\"] = r\"https://realm.com/my_realm_filter/%(hello)s\"\n+ result = self.client_post(\"/json/realm/filters\", info=data)\n+ self.assert_json_error(\n+ result, \"Group 'hello' in URL format string is not present in linkifier pattern.\"\n+ )\n+\n+ data[\"pattern\"] = r\"ZUL-(?P\\d+)-(?P\\d+)\"\n+ data[\"url_format_string\"] = r\"https://realm.com/my_realm_filter/%(hello)s\"\n+ result = self.client_post(\"/json/realm/filters\", info=data)\n+ self.assert_json_error(\n+ result, \"Group 'id' in linkifier pattern is not present in URL format string.\"\n+ )\n+\n+ data[\"pattern\"] = r\"ZULZ-(?P\\d+)-(?P\\d+)\"\n+ data[\"url_format_string\"] = r\"https://realm.com/my_realm_filter/%(hello)s/%(world)s\"\n+ result = self.client_post(\"/json/realm/filters\", info=data)\n+ self.assert_json_success(result)\n+\n+ data[\"pattern\"] = r\"ZUL-(?P\\d+)-(?P\\d+)-(?P\\d+)\"\n+ data[\"url_format_string\"] = r\"https://realm.com/my_realm_filter/%(hello)s\"\n+ result = self.client_post(\"/json/realm/filters\", info=data)\n+ self.assert_json_error(\n+ result, \"Group 'id' in linkifier pattern is not present in URL format string.\"\n+ )\n+\n+ # BUG: In theory, this should be valid, since %% should be a\n+ # valid escaping method. It's unlikely someone actually wants\n+ # to do this, though.\n+ data[\"pattern\"] = r\"ZUL-(?P\\d+)\"\n+ data[\"url_format_string\"] = r\"https://realm.com/my_realm_filter/%%(ignored)s/%(id)s\"\n+ result = self.client_post(\"/json/realm/filters\", info=data)\n+ self.assert_json_error(result, \"Invalid URL format string.\")\n+\n data[\"pattern\"] = r\"(?P[a-zA-Z0-9_-]+)/(?P[a-zA-Z0-9_-]+)#(?P[0-9]+)\"\n data[\"url_format_string\"] = \"https://github.com/%(org)s/%(repo)s/issue/%(id)s\"\n result = self.client_post(\"/json/realm/filters\", info=data)\n"},"problem_statement":{"kind":"string","value":"Linkifier validation -- non-existant group name breaks rendering \nWith the following pattern and replacement:\r\n`#(?P[0-9]+)` / `https://github.com/zulip/zulip/issues/%(bogus)s`\r\n\r\n...sending messages with `#123` results in:\r\n```\r\n2020-10-06 19:14:23.691 ERR [] Exception in Markdown parser; input (sanitized) was: '#xxx'\r\n (message unknown)\r\nTraceback (most recent call last):\r\n File \"/srv/zulip/zerver/lib/markdown/__init__.py\", line 2344, in do_convert\r\n rendered_content = timeout(5, _md_engine.convert, content)\r\n File \"/srv/zulip/zerver/lib/timeout.py\", line 90, in timeout\r\n raise thread.exc_info[1].with_traceback(thread.exc_info[2])\r\n File \"/srv/zulip/zerver/lib/timeout.py\", line 50, in run\r\n self.result = func(*args, **kwargs)\r\n File \"/srv/zulip-py3-venv/lib/python3.6/site-packages/markdown/core.py\", line 267, in convert\r\n newRoot = treeprocessor.run(root)\r\n File \"/srv/zulip-py3-venv/lib/python3.6/site-packages/markdown/treeprocessors.py\", line 370, in run\r\n self.__handleInline(text), child\r\n File \"/srv/zulip-py3-venv/lib/python3.6/site-packages/markdown/treeprocessors.py\", line 131, in __handleInline\r\n self.inlinePatterns[patternIndex], data, patternIndex, startIndex\r\n File \"/srv/zulip-py3-venv/lib/python3.6/site-packages/markdown/treeprocessors.py\", line 285, in __applyPattern\r\n node = pattern.handleMatch(match)\r\n File \"/srv/zulip/zerver/lib/markdown/__init__.py\", line 1634, in handleMatch\r\n self.format_string % m.groupdict(),\r\nKeyError: 'bogus'\r\n```\r\n\r\nWe should at very least not fail to send the message -- especially since there are already such in existance. But we should also prevent the creation of the linkifier in the first place, so people aren't confused why they silently aren't linking.\n"},"hints_text":{"kind":"string","value":"@aero31aero can you help investigate this? \r\n\r\nI think #13398 might be what we need to validate this more correctly. I think most correctly we should just block creating such an invalid linkifier, and purge any that have been already created.\n@timabbott yes, the first commit of #13398 fixes this. I'll test and amend the commit message to close this issue and rebase the PR while I'm at it.\n[This is also possible in topic names](https://sentry.io/share/issue/655e20a2bd4f467cafa4f9c0dd17ad00/). The effects of this are worse if it's in a topic name, as it breaks for more than just a single message.\nLet's see if we can get #13398 integrated.\n@timabbott can I work on this issue ? Or is this dependant on the PR #13398.\nI think ideally we should make a PR that extracts the first commit of #13398 as a separate PR addressing the comments related to that commit; that would allow us to close out this, since #13398 as a whole has a decent number of unresolved comments."},"created_at":{"kind":"timestamp","value":"2020-12-09T08:03:19","string":"2020-12-09T08:03:19"}}},{"rowIdx":633,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":16916,"string":"16,916"},"instance_id":{"kind":"string","value":"zulip__zulip-16916"},"issue_numbers":{"kind":"list like","value":["11895"],"string":"[\n \"11895\"\n]"},"base_commit":{"kind":"string","value":"abd959cf6a77096cd52610e9e66465a86a3c6eb1"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.py\n--- a/zerver/lib/markdown/__init__.py\n+++ b/zerver/lib/markdown/__init__.py\n@@ -1625,9 +1625,65 @@ def __init__(self, compiled_re: Pattern[str], md: markdown.Markdown) -> None:\n \n \n class AutoLink(CompiledPattern):\n+ \"\"\"AutoLink takes care of linkifying link-format strings directly\n+ present in the message (i.e. without markdown link syntax). In\n+ some hardcoded cases, it will rewrite the label to what the user\n+ probably wanted if they'd taken the time to do so.\n+ \"\"\"\n+\n+ # Ideally, we'd use a dynamic commit prefix length based on the\n+ # size of the repository, like Git itself does, but we're\n+ # shortening Git commit IDs without looking at the corresponding\n+ # repository. It's not essential that the shortenings are\n+ # globally unique as they're just shorthand, but 12 characters is\n+ # the minimum to be unique for projects with about 1M commits.\n+ COMMIT_ID_PREFIX_LENGTH = 12\n+\n+ def shorten_links(self, href: str) -> Optional[str]:\n+ parts = urllib.parse.urlparse(href)\n+ scheme, netloc, path, params, query, fragment = parts\n+ if scheme == \"https\" and netloc in [\"github.com\"]:\n+ # Split the path to extract our 4 variables.\n+\n+ # To do it cleanly without multiple if branches based on which of these\n+ # variables are present, we here add a list of [\"\", \"\", \"\"...]\n+ # to the result of path.split, which at worst can be []. We also remove\n+ # the first empty string we'd get from \"/foo/bar\".split(\"/\").\n+\n+ # Example path: \"/foo/bar\" output: [\"foo\", \"bar\", \"\", \"\", \"\"]\n+ # path: \"\" output: [\"\", \"\", \"\", \"\", \"\"]\n+ organisation, repository, artifact, value, remaining_path = (\n+ path.split(\"/\", 5)[1:] + [\"\"] * 5\n+ )[:5]\n+\n+ # Decide what type of links to shorten.\n+ if not organisation or not repository or not artifact or not value:\n+ return None\n+ repo_short_text = \"{}/{}\".format(organisation, repository)\n+\n+ if fragment or remaining_path:\n+ # We only intend to shorten links for the basic issue, PR, and commit ones.\n+ return None\n+\n+ if netloc == \"github.com\":\n+ return self.shorten_github_links(artifact, repo_short_text, value)\n+ return None\n+\n+ def shorten_github_links(\n+ self, artifact: str, repo_short_text: str, value: str\n+ ) -> Optional[str]:\n+ if artifact in [\"pull\", \"issues\"]:\n+ return \"{}#{}\".format(repo_short_text, value)\n+ if artifact == \"commit\":\n+ return \"{}@{}\".format(repo_short_text, value[0 : self.COMMIT_ID_PREFIX_LENGTH])\n+ return None\n+\n def handleMatch(self, match: Match[str]) -> ElementStringNone:\n url = match.group(\"url\")\n db_data = self.md.zulip_db_data\n+ shortened_text = self.shorten_links(url)\n+ if shortened_text is not None:\n+ return url_to_a(db_data, url, shortened_text)\n return url_to_a(db_data, url)\n \n \n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/fixtures/markdown_test_cases.json b/zerver/tests/fixtures/markdown_test_cases.json\n--- a/zerver/tests/fixtures/markdown_test_cases.json\n+++ b/zerver/tests/fixtures/markdown_test_cases.json\n@@ -932,6 +932,121 @@\n \"input\": \"

*

[

Static types in Python

](https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy)*\",\n \"expected_output\": \"

&lt;h1&gt;&lt;h1&gt;&lt;h2&gt;Static types in Python&lt;/h2&gt;&lt;/h1&gt;&lt;/h1&gt;

\",\n \"marked_expected_output\": \"

&lt;h1&gt;&lt;h1&gt;&lt;h2&gt;Static types in Python&lt;/h2&gt;&lt;/h1&gt;&lt;/h1&gt;\\n\\n

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_repo_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile\",\n+ \"expected_output\": \"

https://github.com/zulip/zulip-mobile

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_issues_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/issues/11895\",\n+ \"expected_output\": \"

zulip/zulip-mobile#11895

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_pull_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/pull/16665\",\n+ \"expected_output\": \"

zulip/zulip-mobile#16665

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_commit_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/commit/620e9cbf72ca729534aba41693d7ab2872caa394\",\n+ \"expected_output\": \"

zulip/zulip-mobile@620e9cbf72ca

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_commits_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/pull/16860/commits/19e96bcea616e6e9b1a3c10f25930ac1f75d4f92\",\n+ \"expected_output\": \"

https://github.com/zulip/zulip-mobile/pull/16860/commits/19e96bcea616e6e9b1a3c10f25930ac1f75d4f92

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_pull_initial_comment_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/pull/16665#issue-513297835\",\n+ \"expected_output\": \"

https://github.com/zulip/zulip-mobile/pull/16665#issue-513297835

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_pull_comment_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/pull/16665#issuecomment-719814618\",\n+ \"expected_output\": \"

https://github.com/zulip/zulip-mobile/pull/16665#issuecomment-719814618

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_issues_initial_comment_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/issues/16579#issue-725908927\",\n+ \"expected_output\": \"

https://github.com/zulip/zulip-mobile/issues/16579#issue-725908927

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_issues_comment_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/issues/16482#issuecomment-726354516\",\n+ \"expected_output\": \"

https://github.com/zulip/zulip-mobile/issues/16482#issuecomment-726354516

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_files_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/pull/16860/files\",\n+ \"expected_output\": \"

https://github.com/zulip/zulip-mobile/pull/16860/files

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_files_comment_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/pull/16860/files#r539133612\",\n+ \"expected_output\": \"

https://github.com/zulip/zulip-mobile/pull/16860/files#r539133612

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_repo_issues_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/issues\",\n+ \"expected_output\": \"

https://github.com/zulip/zulip-mobile/issues

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_repo_pull_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/pull\",\n+ \"expected_output\": \"

https://github.com/zulip/zulip-mobile/pull

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_repo_commit_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/commit\",\n+ \"expected_output\": \"

https://github.com/zulip/zulip-mobile/commit

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_repo_clone_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile.git\",\n+ \"expected_output\": \"

https://github.com/zulip/zulip-mobile.git

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_repo_labels_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/labels\",\n+ \"expected_output\": \"

https://github.com/zulip/zulip-mobile/labels

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_labels_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/labels/area%3A%20markdown\",\n+ \"expected_output\": \"

https://github.com/zulip/zulip-mobile/labels/area%3A%20markdown

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_tree_link\",\n+ \"input\": \"https://github.com/zulip/zulip-mobile/tree/chat.zulip.org\",\n+ \"expected_output\": \"

https://github.com/zulip/zulip-mobile/tree/chat.zulip.org

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_marketplace_circleci_link\",\n+ \"input\": \"https://github.com/marketplace/circleci\",\n+ \"expected_output\": \"

https://github.com/marketplace/circleci

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_foo_bar_baz_link\",\n+ \"input\": \"https://github.com/foo/bar/baz\",\n+ \"expected_output\": \"

https://github.com/foo/bar/baz

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_foo_bar_baz_zar_link\",\n+ \"input\": \"https://github.com/foo/bar/baz/zar\",\n+ \"expected_output\": \"

https://github.com/foo/bar/baz/zar

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_marketplace_link\",\n+ \"input\": \"https://github.com/marketplace\",\n+ \"expected_output\": \"

https://github.com/marketplace

\"\n+ },\n+ {\n+ \"name\": \"auto_shorten_github_link\",\n+ \"input\": \"https://github.com\",\n+ \"expected_output\": \"

https://github.com

\"\n }\n ],\n \"linkify_tests\": [\n"},"problem_statement":{"kind":"string","value":"Automatically shorten Github URLs\nCurrently, using [custom linkification filters](https://zulipchat.com/help/add-a-custom-linkification-filter) it's possible to use shortened forms to link to issues or pull requests. It would be nice if GitHub URLs could be automatically transformed into this shorter form. For example, if `https://github.com/org/repo/issues/1234` is used in a message, then it could be automatically shortened into `org/repo#1234` (or into a configured linkification pattern).\r\nOften it is faster to just copy and paste links from Github however then these long URLs tend to clutter the messages so this feature would be nice to have for these cases. \n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-markdown members, this issue was labeled with the \"area: markdown\" label, so you may want to check it out!\n\n\nYeah, this seems like a nice touch that we should add to what we're doing. I think we might want to do it as a built-in feature of the markdown processor's link handler, not an optional linkification filter, since I don't see a reason anyone would want to turn this off.\n@zulipbot claim\nWelcome to Zulip, @scholtzan! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!\n\nHere's some tips to get you off to a good start:\n* Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.\n* Sign the [Dropbox Contributor License Agreement](https://opensource.dropbox.com/cla/), so that Zulip can use your code.\n* [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.\n\nAs you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.\n\nSee you on the other side (that is, the pull request side)!\nthis sounds like a very nice addition!\r\nmaybe there could be a way to enable this also for self-hosted environments?\r\nwe are running a gitlab instance on premise so it would be extremely handy to configure that in the settings in order to get those shortened URL links...\nYeah, a GitLab version of this feature would require a realm-level setting for the GitLab server. We can build the GitHub feature and then plan to extend it to support GitLab as well.\nHello @scholtzan, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 14 days.\n\nYou can reclaim this issue or claim any other issue by commenting `@zulipbot claim` on that issue.\n\nThanks for your contributions, and hope to see you again soon!\nhttps://github.com/zulip/zulip/pull/11924"},"created_at":{"kind":"timestamp","value":"2020-12-17T15:11:10","string":"2020-12-17T15:11:10"}}},{"rowIdx":634,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":16978,"string":"16,978"},"instance_id":{"kind":"string","value":"zulip__zulip-16978"},"issue_numbers":{"kind":"list like","value":["16846"],"string":"[\n \"16846\"\n]"},"base_commit":{"kind":"string","value":"50121cce5ef5764eb1b516fc3e1552552a67345b"},"patch":{"kind":"string","value":"diff --git a/tools/run-dev.py b/tools/run-dev.py\n--- a/tools/run-dev.py\n+++ b/tools/run-dev.py\n@@ -341,7 +341,7 @@ def shutdown_handler(*args: Any, **kwargs: Any) -> None:\n \n def print_listeners() -> None:\n external_host = os.getenv('EXTERNAL_HOST', 'localhost')\n- print(f\"\\nStarting Zulip on {CYAN}http://{external_host}:{proxy_port}/{ENDC}. Internal ports:\")\n+ print(f\"\\nStarting Zulip on:\\n\\n\\t{CYAN}http://{external_host}:{proxy_port}/{ENDC}\\n\\nInternal ports:\")\n ports = [\n (proxy_port, 'Development server proxy (connect here)'),\n (django_port, 'Django'),\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"The terminal message for accessing the server is not very clear.\n After running the server, the terminal message does not tells the user to access the server at http://localhost:9991/ . This is very difficult for the first time user to know how to proceed. \r\n\r\n****Screenshot****\r\n![Zulip ](https://user-images.githubusercontent.com/53913514/101323593-f8771f80-388e-11eb-9d8a-9dafa9b3bf53.png)\r\n\r\n****Changes Proposed****\r\nThere should be an appropriate message stating that \"Your Zulip server is running on http://localhost:9991/ \".\r\n\r\n****My OS/ Browser****\r\nMacOS/ Chrome\r\n\r\n**Zulip chat regarding the issue**\r\nhttps://chat.zulip.org/#narrow/stream/21-provision-help/topic/Not.20able.20to.20set.20development.20environment\n"},"hints_text":{"kind":"string","value":"Can I work on this issue?\n@Riken-Shah Can we both work together?\nI would like that @Gautam-Arora24, But I don't think this issue needs collaboration(as we just need to change one file). As you opened this issue I think you should work on this issue. If you are stuck anywhere feel free to reach out to me will try to solve it together.\n@Riken-Shah Thank you. I will surely work on this issue. Will contact you in case of any doubt.\r\n\n@zulipbot claim\n@hackerkid What should be the correct location for this terminal message?\n@Gautam-Arora24 Probably before \"quit the server with ctrl c\". It can also be in a different color so that it's easily noticeable. Maybe we can take some inspiration from projects like create-react-app or gatsby. I am assuming you have used them since your profile mentions React. \n@hackerkid Ya, I will definitely try something that is more colourful and eye catching. Thanks for assigning me :)\nMy thinking is much of what we want to do is actually to suppress the notices that we don't want (like the webpack notice) that are provided by third-party tools.\nHello @zulip/server-tooling members, this issue was labeled with the \"area: tooling\" label, so you may want to check it out!\n\n\nIs this issue solved? Or can I work on it?\n@ganpa3 If you want, you can work on this issue\r\n\n@zulipbot claim\nWelcome to Zulip, @ganpa3! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!\n\nHere's some tips to get you off to a good start:\n* Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.\n* [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.\n\nAs you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.\n\nSee you on the other side (that is, the pull request side)!"},"created_at":{"kind":"timestamp","value":"2020-12-29T10:26:48","string":"2020-12-29T10:26:48"}}},{"rowIdx":635,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17014,"string":"17,014"},"instance_id":{"kind":"string","value":"zulip__zulip-17014"},"issue_numbers":{"kind":"list like","value":["16163"],"string":"[\n \"16163\"\n]"},"base_commit":{"kind":"string","value":"82d6d925e51a35bdaf940033fc467c4141c390cd"},"patch":{"kind":"string","value":"diff --git a/zerver/openapi/python_examples.py b/zerver/openapi/python_examples.py\n--- a/zerver/openapi/python_examples.py\n+++ b/zerver/openapi/python_examples.py\n@@ -392,6 +392,23 @@ def get_profile(client: Client) -> None:\n validate_against_openapi_schema(result, \"/users/me\", \"get\", \"200\")\n \n \n+@openapi_test_function(\"/users/me:delete\")\n+def deactivate_own_user(client: Client, owner_client: Client) -> None:\n+ user_id = client.get_profile()[\"user_id\"]\n+\n+ # {code_example|start}\n+ # Deactivate the account of the current user/bot that requests.\n+ result = client.call_endpoint(\n+ url=\"/users/me\",\n+ method=\"DELETE\",\n+ )\n+ # {code_example|end}\n+\n+ # Reactivate the account to avoid polluting other tests.\n+ owner_client.reactivate_user_by_id(user_id)\n+ validate_against_openapi_schema(result, \"/users/me\", \"delete\", \"200\")\n+\n+\n @openapi_test_function(\"/get_stream_id:get\")\n def get_stream_id(client: Client) -> int:\n \n@@ -1295,7 +1312,7 @@ def test_messages(client: Client, nonadmin_client: Client) -> None:\n test_delete_message_edit_permission_error(client, nonadmin_client)\n \n \n-def test_users(client: Client) -> None:\n+def test_users(client: Client, owner_client: Client) -> None:\n \n create_user(client)\n get_members(client)\n@@ -1320,6 +1337,7 @@ def test_users(client: Client) -> None:\n get_alert_words(client)\n add_alert_words(client)\n remove_alert_words(client)\n+ deactivate_own_user(client, owner_client)\n \n \n def test_streams(client: Client, nonadmin_client: Client) -> None:\n@@ -1371,10 +1389,10 @@ def test_errors(client: Client) -> None:\n test_invalid_stream_error(client)\n \n \n-def test_the_api(client: Client, nonadmin_client: Client) -> None:\n+def test_the_api(client: Client, nonadmin_client: Client, owner_client: Client) -> None:\n \n get_user_agent(client)\n- test_users(client)\n+ test_users(client, owner_client)\n test_streams(client, nonadmin_client)\n test_messages(client, nonadmin_client)\n test_queues(client)\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/openapi/test_curl_examples.py b/zerver/openapi/test_curl_examples.py\n--- a/zerver/openapi/test_curl_examples.py\n+++ b/zerver/openapi/test_curl_examples.py\n@@ -22,7 +22,7 @@\n )\n \n \n-def test_generated_curl_examples_for_success(client: Client) -> None:\n+def test_generated_curl_examples_for_success(client: Client, owner_client: Client) -> None:\n authentication_line = f\"{client.email}:{client.api_key}\"\n # A limited Markdown engine that just processes the code example syntax.\n realm = get_realm(\"zulip\")\n@@ -49,11 +49,22 @@ def test_generated_curl_examples_for_success(client: Client) -> None:\n curl_command_html = md_engine.convert(line.strip())\n unescaped_html = html.unescape(curl_command_html)\n curl_command_text = unescaped_html[len(\"

curl\\n\") : -len(\"

\")]\n-\n curl_command_text = curl_command_text.replace(\n \"BOT_EMAIL_ADDRESS:BOT_API_KEY\", authentication_line\n )\n \n+ # TODO: This needs_reactivation block is a hack.\n+ # However, it's awkward to test the \"deactivate\n+ # myself\" endpoint with how this system tries to use\n+ # the same account for all tests without some special\n+ # logic for that endpoint; and the hack is better than\n+ # just not documenting the endpoint.\n+ needs_reactivation = False\n+ user_id = 0\n+ if file_name == \"templates/zerver/api/deactivate-own-user.md\":\n+ needs_reactivation = True\n+ user_id = client.get_profile()[\"user_id\"]\n+\n print(\"Testing {} ...\".format(curl_command_text.split(\"\\n\")[0]))\n \n # Turn the text into an arguments list.\n@@ -69,6 +80,8 @@ def test_generated_curl_examples_for_success(client: Client) -> None:\n )\n response = json.loads(response_json)\n assert response[\"result\"] == \"success\"\n+ if needs_reactivation:\n+ owner_client.reactivate_user_by_id(user_id)\n except (AssertionError, Exception):\n error_template = \"\"\"\n Error verifying the success of the API documentation curl example.\n"},"problem_statement":{"kind":"string","value":"API: deactivate_my_account is undocumented.\nThis line: https://github.com/zulip/zulip/blob/33d7a2268563cc89dca662369ccacfd0d35a8a7f/zerver/openapi/zulip.yaml#L4383 is undocumented. https://chat.zulip.org/api/deactivate-my-account currently returns 404. This issue was discussed at https://chat.zulip.org/#narrow/stream/127-integrations/topic/go-zulip-api/near/991579.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-api members, this issue was labeled with the \"area: documentation (api and integrations)\" label, so you may want to check it out!\n\n\n@akashaviator would you be up for taking this issue?\r\n\r\nI believe the bug is that we just haven't written a /api/ page for this; i.e. we only completed one of the two steps involved in writing API documentation for a function.\n@zulipbot claim"},"created_at":{"kind":"timestamp","value":"2021-01-05T22:55:10","string":"2021-01-05T22:55:10"}}},{"rowIdx":636,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17019,"string":"17,019"},"instance_id":{"kind":"string","value":"zulip__zulip-17019"},"issue_numbers":{"kind":"list like","value":["16642"],"string":"[\n \"16642\"\n]"},"base_commit":{"kind":"string","value":"3ef6f6e2e20a40ce4581f457680b1d0f482b3ac2"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/email_mirror.py b/zerver/lib/email_mirror.py\n--- a/zerver/lib/email_mirror.py\n+++ b/zerver/lib/email_mirror.py\n@@ -10,6 +10,7 @@\n from django.utils.timezone import timedelta\n \n from zerver.lib.actions import (\n+ check_send_message,\n internal_send_huddle_message,\n internal_send_private_message,\n internal_send_stream_message,\n@@ -20,7 +21,7 @@\n get_email_gateway_message_string_from_address,\n )\n from zerver.lib.email_notifications import convert_html_to_markdown\n-from zerver.lib.exceptions import RateLimited\n+from zerver.lib.exceptions import JsonableError, RateLimited\n from zerver.lib.message import normalize_body, truncate_topic\n from zerver.lib.queue import queue_json_publish\n from zerver.lib.rate_limiter import RateLimitedObject\n@@ -33,6 +34,7 @@\n Recipient,\n Stream,\n UserProfile,\n+ get_client,\n get_display_recipient,\n get_stream_by_id_in_realm,\n get_system_bot,\n@@ -210,6 +212,27 @@ def send_zulip(sender: UserProfile, stream: Stream, topic: str, content: str) ->\n )\n \n \n+def send_mm_reply_to_stream(\n+ user_profile: UserProfile, stream: Stream, topic: str, body: str\n+) -> None:\n+ try:\n+ check_send_message(\n+ sender=user_profile,\n+ client=get_client(\"Internal\"),\n+ message_type_name=\"stream\",\n+ message_to=[stream.id],\n+ topic_name=topic,\n+ message_content=body,\n+ )\n+ except JsonableError as error:\n+ error_message = \"Error sending message to stream {stream} via missed messages email reply:\\n{error}\".format(\n+ stream=stream.name, error=error.msg\n+ )\n+ internal_send_private_message(\n+ get_system_bot(settings.NOTIFICATION_BOT), user_profile, error_message\n+ )\n+\n+\n def get_message_part_by_type(message: EmailMessage, content_type: str) -> Optional[str]:\n charsets = message.get_charsets()\n \n@@ -429,12 +452,7 @@ def process_missed_message(to: str, message: EmailMessage) -> None:\n \n if recipient.type == Recipient.STREAM:\n stream = get_stream_by_id_in_realm(recipient.type_id, user_profile.realm)\n- internal_send_stream_message(\n- user_profile,\n- stream,\n- topic,\n- body,\n- )\n+ send_mm_reply_to_stream(user_profile, stream, topic, body)\n recipient_str = stream.name\n elif recipient.type == Recipient.PERSONAL:\n display_recipient = get_display_recipient(recipient)\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_email_mirror.py b/zerver/tests/test_email_mirror.py\n--- a/zerver/tests/test_email_mirror.py\n+++ b/zerver/tests/test_email_mirror.py\n@@ -11,7 +11,12 @@\n from django.conf import settings\n from django.http import HttpResponse\n \n-from zerver.lib.actions import do_deactivate_realm, do_deactivate_user, ensure_stream\n+from zerver.lib.actions import (\n+ do_change_stream_post_policy,\n+ do_deactivate_realm,\n+ do_deactivate_user,\n+ ensure_stream,\n+)\n from zerver.lib.email_mirror import (\n ZulipEmailForwardError,\n create_missed_message_address,\n@@ -37,6 +42,7 @@\n from zerver.models import (\n MissedMessageEmailAddress,\n Recipient,\n+ Stream,\n UserProfile,\n get_display_recipient,\n get_realm,\n@@ -927,6 +933,47 @@ def test_receive_missed_stream_message_email_messages(self) -> None:\n self.assertEqual(message.recipient.type, Recipient.STREAM)\n self.assertEqual(message.recipient.id, usermessage.message.recipient.id)\n \n+ def test_receive_email_response_for_auth_failures(self) -> None:\n+ user_profile = self.example_user(\"hamlet\")\n+ self.subscribe(user_profile, \"announce\")\n+ self.login(\"hamlet\")\n+ result = self.client_post(\n+ \"/json/messages\",\n+ {\n+ \"type\": \"stream\",\n+ \"topic\": \"test topic\",\n+ \"content\": \"test_receive_email_response_for_auth_failures\",\n+ \"client\": \"test suite\",\n+ \"to\": \"announce\",\n+ },\n+ )\n+ self.assert_json_success(result)\n+\n+ stream = get_stream(\"announce\", user_profile.realm)\n+ do_change_stream_post_policy(stream, Stream.STREAM_POST_POLICY_ADMINS)\n+\n+ usermessage = most_recent_usermessage(user_profile)\n+\n+ mm_address = create_missed_message_address(user_profile, usermessage.message)\n+\n+ incoming_valid_message = EmailMessage()\n+ incoming_valid_message.set_content(\"TestMissedMessageEmailMessages Body\")\n+\n+ incoming_valid_message[\"Subject\"] = \"TestMissedMessageEmailMessages Subject\"\n+ incoming_valid_message[\"From\"] = user_profile.delivery_email\n+ incoming_valid_message[\"To\"] = mm_address\n+ incoming_valid_message[\"Reply-to\"] = user_profile.delivery_email\n+\n+ process_message(incoming_valid_message)\n+\n+ message = most_recent_message(user_profile)\n+\n+ self.assertEqual(\n+ message.content,\n+ \"Error sending message to stream announce via missed messages email reply:\\nOnly organization administrators can send to this stream.\",\n+ )\n+ self.assertEqual(message.sender, get_system_bot(settings.NOTIFICATION_BOT))\n+\n def test_missed_stream_message_email_response_tracks_topic_change(self) -> None:\n self.subscribe(self.example_user(\"hamlet\"), \"Denmark\")\n self.subscribe(self.example_user(\"othello\"), \"Denmark\")\n"},"problem_statement":{"kind":"string","value":"Failures to send message in email gateway should notify the user in some way\nReplying to an email on, say, an announcements stream (which only allows admins to post) will attempt to reply on the stream, and error out in `_internal_prep_message` due to the authorization check in `check_message`.\r\n\r\nThis results in logging an exception, returning `None` from `internal_send_stream_message` in `process_missed_message`, ignoring that value, and then logging `Successfully processed email from user`. From the user's point of view, they receive no feedback that the message failed to send, or why.\r\n\r\nIf the message is from the email gateway, we should not log an exception for auth failures; rather, we should notify the user (either via a reply email, or via a PM) that their message failed to send.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-development members, this issue was labeled with the \"area: emails\" label, so you may want to check it out!\n\n\n@timabbott I was looking to work on this issue. Shall I go ahead?\n@zulipbot claim\nHi @Abhirup-99, I was actually having a start at this issue but could not have a decent progress as my college exams and practicals kicked in. I would like to carry on with this one after the exams if you don't mind. I hope you can find some other good issue to work on. Btw zulip-bot is down these days, so you may not be able to claim issues.\nSome chat discussion here: https://chat.zulip.org/#narrow/stream/127-integrations/topic/email-gateway/near/1084269\nI wanted to to work on it, @ligmitz are you still working on it?\r\n\n@m-e-l-u-h-a-n Working on it !"},"created_at":{"kind":"timestamp","value":"2021-01-06T08:51:04","string":"2021-01-06T08:51:04"}}},{"rowIdx":637,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17020,"string":"17,020"},"instance_id":{"kind":"string","value":"zulip__zulip-17020"},"issue_numbers":{"kind":"list like","value":["17015"],"string":"[\n \"17015\"\n]"},"base_commit":{"kind":"string","value":"6c888977a6f7b319f5e91ba02eab67557d6a377a"},"patch":{"kind":"string","value":"diff --git a/zerver/forms.py b/zerver/forms.py\n--- a/zerver/forms.py\n+++ b/zerver/forms.py\n@@ -19,7 +19,7 @@\n from two_factor.utils import totp_digits\n \n from zerver.lib.actions import do_change_password, email_not_system_bot\n-from zerver.lib.email_validation import email_allowed_for_realm, validate_email_not_already_in_realm\n+from zerver.lib.email_validation import email_allowed_for_realm\n from zerver.lib.name_restrictions import is_disposable_domain, is_reserved_subdomain\n from zerver.lib.rate_limiter import RateLimited, RateLimitedObject\n from zerver.lib.request import JsonableError\n@@ -178,8 +178,6 @@ def clean_email(self) -> str:\n except EmailContainsPlusError:\n raise ValidationError(_(\"Email addresses containing + are not allowed in this organization.\"))\n \n- validate_email_not_already_in_realm(realm, email)\n-\n if realm.is_zephyr_mirror_realm:\n email_is_not_mit_mailing_list(email)\n \ndiff --git a/zerver/views/registration.py b/zerver/views/registration.py\n--- a/zerver/views/registration.py\n+++ b/zerver/views/registration.py\n@@ -163,9 +163,7 @@ def accounts_register(request: HttpRequest) -> HttpResponse:\n try:\n validate_email_not_already_in_realm(realm, email)\n except ValidationError:\n- view_url = reverse('login')\n- redirect_url = add_query_to_redirect_url(view_url, urlencode({\"email\": email}))\n- return HttpResponseRedirect(redirect_url)\n+ return redirect_to_email_login_url(email)\n \n name_validated = False\n full_name = None\n@@ -486,7 +484,7 @@ def send_confirm_registration_email(email: str, activation_url: str, language: s\n \n def redirect_to_email_login_url(email: str) -> HttpResponseRedirect:\n login_url = reverse('login')\n- redirect_url = add_query_to_redirect_url(login_url, urlencode({\"already_registered\": email}))\n+ redirect_url = add_query_to_redirect_url(login_url, urlencode({\"email\": email, \"already_registered\": 1}))\n return HttpResponseRedirect(redirect_url)\n \n def create_realm(request: HttpRequest, creation_key: Optional[str]=None) -> HttpResponse:\n@@ -555,6 +553,12 @@ def accounts_home(request: HttpRequest, multiuse_object_key: str=\"\",\n form = HomepageForm(request.POST, realm=realm, from_multiuse_invite=from_multiuse_invite)\n if form.is_valid():\n email = form.cleaned_data['email']\n+\n+ try:\n+ validate_email_not_already_in_realm(realm, email)\n+ except ValidationError:\n+ return redirect_to_email_login_url(email)\n+\n activation_url = prepare_activation_url(email, request, streams=streams_to_subscribe,\n invited_as=invited_as)\n try:\n@@ -565,11 +569,6 @@ def accounts_home(request: HttpRequest, multiuse_object_key: str=\"\",\n \n return HttpResponseRedirect(reverse('signup_send_confirm', kwargs={'email': email}))\n \n- email = request.POST['email']\n- try:\n- validate_email_not_already_in_realm(realm, email)\n- except ValidationError:\n- return redirect_to_email_login_url(email)\n else:\n form = HomepageForm(realm=realm)\n context = login_context(request)\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py\n--- a/zerver/tests/test_signup.py\n+++ b/zerver/tests/test_signup.py\n@@ -690,6 +690,18 @@ def test_register_deactivated(self) -> None:\n with self.assertRaises(UserProfile.DoesNotExist):\n self.nonreg_user('test')\n \n+ def test_register_with_invalid_email(self) -> None:\n+ \"\"\"\n+ If you try to register with invalid email, you get an invalid email\n+ page\n+ \"\"\"\n+ invalid_email = \"foo\\x00bar\"\n+ result = self.client_post('/accounts/home/', {'email': invalid_email},\n+ subdomain=\"zulip\")\n+\n+ self.assertEqual(result.status_code, 200)\n+ self.assertContains(result, \"Enter a valid email address\")\n+\n def test_register_deactivated_partway_through(self) -> None:\n \"\"\"\n If you try to register for a deactivated realm, you get a clear error\n@@ -1672,7 +1684,7 @@ def test_validate_email_not_already_in_realm(self) -> None:\n response = self.client_post(url, {\"key\": registration_key, \"from_confirmation\": 1, \"full_name\": \"alice\"})\n self.assertEqual(response.status_code, 302)\n self.assertEqual(response.url, reverse('login') + '?' +\n- urlencode({\"email\": email}))\n+ urlencode({\"email\": email, \"already_registered\": 1}))\n \n class InvitationsTestCase(InviteUserBase):\n def test_do_get_user_invites(self) -> None:\n"},"problem_statement":{"kind":"string","value":"Validate form of emails to /register/\nMost paths in `zerver/views/registration.py` validate the email by calling `validators.validate_email(email)` where necessary. However, the registration from `accounts_home` does not, which can [lead to invalid SQL queries when trying to check if the email is already in use](https://sentry.io/share/issue/6b34ad6039df4d029c85230d6b715df7/), and thus a 500.\r\n\r\nWe should validate the email using `validate_email` before checking if it is in use. This is probably just a case of:\r\n```\r\ndiff --git zerver/views/registration.py zerver/views/registration.py\r\nindex f55d73026e..6d9a072b17 100644\r\n--- zerver/views/registration.py\r\n+++ zerver/views/registration.py\r\n@@ -566,6 +566,10 @@ def accounts_home(request: HttpRequest, multiuse_object_key: str=\"\",\r\n return HttpResponseRedirect(reverse('signup_send_confirm', kwargs={'email': email}))\r\n\r\n email = request.POST['email']\r\n+ try:\r\n+ validators.validate_email(email)\r\n+ except ValidationError:\r\n+ return render(request, \"zerver/invalid_email.html\", context={\"invalid_email\": True})\r\n try:\r\n validate_email_not_already_in_realm(realm, email)\r\n except ValidationError:\r\n```\r\n\r\nBut that is totally untested, and I'd love more coverage on this endpoint.\n"},"hints_text":{"kind":"string","value":"@zulipbot claim\nHello @tushar912, it looks like you've currently claimed 1 issue in this repository. We encourage new contributors to focus their efforts on at most 1 issue at a time, so please complete your work on your other claimed issues before trying to claim this issue again.\n\nWe look forward to your valuable contributions!\nI am working on this\n@zulipbot claim\nWelcome to Zulip, @prakhar-ai! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!\n\nHere's some tips to get you off to a good start:\n* Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.\n* [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.\n\nAs you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.\n\nSee you on the other side (that is, the pull request side)!\n@prakhar-ai I have almost done this.\n@tushar912 I don't think zulipbot allows you to work on two issues simultaneously, which is why you weren't assigned. I'm sorry if this caused any misunderstanding.\n@prakhar-ai No problem ....If you need help do comment here.\nI'm unable to run tests due to [OSError: [Errno 26] Text file busy](https://zulip.readthedocs.io/en/latest/development/setup-vagrant.html#oserror-errno-26-text-file-busy). I have unassigned myself. @tushar912 feel free to work on this issue."},"created_at":{"kind":"timestamp","value":"2021-01-06T17:45:37","string":"2021-01-06T17:45:37"}}},{"rowIdx":638,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17031,"string":"17,031"},"instance_id":{"kind":"string","value":"zulip__zulip-17031"},"issue_numbers":{"kind":"list like","value":["15210"],"string":"[\n \"15210\"\n]"},"base_commit":{"kind":"string","value":"26d97ce7e3a919296582f4cd206932b1ad9e0169"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py\n--- a/zerver/lib/actions.py\n+++ b/zerver/lib/actions.py\n@@ -204,7 +204,12 @@\n )\n from zerver.lib.user_mutes import add_user_mute, get_muting_users, get_user_mutes\n from zerver.lib.user_status import update_user_status\n-from zerver.lib.user_topics import add_topic_mute, get_topic_mutes, remove_topic_mute\n+from zerver.lib.user_topics import (\n+ add_topic_mute,\n+ get_topic_mutes,\n+ get_users_muting_topic,\n+ remove_topic_mute,\n+)\n from zerver.lib.users import (\n check_bot_name_available,\n check_full_name,\n@@ -7086,6 +7091,47 @@ def user_info(um: UserMessage) -> Dict[str, Any]:\n \n users_to_be_notified += list(map(subscriber_info, sorted(list(subscriber_ids))))\n \n+ # Migrate muted topic configuration in the following circumstances:\n+ #\n+ # * If propagate_mode is change_all, do so unconditionally.\n+ #\n+ # * If propagate_mode is change_later, it's likely that we want to\n+ # move these only when it appears that the intent is to move\n+ # most of the topic, not just the last 1-2 messages which may\n+ # have been \"off topic\". At present we do so unconditionally.\n+ #\n+ # * Never move muted topic configuration with change_one.\n+ #\n+ # We may want more complex behavior in cases where one appears to\n+ # be merging topics (E.g. there are existing messages in the\n+ # target topic).\n+ #\n+ # Moving a topic to another stream is complicated in that we want\n+ # to avoid creating a UserTopic row for the user in a stream that\n+ # they don't have access to; doing so could leak information about\n+ # the existence of a private stream to some users. See the\n+ # moved_all_visible_messages below for related details.\n+ #\n+ # So for now, we require new_stream=None for this feature.\n+ if topic_name is not None and propagate_mode != \"change_one\" and new_stream is None:\n+ assert stream_being_edited is not None\n+ for muting_user in get_users_muting_topic(stream_being_edited.id, orig_topic_name):\n+ # TODO: Ideally, this would be a bulk update operation,\n+ # because we are doing database operations in a loop here.\n+ #\n+ # This loop is only acceptable in production because it is\n+ # rare for more than a few users to have muted an\n+ # individual topic that is being moved; as of this\n+ # writing, no individual topic in Zulip Cloud had been\n+ # muted by more than 100 users.\n+\n+ # We call remove_topic_mute rather than do_unmute_topic to\n+ # avoid sending two events with new muted topics in\n+ # immediate succession; this is correct only because\n+ # muted_topics events always send the full set of topics.\n+ remove_topic_mute(muting_user, stream_being_edited.id, orig_topic_name)\n+ do_mute_topic(muting_user, stream_being_edited, topic_name)\n+\n send_event(user_profile.realm, event, users_to_be_notified)\n \n if len(changed_messages) > 0 and new_stream is not None and stream_being_edited is not None:\n@@ -7906,6 +7952,9 @@ def do_mute_topic(\n \n \n def do_unmute_topic(user_profile: UserProfile, stream: Stream, topic: str) -> None:\n+ # Note: If you add any new code to this function, the\n+ # remove_topic_mute call in do_update_message will need to be\n+ # updated for correctness.\n try:\n remove_topic_mute(user_profile, stream.id, topic)\n except UserTopic.DoesNotExist:\ndiff --git a/zerver/lib/user_topics.py b/zerver/lib/user_topics.py\n--- a/zerver/lib/user_topics.py\n+++ b/zerver/lib/user_topics.py\n@@ -1,6 +1,7 @@\n import datetime\n from typing import Any, Callable, Dict, List, Optional, Tuple\n \n+from django.db.models.query import QuerySet\n from django.utils.timezone import now as timezone_now\n from sqlalchemy.sql import ClauseElement, and_, column, not_, or_\n from sqlalchemy.types import Integer\n@@ -152,3 +153,13 @@ def is_muted(recipient_id: int, topic: str) -> bool:\n return (recipient_id, topic.lower()) in tups\n \n return is_muted\n+\n+\n+def get_users_muting_topic(stream_id: int, topic_name: str) -> QuerySet[UserProfile]:\n+ return UserProfile.objects.select_related(\"realm\").filter(\n+ id__in=UserTopic.objects.filter(\n+ stream_id=stream_id,\n+ visibility_policy=UserTopic.MUTED,\n+ topic_name__iexact=topic_name,\n+ ).values(\"user_profile_id\")\n+ )\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.py\n--- a/zerver/tests/test_message_edit.py\n+++ b/zerver/tests/test_message_edit.py\n@@ -9,6 +9,7 @@\n from django.utils.timezone import now as timezone_now\n \n from zerver.lib.actions import (\n+ check_update_message,\n do_add_reaction,\n do_change_realm_plan_type,\n do_change_stream_post_policy,\n@@ -24,6 +25,12 @@\n from zerver.lib.test_classes import ZulipTestCase\n from zerver.lib.test_helpers import cache_tries_captured, queries_captured\n from zerver.lib.topic import RESOLVED_TOPIC_PREFIX, TOPIC_NAME\n+from zerver.lib.user_topics import (\n+ get_topic_mutes,\n+ get_users_muting_topic,\n+ set_topic_mutes,\n+ topic_is_muted,\n+)\n from zerver.models import Message, Realm, Stream, UserMessage, UserProfile, get_realm, get_stream\n \n \n@@ -1236,6 +1243,108 @@ def notify(user_id: int) -> Dict[str, Any]:\n users_to_be_notified = list(map(notify, [hamlet.id]))\n do_update_message_topic_success(hamlet, message, \"Change again\", users_to_be_notified)\n \n+ @mock.patch(\"zerver.lib.actions.send_event\")\n+ def test_edit_muted_topic(self, mock_send_event: mock.MagicMock) -> None:\n+ stream_name = \"Stream 123\"\n+ stream = self.make_stream(stream_name)\n+ hamlet = self.example_user(\"hamlet\")\n+ cordelia = self.example_user(\"cordelia\")\n+ aaron = self.example_user(\"aaron\")\n+ self.subscribe(hamlet, stream_name)\n+ self.login_user(hamlet)\n+ message_id = self.send_stream_message(\n+ hamlet, stream_name, topic_name=\"Topic1\", content=\"Hello World\"\n+ )\n+\n+ self.subscribe(cordelia, stream_name)\n+ self.login_user(cordelia)\n+ self.subscribe(aaron, stream_name)\n+ self.login_user(aaron)\n+\n+ muted_topics = [\n+ [stream_name, \"Topic1\"],\n+ [stream_name, \"Topic2\"],\n+ ]\n+ set_topic_mutes(hamlet, muted_topics)\n+ set_topic_mutes(cordelia, muted_topics)\n+\n+ # Returns the users that need to be notified when a message topic is changed\n+ def notify(user_id: int) -> Dict[str, Any]:\n+ um = UserMessage.objects.get(message=message_id)\n+ if um.user_profile_id == user_id:\n+ return {\n+ \"id\": user_id,\n+ \"flags\": um.flags_list(),\n+ }\n+\n+ else:\n+ return {\n+ \"id\": user_id,\n+ \"flags\": [\"read\"],\n+ }\n+\n+ users_to_be_notified = list(map(notify, [hamlet.id, cordelia.id, aaron.id]))\n+ change_all_topic_name = \"Topic 1 edited\"\n+\n+ with queries_captured() as queries:\n+ check_update_message(\n+ user_profile=hamlet,\n+ message_id=message_id,\n+ stream_id=None,\n+ topic_name=change_all_topic_name,\n+ propagate_mode=\"change_all\",\n+ send_notification_to_old_thread=False,\n+ send_notification_to_new_thread=False,\n+ content=None,\n+ )\n+ # This code path adds 9 (1 + 4/user with muted topics) to\n+ # the number of database queries for moving a topic.\n+ self.assert_length(queries, 18)\n+\n+ for muting_user in get_users_muting_topic(stream.id, change_all_topic_name):\n+ for user in users_to_be_notified:\n+ if muting_user.id == user[\"id\"]:\n+ user[\"muted_topics\"] = get_topic_mutes(muting_user)\n+ break\n+\n+ self.assertFalse(topic_is_muted(hamlet, stream.id, \"Topic1\"))\n+ self.assertFalse(topic_is_muted(cordelia, stream.id, \"Topic1\"))\n+ self.assertFalse(topic_is_muted(aaron, stream.id, \"Topic1\"))\n+ self.assertTrue(topic_is_muted(hamlet, stream.id, \"Topic2\"))\n+ self.assertTrue(topic_is_muted(cordelia, stream.id, \"Topic2\"))\n+ self.assertFalse(topic_is_muted(aaron, stream.id, \"Topic2\"))\n+ self.assertTrue(topic_is_muted(hamlet, stream.id, change_all_topic_name))\n+ self.assertTrue(topic_is_muted(cordelia, stream.id, change_all_topic_name))\n+ self.assertFalse(topic_is_muted(aaron, stream.id, change_all_topic_name))\n+\n+ change_later_topic_name = \"Topic 1 edited again\"\n+ check_update_message(\n+ user_profile=hamlet,\n+ message_id=message_id,\n+ stream_id=None,\n+ topic_name=change_later_topic_name,\n+ propagate_mode=\"change_later\",\n+ send_notification_to_old_thread=False,\n+ send_notification_to_new_thread=False,\n+ content=None,\n+ )\n+ self.assertFalse(topic_is_muted(hamlet, stream.id, change_all_topic_name))\n+ self.assertTrue(topic_is_muted(hamlet, stream.id, change_later_topic_name))\n+\n+ change_one_topic_name = \"Topic 1 edited change_one\"\n+ check_update_message(\n+ user_profile=hamlet,\n+ message_id=message_id,\n+ stream_id=None,\n+ topic_name=change_one_topic_name,\n+ propagate_mode=\"change_one\",\n+ send_notification_to_old_thread=False,\n+ send_notification_to_new_thread=False,\n+ content=None,\n+ )\n+ self.assertFalse(topic_is_muted(hamlet, stream.id, change_one_topic_name))\n+ self.assertTrue(topic_is_muted(hamlet, stream.id, change_later_topic_name))\n+\n @mock.patch(\"zerver.lib.actions.send_event\")\n def test_wildcard_mention(self, mock_send_event: mock.MagicMock) -> None:\n stream_name = \"Macbeth\"\n"},"problem_statement":{"kind":"string","value":"Renaming whole topic causes unmute\nIf you mute a topic and someone takes a message out of it by renaming its topic, the extracted messages are \"unmuted\". Unless I am mistaken, this is a feature that lets you know these messages aren't part of the topic you muted.\r\nHowever, when the whole topic is renamed *a priori* you still do not want to see the contents and thus the topic should stay muted.\r\n\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-message-view members, this issue was labeled with the \"area: message-editing\" label, so you may want to check it out!\n\n\nYeah, I think I agree that in the case that it's a full-topic change, we should update any MutedTopic entries to point to the new topic. This might be a little complicated to do, since we'll need to notify the frontend in addition to updating the backend data model.\r\n\r\nShould this still happen when the stream changed as well? Probably not. \r\n\r\n@aman566 FYI; this is probably lower priority than the other message editing issues on your plate."},"created_at":{"kind":"timestamp","value":"2021-01-09T08:50:12","string":"2021-01-09T08:50:12"}}},{"rowIdx":639,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17033,"string":"17,033"},"instance_id":{"kind":"string","value":"zulip__zulip-17033"},"issue_numbers":{"kind":"list like","value":["16048"],"string":"[\n \"16048\"\n]"},"base_commit":{"kind":"string","value":"2e7aaba0dde5517b4a55cb0bd782f009be45e3ba"},"patch":{"kind":"string","value":"diff --git a/zerver/openapi/python_examples.py b/zerver/openapi/python_examples.py\n--- a/zerver/openapi/python_examples.py\n+++ b/zerver/openapi/python_examples.py\n@@ -1101,6 +1101,22 @@ def update_notification_settings(client: Client) -> None:\n validate_against_openapi_schema(result, \"/settings/notifications\", \"patch\", \"200\")\n \n \n+@openapi_test_function(\"/settings/display:patch\")\n+def update_display_settings(client: Client) -> None:\n+\n+ # {code_example|start}\n+ # Show user list on left sidebar in narrow windows.\n+ # Change emoji set used for display to Google modern.\n+ request = {\n+ \"left_side_userlist\": True,\n+ \"emojiset\": '\"google\"',\n+ }\n+ result = client.call_endpoint(\"settings/display\", method=\"PATCH\", request=request)\n+ # {code_example|end}\n+\n+ validate_against_openapi_schema(result, \"/settings/display\", \"patch\", \"200\")\n+\n+\n @openapi_test_function(\"/user_uploads:post\")\n def upload_file(client: Client) -> None:\n path_to_file = os.path.join(ZULIP_DIR, \"zerver\", \"tests\", \"images\", \"img.jpg\")\n@@ -1391,6 +1407,7 @@ def test_users(client: Client, owner_client: Client) -> None:\n get_subscription_status(client)\n get_profile(client)\n update_notification_settings(client)\n+ update_display_settings(client)\n upload_file(client)\n get_attachments(client)\n set_typing_status(client)\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_openapi.py b/zerver/tests/test_openapi.py\n--- a/zerver/tests/test_openapi.py\n+++ b/zerver/tests/test_openapi.py\n@@ -266,8 +266,6 @@ class OpenAPIArgumentsTest(ZulipTestCase):\n \"/settings\",\n \"/users/me/avatar\",\n \"/users/me/api_key/regenerate\",\n- # Not very useful outside the UI\n- \"/settings/display\",\n # Much more valuable would be an org admin bulk-upload feature.\n \"/users/me/profile_data\",\n #### Should be documented as part of interactive bots documentation\n"},"problem_statement":{"kind":"string","value":"Document display settings in Zulip API documentation\nThis should look very similar to the existing documentation for the notification settings endpoint. \r\n\r\nWhen we do this, we should remember to update the `/register` documentation added in #16000 for display settings to include ir link to the detailed explanations of the meaning of these settings.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-api members, this issue was labeled with the \"area: documentation (api and integrations)\" label, so you may want to check it out!\n\n\nI am working on it.\n@timabbott I have added pr #17033 to address this, it would be great if you could review it."},"created_at":{"kind":"timestamp","value":"2021-01-09T11:46:03","string":"2021-01-09T11:46:03"}}},{"rowIdx":640,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17045,"string":"17,045"},"instance_id":{"kind":"string","value":"zulip__zulip-17045"},"issue_numbers":{"kind":"list like","value":["10830"],"string":"[\n \"10830\"\n]"},"base_commit":{"kind":"string","value":"99636c36a31ba524857833b47e911dd1e6972a1f"},"patch":{"kind":"string","value":"diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py\n--- a/tools/linter_lib/custom_check.py\n+++ b/tools/linter_lib/custom_check.py\n@@ -745,6 +745,10 @@\n \"pattern\": '{{t \"[^\"]+ \" }}',\n \"description\": \"Translatable strings should not have trailing spaces.\",\n },\n+ {\n+ \"pattern\": r'\"{{t \"',\n+ \"description\": \"Invalid quoting for HTML element with translated string.\",\n+ },\n ],\n )\n \n"},"test_patch":{"kind":"string","value":"diff --git a/frontend_tests/puppeteer_tests/realm-linkifier.ts b/frontend_tests/puppeteer_tests/realm-linkifier.ts\n--- a/frontend_tests/puppeteer_tests/realm-linkifier.ts\n+++ b/frontend_tests/puppeteer_tests/realm-linkifier.ts\n@@ -35,11 +35,11 @@ async function test_add_linkifier(page: Page): Promise {\n }\n \n async function test_delete_linkifier(page: Page): Promise {\n- await page.click(\".linkifier_row button\");\n+ await page.click(\".linkifier_row .delete\");\n await page.waitForSelector(\".linkifier_row\", {hidden: true});\n }\n \n-async function test_invalid_linkifier_pattern(page: Page): Promise {\n+async function test_add_invalid_linkifier_pattern(page: Page): Promise {\n await page.waitForSelector(\".admin-linkifier-form\", {visible: true});\n await common.fill_form(page, \"form.admin-linkifier-form\", {\n pattern: \"a$\",\n@@ -54,14 +54,94 @@ async function test_invalid_linkifier_pattern(page: Page): Promise {\n );\n }\n \n+async function test_edit_linkifier(page: Page): Promise {\n+ await page.click(\".linkifier_row .edit\");\n+ await page.waitForFunction(() => document.activeElement === $(\"#linkifier-edit-form-modal\")[0]);\n+ await common.fill_form(page, \"form.linkifier-edit-form\", {\n+ pattern: \"(?P[0-9a-f]{40})\",\n+ url_format_string: \"https://trac.example.com/commit/%(num)s\",\n+ });\n+ await page.click(\".submit-linkifier-info-change\");\n+\n+ await page.waitForSelector(\"#linkifier-edit-form-modal\", {hidden: true});\n+ await page.waitForFunction(() => $(\".edit-linkifier-status\").text().trim() === \"Saved\");\n+ await page.waitForSelector(\".linkifier_row\", {visible: true});\n+ assert.strictEqual(\n+ await common.get_text_from_selector(page, \".linkifier_row span.linkifier_pattern\"),\n+ \"(?P[0-9a-f]{40})\",\n+ );\n+ assert.strictEqual(\n+ await common.get_text_from_selector(\n+ page,\n+ \".linkifier_row span.linkifier_url_format_string\",\n+ ),\n+ \"https://trac.example.com/commit/%(num)s\",\n+ );\n+}\n+\n+async function test_edit_invalid_linkifier(page: Page): Promise {\n+ await page.click(\".linkifier_row .edit\");\n+ await page.waitForFunction(() => document.activeElement === $(\"#linkifier-edit-form-modal\")[0]);\n+ await common.fill_form(page, \"form.linkifier-edit-form\", {\n+ pattern: \"####\",\n+ url_format_string: \"####\",\n+ });\n+ await page.click(\".submit-linkifier-info-change\");\n+\n+ const edit_linkifier_pattern_status_selector = \"div#edit-linkifier-pattern-status\";\n+ await page.waitForSelector(edit_linkifier_pattern_status_selector, {visible: true});\n+ const edit_linkifier_pattern_status = await common.get_text_from_selector(\n+ page,\n+ edit_linkifier_pattern_status_selector,\n+ );\n+ assert.strictEqual(\n+ edit_linkifier_pattern_status,\n+ \"Failed: Invalid linkifier pattern. Valid characters are [ a-zA-Z_#=/:+!-].\",\n+ );\n+\n+ const edit_linkifier_format_status_selector = \"div#edit-linkifier-format-status\";\n+ await page.waitForSelector(edit_linkifier_format_status_selector, {visible: true});\n+ const edit_linkifier_format_status = await common.get_text_from_selector(\n+ page,\n+ edit_linkifier_format_status_selector,\n+ );\n+ assert.strictEqual(\n+ edit_linkifier_format_status,\n+ \"Failed: Enter a valid URL.,Invalid URL format string.\",\n+ );\n+\n+ await page.click(\".cancel-linkifier-info-change\");\n+ await page.waitForSelector(\"#linkifier-edit-form-modal\", {hidden: true});\n+\n+ await page.waitForFunction(\n+ () =>\n+ $(\".edit-linkifier-status\").text().trim() ===\n+ \"Save failed: Invalid linkifier pattern. Valid characters are [ a-zA-Z_#=/:+!-].\",\n+ );\n+ await page.waitForSelector(\".linkifier_row\", {visible: true});\n+ assert.strictEqual(\n+ await common.get_text_from_selector(page, \".linkifier_row span.linkifier_pattern\"),\n+ \"(?P[0-9a-f]{40})\",\n+ );\n+ assert.strictEqual(\n+ await common.get_text_from_selector(\n+ page,\n+ \".linkifier_row span.linkifier_url_format_string\",\n+ ),\n+ \"https://trac.example.com/commit/%(num)s\",\n+ );\n+}\n+\n async function linkifier_test(page: Page): Promise {\n await common.log_in(page);\n await common.manage_organization(page);\n await page.click(\"li[data-section='linkifier-settings']\");\n \n await test_add_linkifier(page);\n+ await test_edit_linkifier(page);\n+ await test_edit_invalid_linkifier(page);\n+ await test_add_invalid_linkifier_pattern(page);\n await test_delete_linkifier(page);\n- await test_invalid_linkifier_pattern(page);\n }\n \n common.run_test(linkifier_test);\n"},"problem_statement":{"kind":"string","value":"Organization linkifiers should be editable in place\nIt would be nice if linkifications were editable, rather than requiring deletion and re-creation. But I understand it would be harder to check for duplicate regex that way.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-markdown, @zulip/server-settings members, this issue was labeled with the \"area: markdown\", \"area: settings (admin/org)\" labels, so you may want to check it out!\n\n\nThis seems like a reasonable UI to add, though probably not super high priority, just because folks tend to edit these only once when setting up an organization.\nSo, there are three functions in file zerver/views/realm_filters.py. For listing, creating and deleting. And I think a function for editing filter needs to be created. Should I do so and hit PR?\n@zulipbot claim\r\n\nWelcome to Zulip, @ruchit2801! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!\n\nHere's some tips to get you off to a good start:\n* Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.\n* Sign the [Dropbox Contributor License Agreement](https://opensource.dropbox.com/cla/), so that Zulip can use your code.\n* [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.\n\nAs you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.\n\nSee you on the other side (that is, the pull request side)!\nThat's correct, we need to extend the API for this.\n@zulipbot abandon\r\n"},"created_at":{"kind":"timestamp","value":"2021-01-12T18:24:50","string":"2021-01-12T18:24:50"}}},{"rowIdx":641,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17091,"string":"17,091"},"instance_id":{"kind":"string","value":"zulip__zulip-17091"},"issue_numbers":{"kind":"list like","value":["17071"],"string":"[\n \"17071\"\n]"},"base_commit":{"kind":"string","value":"5da304d902bbb2dc4df8948ffdac941b4416bed0"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py\n--- a/zerver/lib/actions.py\n+++ b/zerver/lib/actions.py\n@@ -4183,7 +4183,9 @@ def do_update_user_status(user_profile: UserProfile,\n away: Optional[bool],\n status_text: Optional[str],\n client_id: int) -> None:\n- if away:\n+ if away is None:\n+ status = None\n+ elif away:\n status = UserStatus.AWAY\n else:\n status = UserStatus.NORMAL\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_user_status.py b/zerver/tests/test_user_status.py\n--- a/zerver/tests/test_user_status.py\n+++ b/zerver/tests/test_user_status.py\n@@ -230,3 +230,40 @@ def test_endpoints(self) -> None:\n get_user_info_dict(realm_id=realm_id),\n {},\n )\n+\n+ # Turn on \"away\" status again.\n+ payload = dict(away=orjson.dumps(True).decode())\n+\n+ event_info = EventInfo()\n+ with capture_event(event_info):\n+ result = self.client_post('/json/users/me/status', payload)\n+ self.assert_json_success(result)\n+\n+ self.assertEqual(\n+ event_info.payload,\n+ dict(type='user_status', user_id=hamlet.id, away=True),\n+ )\n+\n+ away_user_ids = get_away_user_ids(realm_id=realm_id)\n+ self.assertEqual(away_user_ids, {hamlet.id})\n+\n+ # And set status text while away.\n+ payload = dict(status_text=' at the beach ')\n+\n+ event_info = EventInfo()\n+ with capture_event(event_info):\n+ result = self.client_post('/json/users/me/status', payload)\n+ self.assert_json_success(result)\n+\n+ self.assertEqual(\n+ event_info.payload,\n+ dict(type='user_status', user_id=hamlet.id, status_text='at the beach'),\n+ )\n+\n+ self.assertEqual(\n+ user_info(hamlet),\n+ dict(status_text='at the beach', away=True),\n+ )\n+\n+ away_user_ids = get_away_user_ids(realm_id=realm_id)\n+ self.assertEqual(away_user_ids, {hamlet.id})\n"},"problem_statement":{"kind":"string","value":"Setting status text revokes \"away\"\nSetting a status text while being \"unavailable\" revokes the away status. \r\nhttps://chat.zulip.org/#narrow/stream/9-issues/topic/Setting.20status.20text.20revokes.20away/near/1100185\n"},"hints_text":{"kind":"string","value":"@abhijeetbodas2001 You might still want to look at this, as I believe the solution from @ligmitz might not get to the heart of the bug here."},"created_at":{"kind":"timestamp","value":"2021-01-20T18:34:01","string":"2021-01-20T18:34:01"}}},{"rowIdx":642,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17104,"string":"17,104"},"instance_id":{"kind":"string","value":"zulip__zulip-17104"},"issue_numbers":{"kind":"list like","value":["16970"],"string":"[\n \"16970\"\n]"},"base_commit":{"kind":"string","value":"eefa687832949d86a7b954efbcd5d20d87900120"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/url_preview/preview.py b/zerver/lib/url_preview/preview.py\n--- a/zerver/lib/url_preview/preview.py\n+++ b/zerver/lib/url_preview/preview.py\n@@ -27,9 +27,8 @@\n \n # Use Chrome User-Agent, since some sites refuse to work on old browsers\n ZULIP_URL_PREVIEW_USER_AGENT = (\n- 'Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ZulipURLPreview/{version}; '\n- '+{external_host}) Chrome/81.0.4044.113 Safari/537.36'\n-).format(version=ZULIP_VERSION, external_host=settings.EXTERNAL_HOST)\n+ 'Mozilla/5.0 (compatible; ZulipURLPreview/{version}; +{external_host})'\n+).format(version=ZULIP_VERSION, external_host=settings.ROOT_DOMAIN_URI)\n \n # FIXME: This header and timeout are not used by pyoembed, when trying to autodiscover!\n HEADERS = {'User-Agent': ZULIP_URL_PREVIEW_USER_AGENT}\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Incorrect rendering of YouTube Titles\nI tried sending some youtube videos with setting: Show previews of linked website - checked, but the **extracted** YouTube title is not as expected for most of the videos, it is `YouTube - YouTube` while it should be `YouTube - [Title of the YouTube video]`. Also **extracted** description is `Share your videos with friends, family and the world` for every video sent.\r\nhttps://chat.zulip.org/#narrow/stream/3-backend/topic/Markdown.20Youtube.20Title\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-markdown members, this issue was labeled with the \"area: markdown\" label, so you may want to check it out!\n\n\nHi! @akshatdalton can I try this as my first issue ?\r\n\n@imajit \r\nYeah you can try to give this a shot but I am still not sure about the behaviour of the headers.\r\nMore context in [CZO](https://chat.zulip.org/#narrow/stream/3-backend/topic/Markdown.20Youtube.20Title).\nHey @imajit, are you still working on this issue? If not, I would like to work on this "},"created_at":{"kind":"timestamp","value":"2021-01-22T21:10:27","string":"2021-01-22T21:10:27"}}},{"rowIdx":643,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17112,"string":"17,112"},"instance_id":{"kind":"string","value":"zulip__zulip-17112"},"issue_numbers":{"kind":"list like","value":["17111","17111"],"string":"[\n \"17111\",\n \"17111\"\n]"},"base_commit":{"kind":"string","value":"abff97df39cc051fbfdb1ee3829443922dc7b716"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/users.py b/zerver/lib/users.py\n--- a/zerver/lib/users.py\n+++ b/zerver/lib/users.py\n@@ -222,18 +222,28 @@ def access_bot_by_id(user_profile: UserProfile, user_id: int) -> UserProfile:\n raise JsonableError(_(\"Insufficient permission\"))\n return target\n \n-def access_user_by_id(user_profile: UserProfile, user_id: int,\n- allow_deactivated: bool=False, allow_bots: bool=False,\n- read_only: bool=False) -> UserProfile:\n+def access_user_by_id(\n+ user_profile: UserProfile,\n+ target_user_id: int,\n+ *,\n+ allow_deactivated: bool=False,\n+ allow_bots: bool=False,\n+ for_admin: bool,\n+) -> UserProfile:\n+ \"\"\"Master function for accessing another user by ID in API code;\n+ verifies the user ID is in the same realm, and if requested checks\n+ for administrative privileges, with flags for various special\n+ cases.\n+ \"\"\"\n try:\n- target = get_user_profile_by_id_in_realm(user_id, user_profile.realm)\n+ target = get_user_profile_by_id_in_realm(target_user_id, user_profile.realm)\n except UserProfile.DoesNotExist:\n raise JsonableError(_(\"No such user\"))\n if target.is_bot and not allow_bots:\n raise JsonableError(_(\"No such user\"))\n if not target.is_active and not allow_deactivated:\n raise JsonableError(_(\"User is deactivated\"))\n- if read_only:\n+ if not for_admin:\n # Administrative access is not required just to read a user.\n return target\n if not user_profile.can_admin_user(target):\ndiff --git a/zerver/views/users.py b/zerver/views/users.py\n--- a/zerver/views/users.py\n+++ b/zerver/views/users.py\n@@ -89,7 +89,7 @@ def check_last_owner(user_profile: UserProfile) -> bool:\n \n def deactivate_user_backend(request: HttpRequest, user_profile: UserProfile,\n user_id: int) -> HttpResponse:\n- target = access_user_by_id(user_profile, user_id)\n+ target = access_user_by_id(user_profile, user_id, for_admin=True)\n if target.is_realm_owner and not user_profile.is_realm_owner:\n raise OrganizationOwnerRequired()\n if check_last_owner(target):\n@@ -117,7 +117,8 @@ def _deactivate_user_profile_backend(request: HttpRequest, user_profile: UserPro\n \n def reactivate_user_backend(request: HttpRequest, user_profile: UserProfile,\n user_id: int) -> HttpResponse:\n- target = access_user_by_id(user_profile, user_id, allow_deactivated=True, allow_bots=True)\n+ target = access_user_by_id(user_profile, user_id,\n+ allow_deactivated=True, allow_bots=True, for_admin=True)\n if target.is_bot:\n assert target.bot_type is not None\n check_bot_creation_policy(user_profile, target.bot_type)\n@@ -144,13 +145,19 @@ def update_user_backend(\n default=None, validator=check_profile_data,\n ),\n ) -> HttpResponse:\n- target = access_user_by_id(user_profile, user_id, allow_deactivated=True, allow_bots=True)\n+ target = access_user_by_id(user_profile, user_id,\n+ allow_deactivated=True, allow_bots=True, for_admin=True)\n \n if role is not None and target.role != role:\n- if target.role == UserProfile.ROLE_REALM_OWNER and check_last_owner(user_profile):\n- return json_error(_('The owner permission cannot be removed from the only organization owner.'))\n+ # Require that the current user has permissions to\n+ # grant/remove the role in question. access_user_by_id has\n+ # already verified we're an administrator; here we enforce\n+ # that only owners can toggle the is_realm_owner flag.\n if UserProfile.ROLE_REALM_OWNER in [role, target.role] and not user_profile.is_realm_owner:\n raise OrganizationOwnerRequired()\n+\n+ if target.role == UserProfile.ROLE_REALM_OWNER and check_last_owner(user_profile):\n+ return json_error(_('The owner permission cannot be removed from the only organization owner.'))\n do_change_user_role(target, role, acting_user=user_profile)\n \n if (full_name is not None and target.full_name != full_name and\n@@ -470,7 +477,7 @@ def get_members_backend(request: HttpRequest, user_profile: UserProfile, user_id\n target_user = None\n if user_id is not None:\n target_user = access_user_by_id(user_profile, user_id, allow_deactivated=True,\n- allow_bots=True, read_only=True)\n+ allow_bots=True, for_admin=False)\n \n members = get_raw_user_data(realm, user_profile, target_user=target_user,\n client_gravatar=client_gravatar,\n@@ -548,7 +555,7 @@ def get_subscription_backend(request: HttpRequest, user_profile: UserProfile,\n user_id: int=REQ(validator=check_int, path_only=True),\n stream_id: int=REQ(validator=check_int, path_only=True),\n ) -> HttpResponse:\n- target_user = access_user_by_id(user_profile, user_id, read_only=True)\n+ target_user = access_user_by_id(user_profile, user_id, for_admin=False)\n (stream, sub) = access_stream_by_id(user_profile, stream_id)\n \n subscription_status = {'is_subscribed': subscribed_to_stream(target_user, stream_id)}\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.py\n--- a/zerver/tests/test_users.py\n+++ b/zerver/tests/test_users.py\n@@ -382,29 +382,30 @@ def test_access_user_by_id(self) -> None:\n \n # Must be a valid user ID in the realm\n with self.assertRaises(JsonableError):\n- access_user_by_id(iago, 1234)\n+ access_user_by_id(iago, 1234, for_admin=False)\n with self.assertRaises(JsonableError):\n- access_user_by_id(iago, self.mit_user(\"sipbtest\").id)\n+ access_user_by_id(iago, self.mit_user(\"sipbtest\").id, for_admin=False)\n \n- # Can only access bot users if allow_deactivated is passed\n+ # Can only access bot users if allow_bots is passed\n bot = self.example_user(\"default_bot\")\n- access_user_by_id(iago, bot.id, allow_bots=True)\n+ access_user_by_id(iago, bot.id, allow_bots=True, for_admin=True)\n with self.assertRaises(JsonableError):\n- access_user_by_id(iago, bot.id)\n+ access_user_by_id(iago, bot.id, for_admin=True)\n \n # Can only access deactivated users if allow_deactivated is passed\n hamlet = self.example_user(\"hamlet\")\n do_deactivate_user(hamlet)\n with self.assertRaises(JsonableError):\n- access_user_by_id(iago, hamlet.id)\n- access_user_by_id(iago, hamlet.id, allow_deactivated=True)\n+ access_user_by_id(iago, hamlet.id, for_admin=False)\n+ with self.assertRaises(JsonableError):\n+ access_user_by_id(iago, hamlet.id, for_admin=True)\n+ access_user_by_id(iago, hamlet.id, allow_deactivated=True, for_admin=True)\n \n # Non-admin user can't admin another user\n with self.assertRaises(JsonableError):\n- access_user_by_id(self.example_user(\"cordelia\"), self.example_user(\"aaron\").id)\n+ access_user_by_id(self.example_user(\"cordelia\"), self.example_user(\"aaron\").id, for_admin=True)\n # But does have read-only access to it.\n- access_user_by_id(self.example_user(\"cordelia\"), self.example_user(\"aaron\").id,\n- read_only=True)\n+ access_user_by_id(self.example_user(\"cordelia\"), self.example_user(\"aaron\").id, for_admin=False)\n \n def test_change_regular_member_to_guest(self) -> None:\n iago = self.example_user(\"iago\")\n"},"problem_statement":{"kind":"string","value":"Clarify redability issues over access_user_by_id\nzerver/lib/users.py has a function named access_user_by_id, which was\r\nused in /users views to fetch a user by it's id. Along with fetching\r\nthe user this function also does important validations regarding\r\nchecking of required permissions for fetching the target user.\r\n\r\nAlthough current name works fine but it's name gives no hints to\r\nanyone reading the code about the validations part. This can lead to\r\nunnecessary confusion regarding the permissions for accessing users in\r\nviews.\r\nAn example of this was highlighted and discussed here: [CZO conversation link.](https://chat.zulip.org/#narrow/stream/49-development-help/topic/Admin.20Bot.20.20.2312424/near/1104966)\nClarify redability issues over access_user_by_id\nzerver/lib/users.py has a function named access_user_by_id, which was\r\nused in /users views to fetch a user by it's id. Along with fetching\r\nthe user this function also does important validations regarding\r\nchecking of required permissions for fetching the target user.\r\n\r\nAlthough current name works fine but it's name gives no hints to\r\nanyone reading the code about the validations part. This can lead to\r\nunnecessary confusion regarding the permissions for accessing users in\r\nviews.\r\nAn example of this was highlighted and discussed here: [CZO conversation link.](https://chat.zulip.org/#narrow/stream/49-development-help/topic/Admin.20Bot.20.20.2312424/near/1104966)\n"},"hints_text":{"kind":"string","value":"\n"},"created_at":{"kind":"timestamp","value":"2021-01-23T05:53:46","string":"2021-01-23T05:53:46"}}},{"rowIdx":644,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17166,"string":"17,166"},"instance_id":{"kind":"string","value":"zulip__zulip-17166"},"issue_numbers":{"kind":"list like","value":["17156"],"string":"[\n \"17156\"\n]"},"base_commit":{"kind":"string","value":"830f1fa8c58150b85b0b485dd410502667b2d3af"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/widget.py b/zerver/lib/widget.py\n--- a/zerver/lib/widget.py\n+++ b/zerver/lib/widget.py\n@@ -3,7 +3,7 @@\n from typing import Any, Optional, Tuple\n \n from zerver.lib.message import SendMessageRequest\n-from zerver.models import SubMessage\n+from zerver.models import Message, SubMessage\n \n \n def get_widget_data(content: str) -> Tuple[Optional[str], Optional[str]]:\n@@ -77,3 +77,8 @@ def do_widget_post_save_actions(send_request: SendMessageRequest) -> None:\n )\n submessage.save()\n send_request.submessages = SubMessage.get_raw_db_rows([message_id])\n+\n+\n+def is_widget_message(message: Message) -> bool:\n+ # Right now all messages that are widgetized use submessage, and vice versa.\n+ return message.submessage_set.exists()\ndiff --git a/zerver/views/message_edit.py b/zerver/views/message_edit.py\n--- a/zerver/views/message_edit.py\n+++ b/zerver/views/message_edit.py\n@@ -24,6 +24,7 @@\n from zerver.lib.timestamp import datetime_to_timestamp\n from zerver.lib.topic import LEGACY_PREV_TOPIC, REQ_topic\n from zerver.lib.validator import check_bool, check_string_in, to_non_negative_int\n+from zerver.lib.widget import is_widget_message\n from zerver.models import Message, Realm, UserProfile\n \n \n@@ -139,6 +140,10 @@ def update_message_backend(\n else:\n raise JsonableError(_(\"You don't have permission to edit this message\"))\n \n+ # Right now, we prevent users from editing widgets.\n+ if content is not None and is_widget_message(message):\n+ return json_error(_(\"Widgets cannot be edited.\"))\n+\n # If there is a change to the content, check that it hasn't been too long\n # Allow an extra 20 seconds since we potentially allow editing 15 seconds\n # past the limit, and in case there are network issues, etc. The 15 comes\n"},"test_patch":{"kind":"string","value":"diff --git a/frontend_tests/node_tests/message_edit.js b/frontend_tests/node_tests/message_edit.js\n--- a/frontend_tests/node_tests/message_edit.js\n+++ b/frontend_tests/node_tests/message_edit.js\n@@ -68,6 +68,10 @@ run_test(\"get_editability\", () => {\n // is true, we can edit the topic if there is one.\n message.type = \"stream\";\n assert.equal(get_editability(message, 45), editability_types.TOPIC_ONLY);\n+ // Right now, we prevent users from editing widgets.\n+ message.submessages = [\"/poll\"];\n+ assert.equal(get_editability(message, 45), editability_types.TOPIC_ONLY);\n+ delete message.submessages;\n message.type = \"private\";\n assert.equal(get_editability(message, 45), editability_types.NO_LONGER);\n // If we don't pass a second argument, treat it as 0\ndiff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.py\n--- a/zerver/tests/test_message_edit.py\n+++ b/zerver/tests/test_message_edit.py\n@@ -187,6 +187,24 @@ def test_fetch_raw_message_private_stream(self) -> None:\n result = self.client_get(\"/json/messages/\" + str(msg_id))\n self.assert_json_error(result, \"Invalid message(s)\")\n \n+ # Right now, we prevent users from editing widgets.\n+ def test_edit_submessage(self) -> None:\n+ self.login(\"hamlet\")\n+ msg_id = self.send_stream_message(\n+ self.example_user(\"hamlet\"),\n+ \"Scotland\",\n+ topic_name=\"editing\",\n+ content=\"/poll Games?\\nYES\\nNO\",\n+ )\n+ result = self.client_patch(\n+ \"/json/messages/\" + str(msg_id),\n+ {\n+ \"message_id\": msg_id,\n+ \"content\": \"/poll Games?\\nYES\\nNO\\nMaybe\",\n+ },\n+ )\n+ self.assert_json_error(result, \"Widgets cannot be edited.\")\n+\n def test_edit_message_no_permission(self) -> None:\n self.login(\"hamlet\")\n msg_id = self.send_stream_message(\n"},"problem_statement":{"kind":"string","value":"widgets: Prevent edits to /poll and /todo messages.\nSee #14229 for a more ambitious plan here, but in the short term, we want to prevent users from editing messages that are widgetized, such as \"/poll\" and \"/todo\" messages. You can detect widgets by the presence of `submessage` rows attached to the `message`, although there may be something more explicit.\r\n\r\nWe want to either just remove all the UI ways to perform an edit, or better, have a little popup when users try to edit that says \"Sorry you can not edit this message, because it's a widget.\" We can work on the wording.\r\n\r\nWe should continue to allow admins to fully delete a widgetized message.\n"},"hints_text":{"kind":"string","value":"@zulipbot claim\nTopic editing should still be allowed as normal. These messages should behave like messages sent by someone else, where you’re allowed to View source / Edit topic.\nAh, good point on topic edits. So I think the only difference from the \"View Source\" experience should be that we change the messaging when you hover over the `?` icon next to \"Topic editing only\". \nHello @zulip/server-integrations, @zulip/server-message-view members, this issue was labeled with the \"area: integrations\", \"area: message-editing\" labels, so you may want to check it out!\n\n"},"created_at":{"kind":"timestamp","value":"2021-01-31T17:28:42","string":"2021-01-31T17:28:42"}}},{"rowIdx":645,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17275,"string":"17,275"},"instance_id":{"kind":"string","value":"zulip__zulip-17275"},"issue_numbers":{"kind":"list like","value":["17238"],"string":"[\n \"17238\"\n]"},"base_commit":{"kind":"string","value":"57f2b8760a38a59704aa0133a6ea6a14cbbd215d"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py\n--- a/zerver/lib/actions.py\n+++ b/zerver/lib/actions.py\n@@ -464,8 +464,6 @@ def process_new_human_user(\n \n mit_beta_user = realm.is_zephyr_mirror_realm\n if prereg_user is not None:\n- prereg_user.status = confirmation_settings.STATUS_ACTIVE\n- prereg_user.save(update_fields=[\"status\"])\n streams = prereg_user.streams.all()\n acting_user: Optional[UserProfile] = prereg_user.referred_by\n else:\n@@ -501,20 +499,10 @@ def process_new_human_user(\n user=f\"{user_profile.full_name} <`{user_profile.email}`>\"\n ),\n )\n- # Mark any other PreregistrationUsers that are STATUS_ACTIVE as\n- # inactive so we can keep track of the PreregistrationUser we\n- # actually used for analytics\n- if prereg_user is not None:\n- PreregistrationUser.objects.filter(email__iexact=user_profile.delivery_email).exclude(\n- id=prereg_user.id\n- ).update(status=confirmation_settings.STATUS_REVOKED)\n \n- if prereg_user.referred_by is not None:\n- notify_invites_changed(user_profile)\n- else:\n- PreregistrationUser.objects.filter(email__iexact=user_profile.delivery_email).update(\n- status=confirmation_settings.STATUS_REVOKED\n- )\n+ revoke_preregistration_users(user_profile, prereg_user, realm_creation)\n+ if not realm_creation and prereg_user is not None and prereg_user.referred_by is not None:\n+ notify_invites_changed(user_profile)\n \n notify_new_user(user_profile)\n # Clear any scheduled invitation emails to prevent them\n@@ -530,6 +518,39 @@ def process_new_human_user(\n send_initial_pms(user_profile)\n \n \n+def revoke_preregistration_users(\n+ created_user_profile: UserProfile,\n+ used_preregistration_user: Optional[PreregistrationUser],\n+ realm_creation: bool,\n+) -> None:\n+ if used_preregistration_user is None:\n+ assert not realm_creation, \"realm_creation should only happen with a PreregistrationUser\"\n+\n+ if used_preregistration_user is not None:\n+ used_preregistration_user.status = confirmation_settings.STATUS_ACTIVE\n+ used_preregistration_user.save(update_fields=[\"status\"])\n+\n+ # In the special case of realm creation, there can be no additional PreregistrationUser\n+ # for us to want to modify - because other realm_creation PreregistrationUsers should be\n+ # left usable for creating different realms.\n+ if realm_creation:\n+ return\n+\n+ # Mark any other PreregistrationUsers in the realm that are STATUS_ACTIVE as\n+ # inactive so we can keep track of the PreregistrationUser we\n+ # actually used for analytics.\n+ if used_preregistration_user is not None:\n+ PreregistrationUser.objects.filter(\n+ email__iexact=created_user_profile.delivery_email, realm=created_user_profile.realm\n+ ).exclude(id=used_preregistration_user.id).update(\n+ status=confirmation_settings.STATUS_REVOKED\n+ )\n+ else:\n+ PreregistrationUser.objects.filter(\n+ email__iexact=created_user_profile.delivery_email, realm=created_user_profile.realm\n+ ).update(status=confirmation_settings.STATUS_REVOKED)\n+\n+\n def notify_created_user(user_profile: UserProfile) -> None:\n user_row = user_profile_to_user_row(user_profile)\n person = format_user_row(\ndiff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.py\n--- a/zerver/worker/queue_processors.py\n+++ b/zerver/worker/queue_processors.py\n@@ -410,19 +410,12 @@ def consume(self, event: Dict[str, Any]) -> None:\n @assign_queue(\"invites\")\n class ConfirmationEmailWorker(QueueProcessingWorker):\n def consume(self, data: Mapping[str, Any]) -> None:\n- if \"email\" in data:\n- # When upgrading from a version up through 1.7.1, there may be\n- # existing items in the queue with `email` instead of `prereg_id`.\n- invitee = filter_to_valid_prereg_users(\n- PreregistrationUser.objects.filter(email__iexact=data[\"email\"].strip())\n- ).latest(\"invited_at\")\n- else:\n- invitee = filter_to_valid_prereg_users(\n- PreregistrationUser.objects.filter(id=data[\"prereg_id\"])\n- ).first()\n- if invitee is None:\n- # The invitation could have been revoked\n- return\n+ invitee = filter_to_valid_prereg_users(\n+ PreregistrationUser.objects.filter(id=data[\"prereg_id\"])\n+ ).first()\n+ if invitee is None:\n+ # The invitation could have been revoked\n+ return\n \n referrer = get_user_profile_by_id(data[\"referrer_id\"])\n logger.info(\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_queue_worker.py b/zerver/tests/test_queue_worker.py\n--- a/zerver/tests/test_queue_worker.py\n+++ b/zerver/tests/test_queue_worker.py\n@@ -445,8 +445,6 @@ def test_invites_worker(self) -> None:\n dict(prereg_id=prereg_alice.id, referrer_id=inviter.id, email_body=None),\n # Nonexistent prereg_id, as if the invitation was deleted\n dict(prereg_id=-1, referrer_id=inviter.id, email_body=None),\n- # Form with `email` is from versions up to Zulip 1.7.1\n- dict(email=self.nonreg_email(\"bob\"), referrer_id=inviter.id, email_body=None),\n ]\n for element in data:\n fake_client.enqueue(\"invites\", element)\n@@ -458,7 +456,7 @@ def test_invites_worker(self) -> None:\n \"zerver.worker.queue_processors.send_future_email\"\n ) as send_mock:\n worker.start()\n- self.assertEqual(send_mock.call_count, 2)\n+ self.assertEqual(send_mock.call_count, 1)\n \n def test_error_handling(self) -> None:\n processed = []\ndiff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py\n--- a/zerver/tests/test_signup.py\n+++ b/zerver/tests/test_signup.py\n@@ -1772,8 +1772,13 @@ def test_send_more_than_one_invite_to_same_user(self) -> None:\n do_invite_users(self.user_profile, [\"foo@zulip.com\"], streams, False)\n do_invite_users(self.user_profile, [\"foo@zulip.com\"], streams, False)\n \n+ # Also send an invite from a different realm.\n+ lear = get_realm(\"lear\")\n+ lear_user = self.lear_user(\"cordelia\")\n+ do_invite_users(lear_user, [\"foo@zulip.com\"], [], False)\n+\n invites = PreregistrationUser.objects.filter(email__iexact=\"foo@zulip.com\")\n- self.assertEqual(len(invites), 3)\n+ self.assertEqual(len(invites), 4)\n \n do_create_user(\n \"foo@zulip.com\",\n@@ -1794,9 +1799,13 @@ def test_send_more_than_one_invite_to_same_user(self) -> None:\n self.assertEqual(len(accepted_invite), 1)\n self.assertEqual(accepted_invite[0].id, prereg_user.id)\n \n- expected_revoked_invites = set(invites.exclude(id=prereg_user.id))\n+ expected_revoked_invites = set(invites.exclude(id=prereg_user.id).exclude(realm=lear))\n self.assertEqual(set(revoked_invites), expected_revoked_invites)\n \n+ self.assertEqual(\n+ PreregistrationUser.objects.get(email__iexact=\"foo@zulip.com\", realm=lear).status, 0\n+ )\n+\n def test_confirmation_obj_not_exist_error(self) -> None:\n \"\"\"Since the key is a param input by the user to the registration endpoint,\n if it inserts an invalid value, the confirmation object won't be found. This\n@@ -2745,6 +2754,83 @@ def test_create_realm_during_free_trial(self) -> None:\n self.assertEqual(realm.name, realm_name)\n self.assertEqual(realm.subdomain, string_id)\n \n+ @override_settings(OPEN_REALM_CREATION=True)\n+ def test_create_two_realms(self) -> None:\n+ \"\"\"\n+ Verify correct behavior and PreregistrationUser handling when using\n+ two pre-generated realm creation links to create two different realms.\n+ \"\"\"\n+ password = \"test\"\n+ first_string_id = \"zuliptest\"\n+ second_string_id = \"zuliptest2\"\n+ email = \"user1@test.com\"\n+ first_realm_name = \"Test\"\n+ second_realm_name = \"Test\"\n+\n+ # Make sure the realms do not exist\n+ with self.assertRaises(Realm.DoesNotExist):\n+ get_realm(first_string_id)\n+ with self.assertRaises(Realm.DoesNotExist):\n+ get_realm(second_string_id)\n+\n+ # Now we pre-generate two realm creation links\n+ result = self.client_post(\"/new/\", {\"email\": email})\n+ self.assertEqual(result.status_code, 302)\n+ self.assertTrue(result[\"Location\"].endswith(f\"/accounts/new/send_confirm/{email}\"))\n+ result = self.client_get(result[\"Location\"])\n+ self.assert_in_response(\"Check your email so we can get started.\", result)\n+ first_confirmation_url = self.get_confirmation_url_from_outbox(email)\n+ self.assertEqual(PreregistrationUser.objects.filter(email=email, status=0).count(), 1)\n+\n+ # Get a second realm creation link.\n+ result = self.client_post(\"/new/\", {\"email\": email})\n+ self.assertEqual(result.status_code, 302)\n+ self.assertTrue(result[\"Location\"].endswith(f\"/accounts/new/send_confirm/{email}\"))\n+ result = self.client_get(result[\"Location\"])\n+ self.assert_in_response(\"Check your email so we can get started.\", result)\n+ second_confirmation_url = self.get_confirmation_url_from_outbox(email)\n+\n+ self.assertNotEqual(first_confirmation_url, second_confirmation_url)\n+ self.assertEqual(PreregistrationUser.objects.filter(email=email, status=0).count(), 2)\n+\n+ # Create and verify the first realm\n+ result = self.client_get(first_confirmation_url)\n+ self.assertEqual(result.status_code, 200)\n+ result = self.submit_reg_form_for_user(\n+ email,\n+ password,\n+ realm_subdomain=first_string_id,\n+ realm_name=first_realm_name,\n+ key=first_confirmation_url.split(\"/\")[-1],\n+ )\n+ self.assertEqual(result.status_code, 302)\n+ # Make sure the realm is created\n+ realm = get_realm(first_string_id)\n+ self.assertEqual(realm.string_id, first_string_id)\n+ self.assertEqual(realm.name, first_realm_name)\n+\n+ # One of the PreregistrationUsers should have been used up:\n+ self.assertEqual(PreregistrationUser.objects.filter(email=email, status=0).count(), 1)\n+\n+ # Create and verify the second realm\n+ result = self.client_get(second_confirmation_url)\n+ self.assertEqual(result.status_code, 200)\n+ result = self.submit_reg_form_for_user(\n+ email,\n+ password,\n+ realm_subdomain=second_string_id,\n+ realm_name=second_realm_name,\n+ key=second_confirmation_url.split(\"/\")[-1],\n+ )\n+ self.assertEqual(result.status_code, 302)\n+ # Make sure the realm is created\n+ realm = get_realm(second_string_id)\n+ self.assertEqual(realm.string_id, second_string_id)\n+ self.assertEqual(realm.name, second_realm_name)\n+\n+ # The remaining PreregistrationUser should have been used up:\n+ self.assertEqual(PreregistrationUser.objects.filter(email=email, status=0).count(), 0)\n+\n @override_settings(OPEN_REALM_CREATION=True)\n def test_mailinator_signup(self) -> None:\n result = self.client_post(\"/new/\", {\"email\": \"hi@mailinator.com\"})\n"},"problem_statement":{"kind":"string","value":"wrongly cross-expired invites on zulipchat\nHere's the reproducable bug:\r\n\r\nStep 1: create 2 zulips on *.zulipchat.com:\r\nI created invitebug1.zulipchat.com and invitebug2.zulipchat.com for this demo.\r\n\r\nStep 2: invite the same email address on both.\r\n\r\nStep 3: Follow one link (I followed the most recent first), confirm and join the zulip invitebug1.\r\nThe link was: https://invitebug1.zulipchat.com/accounts/do_confirm/p3ppoywp6sh4fzoshgilmayl\r\n\r\nStep 4: Follow the other link, and you'll get:\r\n\r\n> The registration link has expired or is not valid.\r\n\r\nThe link was: https://invitebug2.zulipchat.com/accounts/do_confirm/jmxogh5ppnilhkzylubsbi22\r\n\r\nI included the links in case they help tracking down the problem.\r\n\n"},"hints_text":{"kind":"string","value":""},"created_at":{"kind":"timestamp","value":"2021-02-11T17:04:55","string":"2021-02-11T17:04:55"}}},{"rowIdx":646,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17409,"string":"17,409"},"instance_id":{"kind":"string","value":"zulip__zulip-17409"},"issue_numbers":{"kind":"list like","value":["16258"],"string":"[\n \"16258\"\n]"},"base_commit":{"kind":"string","value":"2f5eae5c68038b4d43fb3099bd64298906ba2578"},"patch":{"kind":"string","value":"diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.py\n--- a/zerver/webhooks/github/view.py\n+++ b/zerver/webhooks/github/view.py\n@@ -381,6 +381,37 @@ def get_status_body(helper: Helper) -> str:\n )\n \n \n+def get_locked_or_unlocked_pull_request_body(helper: Helper) -> str:\n+ payload = helper.payload\n+\n+ action = payload[\"action\"]\n+\n+ message = \"{sender} has locked [PR #{pr_number}]({pr_url}) as {reason} and limited conversation to collaborators.\"\n+ if action == \"unlocked\":\n+ message = \"{sender} has unlocked [PR #{pr_number}]({pr_url}).\"\n+ return message.format(\n+ sender=get_sender_name(payload),\n+ pr_number=payload[\"pull_request\"][\"number\"],\n+ pr_url=payload[\"pull_request\"][\"html_url\"],\n+ reason=payload[\"pull_request\"][\"active_lock_reason\"],\n+ )\n+\n+\n+def get_pull_request_auto_merge_body(helper: Helper) -> str:\n+ payload = helper.payload\n+\n+ action = payload[\"action\"]\n+\n+ message = \"{sender} has enabled auto merge for [PR #{pr_number}]({pr_url}).\"\n+ if action == \"auto_merge_disabled\":\n+ message = \"{sender} has disabled auto merge for [PR #{pr_number}]({pr_url}).\"\n+ return message.format(\n+ sender=get_sender_name(payload),\n+ pr_number=payload[\"pull_request\"][\"number\"],\n+ pr_url=payload[\"pull_request\"][\"html_url\"],\n+ )\n+\n+\n def get_pull_request_ready_for_review_body(helper: Helper) -> str:\n payload = helper.payload\n \n@@ -603,6 +634,8 @@ def get_subject_based_on_type(payload: Dict[str, Any], event: str) -> str:\n \"pull_request_review\": get_pull_request_review_body,\n \"pull_request_review_comment\": get_pull_request_review_comment_body,\n \"pull_request_review_requested\": get_pull_request_review_requested_body,\n+ \"pull_request_auto_merge\": get_pull_request_auto_merge_body,\n+ \"locked_or_unlocked_pull_request\": get_locked_or_unlocked_pull_request_body,\n \"push_commits\": get_push_commits_body,\n \"push_tags\": get_push_tags_body,\n \"release\": get_release_body,\n@@ -707,6 +740,10 @@ def get_zulip_event_name(\n return \"pull_request_review_requested\"\n if action == \"ready_for_review\":\n return \"pull_request_ready_for_review\"\n+ if action in (\"locked\", \"unlocked\"):\n+ return \"locked_or_unlocked_pull_request\"\n+ if action in (\"auto_merge_enabled\", \"auto_merge_disabled\"):\n+ return \"pull_request_auto_merge\"\n if action in IGNORED_PULL_REQUEST_ACTIONS:\n return None\n elif header_event == \"push\":\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.py\n--- a/zerver/webhooks/github/tests.py\n+++ b/zerver/webhooks/github/tests.py\n@@ -250,6 +250,24 @@ def test_pull_request_review_comment_with_custom_topic_in_url(self) -> None:\n expected_message = \"baxterthehacker created [PR Review Comment on #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692):\\n\\n~~~ quote\\nMaybe you should use more emojji on this line.\\n~~~\"\n self.check_webhook(\"pull_request_review_comment\", expected_topic, expected_message)\n \n+ def test_pull_request_locked(self) -> None:\n+ expected_message = \"tushar912 has locked [PR #1](https://github.com/tushar912/public-repo/pull/1) as off-topic and limited conversation to collaborators.\"\n+ self.check_webhook(\"pull_request__locked\", TOPIC_PR, expected_message)\n+\n+ def test_pull_request_unlocked(self) -> None:\n+ expected_message = (\n+ \"tushar912 has unlocked [PR #1](https://github.com/tushar912/public-repo/pull/1).\"\n+ )\n+ self.check_webhook(\"pull_request__unlocked\", TOPIC_PR, expected_message)\n+\n+ def test_pull_request_auto_merge_enabled(self) -> None:\n+ expected_message = \"tushar912 has enabled auto merge for [PR #1](https://github.com/tushar912/public-repo/pull/1).\"\n+ self.check_webhook(\"pull_request__auto_merge_enabled\", TOPIC_PR, expected_message)\n+\n+ def test_pull_request_auto_merge_disabled(self) -> None:\n+ expected_message = \"tushar912 has disabled auto merge for [PR #1](https://github.com/tushar912/public-repo/pull/1).\"\n+ self.check_webhook(\"pull_request__auto_merge_disabled\", TOPIC_PR, expected_message)\n+\n def test_push_tag_msg(self) -> None:\n expected_message = \"baxterthehacker pushed tag abc.\"\n self.check_webhook(\"push__tag\", TOPIC_REPO, expected_message)\n"},"problem_statement":{"kind":"string","value":"github webhook: Re-visit ignored events and actions\nPlease only try this issue if you have a little bit of knowledge of the github webhook, as it will require making some judgment calls and getting consensus on new features.\r\n\r\nWe have the following:\r\n\r\n~~~ py\r\n522 IGNORED_EVENTS = [\r\n523 \"check_suite\",\r\n524 \"label\",\r\n525 \"meta\",\r\n526 \"milestone\",\r\n527 \"organization\",\r\n528 \"project_card\",\r\n529 \"repository_vulnerability_alert\",\r\n530 ]\r\n531\r\n532 IGNORED_PULL_REQUEST_ACTIONS = [\r\n533 \"approved\",\r\n534 \"converted_to_draft\",\r\n535 \"labeled\",\r\n536 \"review_request_removed\",\r\n537 \"unlabeled\",\r\n538 ]\r\n~~~\r\n\r\n(The latter list hasn't been merged at the time of this writing.)\r\n\r\nSometimes when we ignore events (or actions) it's very deliberate, because the events/actions would be too spammy for users. Other times we might just have been lazy.\r\n\r\nIf you look at the actions for pull request, consider \"approved\" and \"converted_to_draft\" as examples. For the \"approved\" event, that seems like something that folks may want to see, so we might consider getting a good test fixture for it and supporting it in the code. Then the \"converted_to_draft\" action seems likely to be spammy, and we should probably just continue to ignore it.\r\n\r\n\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-integrations members, this issue was labeled with the \"area: integrations\" label, so you may want to check it out!\n\n\nAlso look for:\r\n\r\n~~~ py\r\n+IGNORED_TEAM_ACTIONS = [\r\n+ # These are actions that are well documented by github\r\n+ # (https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads)\r\n+ # but we ignore them for now, possibly just due to laziness.\r\n+ # One curious example here is team/added_to_repository, which is\r\n+ # possibly the same as team_add.\r\n+ \"added_to_repository\",\r\n+ \"created\",\r\n+ \"deleted\",\r\n+ \"removed_from_repository\",\r\n+]\r\n~~~\nI think with the GitHub webhook, it's reasonable to support essentially all actions, since GitHub supports filtering events on the integration configuration side.\nFor convenience, here are the docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads\n@showell There is a `submitted` action with state `approved` but I can't seem to find any docs related to `approved` pull request action.\n@shanukun I would try to help you, but I don't really know their docs too well. I assume the link I provided above is their most current reference, but it's worth poking around on GitHub to see if you can find out what's up here.\n@zulipbot claim"},"created_at":{"kind":"timestamp","value":"2021-02-25T13:36:37","string":"2021-02-25T13:36:37"}}},{"rowIdx":647,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17550,"string":"17,550"},"instance_id":{"kind":"string","value":"zulip__zulip-17550"},"issue_numbers":{"kind":"list like","value":["13395"],"string":"[\n \"13395\"\n]"},"base_commit":{"kind":"string","value":"3a6d44b691b13ca1ea1791a161253dcfc1a81a59"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py\n--- a/zerver/lib/integrations.py\n+++ b/zerver/lib/integrations.py\n@@ -444,6 +444,7 @@ def __init__(self, name: str, *args: Any, **kwargs: Any) -> None:\n ),\n WebhookIntegration(\"slack\", [\"communication\"]),\n WebhookIntegration(\"solano\", [\"continuous-integration\"], display_name=\"Solano Labs\"),\n+ WebhookIntegration(\"sonarqube\", [\"continuous-integration\"], display_name=\"SonarQube\"),\n WebhookIntegration(\"sonarr\", [\"entertainment\"], display_name=\"Sonarr\"),\n WebhookIntegration(\"splunk\", [\"monitoring\"], display_name=\"Splunk\"),\n WebhookIntegration(\"statuspage\", [\"customer-support\"], display_name=\"Statuspage\"),\n@@ -780,6 +781,7 @@ def __init__(self, name: str, *args: Any, **kwargs: Any) -> None:\n ],\n \"slack\": [ScreenshotConfig(\"message_info.txt\")],\n \"solano\": [ScreenshotConfig(\"build_001.json\")],\n+ \"sonarqube\": [ScreenshotConfig(\"error.json\")],\n \"sonarr\": [ScreenshotConfig(\"sonarr_episode_grabbed.json\")],\n \"splunk\": [ScreenshotConfig(\"search_one_result.json\")],\n \"statuspage\": [ScreenshotConfig(\"incident_created.json\")],\ndiff --git a/zerver/webhooks/sonarqube/__init__.py b/zerver/webhooks/sonarqube/__init__.py\nnew file mode 100644\ndiff --git a/zerver/webhooks/sonarqube/view.py b/zerver/webhooks/sonarqube/view.py\nnew file mode 100644\n--- /dev/null\n+++ b/zerver/webhooks/sonarqube/view.py\n@@ -0,0 +1,132 @@\n+# Webhooks for external integrations.\n+\n+from typing import Any, Dict, List, Mapping\n+\n+from django.http import HttpRequest, HttpResponse\n+\n+from zerver.decorator import webhook_view\n+from zerver.lib.request import REQ, has_request_variables\n+from zerver.lib.response import json_success\n+from zerver.lib.webhooks.common import check_send_webhook_message\n+from zerver.models import UserProfile\n+\n+TOPIC_WITH_BRANCH = \"{} / {}\"\n+\n+MESSAGE_WITH_BRANCH_AND_CONDITIONS = \"Project [{}]({}) analysis of branch {} resulted in {}:\\n\"\n+MESSAGE_WITH_BRANCH_AND_WITHOUT_CONDITIONS = (\n+ \"Project [{}]({}) analysis of branch {} resulted in {}.\"\n+)\n+MESSAGE_WITHOUT_BRANCH_AND_WITH_CONDITIONS = \"Project [{}]({}) analysis resulted in {}:\\n\"\n+MESSAGE_WITHOUT_BRANCH_AND_CONDITIONS = \"Project [{}]({}) analysis resulted in {}.\"\n+\n+INVERSE_OPERATORS = {\n+ \"WORSE_THAN\": \"should be better or equal to\",\n+ \"GREATER_THAN\": \"should be less than or equal to\",\n+ \"LESS_THAN\": \"should be greater than or equal to\",\n+}\n+\n+TEMPLATES = {\n+ \"default\": \"* {}: **{}** {} {} {}.\",\n+ \"no_value\": \"* {}: **{}**.\",\n+}\n+\n+\n+def parse_metric_name(metric_name: str) -> str:\n+ return \" \".join(metric_name.split(\"_\"))\n+\n+\n+def parse_condition(condition: Mapping[str, Any]) -> str:\n+ metric = condition[\"metric\"]\n+\n+ metric_name = parse_metric_name(metric)\n+ operator = condition[\"operator\"]\n+ operator = INVERSE_OPERATORS.get(operator, operator)\n+ value = condition.get(\"value\", \"no value\")\n+ status = condition[\"status\"].lower()\n+ threshold = condition[\"errorThreshold\"]\n+\n+ if value == \"no value\":\n+ return TEMPLATES[\"no_value\"].format(metric_name, status)\n+\n+ template = TEMPLATES[\"default\"]\n+\n+ return template.format(metric_name, status, value, operator, threshold)\n+\n+\n+def parse_conditions(conditions: List[Mapping[str, Any]]) -> str:\n+ return \"\\n\".join(\n+ [\n+ parse_condition(condition)\n+ for condition in conditions\n+ if condition[\"status\"].lower() != \"ok\" and condition[\"status\"].lower() != \"no_value\"\n+ ]\n+ )\n+\n+\n+def render_body_with_branch(payload: Mapping[str, Any]) -> str:\n+ project_name = payload[\"project\"][\"name\"]\n+ project_url = payload[\"project\"][\"url\"]\n+ quality_gate_status = payload[\"qualityGate\"][\"status\"].lower()\n+ if quality_gate_status == \"ok\":\n+ quality_gate_status = \"success\"\n+ else:\n+ quality_gate_status = \"error\"\n+ branch = payload[\"branch\"][\"name\"]\n+\n+ conditions = payload[\"qualityGate\"][\"conditions\"]\n+ conditions = parse_conditions(conditions)\n+\n+ if not conditions:\n+ return MESSAGE_WITH_BRANCH_AND_WITHOUT_CONDITIONS.format(\n+ project_name, project_url, branch, quality_gate_status\n+ )\n+ msg = MESSAGE_WITH_BRANCH_AND_CONDITIONS.format(\n+ project_name, project_url, branch, quality_gate_status\n+ )\n+ msg += conditions\n+\n+ return msg\n+\n+\n+def render_body_without_branch(payload: Mapping[str, Any]) -> str:\n+ project_name = payload[\"project\"][\"name\"]\n+ project_url = payload[\"project\"][\"url\"]\n+ quality_gate_status = payload[\"qualityGate\"][\"status\"].lower()\n+ if quality_gate_status == \"ok\":\n+ quality_gate_status = \"success\"\n+ else:\n+ quality_gate_status = \"error\"\n+ conditions = payload[\"qualityGate\"][\"conditions\"]\n+ conditions = parse_conditions(conditions)\n+\n+ if not conditions:\n+ return MESSAGE_WITHOUT_BRANCH_AND_CONDITIONS.format(\n+ project_name, project_url, quality_gate_status\n+ )\n+ msg = MESSAGE_WITHOUT_BRANCH_AND_WITH_CONDITIONS.format(\n+ project_name, project_url, quality_gate_status\n+ )\n+ msg += conditions\n+\n+ return msg\n+\n+\n+@webhook_view(\"Sonarqube\")\n+@has_request_variables\n+def api_sonarqube_webhook(\n+ request: HttpRequest,\n+ user_profile: UserProfile,\n+ payload: Dict[str, Any] = REQ(argument_type=\"body\"),\n+) -> HttpResponse:\n+ project = payload[\"project\"][\"name\"]\n+ branch = None\n+ if \"branch\" in payload.keys():\n+ branch = payload[\"branch\"].get(\"name\", None)\n+ if branch:\n+ topic = TOPIC_WITH_BRANCH.format(project, branch)\n+ message = render_body_with_branch(payload)\n+ else:\n+ topic = project\n+ message = render_body_without_branch(payload)\n+ check_send_webhook_message(request, user_profile, topic, message)\n+ return json_success()\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/webhooks/sonarqube/tests.py b/zerver/webhooks/sonarqube/tests.py\nnew file mode 100644\n--- /dev/null\n+++ b/zerver/webhooks/sonarqube/tests.py\n@@ -0,0 +1,84 @@\n+from zerver.lib.test_classes import WebhookTestCase\n+\n+\n+class SonarqubeHookTests(WebhookTestCase):\n+ STREAM_NAME = \"SonarQube\"\n+ URL_TEMPLATE = \"/api/v1/external/sonarqube?api_key={api_key}&stream={stream}\"\n+ FIXTURE_DIR_NAME = \"sonarqube\"\n+ WEBHOOK_DIR_NAME = \"sonarqube\"\n+\n+ def test_analysis_success(self) -> None:\n+ expected_topic = \"test-sonar / master\"\n+\n+ expected_message = \"\"\"\n+Project [test-sonar](http://localhost:9000/dashboard?id=test-sonar) analysis of branch master resulted in success.\n+ \"\"\".strip()\n+\n+ self.check_webhook(\n+ \"success\",\n+ expected_topic,\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_analysis_error(self) -> None:\n+ expected_topic = \"test-sonar / master\"\n+\n+ expected_message = \"\"\"\n+Project [test-sonar](http://localhost:9000/dashboard?id=test-sonar) analysis of branch master resulted in error:\n+* coverage: **error** 0.0 should be greater than or equal to 80.\n+* duplicated lines density: **error** 89.39828080229226 should be less than or equal to 3.\n+ \"\"\".strip()\n+\n+ self.check_webhook(\n+ \"error\",\n+ expected_topic,\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_analysis_error_no_value(self) -> None:\n+ expected_topic = \"test-sonar / master\"\n+\n+ expected_message = \"\"\"\n+Project [test-sonar](http://localhost:9000/dashboard?id=test-sonar) analysis of branch master resulted in error:\n+* coverage: **error** 0.0 should be greater than or equal to 80.\n+* duplicated lines density: **error**.\n+ \"\"\".strip()\n+\n+ self.check_webhook(\n+ \"error_no_value\",\n+ expected_topic,\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_analysis_success_no_branch(self) -> None:\n+ expected_topic = \"test-sonar\"\n+\n+ expected_message = \"\"\"\n+Project [test-sonar](http://localhost:9000/dashboard?id=test-sonar) analysis resulted in success.\n+ \"\"\".strip()\n+\n+ self.check_webhook(\n+ \"success_no_branch\",\n+ expected_topic,\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_analysis_error_no_branch(self) -> None:\n+ expected_topic = \"test-sonar\"\n+\n+ expected_message = \"\"\"\n+Project [test-sonar](http://localhost:9000/dashboard?id=test-sonar) analysis resulted in error:\n+* coverage: **error** 0.0 should be greater than or equal to 80.\n+* duplicated lines density: **error** 89.39828080229226 should be less than or equal to 3.\n+ \"\"\".strip()\n+\n+ self.check_webhook(\n+ \"error_no_branch\",\n+ expected_topic,\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n"},"problem_statement":{"kind":"string","value":"integrations: Add Sonar Qube.\nSuggest adding Sonar Qube integrations for real-time notifications of code coverage, `#` of bugs ant etc.. I can also work on this since I have made a PR adding grafana integrations.\r\n\r\nSonar Qube webhook\r\nhttps://docs.sonarqube.org/latest/project-administration/webhooks/\r\n\r\ninstructions for adding a new webhook integration\r\nhttps://zulipchat.com/api/incoming-webhooks-overview\n"},"hints_text":{"kind":"string","value":"Feel free to work on adding an integration for it, thanks @Zhenye-Na!\nHello @zulip/server-integrations members, this issue was labeled with the \"area: integrations\" label, so you may want to check it out!\n\n\nThank you for reaching out, @timabbott !\r\n\r\nDefinitely would love to make contributions to this project. Could the core developing team or reviewers review my last PR concerning grafana integrations?\r\n\r\nJust wanna make sure the last PR is on the right way so that I can follow the same procedure on this issue.\r\n\r\nThanks!\r\n\nYeah, can you post a link?\nof course, why not!\r\n\r\nhere is the link: https://github.com/zulip/zulip/pull/13384\nHi @Zhenye-Na are you working on this or planning to? If not can I take this issue? \nGo ahead, checkout my working branch and make the changes. Thanks!\r\n\r\n\r\nOn Dec 4, 2019, at 01:28, kostekIV wrote:\r\n\r\n\r\n\r\nHi @Zhenye-Na are you working on this or planning to? If not can I take this issue?\r\n\r\n—\r\nYou are receiving this because you were mentioned.\r\nReply to this email directly, view it on GitHub, or unsubscribe.\r\n\nThank you, @zulipbot claim \nHello @kostekIV, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 14 days.\n\nYou can reclaim this issue or claim any other issue by commenting `@zulipbot claim` on that issue.\n\nThanks for your contributions, and hope to see you again soon!\n@kostekIV do you wish to continue your PR or I can take it up."},"created_at":{"kind":"timestamp","value":"2021-03-10T16:24:42","string":"2021-03-10T16:24:42"}}},{"rowIdx":648,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17551,"string":"17,551"},"instance_id":{"kind":"string","value":"zulip__zulip-17551"},"issue_numbers":{"kind":"list like","value":["13086"],"string":"[\n \"13086\"\n]"},"base_commit":{"kind":"string","value":"9ce900f2b4ff687c567e637443374a54f348f5c7"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py\n--- a/zerver/lib/integrations.py\n+++ b/zerver/lib/integrations.py\n@@ -463,6 +463,7 @@ def __init__(self, name: str, *args: Any, **kwargs: Any) -> None:\n function=\"zerver.webhooks.yo.view.api_yo_app_webhook\",\n display_name=\"Yo\",\n ),\n+ WebhookIntegration(\"wekan\", [\"productivity\"], display_name=\"Wekan\"),\n WebhookIntegration(\"wordpress\", [\"marketing\"], display_name=\"WordPress\"),\n WebhookIntegration(\"zapier\", [\"meta-integration\"]),\n WebhookIntegration(\"zendesk\", [\"customer-support\"]),\n@@ -805,6 +806,7 @@ def __init__(self, name: str, *args: Any, **kwargs: Any) -> None:\n \"trello\": [ScreenshotConfig(\"adding_comment_to_card.json\")],\n \"updown\": [ScreenshotConfig(\"check_multiple_events.json\")],\n \"uptimerobot\": [ScreenshotConfig(\"uptimerobot_monitor_up.json\")],\n+ \"wekan\": [ScreenshotConfig(\"add_comment.json\")],\n \"wordpress\": [ScreenshotConfig(\"publish_post.txt\", \"wordpress_post_created.png\")],\n \"yo\": [\n ScreenshotConfig(\ndiff --git a/zerver/webhooks/wekan/__init__.py b/zerver/webhooks/wekan/__init__.py\nnew file mode 100644\ndiff --git a/zerver/webhooks/wekan/view.py b/zerver/webhooks/wekan/view.py\nnew file mode 100644\n--- /dev/null\n+++ b/zerver/webhooks/wekan/view.py\n@@ -0,0 +1,50 @@\n+from typing import Any, Dict\n+\n+from django.http import HttpRequest, HttpResponse\n+\n+from zerver.decorator import webhook_view\n+from zerver.lib.request import REQ, has_request_variables\n+from zerver.lib.response import json_success\n+from zerver.lib.webhooks.common import check_send_webhook_message\n+from zerver.models import UserProfile\n+\n+LINK_TEMPLATE = \"[See in Wekan]({url})\"\n+MESSAGE_TEMPLATE = \"{body}\\n\\n{footer}\"\n+\n+\n+def get_url(text: str) -> str:\n+ return text.split(\"\\n\")[-1]\n+\n+\n+def get_hyperlinked_url(text: str) -> str:\n+ url = get_url(text)\n+ return LINK_TEMPLATE.format(url=url)\n+\n+\n+def clean_payload_text(text: str) -> str:\n+ url = get_url(text)\n+ return text.replace(url, \"\").replace(\"\\n\", \"\")\n+\n+\n+def get_message_body(payload: Dict[str, Any], action: str) -> str:\n+ footer = get_hyperlinked_url(payload[\"text\"])\n+ body = process_message_data(payload, action)\n+ return MESSAGE_TEMPLATE.format(body=body, footer=footer)\n+\n+\n+def process_message_data(payload: Dict[str, Any], action: str) -> str:\n+ payload[\"text\"] = clean_payload_text(payload[\"text\"])\n+ return \"{text}.\".format(**payload)\n+\n+\n+@webhook_view(\"Wekan\")\n+@has_request_variables\n+def api_wekan_webhook(\n+ request: HttpRequest,\n+ user_profile: UserProfile,\n+ payload: Dict[str, Any] = REQ(argument_type=\"body\"),\n+) -> HttpResponse:\n+ topic = \"Wekan Notification\"\n+ body = get_message_body(payload, payload[\"description\"])\n+ check_send_webhook_message(request, user_profile, topic, body)\n+ return json_success(request)\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/webhooks/wekan/tests.py b/zerver/webhooks/wekan/tests.py\nnew file mode 100644\n--- /dev/null\n+++ b/zerver/webhooks/wekan/tests.py\n@@ -0,0 +1,217 @@\n+from zerver.lib.test_classes import WebhookTestCase\n+\n+\n+class WekanHookTests(WebhookTestCase):\n+ STREAM_NAME = \"wekan\"\n+ URL_TEMPLATE = \"/api/v1/external/wekan?stream={stream}&api_key={api_key}\"\n+ FIXTURE_DIR_NAME = \"wekan\"\n+\n+ def test_add_attachment_message(self) -> None:\n+ expected_message = 'JohnFish added attachment \"hGfm5ksud8k\" to card \"Markdown and emoji\\'s\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'\n+ self.check_webhook(\n+ \"add_attachment\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_add_checklist_item_message(self) -> None:\n+ expected_message = 'JohnFish added checklist item \"merge commit 9dfe\" to checklist \"To do\" at card \"Markdown and emoji\\'s\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'\n+ self.check_webhook(\n+ \"add_checklist_item\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_add_checklist_message(self) -> None:\n+ expected_message = 'JohnFish added checklist \"To do\" to card \"Markdown and emoji\\'s\" at list \"Design\" at swimlane \"Default\" at board \"bucked-list\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'\n+ self.check_webhook(\n+ \"add_checklist\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_add_label_message(self) -> None:\n+ expected_message = 'JohnFish Added label Language to card \"Markdown & emojis\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/TMmjFnQGuZPsbjXzS)'\n+ self.check_webhook(\n+ \"add_label\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_archived_swimlane_message(self) -> None:\n+ expected_message = 'JohnFish Swimlane \"Default\" at board \"Bucket List\" moved to Archive.\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list)'\n+ self.check_webhook(\n+ \"archived_swimlane\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_archived_card_message(self) -> None:\n+ expected_message = 'JohnFish Card \"Markdown and emoji\\'s\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\" moved to Archive.\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'\n+ self.check_webhook(\n+ \"archived_card\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_archived_list_message(self) -> None:\n+ expected_message = 'JohnFish List \"Design\" at swimlane \"Default\" at board \"Bucket List\" moved to Archive.\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list)'\n+ self.check_webhook(\n+ \"archived_list\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_checked_item_message(self) -> None:\n+ expected_message = 'JohnFish checked To do of checklist \"To do\" at card \"Markdown and emoji\\'s\" at list \"Design\" at swimlane \"Default\" at board \"bucket-list\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'\n+ self.check_webhook(\n+ \"checked_item\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_add_comment_message(self) -> None:\n+ expected_message = 'JohnFish commented on card \"Markdown and emoji\\'s\": \"This feature is important\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'\n+ self.check_webhook(\n+ \"add_comment\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_create_card_message(self) -> None:\n+ expected_message = 'JohnFish created card \"Markdown and emoji\\'s\" to list \"Development & Implementation\" at swimlane \"Default\" at board \"Bucket List\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'\n+ self.check_webhook(\n+ \"create_card\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_create_custom_field_message(self) -> None:\n+ expected_message = 'JohnFish created custom field Language at board \"Bucket List\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list)'\n+ self.check_webhook(\n+ \"create_custom_field\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_create_list_message(self) -> None:\n+ expected_message = 'JohnFish added list \"Testing & Maintenance\" to board \"Bucket List\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list)'\n+ self.check_webhook(\n+ \"create_list\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_create_swimlane_message(self) -> None:\n+ expected_message = 'JohnFish created swimlane \"Jasper\" to board \"Bucket List\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list)'\n+ self.check_webhook(\n+ \"create_swimlane\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_delete_attachment_message(self) -> None:\n+ expected_message = 'JohnFish deleted attachment \"hGfm5ksud8k.jpg\" at card \"Markdown and emoji\\'s\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'\n+ self.check_webhook(\n+ \"delete_attachment\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_join_member_message(self) -> None:\n+ expected_message = 'JohnFish added member kokoboss to card \"Markdown & emojis\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/TMmjFnQGuZPsbjXzS)'\n+ self.check_webhook(\n+ \"join_member\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_move_card_message(self) -> None:\n+ expected_message = 'JohnFish moved card \"Markdown and emoji\\'s\" at board \"Bucket List\" from list \"Development & Implementation\" at swimlane \"Default\" to list \"Design\" at swimlane \"Default\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'\n+ self.check_webhook(\n+ \"move_card\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_remove_list_message(self) -> None:\n+ expected_message = \"JohnFish act-removeList.\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list)\"\n+ self.check_webhook(\n+ \"remove_list\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_remove_swimlane_message(self) -> None:\n+ expected_message = \"JohnFish act-removeSwimlane.\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list)\"\n+ self.check_webhook(\n+ \"remove_swimlane\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_removed_checklist_item_message(self) -> None:\n+ expected_message = \"JohnFish act-removedChecklistItem.\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)\"\n+ self.check_webhook(\n+ \"removed_checklist_item\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_removed_checklist_message(self) -> None:\n+ expected_message = 'JohnFish removed checklist \"To do\" from card \"Markdown and emoji\\'s\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'\n+ self.check_webhook(\n+ \"removed_checklist\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_restored_card_message(self) -> None:\n+ expected_message = 'JohnFish restored card \"Markdown and emoji\\'s\" to list \"Design\" at swimlane \"Default\" at board \"Bucket List\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'\n+ self.check_webhook(\n+ \"restored_card\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_set_custom_field_message(self) -> None:\n+ expected_message = \"JohnFish act-setCustomField.\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)\"\n+ self.check_webhook(\n+ \"set_custom_field\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def test_uncomplete_checklist_message(self) -> None:\n+ expected_message = 'JohnFish uncompleted checklist To do at card \"Markdown and emoji\\'s\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\".\\n\\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'\n+ self.check_webhook(\n+ \"uncomplete_checklist\",\n+ \"Wekan Notification\",\n+ expected_message,\n+ content_type=\"application/x-www-form-urlencoded\",\n+ )\n+\n+ def get_body(self, fixture_name: str) -> str:\n+ return self.webhook_fixture_data(\"wekan\", fixture_name, file_type=\"json\")\n"},"problem_statement":{"kind":"string","value":"Integration of open source project management tool Wekan\nWe are using Wekan as open source alternative for trello at work and I'm looking for a way to integrate notifications into zulip - just like the trello integration. \r\n\r\n- Has anyone experiences in doing so and can help?\r\n\r\nIf this is not the right place for this question please tell me where to ask.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-integrations members, this issue was labeled with the \"area: integrations\" label, so you may want to check it out!\n\n\n@kratsching I'm not aware of an existing integration. It looks like Wekan does support webhooks: \r\nhttps://github.com/wekan/wekan/wiki/Webhook-data\r\n\r\nSo I expect it should be possible to write a Zulip integration following this guide: https://zulipchat.com/api/incoming-webhooks-overview\r\n\r\nIf you can do the fixture collection part, possibly someone from the community would be up for doing the formatting pieces.\n@timabbott thank you for your answer - I will check that out in october. If I find a solution I will come back here.\r\n"},"created_at":{"kind":"timestamp","value":"2021-03-10T16:28:31","string":"2021-03-10T16:28:31"}}},{"rowIdx":649,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17553,"string":"17,553"},"instance_id":{"kind":"string","value":"zulip__zulip-17553"},"issue_numbers":{"kind":"list like","value":["17535"],"string":"[\n \"17535\"\n]"},"base_commit":{"kind":"string","value":"23088b5d78099b989104c366be84bfca2a3ee3b4"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.py\n--- a/zerver/lib/markdown/__init__.py\n+++ b/zerver/lib/markdown/__init__.py\n@@ -147,7 +147,15 @@ def normal_compile(pattern: str) -> Pattern[str]:\n \n @one_time\n def get_compiled_stream_link_regex() -> Pattern[str]:\n- return verbose_compile(STREAM_LINK_REGEX)\n+ # Not using verbose_compile as it adds ^(.*?) and\n+ # (.*?)$ which cause extra overhead of matching\n+ # pattern which is not required.\n+ # With new InlineProcessor these extra patterns\n+ # are not required.\n+ return re.compile(\n+ STREAM_LINK_REGEX,\n+ re.DOTALL | re.UNICODE | re.VERBOSE,\n+ )\n \n \n STREAM_TOPIC_LINK_REGEX = r\"\"\"\n@@ -162,7 +170,15 @@ def get_compiled_stream_link_regex() -> Pattern[str]:\n \n @one_time\n def get_compiled_stream_topic_link_regex() -> Pattern[str]:\n- return verbose_compile(STREAM_TOPIC_LINK_REGEX)\n+ # Not using verbose_compile as it adds ^(.*?) and\n+ # (.*?)$ which cause extra overhead of matching\n+ # pattern which is not required.\n+ # With new InlineProcessor these extra patterns\n+ # are not required.\n+ return re.compile(\n+ STREAM_TOPIC_LINK_REGEX,\n+ re.DOTALL | re.UNICODE | re.VERBOSE,\n+ )\n \n \n LINK_REGEX: Optional[Pattern[str]] = None\n@@ -1796,8 +1812,10 @@ def handleMatch(self, m: Match[str]) -> Union[Element, str]:\n )\n \n \n-class UserMentionPattern(markdown.inlinepatterns.Pattern):\n- def handleMatch(self, m: Match[str]) -> Optional[Element]:\n+class UserMentionPattern(markdown.inlinepatterns.InlineProcessor):\n+ def handleMatch( # type: ignore[override] # supertype incompatible with supersupertype\n+ self, m: Match[str], data: str\n+ ) -> Union[Tuple[None, None, None], Tuple[Element, int, int]]:\n match = m.group(\"match\")\n silent = m.group(\"silent\") == \"_\"\n \n@@ -1806,7 +1824,7 @@ def handleMatch(self, m: Match[str]) -> Optional[Element]:\n if match.startswith(\"**\") and match.endswith(\"**\"):\n name = match[2:-2]\n else:\n- return None\n+ return None, None, None\n \n wildcard = mention.user_mention_matches_wildcard(name)\n \n@@ -1827,7 +1845,7 @@ def handleMatch(self, m: Match[str]) -> Optional[Element]:\n user_id = str(user[\"id\"])\n else:\n # Don't highlight @mentions that don't refer to a valid user\n- return None\n+ return None, None, None\n \n el = Element(\"span\")\n el.set(\"data-user-id\", user_id)\n@@ -1838,15 +1856,17 @@ def handleMatch(self, m: Match[str]) -> Optional[Element]:\n el.set(\"class\", \"user-mention\")\n text = f\"@{text}\"\n el.text = markdown.util.AtomicString(text)\n- return el\n- return None\n-\n+ return el, m.start(), m.end()\n+ return None, None, None\n \n-class UserGroupMentionPattern(markdown.inlinepatterns.Pattern):\n- def handleMatch(self, m: Match[str]) -> Optional[Element]:\n- match = m.group(2)\n \n+class UserGroupMentionPattern(markdown.inlinepatterns.InlineProcessor):\n+ def handleMatch( # type: ignore[override] # supertype incompatible with supersupertype\n+ self, m: Match[str], data: str\n+ ) -> Union[Tuple[None, None, None], Tuple[Element, int, int]]:\n+ match = m.group(1)\n db_data = self.md.zulip_db_data\n+\n if self.md.zulip_message and db_data is not None:\n name = extract_user_group(match)\n user_group = db_data[\"mention_data\"].get_user_group(name)\n@@ -1857,18 +1877,25 @@ def handleMatch(self, m: Match[str]) -> Optional[Element]:\n else:\n # Don't highlight @-mentions that don't refer to a valid user\n # group.\n- return None\n+ return None, None, None\n \n el = Element(\"span\")\n el.set(\"class\", \"user-group-mention\")\n el.set(\"data-user-group-id\", user_group_id)\n text = f\"@{name}\"\n el.text = markdown.util.AtomicString(text)\n- return el\n- return None\n+ return el, m.start(), m.end()\n+ return None, None, None\n \n \n-class StreamPattern(CompiledPattern):\n+class StreamPattern(markdown.inlinepatterns.InlineProcessor):\n+ def __init__(self, compiled_re: Pattern[str], md: markdown.Markdown) -> None:\n+ # This is similar to the superclass's small __init__ function,\n+ # but we skip the compilation step and let the caller give us\n+ # a compiled regex.\n+ self.compiled_re = compiled_re\n+ self.md = md\n+\n def find_stream_by_name(self, name: str) -> Optional[Dict[str, Any]]:\n db_data = self.md.zulip_db_data\n if db_data is None:\n@@ -1876,13 +1903,15 @@ def find_stream_by_name(self, name: str) -> Optional[Dict[str, Any]]:\n stream = db_data[\"stream_names\"].get(name)\n return stream\n \n- def handleMatch(self, m: Match[str]) -> Optional[Element]:\n+ def handleMatch( # type: ignore[override] # supertype incompatible with supersupertype\n+ self, m: Match[str], data: str\n+ ) -> Union[Tuple[None, None, None], Tuple[Element, int, int]]:\n name = m.group(\"stream_name\")\n \n if self.md.zulip_message:\n stream = self.find_stream_by_name(name)\n if stream is None:\n- return None\n+ return None, None, None\n el = Element(\"a\")\n el.set(\"class\", \"stream\")\n el.set(\"data-stream-id\", str(stream[\"id\"]))\n@@ -1895,11 +1924,18 @@ def handleMatch(self, m: Match[str]) -> Optional[Element]:\n el.set(\"href\", f\"/#narrow/stream/{stream_url}\")\n text = f\"#{name}\"\n el.text = markdown.util.AtomicString(text)\n- return el\n- return None\n+ return el, m.start(), m.end()\n+ return None, None, None\n \n \n-class StreamTopicPattern(CompiledPattern):\n+class StreamTopicPattern(markdown.inlinepatterns.InlineProcessor):\n+ def __init__(self, compiled_re: Pattern[str], md: markdown.Markdown) -> None:\n+ # This is similar to the superclass's small __init__ function,\n+ # but we skip the compilation step and let the caller give us\n+ # a compiled regex.\n+ self.compiled_re = compiled_re\n+ self.md = md\n+\n def find_stream_by_name(self, name: str) -> Optional[Dict[str, Any]]:\n db_data = self.md.zulip_db_data\n if db_data is None:\n@@ -1907,14 +1943,16 @@ def find_stream_by_name(self, name: str) -> Optional[Dict[str, Any]]:\n stream = db_data[\"stream_names\"].get(name)\n return stream\n \n- def handleMatch(self, m: Match[str]) -> Optional[Element]:\n+ def handleMatch( # type: ignore[override] # supertype incompatible with supersupertype\n+ self, m: Match[str], data: str\n+ ) -> Union[Tuple[None, None, None], Tuple[Element, int, int]]:\n stream_name = m.group(\"stream_name\")\n topic_name = m.group(\"topic_name\")\n \n if self.md.zulip_message:\n stream = self.find_stream_by_name(stream_name)\n if stream is None or topic_name is None:\n- return None\n+ return None, None, None\n el = Element(\"a\")\n el.set(\"class\", \"stream-topic\")\n el.set(\"data-stream-id\", str(stream[\"id\"]))\n@@ -1924,8 +1962,8 @@ def handleMatch(self, m: Match[str]) -> Optional[Element]:\n el.set(\"href\", link)\n text = f\"#{stream_name} > {topic_name}\"\n el.text = markdown.util.AtomicString(text)\n- return el\n- return None\n+ return el, m.start(), m.end()\n+ return None, None, None\n \n \n def possible_linked_stream_names(content: str) -> Set[str]:\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_markdown.py b/zerver/tests/test_markdown.py\n--- a/zerver/tests/test_markdown.py\n+++ b/zerver/tests/test_markdown.py\n@@ -1845,6 +1845,36 @@ def test_mention_silent(self) -> None:\n )\n self.assertEqual(msg.mentions_user_ids, set())\n \n+ def test_mention_invalid_followed_by_valid(self) -> None:\n+ sender_user_profile = self.example_user(\"othello\")\n+ user_profile = self.example_user(\"hamlet\")\n+ msg = Message(sender=sender_user_profile, sending_client=get_client(\"test\"))\n+ user_id = user_profile.id\n+\n+ content = \"@**Invalid user** and @**King Hamlet**\"\n+ self.assertEqual(\n+ render_markdown(msg, content),\n+ '

@Invalid user and '\n+ \"@King Hamlet

\",\n+ )\n+ self.assertEqual(msg.mentions_user_ids, {user_profile.id})\n+\n+ def test_silent_mention_invalid_followed_by_valid(self) -> None:\n+ sender_user_profile = self.example_user(\"othello\")\n+ user_profile = self.example_user(\"hamlet\")\n+ msg = Message(sender=sender_user_profile, sending_client=get_client(\"test\"))\n+ user_id = user_profile.id\n+\n+ content = \"@_**Invalid user** and @_**King Hamlet**\"\n+ self.assertEqual(\n+ render_markdown(msg, content),\n+ '

@_Invalid user and '\n+ \"King Hamlet

\",\n+ )\n+ self.assertEqual(msg.mentions_user_ids, set())\n+\n def test_possible_mentions(self) -> None:\n def assert_mentions(content: str, names: Set[str], has_wildcards: bool = False) -> None:\n self.assertEqual(possible_mentions(content), (names, has_wildcards))\n@@ -2026,6 +2056,27 @@ def test_user_group_mention_single(self) -> None:\n self.assertEqual(msg.mentions_user_ids, {user_profile.id})\n self.assertEqual(msg.mentions_user_group_ids, {user_group.id})\n \n+ def test_invalid_user_group_followed_by_valid_mention_single(self) -> None:\n+ sender_user_profile = self.example_user(\"othello\")\n+ user_profile = self.example_user(\"hamlet\")\n+ msg = Message(sender=sender_user_profile, sending_client=get_client(\"test\"))\n+ user_id = user_profile.id\n+ user_group = self.create_user_group_for_test(\"support\")\n+\n+ content = \"@**King Hamlet** @*Invalid user group* @*support*\"\n+ self.assertEqual(\n+ render_markdown(msg, content),\n+ '

'\n+ \"@King Hamlet \"\n+ \"@Invalid user group \"\n+ ''\n+ \"@support

\",\n+ )\n+ self.assertEqual(msg.mentions_user_ids, {user_profile.id})\n+ self.assertEqual(msg.mentions_user_group_ids, {user_group.id})\n+\n def test_user_group_mention_atomic_string(self) -> None:\n sender_user_profile = self.example_user(\"othello\")\n realm = get_realm(\"zulip\")\n@@ -2155,6 +2206,18 @@ def test_stream_single(self) -> None:\n ),\n )\n \n+ def test_invalid_stream_followed_by_valid_mention(self) -> None:\n+ denmark = get_stream(\"Denmark\", get_realm(\"zulip\"))\n+ sender_user_profile = self.example_user(\"othello\")\n+ msg = Message(sender=sender_user_profile, sending_client=get_client(\"test\"))\n+ content = \"#**Invalid** and #**Denmark**\"\n+ self.assertEqual(\n+ render_markdown(msg, content),\n+ '

#Invalid and #{d.name}

'.format(\n+ d=denmark,\n+ ),\n+ )\n+\n def test_stream_multiple(self) -> None:\n sender_user_profile = self.example_user(\"othello\")\n msg = Message(sender=sender_user_profile, sending_client=get_client(\"test\"))\n"},"problem_statement":{"kind":"string","value":"inline meniton for users, groups and streams fail if they come after an invalid mention\nThis bug was reported here:\r\n[https://chat.zulip.org/#narrow/stream/9-issues/topic/markdown.20mention.20bug](https://chat.zulip.org/#narrow/stream/9-issues/topic/markdown.20mention.20bug)\r\n\r\nIf there is an invalid user name written inside mention syntax then all the subsequent valid mentions are also treated as invalid. This is true for user groups, and streams mentions too.\r\n\r\n**An example**\r\nfor source:\r\n```\r\n@**invalid** @**iago** @*invalid user group* @*hamletcharacters* #**invalid streams>little URLS isn't loading quickly** #**sales>little URLS isn't loading quickly**\r\n```\r\noutput:\r\n![image](https://user-images.githubusercontent.com/63504956/110537832-39f6bf80-8149-11eb-87a3-5e4d3a4c7f45.png)\r\n\n"},"hints_text":{"kind":"string","value":"@zulipbot claim"},"created_at":{"kind":"timestamp","value":"2021-03-10T20:10:22","string":"2021-03-10T20:10:22"}}},{"rowIdx":650,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17560,"string":"17,560"},"instance_id":{"kind":"string","value":"zulip__zulip-17560"},"issue_numbers":{"kind":"list like","value":["15375"],"string":"[\n \"15375\"\n]"},"base_commit":{"kind":"string","value":"55de66f944533085993618a190123cebd3c2200d"},"patch":{"kind":"string","value":"diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py\n--- a/tools/linter_lib/custom_check.py\n+++ b/tools/linter_lib/custom_check.py\n@@ -630,12 +630,6 @@\n },\n {\n \"pattern\": r'title=\"[^{\\:]',\n- \"exclude_line\": {\n- (\n- \"templates/zerver/app/markdown_help.html\",\n- '\":heart:\"',\n- ),\n- },\n \"exclude\": {\n \"templates/zerver/emails\",\n \"templates/analytics/realm_details.html\",\n@@ -649,7 +643,6 @@\n \"exclude\": {\n \"static/templates/settings/display_settings.hbs\",\n \"templates/zerver/app/keyboard_shortcuts.html\",\n- \"templates/zerver/app/markdown_help.html\",\n },\n \"good_lines\": ['\"{{', ''],\n \"bad_lines\": ['\"Foo'],\n@@ -679,8 +672,6 @@\n + \"'\"\n + \"](display: ?none|background: {{|color: {{|background-color: {{).*\",\n \"exclude\": {\n- # KaTeX output uses style attribute\n- \"templates/zerver/app/markdown_help.html\",\n # 5xx page doesn't have external CSS\n \"static/html/5xx.html\",\n # exclude_pattern above handles color, but have other issues:\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Move markdown help to a frontend template without hardcoded rendered markdown\nOur markdown help file `templates/zerver/app/markdown_help.html`, has a bunch of copied HTML in it, which isn't a robust/maintainable strategy. We have a frontend markdown processor, we should be able to just have a much simpler file HTML containing the raw markdown, and then JavaScript that does extracts the code from each `preserve_spaces` element and installs the rendered markdown based on that in the right column.\r\n\r\nTagging as a priority since this seems like a pretty high-value code cleanup.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-markdown, @zulip/server-refactoring members, this issue was labeled with the \"area: markdown\", \"area: refactoring\" labels, so you may want to check it out!\n\n\n@zulipbot claim\nHello @Krishna-Sivakumar, it looks like you've currently claimed 1 issue in this repository. We encourage new contributors to focus their efforts on at most 1 issue at a time, so please complete your work on your other claimed issues before trying to claim this issue again.\n\nWe look forward to your valuable contributions!\n@zulipbot claim\nWelcome to Zulip, @lokesh576! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!\n\nHere's some tips to get you off to a good start:\n* Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.\n* [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.\n\nAs you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.\n\nSee you on the other side (that is, the pull request side)!\nhello! I am contributing for the first time to open source. Can someone please tell me where I can start on this project and what all it is about?\n@khushboogupta13 You can go through [Contributing guidelines](https://github.com/zulip/zulip/blob/master/CONTRIBUTING.md) and to get help or chat with zulip community check out [zulip community](https://chat.zulip.org).\n@timabbott where would I find the markdown processor? From what I understand, you want to use the markdown processor to render the raw HTML, instead of specifying it manually.\n`static/js/markdown.js`; see also https://zulip.readthedocs.io/en/latest/subsystems/markdown.html. We can use the frontend processor for this.\nHello @shubham00jain, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 14 days.\n\nYou can reclaim this issue or claim any other issue by commenting `@zulipbot claim` on that issue.\n\nThanks for your contributions, and hope to see you again soon!\n@zulipbot claim\nWelcome to Zulip, @AT1452! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!\n\nHere's some tips to get you off to a good start:\n* Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.\n* [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.\n\nAs you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.\n\nSee you on the other side (that is, the pull request side)!\n@zulipbot abandon\n@timabbott I would like to work on this issue, if it's not taken. Please show me where to begin. Thanks!\n@timabbott Is this issue already fixed? Would like to collaborate.\nThis has not been fixed, and the issue description as well as my other comments here should explain what you need to know. \n@zulipbot claim\n@zulipbot claim\nWelcome to Zulip, @kuroriplus! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!\n\nHere's some tips to get you off to a good start:\n* Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.\n* [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.\n\nAs you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.\n\nSee you on the other side (that is, the pull request side)!\nI am working on this one."},"created_at":{"kind":"timestamp","value":"2021-03-11T02:47:32","string":"2021-03-11T02:47:32"}}},{"rowIdx":651,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17677,"string":"17,677"},"instance_id":{"kind":"string","value":"zulip__zulip-17677"},"issue_numbers":{"kind":"list like","value":["8005"],"string":"[\n \"8005\"\n]"},"base_commit":{"kind":"string","value":"daabc52a786d969e036651b934f4282a7f186b5d"},"patch":{"kind":"string","value":"diff --git a/zerver/context_processors.py b/zerver/context_processors.py\n--- a/zerver/context_processors.py\n+++ b/zerver/context_processors.py\n@@ -49,6 +49,13 @@ def common_context(user: UserProfile) -> Dict[str, Any]:\n }\n \n \n+def get_zulip_version_name(zulip_version: str) -> str:\n+ if zulip_version.endswith(\"+git\"):\n+ return \"Zulip \" + zulip_version[:-4]\n+\n+ return \"Zulip \" + zulip_version\n+\n+\n def get_realm_from_request(request: HttpRequest) -> Optional[Realm]:\n if hasattr(request, \"user\") and hasattr(request.user, \"realm\"):\n return request.user.realm\n@@ -135,6 +142,8 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:\n \"request_language\": get_language(),\n }\n \n+ ZULIP_VERSION_NAME = get_zulip_version_name(ZULIP_VERSION)\n+\n context = {\n \"root_domain_landing_page\": settings.ROOT_DOMAIN_LANDING_PAGE,\n \"custom_logo_url\": settings.CUSTOM_LOGO_URL,\n@@ -160,6 +169,7 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:\n \"password_min_length\": settings.PASSWORD_MIN_LENGTH,\n \"password_min_guesses\": settings.PASSWORD_MIN_GUESSES,\n \"zulip_version\": ZULIP_VERSION,\n+ \"zulip_version_name\": ZULIP_VERSION_NAME,\n \"user_is_authenticated\": user_is_authenticated,\n \"settings_path\": settings_path,\n \"secrets_path\": secrets_path,\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_context_processors.py b/zerver/tests/test_context_processors.py\nnew file mode 100644\n--- /dev/null\n+++ b/zerver/tests/test_context_processors.py\n@@ -0,0 +1,8 @@\n+from zerver.context_processors import get_zulip_version_name\n+from zerver.lib.test_classes import ZulipTestCase\n+\n+\n+class TestContextProcessors(ZulipTestCase):\n+ def test_get_zulip_version_name(self) -> None:\n+ self.assertEqual(get_zulip_version_name(\"4.0-dev+git\"), \"Zulip 4.0-dev\")\n+ self.assertEqual(get_zulip_version_name(\"4.0\"), \"Zulip 4.0\")\n"},"problem_statement":{"kind":"string","value":"No way to discover Zulip version number from within UI.\nAs I was adding a comment to issue #6977 just now, I wanted to include the version number of the Zulip instance we're running. But I couldn't find that information anywhere in the UI. Traditionally, the version number is either in the page footer or in an \"About\" page somewhere. But it's not in the footers and I couldn't find an About page, nor any other page that has the instance's version number. I poked around in the documentation pages and settings pages, but couldn't find it anywhere in there either.\r\n\r\nI ended up shelling into the server and looking at the `deployments/2017-10-12-17-22-56/version` file.\r\n\r\n \n"},"hints_text":{"kind":"string","value":"@kfogel you can check the version number using the api endpoint - `yourserver/api/v1/server_settings`\r\nExample - https://chat.zulip.org/api/v1/server_settings\n@zulipbot claim\nIt's at https://chat.zulip.org/history/, which is parked there until we turn it into a proper /about page and link to it from the footer. @skunkmb, I suspect the solution here is just to finish that project, since that's where people will expect it. \nHello @skunkmb, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 14 days.\n\nYou can reclaim this issue or claim any other issue by commenting `@zulipbot claim` on that issue.\n\nThanks for your contributions, and hope to see you again soon!\nWe [discussed this just now](https://chat.zulip.org/#narrow/stream/general/subject/zulipchat.2Ecom/near/494918) in Zulip developer chat.\r\n\r\n> places like https://chat.zulip.org/history/ and https://chat.zulip.org/api/v1/server_settings say \"1.7.1+git\" which is not as precise as I'd like.\r\n\r\n@timabbott said, specifically about exposing the current commit ID for zulipchat.com organizations,\r\n\r\n> It's somewhat useless to do a commit ID (because there's usually a few operational-related or debugging or revert or whatever commits on zulipchat.com that aren't in the main repo), but we could do a count of commits pretty easily. Probably the ideal thing would be to have the merge-base of `upstream/master` with the current commit, but that gets a bit annoying to construct (but still probably doable).\n@zulipbot claim\nHello @rightauth!\n\nThanks for your interest in Zulip! You have attempted to claim an issue without the labels \"help wanted\", \"good first issue\". Since you're a new contributor, you can only claim and submit pull requests for issues with the [help wanted](https://github.com/zulip/zulip/issues?q=is%3Aopen+is%3Aissue+no%3Aassignee+label%3A%22help+wanted%22) or [good first issue](https://github.com/zulip/zulip/issues?q=is%3Aopen+is%3Aissue+no%3Aassignee+label%3A%22good+first+issue%22) labels.\n\nIf this is your first time here, we recommend reading our [guide for new contributors](https://zulip.readthedocs.io/en/latest/overview/contributing.html) before getting started.\n@zulipbot claim"},"created_at":{"kind":"timestamp","value":"2021-03-17T23:43:14","string":"2021-03-17T23:43:14"}}},{"rowIdx":652,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17703,"string":"17,703"},"instance_id":{"kind":"string","value":"zulip__zulip-17703"},"issue_numbers":{"kind":"list like","value":["17607"],"string":"[\n \"17607\"\n]"},"base_commit":{"kind":"string","value":"f18d7fa7ed7bd97a368f00f05ddb89c1eecbbb32"},"patch":{"kind":"string","value":"diff --git a/zerver/models.py b/zerver/models.py\n--- a/zerver/models.py\n+++ b/zerver/models.py\n@@ -1821,6 +1821,11 @@ def __str__(self) -> str:\n get_client_cache: Dict[str, Client] = {}\n \n \n+def clear_client_cache() -> None: # nocoverage\n+ global get_client_cache\n+ get_client_cache = {}\n+\n+\n def get_client(name: str) -> Client:\n # Accessing KEY_PREFIX through the module is necessary\n # because we need the updated value of the variable.\ndiff --git a/zerver/views/development/cache.py b/zerver/views/development/cache.py\nnew file mode 100644\n--- /dev/null\n+++ b/zerver/views/development/cache.py\n@@ -0,0 +1,21 @@\n+import os\n+\n+from django.http import HttpRequest, HttpResponse\n+from django.views.decorators.csrf import csrf_exempt\n+\n+from zerver.decorator import require_post\n+from zerver.lib.cache import get_cache_backend\n+from zerver.lib.response import json_success\n+from zerver.models import clear_client_cache, flush_per_request_caches\n+\n+ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), \"../../../\")\n+\n+# This is used only by the Puppeteer Tests to clear all the cache after each run.\n+@csrf_exempt\n+@require_post\n+def remove_caches(request: HttpRequest) -> HttpResponse:\n+ cache = get_cache_backend(None)\n+ cache.clear()\n+ clear_client_cache()\n+ flush_per_request_caches()\n+ return json_success()\ndiff --git a/zproject/dev_urls.py b/zproject/dev_urls.py\n--- a/zproject/dev_urls.py\n+++ b/zproject/dev_urls.py\n@@ -10,6 +10,7 @@\n from django.views.static import serve\n \n from zerver.views.auth import config_error, login_page\n+from zerver.views.development.cache import remove_caches\n from zerver.views.development.email_log import clear_emails, email_page, generate_all_emails\n from zerver.views.development.integrations import (\n check_send_webhook_fixture_message,\n@@ -73,6 +74,8 @@\n path(\"devtools/integrations//fixtures\", get_fixtures),\n path(\"config-error/\", config_error, name=\"config_error\"),\n path(\"config-error/remoteuser/\", config_error),\n+ # Special endpoint to remove all the server-side caches.\n+ path(\"flush_caches\", remove_caches),\n ]\n \n # Serve static assets via the Django server\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/lib/test_fixtures.py b/zerver/lib/test_fixtures.py\n--- a/zerver/lib/test_fixtures.py\n+++ b/zerver/lib/test_fixtures.py\n@@ -386,3 +386,49 @@ def remove_test_run_directories(expiry_time: int = 60 * 60) -> int:\n except FileNotFoundError:\n pass\n return removed\n+\n+\n+def reset_zulip_test_database() -> None:\n+ \"\"\"\n+ This function is used to reset the zulip_test database fastest way possible,\n+ i.e. First, it deletes the database and then clones it from zulip_test_template.\n+ This function is used with puppeteer tests, so it can quickly reset the test\n+ database after each run.\n+ \"\"\"\n+ from zerver.lib.test_runner import destroy_test_databases\n+\n+ # Make sure default database is 'zulip_test'.\n+ assert connections[\"default\"].settings_dict[\"NAME\"] == \"zulip_test\"\n+\n+ # Clearing all the active PSQL sessions with 'zulip_test'.\n+ run(\n+ [\n+ \"env\",\n+ \"PGHOST=localhost\",\n+ \"PGUSER=zulip_test\",\n+ \"scripts/setup/terminate-psql-sessions\",\n+ \"zulip_test\",\n+ ]\n+ )\n+\n+ destroy_test_databases()\n+ # Pointing default database to test database template, so we can instantly clone it.\n+ settings.DATABASES[\"default\"][\"NAME\"] = settings.BACKEND_DATABASE_TEMPLATE\n+ connection = connections[\"default\"]\n+ clone_database_suffix = \"clone\"\n+ connection.creation.clone_test_db(\n+ suffix=clone_database_suffix,\n+ )\n+ settings_dict = connection.creation.get_test_db_clone_settings(clone_database_suffix)\n+ # We manually rename the clone database to 'zulip_test' because when cloning it,\n+ # its name is set to original database name + some suffix.\n+ # Also, we need it to be 'zulip_test' so that our running server can recognize it.\n+ with connection.cursor() as cursor:\n+ cursor.execute(\"ALTER DATABASE zulip_test_template_clone RENAME TO zulip_test;\")\n+ settings_dict[\"NAME\"] = \"zulip_test\"\n+ # connection.settings_dict must be updated in place for changes to be\n+ # reflected in django.db.connections. If the following line assigned\n+ # connection.settings_dict = settings_dict, new threads would connect\n+ # to the default database instead of the appropriate clone.\n+ connection.settings_dict.update(settings_dict)\n+ connection.close()\ndiff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.py\n--- a/zerver/lib/test_helpers.py\n+++ b/zerver/lib/test_helpers.py\n@@ -495,6 +495,7 @@ def find_pattern(pattern: Any, prefixes: List[str]) -> None:\n \"docs/(?P.+)\",\n \"casper/(?P.+)\",\n \"static/(?P.+)\",\n+ \"flush_caches\",\n *(webhook.url for webhook in WEBHOOK_INTEGRATIONS if not include_webhooks),\n }\n \n"},"problem_statement":{"kind":"string","value":"Some Puppeteer tests fail when repeated during the same run\nThe `tools/test-js-with-puppeteer --interactive` mechanism for debugging failing tests depends on the ability to repeatedly run the same test without restarting the test server. A shell command for trying every test repeated twice is:\r\n\r\n```bash\r\ntools/test-js-with-puppeteer {00..16}{,}\r\n```\r\n\r\nThis uncovers several failures, such as:\r\n\r\n```console\r\n$ tools/test-js-with-puppeteer 02 02\r\n…\r\nAssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:\r\n+ actual - expected ... Lines skipped\r\n\r\n [\r\n [\r\n 'Verona > test',\r\n [\r\n+ 'verona test d',\r\n 'verona test a',\r\n...\r\n ]\r\n ]\r\n ]\r\n at CommonUtils.check_messages_sent (/srv/zulip/frontend_tests/puppeteer_lib/common.ts:453:16)\r\n at processTicksAndRejections (internal/process/task_queues.js:93:5)\r\n at expect_verona_stream (/srv/zulip/frontend_tests/puppeteer_tests/02-message-basics.ts:27:5)\r\n at test_navigations_from_home (/srv/zulip/frontend_tests/puppeteer_tests/02-message-basics.ts:96:5)\r\n at message_basic_tests (/srv/zulip/frontend_tests/puppeteer_tests/02-message-basics.ts:450:5)\r\n at CommonUtils.run_test (/srv/zulip/frontend_tests/puppeteer_lib/common.ts:510:13) {\r\n generatedMessage: true,\r\n code: 'ERR_ASSERTION',\r\n actual: [Array],\r\n expected: [Array],\r\n operator: 'deepStrictEqual'\r\n}\r\nWaiting for children to stop...\r\n\r\nThe Puppeteer frontend tests failed!\r\nFor help debugging, read:\r\n https://zulip.readthedocs.io/en/latest/testing/testing-with-puppeteer.html\r\nor report and ask for help in chat.zulip.org\r\nIt's also worthy to see screenshots generated on failure stored under var/puppeteer/*.png\r\n```\r\n\r\n```console\r\n$ tools/test-js-with-puppeteer 04 04\r\n…\r\nAssertionError [ERR_ASSERTION]: Expected values to be strictly equal:\r\n+ actual - expected\r\n\r\n+ 'Verona'\r\n- 'Puppeteer'\r\n at create_stream (/srv/zulip/frontend_tests/puppeteer_tests/04-subscriptions.ts:174:12)\r\n at processTicksAndRejections (internal/process/task_queues.js:93:5)\r\n at test_stream_creation (/srv/zulip/frontend_tests/puppeteer_tests/04-subscriptions.ts:217:5)\r\n at subscriptions_tests (/srv/zulip/frontend_tests/puppeteer_tests/04-subscriptions.ts:256:5)\r\n at CommonUtils.run_test (/srv/zulip/frontend_tests/puppeteer_lib/common.ts:510:13) {\r\n generatedMessage: true,\r\n code: 'ERR_ASSERTION',\r\n actual: 'Verona',\r\n expected: 'Puppeteer',\r\n operator: 'strictEqual'\r\n}\r\nWaiting for children to stop...\r\n\r\nThe Puppeteer frontend tests failed!\r\nFor help debugging, read:\r\n https://zulip.readthedocs.io/en/latest/testing/testing-with-puppeteer.html\r\nor report and ask for help in chat.zulip.org\r\nIt's also worthy to see screenshots generated on failure stored under var/puppeteer/*.png\r\n```\r\n\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-testing members, this issue was labeled with the \"area: testing-infrastructure\" label, so you may want to check it out!\n\n\n@zulipbot claim\nI think the best path forward for this might be to reset the frontend testing database after each individual test file is completed, rather than only during startup."},"created_at":{"kind":"timestamp","value":"2021-03-19T14:26:25","string":"2021-03-19T14:26:25"}}},{"rowIdx":653,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17870,"string":"17,870"},"instance_id":{"kind":"string","value":"zulip__zulip-17870"},"issue_numbers":{"kind":"list like","value":["17795"],"string":"[\n \"17795\"\n]"},"base_commit":{"kind":"string","value":"37b4d0793472afca86c75d6aefbf20e54f6452af"},"patch":{"kind":"string","value":"diff --git a/zerver/openapi/curl_param_value_generators.py b/zerver/openapi/curl_param_value_generators.py\n--- a/zerver/openapi/curl_param_value_generators.py\n+++ b/zerver/openapi/curl_param_value_generators.py\n@@ -20,11 +20,15 @@\n from zerver.lib.events import do_events_register\n from zerver.lib.initial_password import initial_password\n from zerver.lib.test_classes import ZulipTestCase\n-from zerver.models import Client, Message, UserGroup, UserPresence, get_realm\n+from zerver.lib.users import get_api_key\n+from zerver.models import Client, Message, UserGroup, UserPresence, get_realm, get_user\n \n GENERATOR_FUNCTIONS: Dict[str, Callable[[], Dict[str, object]]] = {}\n REGISTERED_GENERATOR_FUNCTIONS: Set[str] = set()\n CALLED_GENERATOR_FUNCTIONS: Set[str] = set()\n+# This is a List rather than just a string in order to make it easier\n+# to write to it from another module.\n+AUTHENTICATION_LINE: List[str] = [\"\"]\n \n helpers = ZulipTestCase()\n \n@@ -310,3 +314,22 @@ def deactivate_user() -> Dict[str, object]:\n acting_user=None,\n )\n return {\"user_id\": user_profile.id}\n+\n+\n+@openapi_param_value_generator([\"/users/me:delete\"])\n+def deactivate_own_user() -> Dict[str, object]:\n+ test_user_email = \"delete-test@zulip.com\"\n+ deactivate_test_user = do_create_user(\n+ test_user_email,\n+ \"secret\",\n+ get_realm(\"zulip\"),\n+ \"Mr. Delete\",\n+ role=200,\n+ acting_user=None,\n+ )\n+ realm = get_realm(\"zulip\")\n+ test_user = get_user(test_user_email, realm)\n+ test_user_api_key = get_api_key(test_user)\n+ # change authentication line to allow test_client to delete itself.\n+ AUTHENTICATION_LINE[0] = f\"{deactivate_test_user.email}:{test_user_api_key}\"\n+ return {}\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/openapi/test_curl_examples.py b/zerver/openapi/test_curl_examples.py\n--- a/zerver/openapi/test_curl_examples.py\n+++ b/zerver/openapi/test_curl_examples.py\n@@ -16,11 +16,14 @@\n \n from zerver.models import get_realm\n from zerver.openapi import markdown_extension\n-from zerver.openapi.curl_param_value_generators import assert_all_helper_functions_called\n+from zerver.openapi.curl_param_value_generators import (\n+ AUTHENTICATION_LINE,\n+ assert_all_helper_functions_called,\n+)\n \n \n-def test_generated_curl_examples_for_success(client: Client, owner_client: Client) -> None:\n- authentication_line = f\"{client.email}:{client.api_key}\"\n+def test_generated_curl_examples_for_success(client: Client) -> None:\n+ default_authentication_line = f\"{client.email}:{client.api_key}\"\n # A limited Markdown engine that just processes the code example syntax.\n realm = get_realm(\"zulip\")\n md_engine = markdown.Markdown(\n@@ -35,6 +38,10 @@ def test_generated_curl_examples_for_success(client: Client, owner_client: Clien\n for file_name in sorted(glob.glob(\"templates/zerver/api/*.md\")):\n with open(file_name) as f:\n for line in f:\n+ # Set AUTHENTICATION_LINE to default_authentication_line.\n+ # Set this every iteration, because deactivate_own_user\n+ # will override this for its test.\n+ AUTHENTICATION_LINE[0] = default_authentication_line\n # A typical example from the Markdown source looks like this:\n # {generate_code_example(curl, ...}\n if not line.startswith(\"{generate_code_example(curl\"):\n@@ -47,21 +54,9 @@ def test_generated_curl_examples_for_success(client: Client, owner_client: Clien\n unescaped_html = html.unescape(curl_command_html)\n curl_command_text = unescaped_html[len(\"

curl\\n\") : -len(\"

\")]\n curl_command_text = curl_command_text.replace(\n- \"BOT_EMAIL_ADDRESS:BOT_API_KEY\", authentication_line\n+ \"BOT_EMAIL_ADDRESS:BOT_API_KEY\", AUTHENTICATION_LINE[0]\n )\n \n- # TODO: This needs_reactivation block is a hack.\n- # However, it's awkward to test the \"deactivate\n- # myself\" endpoint with how this system tries to use\n- # the same account for all tests without some special\n- # logic for that endpoint; and the hack is better than\n- # just not documenting the endpoint.\n- needs_reactivation = False\n- user_id = 0\n- if file_name == \"templates/zerver/api/deactivate-own-user.md\":\n- needs_reactivation = True\n- user_id = client.get_profile()[\"user_id\"]\n-\n print(\"Testing {} ...\".format(curl_command_text.split(\"\\n\")[0]))\n \n # Turn the text into an arguments list.\n@@ -77,8 +72,6 @@ def test_generated_curl_examples_for_success(client: Client, owner_client: Clien\n )\n response = json.loads(response_json)\n assert response[\"result\"] == \"success\"\n- if needs_reactivation:\n- owner_client.reactivate_user_by_id(user_id)\n except (AssertionError, Exception):\n error_template = \"\"\"\n Error verifying the success of the API documentation curl example.\n"},"problem_statement":{"kind":"string","value":"Clean up code for hacky OpenAPI curl test\nAfter testing `deactivate_own_account` endpoint, we need to reactivate the client so that other tests are not affected by the deactivated client. In `test_curl_examples`, this has been hackily implemented and should be replaced by cleaner code. More details at https://github.com/zulip/zulip/pull/17014#discussion_r601173277\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-testing members, this issue was labeled with the \"area: testing-infrastructure\" label, so you may want to check it out!\n\n\n@MSurfer20 Hey, are you working on this issue?\n@100RABHpy I had planned to take this up after completing work on some other PRs. Feel free to claim this;I'd be happy to review your work :)\nThanks @MSurfer20,\r\nCan you explain a bit on (like what error you get when tried to delete any other user):\r\n>it's awkward to test the \"deactivate myself\" endpoint with how this system tries to use the same account for all tests without some special logic for that endpoint\r\n>\r\nI was thinking to create a new administrator user and delete this in `deactivate_own_user` function. \n@zulipbot claim\n If you deactivate a user, then that user can't call any other endpoints(since it's deactivated), which leads to all remaining tests failing. \r\n>I was thinking to create a new administrator user and delete this in deactivate_own_user function. \r\n\r\nThis seems to be good!\nOh, Okay, that can be handle. \r\nAlso, If I'm getting it right only reason of adding owner_client is for reactivation. Right?\nYes, it was just added for reactivating the client after the deactivation."},"created_at":{"kind":"timestamp","value":"2021-03-29T17:13:45","string":"2021-03-29T17:13:45"}}},{"rowIdx":654,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17872,"string":"17,872"},"instance_id":{"kind":"string","value":"zulip__zulip-17872"},"issue_numbers":{"kind":"list like","value":["17763"],"string":"[\n \"17763\"\n]"},"base_commit":{"kind":"string","value":"f73d101854c3792b1fc947fe16997b7dab1bcf61"},"patch":{"kind":"string","value":"diff --git a/zerver/decorator.py b/zerver/decorator.py\n--- a/zerver/decorator.py\n+++ b/zerver/decorator.py\n@@ -32,7 +32,9 @@\n OrganizationAdministratorRequired,\n OrganizationMemberRequired,\n OrganizationOwnerRequired,\n+ RealmDeactivatedError,\n UnsupportedWebhookEventType,\n+ UserDeactivatedError,\n )\n from zerver.lib.queue import queue_json_publish\n from zerver.lib.rate_limiter import RateLimitedUser\n@@ -268,9 +270,9 @@ def validate_api_key(\n \n def validate_account_and_subdomain(request: HttpRequest, user_profile: UserProfile) -> None:\n if user_profile.realm.deactivated:\n- raise JsonableError(_(\"This organization has been deactivated\"))\n+ raise RealmDeactivatedError()\n if not user_profile.is_active:\n- raise JsonableError(_(\"Account is deactivated\"))\n+ raise UserDeactivatedError()\n \n # Either the subdomain matches, or we're accessing Tornado from\n # and to localhost (aka spoofing a request as the user).\ndiff --git a/zerver/lib/exceptions.py b/zerver/lib/exceptions.py\n--- a/zerver/lib/exceptions.py\n+++ b/zerver/lib/exceptions.py\n@@ -50,6 +50,8 @@ class ErrorCode(AbstractEnum):\n UNAUTHENTICATED_USER = ()\n NONEXISTENT_SUBDOMAIN = ()\n RATE_LIMIT_HIT = ()\n+ USER_DEACTIVATED = ()\n+ REALM_DEACTIVATED = ()\n \n \n class JsonableError(Exception):\n@@ -271,6 +273,30 @@ def msg_format() -> str:\n return _(\"Must be an organization or stream administrator\")\n \n \n+class UserDeactivatedError(JsonableError):\n+ code: ErrorCode = ErrorCode.USER_DEACTIVATED\n+ http_status_code = 403\n+\n+ def __init__(self) -> None:\n+ pass\n+\n+ @staticmethod\n+ def msg_format() -> str:\n+ return _(\"Account is deactivated\")\n+\n+\n+class RealmDeactivatedError(JsonableError):\n+ code: ErrorCode = ErrorCode.REALM_DEACTIVATED\n+ http_status_code = 403\n+\n+ def __init__(self) -> None:\n+ pass\n+\n+ @staticmethod\n+ def msg_format() -> str:\n+ return _(\"This organization has been deactivated\")\n+\n+\n class MarkdownRenderingException(Exception):\n pass\n \ndiff --git a/zerver/openapi/python_examples.py b/zerver/openapi/python_examples.py\n--- a/zerver/openapi/python_examples.py\n+++ b/zerver/openapi/python_examples.py\n@@ -1224,6 +1224,24 @@ def test_missing_request_argument(client: Client) -> None:\n validate_against_openapi_schema(result, \"/rest-error-handling\", \"post\", \"400_1\")\n \n \n+def test_user_account_deactivated(client: Client) -> None:\n+ request = {\n+ \"content\": \"**foo**\",\n+ }\n+ result = client.render_message(request)\n+\n+ validate_against_openapi_schema(result, \"/rest-error-handling\", \"post\", \"403_0\")\n+\n+\n+def test_realm_deactivated(client: Client) -> None:\n+ request = {\n+ \"content\": \"**foo**\",\n+ }\n+ result = client.render_message(request)\n+\n+ validate_against_openapi_schema(result, \"/rest-error-handling\", \"post\", \"403_1\")\n+\n+\n def test_invalid_stream_error(client: Client) -> None:\n result = client.get_stream_id(\"nonexistent\")\n \n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py\n--- a/zerver/tests/test_decorators.py\n+++ b/zerver/tests/test_decorators.py\n@@ -1066,7 +1066,9 @@ def test_send_deactivated_realm(self) -> None:\n \"to\": self.example_email(\"othello\"),\n },\n )\n- self.assert_json_error_contains(result, \"has been deactivated\", status_code=400)\n+ self.assert_json_error_contains(\n+ result, \"This organization has been deactivated\", status_code=403\n+ )\n \n result = self.api_post(\n self.example_user(\"hamlet\"),\n@@ -1078,7 +1080,9 @@ def test_send_deactivated_realm(self) -> None:\n \"to\": self.example_email(\"othello\"),\n },\n )\n- self.assert_json_error_contains(result, \"has been deactivated\", status_code=401)\n+ self.assert_json_error_contains(\n+ result, \"This organization has been deactivated\", status_code=401\n+ )\n \n def test_fetch_api_key_deactivated_realm(self) -> None:\n \"\"\"\n@@ -1094,7 +1098,9 @@ def test_fetch_api_key_deactivated_realm(self) -> None:\n realm.deactivated = True\n realm.save()\n result = self.client_post(\"/json/fetch_api_key\", {\"password\": test_password})\n- self.assert_json_error_contains(result, \"has been deactivated\", status_code=400)\n+ self.assert_json_error_contains(\n+ result, \"This organization has been deactivated\", status_code=403\n+ )\n \n def test_webhook_deactivated_realm(self) -> None:\n \"\"\"\n@@ -1107,7 +1113,9 @@ def test_webhook_deactivated_realm(self) -> None:\n url = f\"/api/v1/external/jira?api_key={api_key}&stream=jira_custom\"\n data = self.webhook_fixture_data(\"jira\", \"created_v2\")\n result = self.client_post(url, data, content_type=\"application/json\")\n- self.assert_json_error_contains(result, \"has been deactivated\", status_code=400)\n+ self.assert_json_error_contains(\n+ result, \"This organization has been deactivated\", status_code=403\n+ )\n \n \n class LoginRequiredTest(ZulipTestCase):\n@@ -1209,7 +1217,7 @@ def test_send_deactivated_user(self) -> None:\n \"to\": self.example_email(\"othello\"),\n },\n )\n- self.assert_json_error_contains(result, \"Account is deactivated\", status_code=400)\n+ self.assert_json_error_contains(result, \"Account is deactivated\", status_code=403)\n \n result = self.api_post(\n self.example_user(\"hamlet\"),\n@@ -1238,7 +1246,7 @@ def test_fetch_api_key_deactivated_user(self) -> None:\n change_user_is_active(user_profile, False)\n \n result = self.client_post(\"/json/fetch_api_key\", {\"password\": test_password})\n- self.assert_json_error_contains(result, \"Account is deactivated\", status_code=400)\n+ self.assert_json_error_contains(result, \"Account is deactivated\", status_code=403)\n \n def test_login_deactivated_user(self) -> None:\n \"\"\"\n@@ -1304,7 +1312,7 @@ def test_webhook_deactivated_user(self) -> None:\n url = f\"/api/v1/external/jira?api_key={api_key}&stream=jira_custom\"\n data = self.webhook_fixture_data(\"jira\", \"created_v2\")\n result = self.client_post(url, data, content_type=\"application/json\")\n- self.assert_json_error_contains(result, \"Account is deactivated\", status_code=400)\n+ self.assert_json_error_contains(result, \"Account is deactivated\", status_code=403)\n \n \n class TestIncomingWebhookBot(ZulipTestCase):\n@@ -1647,7 +1655,9 @@ def test_authenticated_json_post_view_if_user_is_not_active(self) -> None:\n self.login_user(user_profile)\n # we deactivate user manually because do_deactivate_user removes user session\n change_user_is_active(user_profile, False)\n- self.assert_json_error_contains(self._do_test(user_profile), \"Account is deactivated\")\n+ self.assert_json_error_contains(\n+ self._do_test(user_profile), \"Account is deactivated\", status_code=403\n+ )\n do_reactivate_user(user_profile, acting_user=None)\n \n def test_authenticated_json_post_view_if_user_realm_is_deactivated(self) -> None:\n@@ -1657,7 +1667,9 @@ def test_authenticated_json_post_view_if_user_realm_is_deactivated(self) -> None\n user_profile.realm.deactivated = True\n user_profile.realm.save()\n self.assert_json_error_contains(\n- self._do_test(user_profile), \"This organization has been deactivated\"\n+ self._do_test(user_profile),\n+ \"This organization has been deactivated\",\n+ status_code=403,\n )\n do_reactivate_realm(user_profile.realm)\n \n"},"problem_statement":{"kind":"string","value":"Add error codes in `validate_account_and_subdomain` \nThe error cases in `validate_account_and_subdomain` are ones that clients are likely to want to be able to parse, e.g. the mobile/terminal apps will want to know if an authentication error is because of a deactivated realm for error handling. REALM_DEACTIVATED and USER_DEACTIVATED are probably reasonable error code names.\r\n\r\nWe should open zulip-mobile and zulip-terminal issues to support the new error codes once we resolve this.\r\n\r\nSee `ErrorCode` in `zerver/lib/exceptions.py` for how to register these. \r\n\r\n@gnprice FYI.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-api members, this issue was labeled with the \"area: api\" label, so you may want to check it out!\n\n\n@zulipbot claim"},"created_at":{"kind":"timestamp","value":"2021-03-29T17:42:47","string":"2021-03-29T17:42:47"}}},{"rowIdx":655,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17899,"string":"17,899"},"instance_id":{"kind":"string","value":"zulip__zulip-17899"},"issue_numbers":{"kind":"list like","value":["17662"],"string":"[\n \"17662\"\n]"},"base_commit":{"kind":"string","value":"bac96cae8004293608dda674df3ec667264ec064"},"patch":{"kind":"string","value":"diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.py\n--- a/scripts/lib/zulip_tools.py\n+++ b/scripts/lib/zulip_tools.py\n@@ -581,8 +581,10 @@ def get_deploy_options(config_file: configparser.RawConfigParser) -> List[str]:\n \n \n def run_psql_as_postgres(\n+ config_file: configparser.RawConfigParser,\n sql_query: str,\n ) -> None:\n+ dbname = get_config(config_file, \"postgresql\", \"database_name\", \"zulip\")\n subcmd = \" \".join(\n map(\n shlex.quote,\n@@ -590,8 +592,8 @@ def run_psql_as_postgres(\n \"psql\",\n \"-v\",\n \"ON_ERROR_STOP=1\",\n- # TODO: Stop hardcoding the database name.\n- \"zulip\",\n+ \"-d\",\n+ dbname,\n \"-c\",\n sql_query,\n ],\ndiff --git a/scripts/setup/generate_secrets.py b/scripts/setup/generate_secrets.py\n--- a/scripts/setup/generate_secrets.py\n+++ b/scripts/setup/generate_secrets.py\n@@ -7,6 +7,7 @@\n BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))\n sys.path.append(BASE_DIR)\n from scripts.lib.setup_path import setup_path\n+from scripts.lib.zulip_tools import get_config, get_config_file\n \n setup_path()\n \n@@ -101,6 +102,13 @@ def add_secret(name: str, value: str) -> None:\n if development and need_secret(\"local_database_password\"):\n add_secret(\"local_database_password\", random_token())\n \n+ # We only need a secret if the database username does not match\n+ # the OS username, as identd auth works in that case.\n+ if get_config(\n+ get_config_file(), \"postgresql\", \"database_user\", \"zulip\"\n+ ) != \"zulip\" and need_secret(\"postgres_password\"):\n+ add_secret(\"postgres_password\", random_token())\n+\n # The core Django SECRET_KEY setting, used by Django internally to\n # secure sessions. If this gets changed, all users will be logged out.\n if need_secret(\"secret_key\"):\ndiff --git a/zproject/computed_settings.py b/zproject/computed_settings.py\n--- a/zproject/computed_settings.py\n+++ b/zproject/computed_settings.py\n@@ -281,8 +281,8 @@ def get_dirs(self) -> List[PosixPath]:\n DATABASES: Dict[str, Dict[str, Any]] = {\n \"default\": {\n \"ENGINE\": \"django.db.backends.postgresql\",\n- \"NAME\": \"zulip\",\n- \"USER\": \"zulip\",\n+ \"NAME\": get_config(\"postgresql\", \"database_name\", \"zulip\"),\n+ \"USER\": get_config(\"postgresql\", \"database_user\", \"zulip\"),\n # Password = '' => peer/certificate authentication (no password)\n \"PASSWORD\": \"\",\n # Host = '' => connect to localhost by default\n@@ -314,7 +314,12 @@ def get_dirs(self) -> List[PosixPath]:\n DATABASES[\"default\"][\"OPTIONS\"][\"sslmode\"] = REMOTE_POSTGRES_SSLMODE\n else:\n DATABASES[\"default\"][\"OPTIONS\"][\"sslmode\"] = \"verify-full\"\n-\n+elif get_config(\"postgresql\", \"database_user\") != \"zulip\":\n+ if get_secret(\"postgres_password\") is not None:\n+ DATABASES[\"default\"].update(\n+ PASSWORD=get_secret(\"postgres_password\"),\n+ HOST=\"localhost\",\n+ )\n POSTGRESQL_MISSING_DICTIONARIES = bool(get_config(\"postgresql\", \"missing_dictionaries\", None))\n \n DEFAULT_AUTO_FIELD = \"django.db.models.AutoField\"\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Add Support for Custom Database Names & Users\nAdd Support for Custom Database Names & Users\r\n\r\nAs per - https://chat.zulip.org/#narrow/stream/2-general/topic/Change.20DB.20user.20and.20name & https://github.com/zulip/docker-zulip/issues/289\r\n\r\n@zulipbot claim\n"},"hints_text":{"kind":"string","value":"@zulipbot add \"area: production installer\"\nHello @zulip/server-production members, this issue was labeled with the \"area: production installer\" label, so you may want to check it out!\n\n\nHello @adambirds, you claimed this issue to work on it, but this issue and any referenced pull requests haven't been updated for 10 days. Are you still working on this issue?\n\nIf so, please update this issue by leaving a comment on this issue to let me know that you're still working on it. Otherwise, I'll automatically remove you from this issue in 4 days.\n\nIf you've decided to work on something else, simply comment `@zulipbot abandon` so that someone else can claim it and continue from where you left off.\n\nThank you for your valuable contributions to Zulip!\n\n"},"created_at":{"kind":"timestamp","value":"2021-03-31T01:33:56","string":"2021-03-31T01:33:56"}}},{"rowIdx":656,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":17906,"string":"17,906"},"instance_id":{"kind":"string","value":"zulip__zulip-17906"},"issue_numbers":{"kind":"list like","value":["16971"],"string":"[\n \"16971\"\n]"},"base_commit":{"kind":"string","value":"88262a484c9d3ec87022d25fce5366586367aae6"},"patch":{"kind":"string","value":"diff --git a/zerver/openapi/python_examples.py b/zerver/openapi/python_examples.py\n--- a/zerver/openapi/python_examples.py\n+++ b/zerver/openapi/python_examples.py\n@@ -424,19 +424,19 @@ def get_stream_id(client: Client) -> int:\n \n \n @openapi_test_function(\"/streams/{stream_id}:delete\")\n-def delete_stream(client: Client, stream_id: int) -> None:\n+def archive_stream(client: Client, stream_id: int) -> None:\n result = client.add_subscriptions(\n streams=[\n {\n- \"name\": \"stream to be deleted\",\n+ \"name\": \"stream to be archived\",\n \"description\": \"New stream for testing\",\n },\n ],\n )\n \n # {code_example|start}\n- # Delete the stream named 'stream to be deleted'\n- stream_id = client.get_stream_id(\"stream to be deleted\")[\"stream_id\"]\n+ # Archive the stream named 'stream to be archived'\n+ stream_id = client.get_stream_id(\"stream to be archived\")[\"stream_id\"]\n result = client.delete_stream(stream_id)\n # {code_example|end}\n validate_against_openapi_schema(result, \"/streams/{stream_id}\", \"delete\", \"200\")\n@@ -1368,7 +1368,7 @@ def test_streams(client: Client, nonadmin_client: Client) -> None:\n update_subscription_settings(client)\n update_notification_settings(client)\n get_stream_topics(client, 1)\n- delete_stream(client, stream_id)\n+ archive_stream(client, stream_id)\n \n test_user_not_authorized_error(nonadmin_client)\n test_authorization_errors_fatal(client, nonadmin_client)\ndiff --git a/zproject/urls.py b/zproject/urls.py\n--- a/zproject/urls.py\n+++ b/zproject/urls.py\n@@ -764,6 +764,11 @@\n template_name=\"zerver/documentation_main.html\", path_template=\"/zerver/api/%s.md\"\n )\n urls += [\n+ # Redirects due to us having moved the docs:\n+ path(\n+ \"help/delete-a-stream\", RedirectView.as_view(url=\"/help/archive-a-stream\", permanent=True)\n+ ),\n+ path(\"api/delete-stream\", RedirectView.as_view(url=\"/api/archive-stream\", permanent=True)),\n path(\"help/\", help_documentation_view),\n path(\"help/\", help_documentation_view),\n path(\"api/\", api_documentation_view),\n"},"test_patch":{"kind":"string","value":"diff --git a/frontend_tests/node_tests/stream_data.js b/frontend_tests/node_tests/stream_data.js\n--- a/frontend_tests/node_tests/stream_data.js\n+++ b/frontend_tests/node_tests/stream_data.js\n@@ -418,7 +418,7 @@ test(\"delete_sub\", () => {\n assert(!stream_data.get_sub(\"Canada\"));\n assert(!stream_data.get_sub_by_id(canada.stream_id));\n \n- blueslip.expect(\"warn\", \"Failed to delete stream 99999\");\n+ blueslip.expect(\"warn\", \"Failed to archive stream 99999\");\n stream_data.delete_sub(99999);\n });\n \ndiff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.py\n--- a/zerver/lib/test_helpers.py\n+++ b/zerver/lib/test_helpers.py\n@@ -496,6 +496,8 @@ def find_pattern(pattern: Any, prefixes: List[str]) -> None:\n \"confirmation_key/\",\n \"node-coverage/(?P.+)\",\n \"docs/(?P.+)\",\n+ \"help/delete-a-stream\",\n+ \"api/delete-stream\",\n \"casper/(?P.+)\",\n \"static/(?P.+)\",\n \"flush_caches\",\ndiff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py\n--- a/zerver/tests/test_subs.py\n+++ b/zerver/tests/test_subs.py\n@@ -1305,17 +1305,17 @@ def test_stream_message_retention_days_on_stream_creation(self) -> None:\n self.assertEqual(result[1][2].name, \"new_stream3\")\n self.assertEqual(result[1][2].message_retention_days, None)\n \n- def set_up_stream_for_deletion(\n+ def set_up_stream_for_archiving(\n self, stream_name: str, invite_only: bool = False, subscribed: bool = True\n ) -> Stream:\n \"\"\"\n- Create a stream for deletion by an administrator.\n+ Create a stream for archiving by an administrator.\n \"\"\"\n user_profile = self.example_user(\"hamlet\")\n self.login_user(user_profile)\n stream = self.make_stream(stream_name, invite_only=invite_only)\n \n- # For testing deleting streams you aren't on.\n+ # For testing archiving streams you aren't on.\n if subscribed:\n self.subscribe(user_profile, stream_name)\n \n@@ -1323,9 +1323,9 @@ def set_up_stream_for_deletion(\n \n return stream\n \n- def delete_stream(self, stream: Stream) -> None:\n+ def archive_stream(self, stream: Stream) -> None:\n \"\"\"\n- Delete the stream and assess the result.\n+ Archive the stream and assess the result.\n \"\"\"\n active_name = stream.name\n realm = stream.realm\n@@ -1402,28 +1402,28 @@ def test_delete_public_stream(self) -> None:\n When an administrator deletes a public stream, that stream is not\n visible to users at all anymore.\n \"\"\"\n- stream = self.set_up_stream_for_deletion(\"newstream\")\n- self.delete_stream(stream)\n+ stream = self.set_up_stream_for_archiving(\"newstream\")\n+ self.archive_stream(stream)\n \n def test_delete_private_stream(self) -> None:\n \"\"\"\n Administrators can delete private streams they are on.\n \"\"\"\n- stream = self.set_up_stream_for_deletion(\"newstream\", invite_only=True)\n- self.delete_stream(stream)\n+ stream = self.set_up_stream_for_archiving(\"newstream\", invite_only=True)\n+ self.archive_stream(stream)\n \n- def test_delete_streams_youre_not_on(self) -> None:\n+ def test_archive_streams_youre_not_on(self) -> None:\n \"\"\"\n Administrators can delete public streams they aren't on, including\n private streams in their realm.\n \"\"\"\n- pub_stream = self.set_up_stream_for_deletion(\"pubstream\", subscribed=False)\n- self.delete_stream(pub_stream)\n+ pub_stream = self.set_up_stream_for_archiving(\"pubstream\", subscribed=False)\n+ self.archive_stream(pub_stream)\n \n- priv_stream = self.set_up_stream_for_deletion(\n+ priv_stream = self.set_up_stream_for_archiving(\n \"privstream\", subscribed=False, invite_only=True\n )\n- self.delete_stream(priv_stream)\n+ self.archive_stream(priv_stream)\n \n def attempt_unsubscribe_of_principal(\n self,\n@@ -4369,7 +4369,7 @@ def test_gather_subscriptions_excludes_deactivated_streams(self) -> None:\n self.subscribe(non_admin_user, stream_name)\n self.subscribe(self.example_user(\"othello\"), stream_name)\n \n- def delete_stream(stream_name: str) -> None:\n+ def archive_stream(stream_name: str) -> None:\n stream_id = get_stream(stream_name, realm).id\n result = self.client_delete(f\"/json/streams/{stream_id}\")\n self.assert_json_success(result)\n@@ -4379,7 +4379,7 @@ def delete_stream(stream_name: str) -> None:\n non_admin_before_delete = gather_subscriptions_helper(non_admin_user)\n \n # Delete our stream\n- delete_stream(\"stream1\")\n+ archive_stream(\"stream1\")\n \n # Get subs after delete\n admin_after_delete = gather_subscriptions_helper(admin_user)\n"},"problem_statement":{"kind":"string","value":"Starred messages view shows messages in inaccessible streams\nIf you star a message in a stream and either:\r\n1. Unsub from the stream.\r\n2. Deactivate the stream.\r\n\r\nThe message will stay visible in the Starred messages view even though it shouldn't. E.g. in the screenshot below you can see messages I starred - first one in a deactivated stream, second one in a private stream I unsubscribed from.\r\n![image](https://user-images.githubusercontent.com/45007152/103225499-51842180-492a-11eb-922c-544404150248.png)\r\n\n"},"hints_text":{"kind":"string","value":"@sahil839 Would you be interested in looking into this?\nSure, I will fix this.\r\n@zulipbot claim.\n@sahil839 , Are you still working on this? I would like to contribute too.\r\n\nYes I am working on this. \nI am busy with college work, so I am abandoning this for now. WIll get back to this when I get time (if this will not be solved till then). Anyone who is taking this can have a look on the discussion [here](https://chat.zulip.org/#narrow/stream/9-issues/topic/.2316971.20starred.20messages.20view). @zulipbot abandon\r\n@Pranav2612000 you can take this if you want.\nI have gone through the discussions on Zulip Community , i think i can fix this \r\n@zulipbot claim.\nHello @deto-5420!\n\nThanks for your interest in Zulip! You have attempted to claim an issue without the labels \"help wanted\", \"good first issue\". Since you're a new contributor, you can only claim and submit pull requests for issues with the [help wanted](https://github.com/zulip/zulip/issues?q=is%3Aopen+is%3Aissue+no%3Aassignee+label%3A%22help+wanted%22) or [good first issue](https://github.com/zulip/zulip/issues?q=is%3Aopen+is%3Aissue+no%3Aassignee+label%3A%22good+first+issue%22) labels.\n\nIf this is your first time here, we recommend reading our [guide for new contributors](https://zulip.readthedocs.io/en/latest/overview/contributing.html) before getting started.\n@deto-5420 are you working on this issue. Can I start working over it, if you haven't?\n@zulipbot claim\nLooks like there is some misconversation @m-e-l-u-h-a-n .I am working on it which I mentioned in Czo. Thanks in advance.\r\nWill let you know if I dismiss it.\nActually I just looked into the thread mentioned by sahil above but couldn't find your message there, sorry if you have started over it(please confirm) I will unclaim it.\r\nOhh I think you clarified you are still working on it in above message itself. Sorry I will unclaim it.\nHi @aryanshridhar , I hope everything is going well. I suggest claiming the issue and assigning it to you so it would be clear someone is working on it.\n@aryanshridhar are you still working on this, Can I take this up if you are busy?"},"created_at":{"kind":"timestamp","value":"2021-03-31T14:21:07","string":"2021-03-31T14:21:07"}}},{"rowIdx":657,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18016,"string":"18,016"},"instance_id":{"kind":"string","value":"zulip__zulip-18016"},"issue_numbers":{"kind":"list like","value":["17898"],"string":"[\n \"17898\"\n]"},"base_commit":{"kind":"string","value":"3e5e89991dd1fd307bf60a9011353f7a503dc9e1"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py\n--- a/zerver/lib/actions.py\n+++ b/zerver/lib/actions.py\n@@ -1928,6 +1928,15 @@ def do_send_messages(\n about changing the next line.\n \"\"\"\n user_ids = send_request.active_user_ids | set(user_flags.keys())\n+ sender_id = send_request.message.sender_id\n+\n+ # We make sure the sender is listed first in the `users` list;\n+ # this results in the sender receiving the message first if\n+ # there are thousands of recipients, decreasing perceived latency.\n+ if sender_id in user_ids:\n+ user_list = [sender_id] + list(user_ids - {sender_id})\n+ else:\n+ user_list = list(user_ids)\n \n users = [\n dict(\n@@ -1938,7 +1947,7 @@ def do_send_messages(\n stream_email_notify=(user_id in send_request.stream_email_user_ids),\n wildcard_mention_notify=(user_id in send_request.wildcard_mention_user_ids),\n )\n- for user_id in user_ids\n+ for user_id in user_list\n ]\n \n if send_request.message.is_stream_message():\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Improve perceived latency for sender when sending/editing a message in very large streams\nWhen sending messages to a stream with 15k+ subscribers, it can take 300ms between when the first user receives the message and the last does. It would be desirable for the sender to be \"first in line\" for this purpose, since the UX for the sender is not ideal while waiting for the message to send (especially with edits).\r\n\r\nThe logic for this system involves several `Set` data structures, starting with this part of `do_send_messages`:\r\n\r\n```\r\n user_ids = send_request.active_user_ids | set(user_flags.keys()) \r\n \r\n users = [ \r\n dict( \r\n id=user_id, \r\n flags=user_flags.get(user_id, []), \r\n always_push_notify=(user_id in send_request.push_notify_user_ids), \r\n stream_push_notify=(user_id in send_request.stream_push_user_ids), \r\n stream_email_notify=(user_id in send_request.stream_email_user_ids), \r\n wildcard_mention_notify=(user_id in send_request.wildcard_mention_user_ids), \r\n ) \r\n for user_id in user_ids \r\n ] \r\n \r\n send_event(send_request.realm, event, users) \r\n```\r\n\r\nThat then runs to `zerver/tornado/events_queue.py`, and in particular `get_client_info_for_message_event` (and `process_message_event`, which actually does the work). I think if we do a bit of work to make sure the sender is first in the list sent from `do_send_messages` and then modify the Tornado code to use an OrderedDict or something (actually I think modern Python dicts all?) to avoid changing the iteration order, we can arrange it so that the order in the event sent from `do_send_messages` is also the processing order.\r\n\r\nA fix should be testable by just adding `print(user_id)` type statements in `process_message_event` (with a bit of extra work to make sure `send_to_clients` doesn't break the ordering).\r\n\r\nhttps://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html has relevant background.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-compose, @zulip/server-message-view members, this issue was labeled with the \"area: compose\", \"area: message-editing\" labels, so you may want to check it out!\n\n\nI have less idea about the backend. But this one will be interesting to try on as related to compose.\r\n@zulipbot claim\r\n\nI think this should be doable for you -- I've mentioned the code paths involved and I think it just takes some print-debugging and care with sort order."},"created_at":{"kind":"timestamp","value":"2021-04-06T21:17:27","string":"2021-04-06T21:17:27"}}},{"rowIdx":658,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18021,"string":"18,021"},"instance_id":{"kind":"string","value":"zulip__zulip-18021"},"issue_numbers":{"kind":"list like","value":["18021"],"string":"[\n \"18021\"\n]"},"base_commit":{"kind":"string","value":"60c8b0123f986adb346ece7e2cba0831f47064af"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/markdown/api_arguments_table_generator.py b/zerver/lib/markdown/api_arguments_table_generator.py\n--- a/zerver/lib/markdown/api_arguments_table_generator.py\n+++ b/zerver/lib/markdown/api_arguments_table_generator.py\n@@ -124,7 +124,14 @@ def render_table(self, arguments: Sequence[Mapping[str, Any]]) -> List[str]:\n # (path, querystring, form data...). We should document this detail.\n example = \"\"\n if \"example\" in argument:\n- example = argument[\"example\"]\n+ # We use this style without explicit JSON encoding for\n+ # integers, strings, and booleans.\n+ # * For booleans, JSON encoding correctly corrects for Python's\n+ # str(True)=\"True\" not matching the encoding of \"true\".\n+ # * For strings, doing so nicely results in strings being quoted\n+ # in the documentation, improving readability.\n+ # * For integers, it is a noop, since json.dumps(3) == str(3) == \"3\".\n+ example = json.dumps(argument[\"example\"])\n else:\n example = json.dumps(argument[\"content\"][\"application/json\"][\"example\"])\n \ndiff --git a/zerver/openapi/markdown_extension.py b/zerver/openapi/markdown_extension.py\n--- a/zerver/openapi/markdown_extension.py\n+++ b/zerver/openapi/markdown_extension.py\n@@ -208,6 +208,7 @@ def get_openapi_param_example_value_as_string(\n # union type. But for this logic's purpose, it's good enough\n # to just check the first parameter.\n param_type = param[\"schema\"][\"oneOf\"][0][\"type\"]\n+\n if param_type in [\"object\", \"array\"]:\n example_value = param.get(\"example\", None)\n if not example_value:\n@@ -225,7 +226,9 @@ def get_openapi_param_example_value_as_string(\n else:\n example_value = param.get(\"example\", DEFAULT_EXAMPLE[param_type])\n if isinstance(example_value, bool):\n- example_value = str(example_value).lower()\n+ # Booleans are effectively JSON-encoded, in that we pass\n+ # true/false, not the Python str(True) = \"True\"\n+ jsonify = True\n if jsonify:\n example_value = json.dumps(example_value)\n if curl_argument:\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"openapi: Fix display of boolean types in examples.\nFixed boolean statements being displayed in camel case in API\r\ndocumentations to match JSON format.\r\n\r\n\r\nFixes #18010\r\n\r\n**Testing plan:** \r\nManually tested in browser\r\n\r\n**GIFs or screenshots:** \r\n![boolean](https://user-images.githubusercontent.com/42570356/113869287-2a14de80-97ce-11eb-86e3-5cec5852532d.JPG)\r\n\r\n\r\n\r\n\n"},"hints_text":{"kind":"string","value":""},"created_at":{"kind":"timestamp","value":"2021-04-07T12:52:50","string":"2021-04-07T12:52:50"}}},{"rowIdx":659,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18051,"string":"18,051"},"instance_id":{"kind":"string","value":"zulip__zulip-18051"},"issue_numbers":{"kind":"list like","value":["14499"],"string":"[\n \"14499\"\n]"},"base_commit":{"kind":"string","value":"de6bd22ee91bae31d8f2c43d6fd222391b5943ad"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py\n--- a/zerver/lib/actions.py\n+++ b/zerver/lib/actions.py\n@@ -143,6 +143,7 @@\n access_stream_by_id,\n access_stream_for_send_message,\n can_access_stream_user_ids,\n+ check_stream_access_based_on_stream_post_policy,\n check_stream_name,\n create_stream_if_needed,\n get_default_value_for_history_public_to_subscribers,\n@@ -2802,7 +2803,7 @@ def check_update_message(\n if stream_id is not None:\n if not message.is_stream_message():\n raise JsonableError(_(\"Message must be a stream message\"))\n- if not user_profile.is_realm_admin:\n+ if not user_profile.can_move_messages_between_streams():\n raise JsonableError(_(\"You don't have permission to move this message\"))\n try:\n access_stream_by_id(user_profile, message.recipient.type_id)\n@@ -2816,6 +2817,7 @@ def check_update_message(\n raise JsonableError(_(\"Cannot change message content while changing stream\"))\n \n new_stream = access_stream_by_id(user_profile, stream_id, require_active=True)[0]\n+ check_stream_access_based_on_stream_post_policy(user_profile, new_stream)\n \n number_changed = do_update_message(\n user_profile,\n"},"test_patch":{"kind":"string","value":"diff --git a/frontend_tests/node_tests/settings_data.js b/frontend_tests/node_tests/settings_data.js\n--- a/frontend_tests/node_tests/settings_data.js\n+++ b/frontend_tests/node_tests/settings_data.js\n@@ -107,117 +107,58 @@ run_test(\"user_can_change_logo\", () => {\n assert.equal(can_change_logo(), false);\n });\n \n-run_test(\"user_can_invite_others_to_realm\", () => {\n- const can_invite_others_to_realm = settings_data.user_can_invite_others_to_realm;\n-\n- page_params.is_admin = true;\n- page_params.realm_invite_to_realm_policy =\n- settings_config.common_policy_values.by_admins_only.code;\n- assert.equal(can_invite_others_to_realm(), true);\n-\n- page_params.is_admin = false;\n- assert.equal(can_invite_others_to_realm(), false);\n-\n- page_params.is_moderator = true;\n- page_params.realm_invite_to_realm_policy =\n- settings_config.common_policy_values.by_moderators_only.code;\n- assert.equal(can_invite_others_to_realm(), true);\n-\n- page_params.is_moderator = false;\n- assert.equal(can_invite_others_to_realm(), false);\n-\n- page_params.is_guest = true;\n- page_params.realm_invite_to_realm_policy = settings_config.common_policy_values.by_members.code;\n- assert.equal(can_invite_others_to_realm(), false);\n-\n- page_params.is_guest = false;\n- assert.equal(can_invite_others_to_realm(), true);\n-\n- page_params.realm_invite_to_realm_policy =\n- settings_config.common_policy_values.by_full_members.code;\n- page_params.user_id = 30;\n- people.add_active_user(isaac);\n- isaac.date_joined = new Date(Date.now());\n- page_params.realm_waiting_period_threshold = 10;\n- assert.equal(can_invite_others_to_realm(), false);\n-\n- isaac.date_joined = new Date(Date.now() - 20 * 86400000);\n- assert.equal(can_invite_others_to_realm(), true);\n-});\n-\n-run_test(\"user_can_subscribe_other_users\", () => {\n- const can_subscribe_other_users = settings_data.user_can_subscribe_other_users;\n-\n- page_params.is_admin = true;\n- page_params.realm_invite_to_stream_policy =\n- settings_config.common_policy_values.by_admins_only.code;\n- assert.equal(can_subscribe_other_users(), true);\n-\n- page_params.is_admin = false;\n- assert.equal(can_subscribe_other_users(), false);\n-\n- page_params.is_moderator = true;\n- page_params.realm_invite_to_stream_policy =\n- settings_config.common_policy_values.by_moderators_only.code;\n- assert.equal(can_subscribe_other_users(), true);\n-\n- page_params.is_moderator = false;\n- assert.equal(can_subscribe_other_users(), false);\n-\n- page_params.is_guest = true;\n- page_params.realm_invite_to_stream_policy =\n- settings_config.common_policy_values.by_members.code;\n- assert.equal(can_subscribe_other_users(), false);\n-\n- page_params.is_guest = false;\n- assert.equal(can_subscribe_other_users(), true);\n-\n- page_params.realm_invite_to_stream_policy =\n- settings_config.common_policy_values.by_full_members.code;\n- page_params.user_id = 30;\n- people.add_active_user(isaac);\n- isaac.date_joined = new Date(Date.now());\n- page_params.realm_waiting_period_threshold = 10;\n- assert.equal(can_subscribe_other_users(), false);\n-\n- isaac.date_joined = new Date(Date.now() - 20 * 86400000);\n- assert.equal(can_subscribe_other_users(), true);\n-});\n-\n-run_test(\"user_can_create_streams\", () => {\n- const can_create_streams = settings_data.user_can_create_streams;\n-\n- page_params.is_admin = true;\n- page_params.realm_create_stream_policy =\n- settings_config.common_policy_values.by_admins_only.code;\n- assert.equal(can_create_streams(), true);\n-\n- page_params.is_admin = false;\n- assert.equal(can_create_streams(), false);\n-\n- page_params.is_moderator = true;\n- page_params.realm_create_stream_policy =\n- settings_config.common_policy_values.by_moderators_only.code;\n- assert.equal(can_create_streams(), true);\n-\n- page_params.is_moderator = false;\n- assert.equal(can_create_streams(), false);\n-\n- page_params.is_guest = true;\n- page_params.realm_create_stream_policy = settings_config.common_policy_values.by_members.code;\n- assert.equal(can_create_streams(), false);\n-\n- page_params.is_guest = false;\n- assert.equal(can_create_streams(), true);\n-\n- page_params.realm_create_stream_policy =\n- settings_config.common_policy_values.by_full_members.code;\n- page_params.user_id = 30;\n- people.add_active_user(isaac);\n- isaac.date_joined = new Date(Date.now());\n- page_params.realm_waiting_period_threshold = 10;\n- assert.equal(can_create_streams(), false);\n-\n- isaac.date_joined = new Date(Date.now() - 20 * 86400000);\n- assert.equal(can_create_streams(), true);\n-});\n+function test_policy(label, policy, validation_func) {\n+ run_test(label, () => {\n+ page_params.is_admin = true;\n+ page_params[policy] = settings_config.common_policy_values.by_admins_only.code;\n+ assert.equal(validation_func(), true);\n+\n+ page_params.is_admin = false;\n+ assert.equal(validation_func(), false);\n+\n+ page_params.is_moderator = true;\n+ page_params[policy] = settings_config.common_policy_values.by_moderators_only.code;\n+ assert.equal(validation_func(), true);\n+\n+ page_params.is_moderator = false;\n+ assert.equal(validation_func(), false);\n+\n+ page_params.is_guest = true;\n+ page_params[policy] = settings_config.common_policy_values.by_members.code;\n+ assert.equal(validation_func(), false);\n+\n+ page_params.is_guest = false;\n+ assert.equal(validation_func(), true);\n+\n+ page_params[policy] = settings_config.common_policy_values.by_full_members.code;\n+ page_params.user_id = 30;\n+ people.add_active_user(isaac);\n+ isaac.date_joined = new Date(Date.now());\n+ page_params.realm_waiting_period_threshold = 10;\n+ assert.equal(validation_func(), false);\n+\n+ isaac.date_joined = new Date(Date.now() - 20 * 86400000);\n+ assert.equal(validation_func(), true);\n+ });\n+}\n+\n+test_policy(\n+ \"user_can_create_streams\",\n+ \"realm_create_stream_policy\",\n+ settings_data.user_can_create_streams,\n+);\n+test_policy(\n+ \"user_can_subscribe_other_users\",\n+ \"realm_invite_to_stream_policy\",\n+ settings_data.user_can_subscribe_other_users,\n+);\n+test_policy(\n+ \"user_can_invite_others_to_realm\",\n+ \"realm_invite_to_realm_policy\",\n+ settings_data.user_can_invite_others_to_realm,\n+);\n+test_policy(\n+ \"user_can_move_messages_between_streams\",\n+ \"realm_move_messages_between_streams_policy\",\n+ settings_data.user_can_move_messages_between_streams,\n+);\ndiff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.py\n--- a/zerver/tests/test_message_edit.py\n+++ b/zerver/tests/test_message_edit.py\n@@ -1,6 +1,6 @@\n import datetime\n from operator import itemgetter\n-from typing import Any, Dict, List, Tuple\n+from typing import Any, Dict, List, Optional, Tuple\n from unittest import mock\n \n import orjson\n@@ -8,6 +8,8 @@\n from django.http import HttpResponse\n \n from zerver.lib.actions import (\n+ do_change_stream_post_policy,\n+ do_change_user_role,\n do_set_realm_property,\n do_update_message,\n get_topic_messages,\n@@ -17,7 +19,7 @@\n from zerver.lib.test_classes import ZulipTestCase\n from zerver.lib.test_helpers import cache_tries_captured, queries_captured\n from zerver.lib.topic import LEGACY_PREV_TOPIC, TOPIC_NAME\n-from zerver.models import Message, Stream, UserMessage, UserProfile, get_realm, get_stream\n+from zerver.models import Message, Realm, Stream, UserMessage, UserProfile, get_realm, get_stream\n \n \n class EditMessageTest(ZulipTestCase):\n@@ -1214,6 +1216,58 @@ def test_move_message_realm_admin_cant_move_from_private_stream_without_subscrip\n \"You don't have permission to move this message due to missing access to its stream\",\n )\n \n+ def test_move_message_from_private_stream_message_access_checks(\n+ self,\n+ ) -> None:\n+ hamlet = self.example_user(\"hamlet\")\n+ user_profile = self.example_user(\"iago\")\n+ self.assertEqual(user_profile.role, UserProfile.ROLE_REALM_ADMINISTRATOR)\n+ self.login(\"iago\")\n+\n+ private_stream = self.make_stream(\n+ \"privatestream\", invite_only=True, history_public_to_subscribers=False\n+ )\n+ self.subscribe(hamlet, \"privatestream\")\n+ original_msg_id = self.send_stream_message(hamlet, \"privatestream\", topic_name=\"test123\")\n+ self.subscribe(user_profile, \"privatestream\")\n+ new_msg_id = self.send_stream_message(user_profile, \"privatestream\", topic_name=\"test123\")\n+\n+ # Now we unsub and hamlet sends a new message (we won't have access to it even after re-subbing!)\n+ self.unsubscribe(user_profile, \"privatestream\")\n+ new_inaccessible_msg_id = self.send_stream_message(\n+ hamlet, \"privatestream\", topic_name=\"test123\"\n+ )\n+\n+ # Re-subscribe and send another message:\n+ self.subscribe(user_profile, \"privatestream\")\n+ newest_msg_id = self.send_stream_message(\n+ user_profile, \"privatestream\", topic_name=\"test123\"\n+ )\n+\n+ verona = get_stream(\"Verona\", user_profile.realm)\n+\n+ result = self.client_patch(\n+ \"/json/messages/\" + str(new_msg_id),\n+ {\n+ \"message_id\": new_msg_id,\n+ \"stream_id\": verona.id,\n+ \"propagate_mode\": \"change_all\",\n+ },\n+ )\n+\n+ self.assert_json_success(result)\n+ self.assertEqual(Message.objects.get(id=new_msg_id).recipient_id, verona.recipient_id)\n+ self.assertEqual(Message.objects.get(id=newest_msg_id).recipient_id, verona.recipient_id)\n+ # The original message and the new, inaccessible message weren't moved,\n+ # because user_profile doesn't have access to them.\n+ self.assertEqual(\n+ Message.objects.get(id=original_msg_id).recipient_id, private_stream.recipient_id\n+ )\n+ self.assertEqual(\n+ Message.objects.get(id=new_inaccessible_msg_id).recipient_id,\n+ private_stream.recipient_id,\n+ )\n+\n def test_move_message_cant_move_private_message(\n self,\n ) -> None:\n@@ -1268,26 +1322,174 @@ def test_move_message_to_stream_change_later(self) -> None:\n f\"This topic was moved here from #**test move stream>test** by @_**Iago|{user_profile.id}**\",\n )\n \n- def test_move_message_to_stream_no_allowed(self) -> None:\n+ def test_move_message_between_streams_policy_setting(self) -> None:\n (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(\n- \"aaron\", \"test move stream\", \"new stream\", \"test\"\n+ \"othello\", \"old_stream_1\", \"new_stream_1\", \"test\"\n )\n \n- result = self.client_patch(\n- \"/json/messages/\" + str(msg_id),\n- {\n- \"message_id\": msg_id,\n- \"stream_id\": new_stream.id,\n- \"propagate_mode\": \"change_all\",\n- },\n+ def check_move_message_according_to_policy(role: int, expect_fail: bool = False) -> None:\n+ do_change_user_role(user_profile, role, acting_user=None)\n+\n+ result = self.client_patch(\n+ \"/json/messages/\" + str(msg_id),\n+ {\n+ \"message_id\": msg_id,\n+ \"stream_id\": new_stream.id,\n+ \"propagate_mode\": \"change_all\",\n+ },\n+ )\n+\n+ if expect_fail:\n+ self.assert_json_error(result, \"You don't have permission to move this message\")\n+ messages = get_topic_messages(user_profile, old_stream, \"test\")\n+ self.assertEqual(len(messages), 3)\n+ messages = get_topic_messages(user_profile, new_stream, \"test\")\n+ self.assertEqual(len(messages), 0)\n+ else:\n+ self.assert_json_success(result)\n+ messages = get_topic_messages(user_profile, old_stream, \"test\")\n+ self.assertEqual(len(messages), 1)\n+ messages = get_topic_messages(user_profile, new_stream, \"test\")\n+ self.assertEqual(len(messages), 4)\n+\n+ # Check sending messages when policy is Realm.POLICY_ADMINS_ONLY.\n+ do_set_realm_property(\n+ user_profile.realm,\n+ \"move_messages_between_streams_policy\",\n+ Realm.POLICY_ADMINS_ONLY,\n+ acting_user=None,\n+ )\n+ check_move_message_according_to_policy(UserProfile.ROLE_MODERATOR, expect_fail=True)\n+ check_move_message_according_to_policy(UserProfile.ROLE_REALM_ADMINISTRATOR)\n+\n+ (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(\n+ \"othello\", \"old_stream_2\", \"new_stream_2\", \"test\"\n+ )\n+ # Check sending messages when policy is Realm.POLICY_MODERATORS_ONLY.\n+ do_set_realm_property(\n+ user_profile.realm,\n+ \"move_messages_between_streams_policy\",\n+ Realm.POLICY_MODERATORS_ONLY,\n+ acting_user=None,\n )\n- self.assert_json_error(result, \"You don't have permission to move this message\")\n+ check_move_message_according_to_policy(UserProfile.ROLE_MEMBER, expect_fail=True)\n+ check_move_message_according_to_policy(UserProfile.ROLE_MODERATOR)\n \n- messages = get_topic_messages(user_profile, old_stream, \"test\")\n- self.assertEqual(len(messages), 3)\n+ (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(\n+ \"othello\", \"old_stream_3\", \"new_stream_3\", \"test\"\n+ )\n+ # Check sending messages when policy is Realm.POLICY_FULL_MEMBERS_ONLY.\n+ do_set_realm_property(\n+ user_profile.realm,\n+ \"move_messages_between_streams_policy\",\n+ Realm.POLICY_FULL_MEMBERS_ONLY,\n+ acting_user=None,\n+ )\n+ do_set_realm_property(\n+ user_profile.realm, \"waiting_period_threshold\", 100000, acting_user=None\n+ )\n+ check_move_message_according_to_policy(UserProfile.ROLE_MEMBER, expect_fail=True)\n \n- messages = get_topic_messages(user_profile, new_stream, \"test\")\n- self.assertEqual(len(messages), 0)\n+ do_set_realm_property(user_profile.realm, \"waiting_period_threshold\", 0, acting_user=None)\n+ check_move_message_according_to_policy(UserProfile.ROLE_MEMBER)\n+\n+ (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(\n+ \"othello\", \"old_stream_4\", \"new_stream_4\", \"test\"\n+ )\n+ # Check sending messages when policy is Realm.POLICY_MEMBERS_ONLY.\n+ do_set_realm_property(\n+ user_profile.realm,\n+ \"move_messages_between_streams_policy\",\n+ Realm.POLICY_MEMBERS_ONLY,\n+ acting_user=None,\n+ )\n+ check_move_message_according_to_policy(UserProfile.ROLE_GUEST, expect_fail=True)\n+ check_move_message_according_to_policy(UserProfile.ROLE_MEMBER)\n+\n+ def test_move_message_to_stream_based_on_stream_post_policy(self) -> None:\n+ (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(\n+ \"othello\", \"old_stream_1\", \"new_stream_1\", \"test\"\n+ )\n+ do_set_realm_property(\n+ user_profile.realm,\n+ \"move_messages_between_streams_policy\",\n+ Realm.POLICY_MEMBERS_ONLY,\n+ acting_user=None,\n+ )\n+\n+ def check_move_message_to_stream(role: int, error_msg: Optional[str] = None) -> None:\n+ do_change_user_role(user_profile, role, acting_user=None)\n+\n+ result = self.client_patch(\n+ \"/json/messages/\" + str(msg_id),\n+ {\n+ \"message_id\": msg_id,\n+ \"stream_id\": new_stream.id,\n+ \"propagate_mode\": \"change_all\",\n+ },\n+ )\n+\n+ if error_msg is not None:\n+ self.assert_json_error(result, error_msg)\n+ messages = get_topic_messages(user_profile, old_stream, \"test\")\n+ self.assertEqual(len(messages), 3)\n+ messages = get_topic_messages(user_profile, new_stream, \"test\")\n+ self.assertEqual(len(messages), 0)\n+ else:\n+ self.assert_json_success(result)\n+ messages = get_topic_messages(user_profile, old_stream, \"test\")\n+ self.assertEqual(len(messages), 1)\n+ messages = get_topic_messages(user_profile, new_stream, \"test\")\n+ self.assertEqual(len(messages), 4)\n+\n+ # Check when stream_post_policy is STREAM_POST_POLICY_ADMINS.\n+ do_change_stream_post_policy(new_stream, Stream.STREAM_POST_POLICY_ADMINS)\n+ error_msg = \"Only organization administrators can send to this stream.\"\n+ check_move_message_to_stream(UserProfile.ROLE_MODERATOR, error_msg)\n+ check_move_message_to_stream(UserProfile.ROLE_REALM_ADMINISTRATOR)\n+\n+ (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(\n+ \"othello\", \"old_stream_2\", \"new_stream_2\", \"test\"\n+ )\n+\n+ # Check when stream_post_policy is STREAM_POST_POLICY_MODERATORS.\n+ do_change_stream_post_policy(new_stream, Stream.STREAM_POST_POLICY_MODERATORS)\n+ error_msg = \"Only organization administrators and moderators can send to this stream.\"\n+ check_move_message_to_stream(UserProfile.ROLE_MEMBER, error_msg)\n+ check_move_message_to_stream(UserProfile.ROLE_MODERATOR)\n+\n+ (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(\n+ \"othello\", \"old_stream_3\", \"new_stream_3\", \"test\"\n+ )\n+\n+ # Check when stream_post_policy is STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS.\n+ do_change_stream_post_policy(new_stream, Stream.STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS)\n+ error_msg = \"New members cannot send to this stream.\"\n+\n+ do_set_realm_property(\n+ user_profile.realm, \"waiting_period_threshold\", 100000, acting_user=None\n+ )\n+ check_move_message_to_stream(UserProfile.ROLE_MEMBER, error_msg)\n+\n+ do_set_realm_property(user_profile.realm, \"waiting_period_threshold\", 0, acting_user=None)\n+ check_move_message_to_stream(UserProfile.ROLE_MEMBER)\n+\n+ (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(\n+ \"othello\", \"old_stream_4\", \"new_stream_4\", \"test\"\n+ )\n+\n+ # Check when stream_post_policy is STREAM_POST_POLICY_EVERYONE.\n+ # In this case also, guest is not allowed as we do not allow guest to move\n+ # messages between streams in any case, so stream_post_policy of new stream does\n+ # not matter.\n+ do_change_stream_post_policy(new_stream, Stream.STREAM_POST_POLICY_EVERYONE)\n+ do_set_realm_property(\n+ user_profile.realm, \"waiting_period_threshold\", 100000, acting_user=None\n+ )\n+ check_move_message_to_stream(\n+ UserProfile.ROLE_GUEST, \"You don't have permission to move this message\"\n+ )\n+ check_move_message_to_stream(UserProfile.ROLE_MEMBER)\n \n def test_move_message_to_stream_with_content(self) -> None:\n (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(\n"},"problem_statement":{"kind":"string","value":"Relax restrictions on moving messages to other streams\nFollowing #6427 and #14498, we should be able to make the feature to move messages to new streams more accessible. There's several directions I'd except this to take:\r\n\r\n* [x] Allowing administrators (eventually perhaps stream owners) to move messages to-and-from private streams. We'll need to take some care about how to do the announcement messages about these moves (From a security perspective, it perhaps should say \"To a private stream\" or \"From a private stream\" in automated the tombstone messages, rather than naming which stream it went to? Not sure.)\r\n* [ ] Allowing non-administrators to use this feature. I'm guessing we'd extend the options for \"who can edit message topics\" to include values for who can move messages between streams.\r\n* [x] Offering the option to move a topic to another stream in the main message-edit UI on a message (#13912 primarily implements an out-of-band version right now).\r\n\r\nAt the moment, I'd like to use this issue thread for feedback on what the semantics/options for this feature should be.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-message-view members, this issue was labeled with the \"area: message-editing\" label, so you may want to check it out!\n\n\nComment on 1)\r\n\r\nI don't see a need for special care here:\r\nIf a topic is moved from a private stream to a public one its content is anyway becoming public so why hide where this content came from? Same the other way around: If a topic was public before, i.e. everybody has seen it anyway, what's the point in hiding this fact once it's available only to a subset of those same people?\nComment on 2)\r\n\r\nIt would indeed be nice to allow administrators to decide whether normal users can use this feature or not. I could imagine some users are less careless/knowledgeable and might move topics by accident, not knowing the implications. Some administrators may decide to educate their users but others may want to simply disable the functionality altogether/keep it in their hands.\n> If a topic is moved from a private stream to a public one its content is anyway becoming public so why hide where this content came from? Same the other way around: If a topic was public before, i.e. everybody has seen it anyway, what's the point in hiding this fact once it's available only to a subset of those same people?\r\n\r\n@andreas-bulling - just because the content of a message is public doesn't mean that you'd want to make the name of a private stream public. I think the \"to/from a private stream\" approach in the tombstones makes sense- it minimizes information leakage.\nI agree that the scenario \"name of a topic is more private than its content\" is possible in theory - but highly unlikely in practice I think (we are talking about moving a private topic to a public one, just to be on the same page. Moving from public to private is not critical I believe we can easily agree). \r\n\r\nThe question is whether this arguably small likelihood of practical relevance warrants making the UI more complex but this is not up to me to decide. I simply think few people will ever use this feature so as a user I'd prefer a leaner UI.\nAnother idea would be to make the tombstones optional (with a checkbox for whether to create tombstone messages or not). I think there are cases where the topic only has one message that's a quick question and the tombstones might feel like excessive overhead (Or where someone is doing an administrative merge of two streams). \r\n\r\nI think making the tombstone messages say \"from a private stream\" would be reasonable.\nI've been looking through the pull requests a bit.\r\nHow far is the implementation of this feature? Especially 1) would be very helpful for a workflow we're trying to build up right now.\r\n\r\nTo give a bit of feedback on the ideas: I think the newest idea (by tim) summarizes this the best: Tombstones should be optional and having them say \"from/to a private stream\" seems like a good idea to prevent the potential leaking of confidential information\nThis issue is a bit out of date; we've already implemented making the tombstones optional in the 3.0 release. Though we haven't added the \"to a private stream\" text change.\r\n\r\nThe much more complicated issue involves UserMessage objects (which track which users actually received the message, and is used in private streams without shared history to determine which users should have access to which messages). A wrong implementation would be the naive one that preserves those objects; the end result would be that users who were on the public stream when messages were sent could still access them via the API even though they were moved to a private stream (because they'd still be part of that user's private history). We resolved the analog of that issue for guest users in 3.0, but need to resolve the similar issue for private streams. \r\n\r\nI think given the work we've already done, doing the groundwork to allow moving messages TO private streams won't actually be very hard; @amanagr are you up for making this happen?\r\n\r\n(And then we can think about the FROM side as well -- that is simpler in many ways assuming we're OK with the security implications)\r\n\r\n\r\n\nSure! I will try to pick this up soon.\nAny new developments on this?\n@Lithimlin thanks for pinging on this issue, I can try some positive work done on it this week, seems simple enough.\nThis private stream feature was implemented via https://github.com/zulip/zulip/issues/16284. I think the last bit of this will likely be that we'll include stream administrators in who can move messages between streams. \nCan this be used to rename a topic as well?"},"created_at":{"kind":"timestamp","value":"2021-04-08T19:56:07","string":"2021-04-08T19:56:07"}}},{"rowIdx":660,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18054,"string":"18,054"},"instance_id":{"kind":"string","value":"zulip__zulip-18054"},"issue_numbers":{"kind":"list like","value":["17969"],"string":"[\n \"17969\"\n]"},"base_commit":{"kind":"string","value":"f71b591f95c3883550adef090068d5523ab13cdf"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py\n--- a/zerver/lib/integrations.py\n+++ b/zerver/lib/integrations.py\n@@ -398,6 +398,7 @@ def __init__(self, name: str, *args: Any, **kwargs: Any) -> None:\n WebhookIntegration(\"intercom\", [\"customer-support\"], display_name=\"Intercom\"),\n WebhookIntegration(\"jira\", [\"project-management\"], display_name=\"JIRA\"),\n WebhookIntegration(\"jotform\", [\"misc\"], display_name=\"Jotform\"),\n+ WebhookIntegration(\"json\", [\"misc\"], display_name=\"JSON formatter\"),\n WebhookIntegration(\"librato\", [\"monitoring\"]),\n WebhookIntegration(\"mention\", [\"marketing\"], display_name=\"Mention\"),\n WebhookIntegration(\"netlify\", [\"continuous-integration\", \"deployment\"], display_name=\"Netlify\"),\n@@ -730,6 +731,7 @@ def __init__(self, name: str, *args: Any, **kwargs: Any) -> None:\n \"intercom\": [ScreenshotConfig(\"conversation_admin_replied.json\")],\n \"jira\": [ScreenshotConfig(\"created_v1.json\")],\n \"jotform\": [ScreenshotConfig(\"response.json\")],\n+ \"json\": [ScreenshotConfig(\"json_github_push__1_commit.json\")],\n \"librato\": [ScreenshotConfig(\"three_conditions_alert.json\", payload_as_query_param=True)],\n \"mention\": [ScreenshotConfig(\"webfeeds.json\")],\n \"netlify\": [ScreenshotConfig(\"deploy_building.json\")],\ndiff --git a/zerver/webhooks/json/__init__.py b/zerver/webhooks/json/__init__.py\nnew file mode 100644\ndiff --git a/zerver/webhooks/json/view.py b/zerver/webhooks/json/view.py\nnew file mode 100644\n--- /dev/null\n+++ b/zerver/webhooks/json/view.py\n@@ -0,0 +1,39 @@\n+import json\n+from typing import Any, Dict\n+\n+from django.http import HttpRequest, HttpResponse\n+\n+from zerver.decorator import REQ, has_request_variables, webhook_view\n+from zerver.lib.response import json_success\n+from zerver.lib.webhooks.common import check_send_webhook_message\n+from zerver.models import UserProfile\n+\n+JSON_MESSAGE_TEMPLATE = \"\"\"\n+```json\n+{webhook_payload}\n+```\n+\"\"\".strip()\n+\n+\n+@webhook_view(\"JSON\")\n+@has_request_variables\n+def api_json_webhook(\n+ request: HttpRequest,\n+ user_profile: UserProfile,\n+ payload: Dict[str, Any] = REQ(argument_type=\"body\"),\n+) -> HttpResponse:\n+\n+ body = get_body_for_http_request(payload)\n+ subject = get_subject_for_http_request(payload)\n+\n+ check_send_webhook_message(request, user_profile, subject, body)\n+ return json_success()\n+\n+\n+def get_subject_for_http_request(payload: Dict[str, Any]) -> str:\n+ return \"JSON\"\n+\n+\n+def get_body_for_http_request(payload: Dict[str, Any]) -> str:\n+ prettypayload = json.dumps(payload, indent=2)\n+ return JSON_MESSAGE_TEMPLATE.format(webhook_payload=prettypayload, sort_keys=True)\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/webhooks/json/tests.py b/zerver/webhooks/json/tests.py\nnew file mode 100644\n--- /dev/null\n+++ b/zerver/webhooks/json/tests.py\n@@ -0,0 +1,54 @@\n+import json\n+\n+from zerver.lib.test_classes import WebhookTestCase\n+\n+\n+class JsonHookTests(WebhookTestCase):\n+ STREAM_NAME = \"json\"\n+ URL_TEMPLATE = \"/api/v1/external/json?api_key={api_key}&stream={stream}\"\n+ FIXTURE_DIR_NAME = \"json\"\n+\n+ def test_json_github_push__1_commit_message(self) -> None:\n+ \"\"\"\n+ Tests if json github push 1 commit is handled correctly\n+ \"\"\"\n+ with open(\"zerver/webhooks/json/fixtures/json_github_push__1_commit.json\") as f:\n+ original_fixture = json.load(f)\n+\n+ expected_topic = \"JSON\"\n+ expected_message = \"\"\"```json\n+{original_fixture}\n+```\"\"\".format(\n+ original_fixture=json.dumps(original_fixture, indent=2)\n+ )\n+ self.check_webhook(\"json_github_push__1_commit\", expected_topic, expected_message)\n+\n+ def test_json_pingdom_http_up_to_down_message(self) -> None:\n+ \"\"\"\n+ Tests if json pingdom http up to down is handled correctly\n+ \"\"\"\n+ with open(\"zerver/webhooks/json/fixtures/json_pingdom_http_up_to_down.json\") as f:\n+ original_fixture = json.load(f)\n+\n+ expected_topic = \"JSON\"\n+ expected_message = \"\"\"```json\n+{original_fixture}\n+```\"\"\".format(\n+ original_fixture=json.dumps(original_fixture, indent=2)\n+ )\n+ self.check_webhook(\"json_pingdom_http_up_to_down\", expected_topic, expected_message)\n+\n+ def test_json_sentry_event_for_exception_js_message(self) -> None:\n+ \"\"\"\n+ Tests if json sentry event for exception js is handled correctly\n+ \"\"\"\n+ with open(\"zerver/webhooks/json/fixtures/json_sentry_event_for_exception_js.json\") as f:\n+ original_fixture = json.load(f)\n+\n+ expected_topic = \"JSON\"\n+ expected_message = \"\"\"```json\n+{original_fixture}\n+```\"\"\".format(\n+ original_fixture=json.dumps(original_fixture, indent=2)\n+ )\n+ self.check_webhook(\"json_sentry_event_for_exception_js\", expected_topic, expected_message)\n"},"problem_statement":{"kind":"string","value":"Create Integration for Json Printing any Webhook Payload\nCreate Integration for JSON Printing any Webhook Payload\r\n\r\nUseful for webhook testing\r\n\r\nhttps://chat.zulip.org/#narrow/stream/127-integrations/topic/webhook.20testing\n"},"hints_text":{"kind":"string","value":"@zulipbot claim\n@zulipbot add \"area: integrations\"\nHello @zulip/server-integrations members, this issue was labeled with the \"area: integrations\" label, so you may want to check it out!\n\n"},"created_at":{"kind":"timestamp","value":"2021-04-09T01:53:28","string":"2021-04-09T01:53:28"}}},{"rowIdx":661,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18065,"string":"18,065"},"instance_id":{"kind":"string","value":"zulip__zulip-18065"},"issue_numbers":{"kind":"list like","value":["17928"],"string":"[\n \"17928\"\n]"},"base_commit":{"kind":"string","value":"d31f01bd0f033fcc7c923ba44993b1da19fc6e47"},"patch":{"kind":"string","value":"diff --git a/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py b/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py\n--- a/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py\n+++ b/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py\n@@ -2,6 +2,7 @@\n import os\n import re\n from typing import Callable, Iterator, List, Optional, Union\n+from urllib.parse import urlparse\n \n import scrapy\n from scrapy.http import Request, Response\n@@ -11,6 +12,15 @@\n from scrapy.utils.url import url_has_any_extension\n from twisted.python.failure import Failure\n \n+EXCLUDED_DOMAINS = [\n+ # Returns 429 Rate-Limited Errors\n+ \"github.com\",\n+ \"gist.github.com\",\n+ # Returns 503 Errors\n+ \"www.amazon.com\",\n+ \"gitlab.com\",\n+]\n+\n EXCLUDED_URLS = [\n # Google calendar returns 404s on HEAD requests unconditionally\n \"https://calendar.google.com/calendar/embed?src=ktiduof4eoh47lmgcl2qunnc0o@group.calendar.google.com\",\n@@ -19,6 +29,8 @@\n # Returns 404 to HEAD requests unconditionally\n \"https://www.git-tower.com/blog/command-line-cheat-sheet/\",\n \"https://marketplace.visualstudio.com/items?itemName=rafaelmaiolla.remote-vscode\",\n+ \"https://www.transifex.com/zulip/zulip/announcements/\",\n+ \"https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh\",\n # Requires authentication\n \"https://circleci.com/gh/zulip/zulip/tree/master\",\n \"https://circleci.com/gh/zulip/zulip/16617\",\n@@ -164,6 +176,10 @@ def _make_requests(self, url: str) -> Iterator[Request]:\n callback = self.check_fragment\n if getattr(self, \"skip_external\", False) and self._is_external_link(url):\n return\n+ if urlparse(url).netloc in EXCLUDED_DOMAINS:\n+ return\n+ if url in EXCLUDED_URLS:\n+ return\n yield Request(\n url,\n method=method,\n@@ -204,13 +220,12 @@ def retry_request_with_get(self, request: Request) -> Iterator[Request]:\n request.dont_filter = True\n yield request\n \n- def exclude_error(self, url: str) -> bool:\n- return url in EXCLUDED_URLS\n-\n def error_callback(self, failure: Failure) -> Optional[Union[Failure, Iterator[Request]]]:\n if isinstance(failure.value, HttpError):\n response = failure.value.response\n- if self.exclude_error(response.url):\n+ # Hack: The filtering above does not catch this URL,\n+ # likely due to a redirect.\n+ if urlparse(response.url).netloc == \"idmsa.apple.com\":\n return None\n if response.status == 405 and response.request.method == \"HEAD\":\n # Method 'HEAD' not allowed, repeat request with 'GET'\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"test-documentation: Fix output spam from external links\nCurrently, test-documentation run in a development environment (i.e. without `--skip-external-links`) prints like 2 screenfuls of errors like this:\r\n```\r\n2021-04-01 10:20:38 [documentation_crawler] ERROR: Please check link: https://github.com/zulip/zulip/commit/49dbd85a8985b12666087f9ea36acb6f7da0aa4f\r\n2021-04-01 10:20:38 [documentation_crawler] ERROR: Please check link: https://github.com/zulip/zulip-desktop\r\n2021-04-01 10:20:38 [documentation_crawler] ERROR: Please check link: https://github.com/zulip/zulip/issues/10976\r\n```\r\n\r\nI imagine this is really confusing for anyone new to our ReadTheDocs documentation.\r\n\r\nMost of these are 429 errors because GitHub doesn't want automation hitting their servers all the time; we could probably just suppress most of them that fit a pattern that we expect to be statically correct (E.g. anything in github.com/zulip/ that is not a tree path).\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-tooling, @zulip/server-user-docs members, this issue was labeled with the \"area: documentation (user)\", \"area: tooling\" labels, so you may want to check it out!\n\n\n@zulipbot claim"},"created_at":{"kind":"timestamp","value":"2021-04-09T17:43:28","string":"2021-04-09T17:43:28"}}},{"rowIdx":662,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18082,"string":"18,082"},"instance_id":{"kind":"string","value":"zulip__zulip-18082"},"issue_numbers":{"kind":"list like","value":["18022"],"string":"[\n \"18022\"\n]"},"base_commit":{"kind":"string","value":"1288dcbaafcad06307357172e3de37e06edc52a5"},"patch":{"kind":"string","value":"diff --git a/zerver/webhooks/clubhouse/view.py b/zerver/webhooks/clubhouse/view.py\n--- a/zerver/webhooks/clubhouse/view.py\n+++ b/zerver/webhooks/clubhouse/view.py\n@@ -1,5 +1,5 @@\n from functools import partial\n-from typing import Any, Callable, Dict, Optional\n+from typing import Any, Callable, Dict, Generator, List, Optional\n \n from django.http import HttpRequest, HttpResponse\n \n@@ -30,20 +30,22 @@\n \"The name of the {entity} {name_template} was changed from:\\n\"\n \"``` quote\\n{old}\\n```\\nto\\n``` quote\\n{new}\\n```\"\n )\n-ARCHIVED_TEMPLATE = \"The {entity} {name_template} was {action}.\"\n-STORY_TASK_TEMPLATE = \"Task **{task_description}** was {action} the story {name_template}.\"\n+ARCHIVED_TEMPLATE = \"The {entity} {name_template} was {operation}.\"\n+STORY_TASK_TEMPLATE = \"Task **{task_description}** was {operation} the story {name_template}.\"\n STORY_TASK_COMPLETED_TEMPLATE = (\n \"Task **{task_description}** ({name_template}) was completed. :tada:\"\n )\n STORY_ADDED_REMOVED_EPIC_TEMPLATE = (\n- \"The story {story_name_template} was {action} the epic {epic_name_template}.\"\n+ \"The story {story_name_template} was {operation} the epic {epic_name_template}.\"\n )\n STORY_EPIC_CHANGED_TEMPLATE = \"The story {story_name_template} was moved from {old_epic_name_template} to {new_epic_name_template}.\"\n STORY_ESTIMATE_TEMPLATE = \"The estimate for the story {story_name_template} was set to {estimate}.\"\n FILE_ATTACHMENT_TEMPLATE = (\n \"A {type} attachment `{file_name}` was added to the story {name_template}.\"\n )\n-STORY_LABEL_TEMPLATE = \"The label **{label_name}** was added to the story {name_template}.\"\n+LABEL_TEMPLATE = \"**{name}**\"\n+STORY_LABEL_TEMPLATE = \"The label {labels} was added to the story {name_template}.\"\n+STORY_LABEL_PLURAL_TEMPLATE = \"The labels {labels} were added to the story {name_template}.\"\n STORY_UPDATE_PROJECT_TEMPLATE = (\n \"The story {name_template} was moved from the **{old}** project to **{new}**.\"\n )\n@@ -52,12 +54,16 @@\n )\n DELETE_TEMPLATE = \"The {entity_type} **{name}** was deleted.\"\n STORY_UPDATE_OWNER_TEMPLATE = \"New owner added to the story {name_template}.\"\n+TRAILING_WORKFLOW_STATE_CHANGE_TEMPLATE = \" ({old} -> {new})\"\n STORY_GITHUB_PR_TEMPLATE = (\n- \"New GitHub PR [#{name}]({url}) opened for story {name_template} ({old} -> {new}).\"\n-)\n-STORY_GITHUB_BRANCH_TEMPLATE = (\n- \"New GitHub branch [{name}]({url}) associated with story {name_template} ({old} -> {new}).\"\n+ \"New GitHub PR [#{name}]({url}) opened for story {name_template}{workflow_state_template}.\"\n )\n+STORY_GITHUB_COMMENT_PR_TEMPLATE = \"Existing GitHub PR [#{name}]({url}) associated with story {name_template}{workflow_state_template}.\"\n+STORY_GITHUB_BRANCH_TEMPLATE = \"New GitHub branch [{name}]({url}) associated with story {name_template}{workflow_state_template}.\"\n+STORY_UPDATE_BATCH_TEMPLATE = \"The story {name_template} {templates}{workflow_state_template}.\"\n+STORY_UPDATE_BATCH_CHANGED_TEMPLATE = \"{operation} from {sub_templates}\"\n+STORY_UPDATE_BATCH_CHANGED_SUB_TEMPLATE = \"{entity_type} **{old}** to **{new}**\"\n+STORY_UPDATE_BATCH_ADD_REMOVE_TEMPLATE = \"{operation} with {entity}\"\n \n \n def get_action_with_primary_id(payload: Dict[str, Any]) -> Dict[str, Any]:\n@@ -68,10 +74,13 @@ def get_action_with_primary_id(payload: Dict[str, Any]) -> Dict[str, Any]:\n return action_with_primary_id\n \n \n-def get_event(payload: Dict[str, Any]) -> Optional[str]:\n- action = get_action_with_primary_id(payload)\n+def get_event(payload: Dict[str, Any], action: Dict[str, Any]) -> Optional[str]:\n event = \"{}_{}\".format(action[\"entity_type\"], action[\"action\"])\n \n+ # We only consider the change to be a batch update only if there are multiple stories (thus there is no primary_id)\n+ if event == \"story_update\" and payload.get(\"primary_id\") is None:\n+ return \"{}_{}\".format(event, \"batch\")\n+\n if event in IGNORED_EVENTS:\n return None\n \n@@ -107,19 +116,16 @@ def get_event(payload: Dict[str, Any]) -> Optional[str]:\n return event\n \n \n-def get_topic_function_based_on_type(payload: Dict[str, Any]) -> Any:\n- entity_type = get_action_with_primary_id(payload)[\"entity_type\"]\n+def get_topic_function_based_on_type(payload: Dict[str, Any], action: Dict[str, Any]) -> Any:\n+ entity_type = action[\"entity_type\"]\n return EVENT_TOPIC_FUNCTION_MAPPER.get(entity_type)\n \n \n-def get_delete_body(payload: Dict[str, Any]) -> str:\n- action = get_action_with_primary_id(payload)\n+def get_delete_body(payload: Dict[str, Any], action: Dict[str, Any]) -> str:\n return DELETE_TEMPLATE.format(**action)\n \n \n-def get_story_create_body(payload: Dict[str, Any]) -> str:\n- action = get_action_with_primary_id(payload)\n-\n+def get_story_create_body(payload: Dict[str, Any], action: Dict[str, Any]) -> str:\n if action.get(\"epic_id\") is None:\n message = \"New story [{name}]({app_url}) of type **{story_type}** was created.\"\n kwargs = action\n@@ -138,13 +144,12 @@ def get_story_create_body(payload: Dict[str, Any]) -> str:\n return message.format(**kwargs)\n \n \n-def get_epic_create_body(payload: Dict[str, Any]) -> str:\n- action = get_action_with_primary_id(payload)\n+def get_epic_create_body(payload: Dict[str, Any], action: Dict[str, Any]) -> str:\n message = \"New epic **{name}**({state}) was created.\"\n return message.format(**action)\n \n \n-def get_comment_added_body(payload: Dict[str, Any], entity: str) -> str:\n+def get_comment_added_body(payload: Dict[str, Any], action: Dict[str, Any], entity: str) -> str:\n actions = payload[\"actions\"]\n kwargs = {\"entity\": entity}\n for action in actions:\n@@ -160,8 +165,9 @@ def get_comment_added_body(payload: Dict[str, Any], entity: str) -> str:\n return COMMENT_ADDED_TEMPLATE.format(**kwargs)\n \n \n-def get_update_description_body(payload: Dict[str, Any], entity: str) -> str:\n- action = get_action_with_primary_id(payload)\n+def get_update_description_body(\n+ payload: Dict[str, Any], action: Dict[str, Any], entity: str\n+) -> str:\n desc = action[\"changes\"][\"description\"]\n \n kwargs = {\n@@ -184,8 +190,7 @@ def get_update_description_body(payload: Dict[str, Any], entity: str) -> str:\n return body\n \n \n-def get_epic_update_state_body(payload: Dict[str, Any]) -> str:\n- action = get_action_with_primary_id(payload)\n+def get_epic_update_state_body(payload: Dict[str, Any], action: Dict[str, Any]) -> str:\n state = action[\"changes\"][\"state\"]\n kwargs = {\n \"entity\": \"epic\",\n@@ -197,8 +202,7 @@ def get_epic_update_state_body(payload: Dict[str, Any]) -> str:\n return STATE_CHANGED_TEMPLATE.format(**kwargs)\n \n \n-def get_story_update_state_body(payload: Dict[str, Any]) -> str:\n- action = get_action_with_primary_id(payload)\n+def get_story_update_state_body(payload: Dict[str, Any], action: Dict[str, Any]) -> str:\n workflow_state_id = action[\"changes\"][\"workflow_state_id\"]\n references = payload[\"references\"]\n \n@@ -222,8 +226,7 @@ def get_story_update_state_body(payload: Dict[str, Any]) -> str:\n return STATE_CHANGED_TEMPLATE.format(**kwargs)\n \n \n-def get_update_name_body(payload: Dict[str, Any], entity: str) -> str:\n- action = get_action_with_primary_id(payload)\n+def get_update_name_body(payload: Dict[str, Any], action: Dict[str, Any], entity: str) -> str:\n name = action[\"changes\"][\"name\"]\n kwargs = {\n \"entity\": entity,\n@@ -238,32 +241,29 @@ def get_update_name_body(payload: Dict[str, Any], entity: str) -> str:\n return NAME_CHANGED_TEMPLATE.format(**kwargs)\n \n \n-def get_update_archived_body(payload: Dict[str, Any], entity: str) -> str:\n- primary_action = get_action_with_primary_id(payload)\n- archived = primary_action[\"changes\"][\"archived\"]\n+def get_update_archived_body(payload: Dict[str, Any], action: Dict[str, Any], entity: str) -> str:\n+ archived = action[\"changes\"][\"archived\"]\n if archived[\"new\"]:\n- action = \"archived\"\n+ operation = \"archived\"\n else:\n- action = \"unarchived\"\n+ operation = \"unarchived\"\n \n kwargs = {\n \"entity\": entity,\n \"name_template\": get_name_template(entity).format(\n- name=primary_action[\"name\"],\n- app_url=primary_action.get(\"app_url\"),\n+ name=action[\"name\"],\n+ app_url=action.get(\"app_url\"),\n ),\n- \"action\": action,\n+ \"operation\": operation,\n }\n \n return ARCHIVED_TEMPLATE.format(**kwargs)\n \n \n-def get_story_task_body(payload: Dict[str, Any], action: str) -> str:\n- primary_action = get_action_with_primary_id(payload)\n-\n+def get_story_task_body(payload: Dict[str, Any], action: Dict[str, Any], operation: str) -> str:\n kwargs = {\n- \"task_description\": primary_action[\"description\"],\n- \"action\": action,\n+ \"task_description\": action[\"description\"],\n+ \"operation\": operation,\n }\n \n for a in payload[\"actions\"]:\n@@ -276,9 +276,7 @@ def get_story_task_body(payload: Dict[str, Any], action: str) -> str:\n return STORY_TASK_TEMPLATE.format(**kwargs)\n \n \n-def get_story_task_completed_body(payload: Dict[str, Any]) -> Optional[str]:\n- action = get_action_with_primary_id(payload)\n-\n+def get_story_task_completed_body(payload: Dict[str, Any], action: Dict[str, Any]) -> Optional[str]:\n kwargs = {\n \"task_description\": action[\"description\"],\n }\n@@ -297,9 +295,7 @@ def get_story_task_completed_body(payload: Dict[str, Any]) -> Optional[str]:\n return None\n \n \n-def get_story_update_epic_body(payload: Dict[str, Any]) -> str:\n- action = get_action_with_primary_id(payload)\n-\n+def get_story_update_epic_body(payload: Dict[str, Any], action: Dict[str, Any]) -> str:\n kwargs = {\n \"story_name_template\": STORY_NAME_TEMPLATE.format(\n name=action[\"name\"],\n@@ -321,17 +317,15 @@ def get_story_update_epic_body(payload: Dict[str, Any]) -> str:\n return STORY_EPIC_CHANGED_TEMPLATE.format(**kwargs)\n elif new_id:\n kwargs[\"epic_name_template\"] = kwargs[\"new_epic_name_template\"]\n- kwargs[\"action\"] = \"added to\"\n+ kwargs[\"operation\"] = \"added to\"\n else:\n kwargs[\"epic_name_template\"] = kwargs[\"old_epic_name_template\"]\n- kwargs[\"action\"] = \"removed from\"\n+ kwargs[\"operation\"] = \"removed from\"\n \n return STORY_ADDED_REMOVED_EPIC_TEMPLATE.format(**kwargs)\n \n \n-def get_story_update_estimate_body(payload: Dict[str, Any]) -> str:\n- action = get_action_with_primary_id(payload)\n-\n+def get_story_update_estimate_body(payload: Dict[str, Any], action: Dict[str, Any]) -> str:\n kwargs = {\n \"story_name_template\": STORY_NAME_TEMPLATE.format(\n name=action[\"name\"],\n@@ -357,36 +351,52 @@ def get_reference_by_id(payload: Dict[str, Any], ref_id: int) -> Dict[str, Any]:\n return ref\n \n \n-def get_story_create_github_entity_body(payload: Dict[str, Any], entity: str) -> str:\n- action = get_action_with_primary_id(payload)\n+def get_secondary_actions_with_param(\n+ payload: Dict[str, Any], entity: str, changed_attr: str\n+) -> Generator[Dict[str, Any], None, None]:\n+ # This function is a generator for secondary actions that have the required changed attributes,\n+ # i.e.: \"story\" that has \"pull-request_ids\" changed.\n+ for action in payload[\"actions\"]:\n+ if action[\"entity_type\"] == entity and action[\"changes\"].get(changed_attr) is not None:\n+ yield action\n \n- story: Dict[str, Any] = {}\n- for a in payload[\"actions\"]:\n- if a[\"entity_type\"] == \"story\" and a[\"changes\"].get(\"workflow_state_id\") is not None:\n- story = a\n \n- new_state_id = story[\"changes\"][\"workflow_state_id\"][\"new\"]\n- old_state_id = story[\"changes\"][\"workflow_state_id\"][\"old\"]\n- new_state = get_reference_by_id(payload, new_state_id)[\"name\"]\n- old_state = get_reference_by_id(payload, old_state_id)[\"name\"]\n+def get_story_create_github_entity_body(\n+ payload: Dict[str, Any], action: Dict[str, Any], entity: str\n+) -> str:\n+ pull_request_action: Dict[str, Any] = get_action_with_primary_id(payload)\n \n kwargs = {\n- \"name_template\": STORY_NAME_TEMPLATE.format(**story),\n- \"name\": action.get(\"number\") if entity == \"pull-request\" else action.get(\"name\"),\n- \"url\": action[\"url\"],\n- \"new\": new_state,\n- \"old\": old_state,\n+ \"name_template\": STORY_NAME_TEMPLATE.format(**action),\n+ \"name\": pull_request_action.get(\"number\")\n+ if entity == \"pull-request\" or entity == \"pull-request-comment\"\n+ else pull_request_action.get(\"name\"),\n+ \"url\": pull_request_action[\"url\"],\n+ \"workflow_state_template\": \"\",\n }\n \n- template = (\n- STORY_GITHUB_PR_TEMPLATE if entity == \"pull-request\" else STORY_GITHUB_BRANCH_TEMPLATE\n- )\n+ # Sometimes the workflow state of the story will not be changed when linking to a PR.\n+ if action[\"changes\"].get(\"workflow_state_id\") is not None:\n+ new_state_id = action[\"changes\"][\"workflow_state_id\"][\"new\"]\n+ old_state_id = action[\"changes\"][\"workflow_state_id\"][\"old\"]\n+ new_state = get_reference_by_id(payload, new_state_id)[\"name\"]\n+ old_state = get_reference_by_id(payload, old_state_id)[\"name\"]\n+ kwargs[\"workflow_state_template\"] = TRAILING_WORKFLOW_STATE_CHANGE_TEMPLATE.format(\n+ new=new_state, old=old_state\n+ )\n+\n+ if entity == \"pull-request\":\n+ template = STORY_GITHUB_PR_TEMPLATE\n+ elif entity == \"pull-request-comment\":\n+ template = STORY_GITHUB_COMMENT_PR_TEMPLATE\n+ else:\n+ template = STORY_GITHUB_BRANCH_TEMPLATE\n return template.format(**kwargs)\n \n \n-def get_story_update_attachment_body(payload: Dict[str, Any]) -> Optional[str]:\n- action = get_action_with_primary_id(payload)\n-\n+def get_story_update_attachment_body(\n+ payload: Dict[str, Any], action: Dict[str, Any]\n+) -> Optional[str]:\n kwargs = {\n \"name_template\": STORY_NAME_TEMPLATE.format(\n name=action[\"name\"],\n@@ -410,9 +420,27 @@ def get_story_update_attachment_body(payload: Dict[str, Any]) -> Optional[str]:\n return FILE_ATTACHMENT_TEMPLATE.format(**kwargs)\n \n \n-def get_story_label_body(payload: Dict[str, Any]) -> Optional[str]:\n- action = get_action_with_primary_id(payload)\n+def get_story_joined_label_list(\n+ payload: Dict[str, Any], action: Dict[str, Any], label_ids_added: List[int]\n+) -> str:\n+ labels = []\n \n+ for label_id in label_ids_added:\n+ label_name = \"\"\n+\n+ for action in payload[\"actions\"]:\n+ if action.get(\"id\") == label_id:\n+ label_name = action.get(\"name\", \"\")\n+\n+ if label_name == \"\":\n+ label_name = get_reference_by_id(payload, label_id).get(\"name\", \"\")\n+\n+ labels.append(LABEL_TEMPLATE.format(name=label_name))\n+\n+ return \", \".join(labels)\n+\n+\n+def get_story_label_body(payload: Dict[str, Any], action: Dict[str, Any]) -> Optional[str]:\n kwargs = {\n \"name_template\": STORY_NAME_TEMPLATE.format(\n name=action[\"name\"],\n@@ -421,29 +449,20 @@ def get_story_label_body(payload: Dict[str, Any]) -> Optional[str]:\n }\n label_ids_added = action[\"changes\"][\"label_ids\"].get(\"adds\")\n \n- # If this is a payload for when a label is removed, ignore it\n+ # If this is a payload for when no label is added, ignore it\n if not label_ids_added:\n return None\n \n- label_id = label_ids_added[0]\n-\n- label_name = \"\"\n- for action in payload[\"actions\"]:\n- if action[\"id\"] == label_id:\n- label_name = action.get(\"name\", \"\")\n-\n- if not label_name:\n- for reference in payload[\"references\"]:\n- if reference[\"id\"] == label_id:\n- label_name = reference.get(\"name\", \"\")\n+ kwargs.update(labels=get_story_joined_label_list(payload, action, label_ids_added))\n \n- kwargs.update(label_name=label_name)\n-\n- return STORY_LABEL_TEMPLATE.format(**kwargs)\n+ return (\n+ STORY_LABEL_TEMPLATE.format(**kwargs)\n+ if len(label_ids_added) == 1\n+ else STORY_LABEL_PLURAL_TEMPLATE.format(**kwargs)\n+ )\n \n \n-def get_story_update_project_body(payload: Dict[str, Any]) -> str:\n- action = get_action_with_primary_id(payload)\n+def get_story_update_project_body(payload: Dict[str, Any], action: Dict[str, Any]) -> str:\n kwargs = {\n \"name_template\": STORY_NAME_TEMPLATE.format(\n name=action[\"name\"],\n@@ -462,8 +481,7 @@ def get_story_update_project_body(payload: Dict[str, Any]) -> str:\n return STORY_UPDATE_PROJECT_TEMPLATE.format(**kwargs)\n \n \n-def get_story_update_type_body(payload: Dict[str, Any]) -> str:\n- action = get_action_with_primary_id(payload)\n+def get_story_update_type_body(payload: Dict[str, Any], action: Dict[str, Any]) -> str:\n kwargs = {\n \"name_template\": STORY_NAME_TEMPLATE.format(\n name=action[\"name\"],\n@@ -476,8 +494,7 @@ def get_story_update_type_body(payload: Dict[str, Any]) -> str:\n return STORY_UPDATE_TYPE_TEMPLATE.format(**kwargs)\n \n \n-def get_story_update_owner_body(payload: Dict[str, Any]) -> str:\n- action = get_action_with_primary_id(payload)\n+def get_story_update_owner_body(payload: Dict[str, Any], action: Dict[str, Any]) -> str:\n kwargs = {\n \"name_template\": STORY_NAME_TEMPLATE.format(\n name=action[\"name\"],\n@@ -488,8 +505,104 @@ def get_story_update_owner_body(payload: Dict[str, Any]) -> str:\n return STORY_UPDATE_OWNER_TEMPLATE.format(**kwargs)\n \n \n-def get_entity_name(payload: Dict[str, Any], entity: Optional[str] = None) -> Optional[str]:\n- action = get_action_with_primary_id(payload)\n+def get_story_update_batch_body(payload: Dict[str, Any], action: Dict[str, Any]) -> Optional[str]:\n+ # When the user selects one or more stories with the checkbox, they can perform\n+ # a batch update on multiple stories while changing multiple attribtues at the\n+ # same time.\n+ changes = action[\"changes\"]\n+ kwargs = {\n+ \"name_template\": STORY_NAME_TEMPLATE.format(\n+ name=action[\"name\"],\n+ app_url=action[\"app_url\"],\n+ ),\n+ \"workflow_state_template\": \"\",\n+ }\n+\n+ templates = []\n+ last_change = \"other\"\n+\n+ move_sub_templates = []\n+ if \"epic_id\" in changes:\n+ last_change = \"epic\"\n+ move_sub_templates.append(\n+ STORY_UPDATE_BATCH_CHANGED_SUB_TEMPLATE.format(\n+ entity_type=\"Epic\",\n+ old=get_reference_by_id(payload, changes[\"epic_id\"].get(\"old\")).get(\"name\"),\n+ new=get_reference_by_id(payload, changes[\"epic_id\"].get(\"new\")).get(\"name\"),\n+ )\n+ )\n+ if \"project_id\" in changes:\n+ last_change = \"project\"\n+ move_sub_templates.append(\n+ STORY_UPDATE_BATCH_CHANGED_SUB_TEMPLATE.format(\n+ entity_type=\"Project\",\n+ old=get_reference_by_id(payload, changes[\"project_id\"].get(\"old\")).get(\"name\"),\n+ new=get_reference_by_id(payload, changes[\"project_id\"].get(\"new\")).get(\"name\"),\n+ )\n+ )\n+ if len(move_sub_templates) > 0:\n+ templates.append(\n+ STORY_UPDATE_BATCH_CHANGED_TEMPLATE.format(\n+ operation=\"was moved\",\n+ sub_templates=\", \".join(move_sub_templates),\n+ )\n+ )\n+\n+ if \"story_type\" in changes:\n+ last_change = \"type\"\n+ templates.append(\n+ STORY_UPDATE_BATCH_CHANGED_TEMPLATE.format(\n+ operation=\"{} changed\".format(\"was\" if len(templates) == 0 else \"and\"),\n+ sub_templates=STORY_UPDATE_BATCH_CHANGED_SUB_TEMPLATE.format(\n+ entity_type=\"type\",\n+ old=changes[\"story_type\"].get(\"old\"),\n+ new=changes[\"story_type\"].get(\"new\"),\n+ ),\n+ )\n+ )\n+\n+ if \"label_ids\" in changes:\n+ last_change = \"label\"\n+ labels = get_story_joined_label_list(payload, action, changes[\"label_ids\"].get(\"adds\"))\n+ templates.append(\n+ STORY_UPDATE_BATCH_ADD_REMOVE_TEMPLATE.format(\n+ operation=\"{} added\".format(\"was\" if len(templates) == 0 else \"and\"),\n+ entity=\"the new label{plural} {labels}\".format(\n+ plural=\"s\" if len(changes[\"label_ids\"]) > 1 else \"\", labels=labels\n+ ),\n+ )\n+ )\n+\n+ if \"workflow_state_id\" in changes:\n+ last_change = \"state\"\n+ kwargs.update(\n+ workflow_state_template=TRAILING_WORKFLOW_STATE_CHANGE_TEMPLATE.format(\n+ old=get_reference_by_id(payload, changes[\"workflow_state_id\"].get(\"old\")).get(\n+ \"name\"\n+ ),\n+ new=get_reference_by_id(payload, changes[\"workflow_state_id\"].get(\"new\")).get(\n+ \"name\"\n+ ),\n+ )\n+ )\n+\n+ # Use the default template for state change if it is the only one change.\n+ if len(templates) <= 1 or (len(templates) == 0 and last_change == \"state\"):\n+ event: str = \"{}_{}\".format(\"story_update\", last_change)\n+ alternative_body_func = EVENT_BODY_FUNCTION_MAPPER.get(event)\n+ # If last_change is not one of \"epic\", \"project\", \"type\", \"label\" and \"state\"\n+ # we should ignore the action as there is no way for us to render the changes.\n+ if alternative_body_func is None:\n+ return None\n+ return alternative_body_func(payload, action)\n+\n+ kwargs.update(templates=\", \".join(templates))\n+ return STORY_UPDATE_BATCH_TEMPLATE.format(**kwargs)\n+\n+\n+def get_entity_name(\n+ payload: Dict[str, Any], action: Dict[str, Any], entity: Optional[str] = None\n+) -> Optional[str]:\n name = action.get(\"name\")\n \n if name is None or action[\"entity_type\"] == \"branch\":\n@@ -511,16 +624,38 @@ def get_name_template(entity: str) -> str:\n return EPIC_NAME_TEMPLATE\n \n \n-EVENT_BODY_FUNCTION_MAPPER: Dict[str, Callable[[Dict[str, Any]], Optional[str]]] = {\n+def send_stream_messages_for_actions(\n+ request: HttpRequest,\n+ user_profile: UserProfile,\n+ payload: Dict[str, Any],\n+ action: Dict[str, Any],\n+ event: str,\n+) -> None:\n+ body_func = EVENT_BODY_FUNCTION_MAPPER.get(event)\n+ topic_func = get_topic_function_based_on_type(payload, action)\n+ if body_func is None or topic_func is None:\n+ raise UnsupportedWebhookEventType(event)\n+\n+ topic = topic_func(payload, action)\n+ body = body_func(payload, action)\n+\n+ if topic and body:\n+ check_send_webhook_message(request, user_profile, topic, body)\n+\n+\n+EVENT_BODY_FUNCTION_MAPPER: Dict[str, Callable[[Dict[str, Any], Dict[str, Any]], Optional[str]]] = {\n \"story_update_archived\": partial(get_update_archived_body, entity=\"story\"),\n \"epic_update_archived\": partial(get_update_archived_body, entity=\"epic\"),\n \"story_create\": get_story_create_body,\n \"pull-request_create\": partial(get_story_create_github_entity_body, entity=\"pull-request\"),\n+ \"pull-request_comment\": partial(\n+ get_story_create_github_entity_body, entity=\"pull-request-comment\"\n+ ),\n \"branch_create\": partial(get_story_create_github_entity_body, entity=\"branch\"),\n \"story_delete\": get_delete_body,\n \"epic_delete\": get_delete_body,\n- \"story-task_create\": partial(get_story_task_body, action=\"added to\"),\n- \"story-task_delete\": partial(get_story_task_body, action=\"removed from\"),\n+ \"story-task_create\": partial(get_story_task_body, operation=\"added to\"),\n+ \"story-task_delete\": partial(get_story_task_body, operation=\"removed from\"),\n \"story-task_update_complete\": get_story_task_completed_body,\n \"story_update_epic\": get_story_update_epic_body,\n \"story_update_estimate\": get_story_update_estimate_body,\n@@ -538,6 +673,7 @@ def get_name_template(entity: str) -> str:\n \"story_update_state\": get_story_update_state_body,\n \"epic_update_name\": partial(get_update_name_body, entity=\"epic\"),\n \"story_update_name\": partial(get_update_name_body, entity=\"story\"),\n+ \"story_update_batch\": get_story_update_batch_body,\n }\n \n EVENT_TOPIC_FUNCTION_MAPPER = {\n@@ -554,6 +690,20 @@ def get_name_template(entity: str) -> str:\n \"story-comment_update\",\n }\n \n+EVENTS_SECONDARY_ACTIONS_FUNCTION_MAPPER: Dict[\n+ str, Callable[[Dict[str, Any]], Generator[Dict[str, Any], None, None]]\n+] = {\n+ \"pull-request_create\": partial(\n+ get_secondary_actions_with_param, entity=\"story\", changed_attr=\"pull_request_ids\"\n+ ),\n+ \"branch_create\": partial(\n+ get_secondary_actions_with_param, entity=\"story\", changed_attr=\"branch_ids\"\n+ ),\n+ \"pull-request_comment\": partial(\n+ get_secondary_actions_with_param, entity=\"story\", changed_attr=\"pull_request_ids\"\n+ ),\n+}\n+\n \n @webhook_view(\"ClubHouse\")\n @has_request_variables\n@@ -570,18 +720,22 @@ def api_clubhouse_webhook(\n if payload is None:\n return json_success()\n \n- event = get_event(payload)\n- if event is None:\n- return json_success()\n-\n- body_func = EVENT_BODY_FUNCTION_MAPPER.get(event)\n- topic_func = get_topic_function_based_on_type(payload)\n- if body_func is None or topic_func is None:\n- raise UnsupportedWebhookEventType(event)\n- topic = topic_func(payload)\n- body = body_func(payload)\n-\n- if topic and body:\n- check_send_webhook_message(request, user_profile, topic, body)\n+ if payload.get(\"primary_id\") is not None:\n+ action = get_action_with_primary_id(payload)\n+ primary_actions = [action]\n+ else:\n+ primary_actions = payload[\"actions\"]\n+\n+ for primary_action in primary_actions:\n+ event = get_event(payload, primary_action)\n+ if event is None:\n+ continue\n+\n+ if event in EVENTS_SECONDARY_ACTIONS_FUNCTION_MAPPER:\n+ sec_actions_func = EVENTS_SECONDARY_ACTIONS_FUNCTION_MAPPER[event]\n+ for sec_action in sec_actions_func(payload):\n+ send_stream_messages_for_actions(request, user_profile, payload, sec_action, event)\n+ else:\n+ send_stream_messages_for_actions(request, user_profile, payload, primary_action, event)\n \n return json_success()\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/webhooks/clubhouse/tests.py b/zerver/webhooks/clubhouse/tests.py\n--- a/zerver/webhooks/clubhouse/tests.py\n+++ b/zerver/webhooks/clubhouse/tests.py\n@@ -1,5 +1,5 @@\n import json\n-from unittest.mock import MagicMock, patch\n+from unittest.mock import MagicMock, call, patch\n \n from zerver.lib.test_classes import WebhookTestCase\n \n@@ -121,7 +121,7 @@ def test_story_task_completed(self) -> None:\n expected_message = \"Task **A new task for this story** ([Add cool feature!](https://app.clubhouse.io/zulip/story/11)) was completed. :tada:\"\n self.check_webhook(\"story_task_complete\", \"Add cool feature!\", expected_message)\n \n- @patch(\"zerver.lib.webhooks.common.check_send_webhook_message\")\n+ @patch(\"zerver.webhooks.clubhouse.view.check_send_webhook_message\")\n def test_story_task_incomplete_ignore(self, check_send_webhook_message_mock: MagicMock) -> None:\n payload = self.get_body(\"story_task_not_complete\")\n result = self.client_post(self.url, payload, content_type=\"application/json\")\n@@ -159,7 +159,7 @@ def test_story_file_attachment_added(self) -> None:\n expected_message = \"A file attachment `zuliprc` was added to the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11).\"\n self.check_webhook(\"story_update_add_attachment\", \"Add cool feature!\", expected_message)\n \n- @patch(\"zerver.lib.webhooks.common.check_send_webhook_message\")\n+ @patch(\"zerver.webhooks.clubhouse.view.check_send_webhook_message\")\n def test_story_file_attachment_removed_ignore(\n self, check_send_webhook_message_mock: MagicMock\n ) -> None:\n@@ -172,13 +172,17 @@ def test_story_label_added(self) -> None:\n expected_message = \"The label **mockup** was added to the story [An epic story!](https://app.clubhouse.io/zulip/story/23).\"\n self.check_webhook(\"story_update_add_label\", \"An epic story!\", expected_message)\n \n+ def test_story_label_multiple_added(self) -> None:\n+ expected_message = \"The labels **mockup**, **label** were added to the story [An epic story!](https://app.clubhouse.io/zulip/story/23).\"\n+ self.check_webhook(\"story_update_add_multiple_labels\", \"An epic story!\", expected_message)\n+\n def test_story_label_added_label_name_in_actions(self) -> None:\n expected_message = \"The label **sad** was added to the story [An emotional story!](https://app.clubhouse.io/zulip/story/28).\"\n self.check_webhook(\n \"story_update_add_label_name_in_action\", \"An emotional story!\", expected_message\n )\n \n- @patch(\"zerver.lib.webhooks.common.check_send_webhook_message\")\n+ @patch(\"zerver.webhooks.clubhouse.view.check_send_webhook_message\")\n def test_story_label_removed_ignore(self, check_send_webhook_message_mock: MagicMock) -> None:\n payload = self.get_body(\"story_update_remove_label\")\n result = self.client_post(self.url, payload, content_type=\"application/json\")\n@@ -201,13 +205,180 @@ def test_story_update_add_github_pull_request(self) -> None:\n expected_message,\n )\n \n+ def test_story_update_add_github_pull_request_without_workflow_state(self) -> None:\n+ expected_message = \"New GitHub PR [#10](https://github.com/eeshangarg/Scheduler/pull/10) opened for story [Testing pull requests with Story](https://app.clubhouse.io/zulip/story/28).\"\n+ self.check_webhook(\n+ \"story_update_add_github_pull_request_without_workflow_state\",\n+ \"Testing pull requests with Story\",\n+ expected_message,\n+ )\n+\n+ @patch(\"zerver.webhooks.clubhouse.view.check_send_webhook_message\")\n+ def test_story_update_add_github_multiple_pull_requests(\n+ self, check_send_webhook_message_mock: MagicMock\n+ ) -> None:\n+ payload = self.get_body(\"story_update_add_github_multiple_pull_requests\")\n+ self.client_post(self.url, payload, content_type=\"application/json\")\n+ expected_message = \"New GitHub PR [#2](https://github.com/PIG208/test-clubhouse/pull/2) opened for story [{name}]({url}) (Unscheduled -> In Development).\"\n+ request, user_profile = (\n+ check_send_webhook_message_mock.call_args_list[0][0][0],\n+ check_send_webhook_message_mock.call_args_list[0][0][1],\n+ )\n+ expected_list = [\n+ call(\n+ request,\n+ user_profile,\n+ \"Story1\",\n+ expected_message.format(\n+ name=\"Story1\", url=\"https://app.clubhouse.io/pig208/story/17\"\n+ ),\n+ ),\n+ call(\n+ request,\n+ user_profile,\n+ \"Story2\",\n+ expected_message.format(\n+ name=\"Story2\", url=\"https://app.clubhouse.io/pig208/story/18\"\n+ ),\n+ ),\n+ ]\n+ self.assertEqual(check_send_webhook_message_mock.call_args_list, expected_list)\n+\n+ def test_story_update_add_github_pull_request_with_comment(self) -> None:\n+ expected_message = \"Existing GitHub PR [#2](https://github.com/PIG208/test-clubhouse/pull/2) associated with story [asd2](https://app.clubhouse.io/pig208/story/15).\"\n+ self.check_webhook(\n+ \"story_update_add_github_pull_request_with_comment\",\n+ \"asd2\",\n+ expected_message,\n+ )\n+\n+ @patch(\"zerver.webhooks.clubhouse.view.check_send_webhook_message\")\n+ def test_story_update_add_github_multiple_pull_requests_with_comment(\n+ self, check_send_webhook_message_mock: MagicMock\n+ ) -> None:\n+ payload = self.get_body(\"story_update_add_github_multiple_pull_requests_with_comment\")\n+ self.client_post(self.url, payload, content_type=\"application/json\")\n+ expected_message = \"Existing GitHub PR [#1](https://github.com/PIG208/test-clubhouse/pull/1) associated with story [{name}]({url}) (Unscheduled -> In Development).\"\n+ request, user_profile = (\n+ check_send_webhook_message_mock.call_args_list[0][0][0],\n+ check_send_webhook_message_mock.call_args_list[0][0][1],\n+ )\n+ expected_list = [\n+ call(\n+ request,\n+ user_profile,\n+ \"new1\",\n+ expected_message.format(\n+ name=\"new1\", url=\"https://app.clubhouse.io/pig208/story/26\"\n+ ),\n+ ),\n+ call(\n+ request,\n+ user_profile,\n+ \"new2\",\n+ expected_message.format(\n+ name=\"new2\", url=\"https://app.clubhouse.io/pig208/story/27\"\n+ ),\n+ ),\n+ ]\n+ self.assertEqual(check_send_webhook_message_mock.call_args_list, expected_list)\n+\n def test_story_update_add_github_branch(self) -> None:\n expected_message = \"New GitHub branch [eeshangarg/ch27/testing-pull-requests-with-story](https://github.com/eeshangarg/scheduler/tree/eeshangarg/ch27/testing-pull-requests-with-story) associated with story [Testing pull requests with Story](https://app.clubhouse.io/zulip/story/27) (Unscheduled -> In Development).\"\n self.check_webhook(\n \"story_update_add_github_branch\", \"Testing pull requests with Story\", expected_message\n )\n \n- @patch(\"zerver.lib.webhooks.common.check_send_webhook_message\")\n+ @patch(\"zerver.webhooks.clubhouse.view.check_send_webhook_message\")\n+ def test_story_update_batch(self, check_send_webhook_message_mock: MagicMock) -> None:\n+ payload = self.get_body(\"story_update_everything_at_once\")\n+ self.client_post(self.url, payload, content_type=\"application/json\")\n+ expected_message = \"The story [{name}]({url}) was moved from Epic **epic** to **testeipc**, Project **Product Development** to **test2**, and changed from type **feature** to **bug**, and added with the new label **low priority** (In Development -> Ready for Review).\"\n+ request, user_profile = (\n+ check_send_webhook_message_mock.call_args_list[0][0][0],\n+ check_send_webhook_message_mock.call_args_list[0][0][1],\n+ )\n+ expected_list = [\n+ call(\n+ request,\n+ user_profile,\n+ \"asd4\",\n+ expected_message.format(\n+ name=\"asd4\", url=\"https://app.clubhouse.io/pig208/story/17\"\n+ ),\n+ ),\n+ call(\n+ request,\n+ user_profile,\n+ \"new1\",\n+ expected_message.format(\n+ name=\"new1\", url=\"https://app.clubhouse.io/pig208/story/26\"\n+ ),\n+ ),\n+ call(\n+ request,\n+ user_profile,\n+ \"new2\",\n+ expected_message.format(\n+ name=\"new2\", url=\"https://app.clubhouse.io/pig208/story/27\"\n+ ),\n+ ),\n+ ]\n+ self.assertEqual(check_send_webhook_message_mock.call_args_list, expected_list)\n+\n+ @patch(\"zerver.webhooks.clubhouse.view.check_send_webhook_message\")\n+ def test_story_update_batch_each_with_one_change(\n+ self, check_send_webhook_message_mock: MagicMock\n+ ) -> None:\n+ payload = self.get_body(\"story_update_multiple_at_once\")\n+ self.client_post(self.url, payload, content_type=\"application/json\")\n+ expected_messages = [\n+ (\n+ \"asd4\",\n+ \"The type of the story [asd4](https://app.clubhouse.io/pig208/story/17) was changed from **feature** to **bug**.\",\n+ ),\n+ (\n+ \"new1\",\n+ \"The story [new1](https://app.clubhouse.io/pig208/story/26) was moved from **epic** to **testeipc**.\",\n+ ),\n+ (\n+ \"new2\",\n+ \"The label **low priority** was added to the story [new2](https://app.clubhouse.io/pig208/story/27).\",\n+ ),\n+ (\n+ \"new3\",\n+ \"State of the story [new3](https://app.clubhouse.io/pig208/story/28) was changed from **In Development** to **Ready for Review**.\",\n+ ),\n+ (\n+ \"new4\",\n+ \"The story [new4](https://app.clubhouse.io/pig208/story/29) was moved from the **Product Development** project to **test2**.\",\n+ ),\n+ ]\n+ request, user_profile = (\n+ check_send_webhook_message_mock.call_args_list[0][0][0],\n+ check_send_webhook_message_mock.call_args_list[0][0][1],\n+ )\n+ expected_list = [\n+ call(\n+ request,\n+ user_profile,\n+ expected_message[0],\n+ expected_message[1],\n+ )\n+ for expected_message in expected_messages\n+ ]\n+ self.assertEqual(check_send_webhook_message_mock.call_args_list, expected_list)\n+\n+ @patch(\"zerver.webhooks.clubhouse.view.check_send_webhook_message\")\n+ def test_story_update_batch_not_supported_ignore(\n+ self, check_send_webhook_message_mock: MagicMock\n+ ) -> None:\n+ payload = self.get_body(\"story_update_multiple_not_supported\")\n+ result = self.client_post(self.url, payload, content_type=\"application/json\")\n+ self.assertFalse(check_send_webhook_message_mock.called)\n+ self.assert_json_success(result)\n+\n+ @patch(\"zerver.webhooks.clubhouse.view.check_send_webhook_message\")\n def test_empty_post_request_body_ignore(\n self, check_send_webhook_message_mock: MagicMock\n ) -> None:\n@@ -216,7 +387,7 @@ def test_empty_post_request_body_ignore(\n self.assertFalse(check_send_webhook_message_mock.called)\n self.assert_json_success(result)\n \n- @patch(\"zerver.lib.webhooks.common.check_send_webhook_message\")\n+ @patch(\"zerver.webhooks.clubhouse.view.check_send_webhook_message\")\n def test_story_comment_updated_ignore(self, check_send_webhook_message_mock: MagicMock) -> None:\n payload = self.get_body(\"story_comment_updated\")\n result = self.client_post(self.url, payload, content_type=\"application/json\")\n"},"problem_statement":{"kind":"string","value":"Make clubhouse integration handle multiple relevant secondary actions\nEach clubhouse payload has a primary action and a bunch of secondary actions. The primary action can be for example creating a pull request and the secondary action can be including the pull request to a story. So for each payload the clubhouse integration would send a message to a stream. Eg when a pull request is created and added to a story a message would be send under the topic Story name that the pull request has been created.\r\n\r\nOur integration currently assumes that there is only one relevant secondary action to a primary action. For example, in case of creating a new pull request(primary action), it assumes that the pull request would be added(secondary action) only to one story. So the action sends a message to the topic story name and with body containing the pull request details.\r\n\r\nThis is not fully correct since there can be multiple stories associated with a given pull request[1][2].\r\n\r\n![Screenshot from 2021-04-07 18-17-09](https://user-images.githubusercontent.com/7190633/113868613-7d3a6180-97cd-11eb-8b69-893d21df33dc.png)\r\n\r\n\r\nThe current implementation of the clubhouse integration sends message only to one story topic instead of sending messages to all the story topics.\r\n\r\n
\r\nClick to show JSON payload\r\n\r\n```json\r\n{\r\n \"id\":\"70686928-f649-607f-b640-8b80310559f4\",\r\n \"changed_at\":\"2021-04-02T18:57:41.201Z\",\r\n \"version\":\"v1\",\r\n \"primary_id\":700000036,\r\n \"member_id\":\"20576d78-5b7a-5f88-b59c-a67506a49fa8\",\r\n \"actions\":[\r\n {\r\n \"id\":700000036,\r\n \"entity_type\":\"pull-request\",\r\n \"action\":\"create\",\r\n \"number\":2,\r\n \"title\":\"Test 2\",\r\n \"url\":\"https://github.com/hackerkid/test/pull/2\"\r\n },\r\n {\r\n \"id\":12,\r\n \"entity_type\":\"story\",\r\n \"action\":\"update\",\r\n \"name\":\"test story 1\",\r\n \"story_type\":\"feature\",\r\n \"app_url\":\"https://app.clubhouse.io/hackerkid/story/12\",\r\n \"changes\":{\r\n \"pull_request_ids\":{\r\n \"adds\":[\r\n 700000036\r\n ]\r\n },\r\n \"started\":{\r\n \"new\":true,\r\n \"old\":false\r\n },\r\n \"position\":{\r\n \"new\":42147680257,\r\n \"old\":12547680256\r\n },\r\n \"workflow_state_id\":{\r\n \"new\":500000006,\r\n \"old\":500000008\r\n },\r\n \"started_at\":{\r\n \"new\":\"2021-04-02T18:57:41Z\"\r\n },\r\n \"owner_ids\":{\r\n \"adds\":[\r\n \"20576d78-5b7a-5f88-b59c-a67506a49fa8\"\r\n ]\r\n }\r\n }\r\n },\r\n {\r\n \"id\":10,\r\n \"entity_type\":\"story\",\r\n \"action\":\"update\",\r\n \"name\":\"www\",\r\n \"story_type\":\"feature\",\r\n \"app_url\":\"https://app.clubhouse.io/hackerkid/story/10\",\r\n \"changes\":{\r\n \"pull_request_ids\":{\r\n \"adds\":[\r\n 700000036\r\n ]\r\n },\r\n \"started\":{\r\n \"new\":true,\r\n \"old\":false\r\n },\r\n \"position\":{\r\n \"new\":32147549184,\r\n \"old\":12147549184\r\n },\r\n \"workflow_state_id\":{\r\n \"new\":500000006,\r\n \"old\":500000008\r\n },\r\n \"started_at\":{\r\n \"new\":\"2021-04-02T18:57:41Z\"\r\n },\r\n \"owner_ids\":{\r\n \"adds\":[\r\n \"20576d78-5b7a-5f88-b59c-a67506a49fa8\"\r\n ]\r\n }\r\n }\r\n }\r\n ],\r\n \"references\":[\r\n {\r\n \"id\":500000006,\r\n \"entity_type\":\"workflow-state\",\r\n \"name\":\"In Development\",\r\n \"type\":\"started\"\r\n },\r\n {\r\n \"id\":500000008,\r\n \"entity_type\":\"workflow-state\",\r\n \"name\":\"Unscheduled\",\r\n \"type\":\"unstarted\"\r\n }\r\n ]\r\n }\r\n ```\r\n
\r\n\r\n\r\n![Screenshot from 2021-04-07 18-16-03](https://user-images.githubusercontent.com/7190633/113868486-5845ee80-97cd-11eb-9f93-a9a0a44c2454.png)\r\n\r\n\r\nThe pull request is just one example of how the integration fails in handling multiple secondary actions. There should be other cases as well. I have not investigated the other scerios.\r\n\r\nWe should rewrite the clubhouse integration to make sure that all the pull requests are handled.\r\n\r\n[1]https://help.clubhouse.io/hc/en-us/articles/207540323-Using-Branches-and-Pull-Requests-with-the-Clubhouse-VCS-Integrations\r\n[2]https://github.com/hackerkid/test/pull/2\r\n\r\n\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-integrations members, this issue was labeled with the \"area: integrations\" label, so you may want to check it out!\n\n\n@zulipbot claim"},"created_at":{"kind":"timestamp","value":"2021-04-10T18:27:29","string":"2021-04-10T18:27:29"}}},{"rowIdx":663,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18100,"string":"18,100"},"instance_id":{"kind":"string","value":"zulip__zulip-18100"},"issue_numbers":{"kind":"list like","value":["13939"],"string":"[\n \"13939\"\n]"},"base_commit":{"kind":"string","value":"831b7ca965c77103a31f0bf56e5b04bf527c368b"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py\n--- a/zerver/lib/integrations.py\n+++ b/zerver/lib/integrations.py\n@@ -445,6 +445,7 @@ def __init__(self, name: str, *args: Any, **kwargs: Any) -> None:\n WebhookIntegration(\"travis\", [\"continuous-integration\"], display_name=\"Travis CI\"),\n WebhookIntegration(\"trello\", [\"project-management\"]),\n WebhookIntegration(\"updown\", [\"monitoring\"]),\n+ WebhookIntegration(\"uptimerobot\", [\"monitoring\"], display_name=\"Uptime Robot\"),\n WebhookIntegration(\n \"yo\",\n [\"communication\"],\n@@ -781,6 +782,7 @@ def __init__(self, name: str, *args: Any, **kwargs: Any) -> None:\n \"travis\": [ScreenshotConfig(\"build.json\", payload_as_query_param=True)],\n \"trello\": [ScreenshotConfig(\"adding_comment_to_card.json\")],\n \"updown\": [ScreenshotConfig(\"check_multiple_events.json\")],\n+ \"uptimerobot\": [ScreenshotConfig(\"uptimerobot_monitor_up.json\")],\n \"wordpress\": [ScreenshotConfig(\"publish_post.txt\", \"wordpress_post_created.png\")],\n \"yo\": [\n ScreenshotConfig(\ndiff --git a/zerver/webhooks/uptimerobot/__init__.py b/zerver/webhooks/uptimerobot/__init__.py\nnew file mode 100644\ndiff --git a/zerver/webhooks/uptimerobot/view.py b/zerver/webhooks/uptimerobot/view.py\nnew file mode 100644\n--- /dev/null\n+++ b/zerver/webhooks/uptimerobot/view.py\n@@ -0,0 +1,65 @@\n+from typing import Any, Dict\n+\n+from django.http import HttpRequest, HttpResponse\n+from django.utils.translation import ugettext as _\n+\n+from zerver.decorator import REQ, has_request_variables, webhook_view\n+from zerver.lib.actions import send_rate_limited_pm_notification_to_bot_owner\n+from zerver.lib.response import json_error, json_success\n+from zerver.lib.send_email import FromAddress\n+from zerver.lib.webhooks.common import check_send_webhook_message\n+from zerver.models import UserProfile\n+\n+MISCONFIGURED_PAYLOAD_ERROR_MESSAGE = \"\"\"\n+Hi there! Your bot {bot_name} just received a Uptime Robot payload that is missing\n+some data that Zulip requires. This usually indicates a configuration issue\n+in your Uptime Robot webhook settings. Please make sure that you set the required parameters\n+when configuring the Uptime Robot webhook. Contact {support_email} if you\n+need further help!\n+\"\"\"\n+\n+UPTIMEROBOT_TOPIC_TEMPLATE = \"{monitor_friendly_name}\"\n+UPTIMEROBOT_MESSAGE_UP_TEMPLATE = \"\"\"\n+{monitor_friendly_name} ({monitor_url}) is back UP ({alert_details}).\n+It was down for {alert_friendly_duration}.\n+\"\"\".strip()\n+UPTIMEROBOT_MESSAGE_DOWN_TEMPLATE = (\n+ \"{monitor_friendly_name} ({monitor_url}) is DOWN ({alert_details}).\"\n+)\n+\n+\n+@webhook_view(\"UptimeRobot\")\n+@has_request_variables\n+def api_uptimerobot_webhook(\n+ request: HttpRequest,\n+ user_profile: UserProfile,\n+ payload: Dict[str, Any] = REQ(argument_type=\"body\"),\n+) -> HttpResponse:\n+\n+ try:\n+ body = get_body_for_http_request(payload)\n+ subject = get_subject_for_http_request(payload)\n+ except KeyError:\n+ message = MISCONFIGURED_PAYLOAD_ERROR_MESSAGE.format(\n+ bot_name=user_profile.full_name,\n+ support_email=FromAddress.SUPPORT,\n+ ).strip()\n+ send_rate_limited_pm_notification_to_bot_owner(user_profile, user_profile.realm, message)\n+\n+ return json_error(_(\"Invalid payload\"))\n+\n+ check_send_webhook_message(request, user_profile, subject, body)\n+ return json_success()\n+\n+\n+def get_subject_for_http_request(payload: Dict[str, Any]) -> str:\n+ return UPTIMEROBOT_TOPIC_TEMPLATE.format(monitor_friendly_name=payload[\"monitor_friendly_name\"])\n+\n+\n+def get_body_for_http_request(payload: Dict[str, Any]) -> str:\n+ if payload[\"alert_type_friendly_name\"] == \"Up\":\n+ body = UPTIMEROBOT_MESSAGE_UP_TEMPLATE.format(**payload)\n+ elif payload[\"alert_type_friendly_name\"] == \"Down\":\n+ body = UPTIMEROBOT_MESSAGE_DOWN_TEMPLATE.format(**payload)\n+\n+ return body\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/webhooks/uptimerobot/tests.py b/zerver/webhooks/uptimerobot/tests.py\nnew file mode 100644\n--- /dev/null\n+++ b/zerver/webhooks/uptimerobot/tests.py\n@@ -0,0 +1,47 @@\n+from zerver.lib.send_email import FromAddress\n+from zerver.lib.test_classes import WebhookTestCase\n+from zerver.models import Recipient\n+from zerver.webhooks.uptimerobot.view import MISCONFIGURED_PAYLOAD_ERROR_MESSAGE\n+\n+\n+class UptimeRobotHookTests(WebhookTestCase):\n+ STREAM_NAME = \"uptimerobot\"\n+ URL_TEMPLATE = \"/api/v1/external/uptimerobot?stream={stream}&api_key={api_key}\"\n+ FIXTURE_DIR_NAME = \"uptimerobot\"\n+\n+ def test_uptimerobot_monitor_down(self) -> None:\n+ \"\"\"\n+ Tests if uptimerobot monitor down is handled correctly\n+ \"\"\"\n+ expected_topic = \"Web Server\"\n+ expected_message = \"Web Server (server1.example.com) is DOWN (Host Is Unreachable).\"\n+ self.check_webhook(\"uptimerobot_monitor_down\", expected_topic, expected_message)\n+\n+ def test_uptimerobot_monitor_up(self) -> None:\n+ \"\"\"\n+ Tests if uptimerobot monitor up is handled correctly\n+ \"\"\"\n+ expected_topic = \"Mail Server\"\n+ expected_message = \"\"\"\n+Mail Server (server2.example.com) is back UP (Host Is Reachable).\n+It was down for 44 minutes and 37 seconds.\n+\"\"\".strip()\n+ self.check_webhook(\"uptimerobot_monitor_up\", expected_topic, expected_message)\n+\n+ def test_uptimerobot_invalid_payload_with_missing_data(self) -> None:\n+ \"\"\"\n+ Tests if invalid uptime robot payloads are handled correctly\n+ \"\"\"\n+ self.url = self.build_webhook_url()\n+ payload = self.get_body(\"uptimerobot_invalid_payload_with_missing_data\")\n+ result = self.client_post(self.url, payload, content_type=\"application/json\")\n+ self.assert_json_error(result, \"Invalid payload\")\n+\n+ expected_message = MISCONFIGURED_PAYLOAD_ERROR_MESSAGE.format(\n+ bot_name=self.test_user.full_name,\n+ support_email=FromAddress.SUPPORT,\n+ ).strip()\n+\n+ msg = self.get_last_message()\n+ self.assertEqual(msg.content, expected_message)\n+ self.assertEqual(msg.recipient.type, Recipient.PERSONAL)\n"},"problem_statement":{"kind":"string","value":"integrations: Add Uptime Robot integration.\nAdd Uptime Robot Integration.\r\n\r\nUptime Robot webhook informs users if their site is up or down, so give appropriate message for these two events.\r\n\r\nFixes #13854.\n"},"hints_text":{"kind":"string","value":""},"created_at":{"kind":"timestamp","value":"2021-04-12T01:04:25","string":"2021-04-12T01:04:25"}}},{"rowIdx":664,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18120,"string":"18,120"},"instance_id":{"kind":"string","value":"zulip__zulip-18120"},"issue_numbers":{"kind":"list like","value":["18116"],"string":"[\n \"18116\"\n]"},"base_commit":{"kind":"string","value":"2da4443cc5948ace06c5d0418fbb7e9d9eba1c86"},"patch":{"kind":"string","value":"diff --git a/tools/setup/emoji/emoji_names.py b/tools/setup/emoji/emoji_names.py\n--- a/tools/setup/emoji/emoji_names.py\n+++ b/tools/setup/emoji/emoji_names.py\n@@ -121,8 +121,7 @@\n # queasy seemed like a natural addition\n \"1f922\": {\"canonical_name\": \"nauseated\", \"aliases\": [\"queasy\"]},\n \"1f927\": {\"canonical_name\": \"sneezing\", \"aliases\": []},\n- # cant_talk from https://beebom.com/emoji-meanings/\n- \"1f637\": {\"canonical_name\": \"cant_talk\", \"aliases\": [\"mask\"]},\n+ \"1f637\": {\"canonical_name\": \"mask\", \"aliases\": []},\n # flu from https://mashable.com/2015/10/23/ios-9-1-emoji-guide/, sick from\n # https://emojipedia.org/face-with-thermometer/, face_with_thermometer so\n # it shows up in typeahead (thermometer taken by Objects/82)\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Incorrect short code for mask emoji\nThe mask emoji (:mask:) is aliased as `:cant_talk:` in Zulip. This is incorrect for several reasons. First, this is not the recognized name by Unicode (see https://unicode.org/emoji/charts-13.1/emoji-list.html). The official name is \"face with medical mask\". Recognized aliases include: cold | doctor | face | face with medical mask | mask | sick. It's also not aliased this way on any other platform. GitHub, GitLab, and Gitter, for example, only use `:mask:`. Second, the alias implies that you can't talk with a mask on, which is categorically false. A person with a mask can talk and be heard just fine, as we've all become accustomed to in the last year. Third, using the alias \"cant_talk\" puts a stigma on wearing masks, which is not good. We need to frame as something positive as it will help us curb the spread of this virus (and others ones in the future).\r\n\r\nPlease consider dropping the alias \"cant_talk\" (since `:mask:` also works).\n"},"hints_text":{"kind":"string","value":"I looked into the code and found a reference to an article. But the [article](https://beebom.com/emoji-meanings/\r\n) doesn't tell anything about the \"cant_talk\" alias. So I guess it might have been a mistake.\r\n```\r\n # cant_talk from https://beebom.com/emoji-meanings/\r\n \"1f637\": {\"canonical_name\": \"cant_talk\", \"aliases\": [\"mask\"]},\r\n```"},"created_at":{"kind":"timestamp","value":"2021-04-13T01:15:10","string":"2021-04-13T01:15:10"}}},{"rowIdx":665,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18259,"string":"18,259"},"instance_id":{"kind":"string","value":"zulip__zulip-18259"},"issue_numbers":{"kind":"list like","value":["15964"],"string":"[\n \"15964\"\n]"},"base_commit":{"kind":"string","value":"c3247128ff5860e5f9ba13d4531ced182fbbb579"},"patch":{"kind":"string","value":"diff --git a/scripts/lib/clean_yarn_cache.py b/scripts/lib/clean_yarn_cache.py\nnew file mode 100644\n--- /dev/null\n+++ b/scripts/lib/clean_yarn_cache.py\n@@ -0,0 +1,47 @@\n+#!/usr/bin/env python3\n+import argparse\n+import os\n+import sys\n+\n+ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))\n+sys.path.append(ZULIP_PATH)\n+\n+from scripts.lib.zulip_tools import may_be_perform_purging, parse_cache_script_args\n+\n+YARN_CACHE_PATH = os.path.expanduser(\"~/.cache/yarn/\")\n+CURRENT_VERSION = \"v6\"\n+\n+\n+def remove_unused_versions_dir(args: argparse.Namespace) -> None:\n+ \"\"\"Deletes cache data from obsolete Yarn versions.\n+\n+ Yarn does not provide an interface for removing obsolete data from\n+ ~/.cache/yarn for packages that you haven't installed in years; but one\n+ can always remove the cache entirely.\n+ \"\"\"\n+ current_version_dir = os.path.join(YARN_CACHE_PATH, CURRENT_VERSION)\n+ dirs_to_purge = set(\n+ [\n+ os.path.join(YARN_CACHE_PATH, directory)\n+ for directory in os.listdir(YARN_CACHE_PATH)\n+ if directory != CURRENT_VERSION\n+ ]\n+ )\n+\n+ may_be_perform_purging(\n+ dirs_to_purge,\n+ {current_version_dir},\n+ \"yarn cache\",\n+ args.dry_run,\n+ args.verbose,\n+ args.no_headings,\n+ )\n+\n+\n+def main(args: argparse.Namespace) -> None:\n+ remove_unused_versions_dir(args)\n+\n+\n+if __name__ == \"__main__\":\n+ args = parse_cache_script_args(\"This script cleans redundant Zulip yarn caches.\")\n+ main(args)\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Avoid leaking huge amounts of disk in the yarn cache in old production servers\nOn chat.zulip.org, `/home/zulip/.cache` is 7GB; some other users have reported sizes more like 2.6GB. This is large compared to the rest of a Zulip installation, and probably deserves some attention.\r\n\r\nThe main cause of this is `yarn` caching; which sadly doesn't have any feature to auto-prune its caches.\r\n```\r\nzulip@zulip:~/.cache/yarn$ du -shc *\r\n1.8G v1\r\n1.9G v4\r\n962M v5\r\n2.5G v6\r\n7.0G total\r\n```\r\n\r\nThere are 2 things we should do to fix this, both in `scripts/lib/clean-unused-caches`:\r\n* Remove the old directories under `~/.cache/yarn/v{1,4,5}`, since those will never be used.\r\n* Remove and individual files under ~/.cache/yarn/v6` that have a modification time 6 months or more ago.\r\n\r\n\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-production, @zulip/server-tooling members, this issue was labeled with the \"area: production\", \"area: tooling\" labels, so you may want to check it out!\n\n\n@zulipbot claim"},"created_at":{"kind":"timestamp","value":"2021-04-25T10:25:16","string":"2021-04-25T10:25:16"}}},{"rowIdx":666,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18264,"string":"18,264"},"instance_id":{"kind":"string","value":"zulip__zulip-18264"},"issue_numbers":{"kind":"list like","value":["18223"],"string":"[\n \"18223\"\n]"},"base_commit":{"kind":"string","value":"4c4c2e46fbe8a99ce94b1b60fb5749a1444ba733"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/outgoing_webhook.py b/zerver/lib/outgoing_webhook.py\n--- a/zerver/lib/outgoing_webhook.py\n+++ b/zerver/lib/outgoing_webhook.py\n@@ -288,8 +288,10 @@ def process_success_response(\n try:\n response_json = json.loads(response.text)\n except json.JSONDecodeError:\n- fail_with_message(event, \"Invalid JSON in response\")\n- return\n+ raise JsonableError(_(\"Invalid JSON in response\"))\n+\n+ if not isinstance(response_json, dict):\n+ raise JsonableError(_(\"Invalid response format\"))\n \n success_data = service_handler.process_success(response_json)\n \n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_outgoing_webhook_interfaces.py b/zerver/tests/test_outgoing_webhook_interfaces.py\n--- a/zerver/tests/test_outgoing_webhook_interfaces.py\n+++ b/zerver/tests/test_outgoing_webhook_interfaces.py\n@@ -5,6 +5,7 @@\n import requests\n \n from zerver.lib.avatar import get_gravatar_url\n+from zerver.lib.exceptions import JsonableError\n from zerver.lib.message import MessageDict\n from zerver.lib.outgoing_webhook import get_service_interface_class, process_success_response\n from zerver.lib.test_classes import ZulipTestCase\n@@ -47,13 +48,12 @@ def test_process_success_response(self) -> None:\n response.status_code = 200\n response.text = \"unparsable text\"\n \n- with mock.patch(\"zerver.lib.outgoing_webhook.fail_with_message\") as m:\n+ with self.assertRaisesRegex(JsonableError, \"Invalid JSON in response\"):\n process_success_response(\n event=event,\n service_handler=service_handler,\n response=response,\n )\n- self.assertTrue(m.called)\n \n def test_make_request(self) -> None:\n othello = self.example_user(\"othello\")\ndiff --git a/zerver/tests/test_outgoing_webhook_system.py b/zerver/tests/test_outgoing_webhook_system.py\n--- a/zerver/tests/test_outgoing_webhook_system.py\n+++ b/zerver/tests/test_outgoing_webhook_system.py\n@@ -86,7 +86,7 @@ def test_successful_request(self) -> None:\n for service_class in [GenericOutgoingWebhookService, SlackOutgoingWebhookService]:\n handler = service_class(\"token\", bot_user, \"service\")\n with mock.patch.object(handler, \"session\") as session:\n- session.post.return_value = ResponseMock(200)\n+ session.post.return_value = ResponseMock(200, b\"{}\")\n do_rest_call(\"\", mock_event, handler)\n session.post.assert_called_once()\n \n@@ -158,7 +158,7 @@ def test_headers(self) -> None:\n \n session = service_handler.session\n with mock.patch.object(session, \"send\") as mock_send:\n- mock_send.return_value = ResponseMock(200)\n+ mock_send.return_value = ResponseMock(200, b\"{}\")\n final_response = do_rest_call(\"https://example.com/\", mock_event, service_handler)\n assert final_response is not None\n \n@@ -261,6 +261,62 @@ def test_jsonable_exception(self) -> None:\n assert bot_user.bot_owner is not None\n self.assertEqual(bot_owner_notification.recipient_id, bot_user.bot_owner.recipient_id)\n \n+ def test_invalid_response_format(self) -> None:\n+ bot_user = self.example_user(\"outgoing_webhook_bot\")\n+ mock_event = self.mock_event(bot_user)\n+ service_handler = GenericOutgoingWebhookService(\"token\", bot_user, \"service\")\n+\n+ expect_logging_info = self.assertLogs(level=\"INFO\")\n+ expect_fail = mock.patch(\"zerver.lib.outgoing_webhook.fail_with_message\")\n+\n+ with responses.RequestsMock(assert_all_requests_are_fired=True) as requests_mock:\n+ # We mock the endpoint to return response with valid json which doesn't\n+ # translate to a dict like is expected,\n+ requests_mock.add(\n+ requests_mock.POST, \"https://example.zulip.com\", status=200, json=True\n+ )\n+ with expect_logging_info, expect_fail as mock_fail:\n+ do_rest_call(\"https://example.zulip.com\", mock_event, service_handler)\n+ self.assertTrue(mock_fail.called)\n+ bot_owner_notification = self.get_last_message()\n+ self.assertEqual(\n+ bot_owner_notification.content,\n+ \"\"\"[A message](http://zulip.testserver/#narrow/stream/999-Verona/topic/Foo/near/) to your bot @_**Outgoing Webhook** triggered an outgoing webhook.\n+The outgoing webhook server attempted to send a message in Zulip, but that request resulted in the following error:\n+> Invalid response format\"\"\",\n+ )\n+ assert bot_user.bot_owner is not None\n+ self.assertEqual(bot_owner_notification.recipient_id, bot_user.bot_owner.recipient_id)\n+\n+ def test_invalid_json_in_response(self) -> None:\n+ bot_user = self.example_user(\"outgoing_webhook_bot\")\n+ mock_event = self.mock_event(bot_user)\n+ service_handler = GenericOutgoingWebhookService(\"token\", bot_user, \"service\")\n+\n+ expect_logging_info = self.assertLogs(level=\"INFO\")\n+ expect_fail = mock.patch(\"zerver.lib.outgoing_webhook.fail_with_message\")\n+\n+ with responses.RequestsMock(assert_all_requests_are_fired=True) as requests_mock:\n+ # We mock the endpoint to return response with a body which isn't valid json.\n+ requests_mock.add(\n+ requests_mock.POST,\n+ \"https://example.zulip.com\",\n+ status=200,\n+ body=\"this isn't valid json\",\n+ )\n+ with expect_logging_info, expect_fail as mock_fail:\n+ do_rest_call(\"https://example.zulip.com\", mock_event, service_handler)\n+ self.assertTrue(mock_fail.called)\n+ bot_owner_notification = self.get_last_message()\n+ self.assertEqual(\n+ bot_owner_notification.content,\n+ \"\"\"[A message](http://zulip.testserver/#narrow/stream/999-Verona/topic/Foo/near/) to your bot @_**Outgoing Webhook** triggered an outgoing webhook.\n+The outgoing webhook server attempted to send a message in Zulip, but that request resulted in the following error:\n+> Invalid JSON in response\"\"\",\n+ )\n+ assert bot_user.bot_owner is not None\n+ self.assertEqual(bot_owner_notification.recipient_id, bot_user.bot_owner.recipient_id)\n+\n \n class TestOutgoingWebhookMessaging(ZulipTestCase):\n def create_outgoing_bot(self, bot_owner: UserProfile) -> UserProfile:\n@@ -305,7 +361,7 @@ def test_multiple_services(self) -> None:\n \n session = mock.Mock(spec=requests.Session)\n session.headers = {}\n- session.post.return_value = ResponseMock(200)\n+ session.post.return_value = ResponseMock(200, b\"{}\")\n with mock.patch(\"zerver.lib.outgoing_webhook.Session\") as sessionmaker:\n sessionmaker.return_value = session\n self.send_personal_message(\n"},"problem_statement":{"kind":"string","value":"TypeError: argument of type 'NoneType' is not iterable\nhttps://sentry.io/share/issue/71c35f8aca6444b4a8e1d3ab6880ef71/\n\n```\nTypeError: argument of type 'NoneType' is not iterable\n(1 additional frame(s) were not displayed)\n...\n File \"zerver/worker/queue_processors.py\", line 335, in \n consume_func = lambda events: self.consume(events[0])\n File \"zerver/worker/queue_processors.py\", line 749, in consume\n do_rest_call(service.base_url, event, service_handler)\n File \"zerver/lib/outgoing_webhook.py\", line 325, in do_rest_call\n process_success_response(event, service_handler, response)\n File \"zerver/lib/outgoing_webhook.py\", line 293, in process_success_response\n success_data = service_handler.process_success(response_json)\n File \"zerver/lib/outgoing_webhook.py\", line 79, in process_success\n if \"response_not_required\" in response_json and response_json[\"response_not_required\"]:\n```\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-production members, this issue was labeled with the \"area: production\" label, so you may want to check it out!\n\n"},"created_at":{"kind":"timestamp","value":"2021-04-25T19:44:48","string":"2021-04-25T19:44:48"}}},{"rowIdx":667,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18274,"string":"18,274"},"instance_id":{"kind":"string","value":"zulip__zulip-18274"},"issue_numbers":{"kind":"list like","value":["16090"],"string":"[\n \"16090\"\n]"},"base_commit":{"kind":"string","value":"8e2042d37837f1fe16b8eb8db1c0860e7eddfa48"},"patch":{"kind":"string","value":"diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py\n--- a/zerver/views/user_settings.py\n+++ b/zerver/views/user_settings.py\n@@ -272,6 +272,7 @@ def json_change_notify_settings(\n if (\n notification_sound is not None\n and notification_sound not in get_available_notification_sounds()\n+ and notification_sound != \"none\"\n ):\n raise JsonableError(_(\"Invalid notification sound '{}'\").format(notification_sound))\n \n"},"test_patch":{"kind":"string","value":"diff --git a/frontend_tests/node_tests/notifications.js b/frontend_tests/node_tests/notifications.js\n--- a/frontend_tests/node_tests/notifications.js\n+++ b/frontend_tests/node_tests/notifications.js\n@@ -59,6 +59,7 @@ function test(label, f) {\n page_params.enable_desktop_notifications = true;\n page_params.enable_sounds = true;\n page_params.wildcard_mentions_notify = true;\n+ page_params.notification_sound = \"ding\";\n f(override);\n });\n }\n@@ -239,13 +240,35 @@ test(\"message_is_notifiable\", () => {\n assert.equal(notifications.should_send_audible_notification(message), true);\n assert.equal(notifications.message_is_notifiable(message), false);\n \n+ // Case 9: If `None` is selected as the notification sound, send no\n+ // audible notification, no matter what other user configurations are.\n+ message = {\n+ id: 50,\n+ content: \"message number 7\",\n+ sent_by_me: false,\n+ notification_sent: false,\n+ mentioned: true,\n+ mentioned_me_directly: true,\n+ type: \"stream\",\n+ stream: \"general\",\n+ stream_id: general.stream_id,\n+ topic: \"whatever\",\n+ };\n+ page_params.notification_sound = \"none\";\n+ assert.equal(notifications.should_send_desktop_notification(message), true);\n+ assert.equal(notifications.should_send_audible_notification(message), false);\n+ assert.equal(notifications.message_is_notifiable(message), true);\n+\n+ // Reset state\n+ page_params.notification_sound = \"ding\";\n+\n // If none of the above cases apply\n // (ie: topic is not muted, message does not mention user,\n // no notification sent before, message not sent by user),\n // return true to pass it to notifications settings, which will return false.\n message = {\n id: 60,\n- content: \"message number 7\",\n+ content: \"message number 8\",\n sent_by_me: false,\n notification_sent: false,\n mentioned: false,\n"},"problem_statement":{"kind":"string","value":"Disable Notification Sound Not available\n**Describe the bug**\r\nI could not disable the notification sound because the page only gives 2 choices of music, and no \"no sound\" option.\r\n\r\n\r\n\r\n**To Reproduce**\r\nGo to settings -> notifications -> other notification settings -> notification sound. \r\n\r\n**Expected behavior**\r\nEither a check option to disable the sound or no sound as one of options\r\n\r\n**Screenshots**\r\n![image](https://user-images.githubusercontent.com/11896263/89756891-55d9aa80-db01-11ea-8fca-5d11c5b2872d.png)\r\n\r\n**Desktop (please complete the following information):**\r\n - Operating System: Win 10 Home (18362)\r\n - Zulip Desktop Version: 5.4.0\r\n\r\n\r\n\r\n\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-settings members, this issue was labeled with the \"area: settings (user)\" label, so you may want to check it out!\n\n\nThis seems worth supporting, and is likely quite easy. The main decision is how to represent \"no sound\" in the API -- maybe the empty string would be most consistent? I could also imagine the string \"none\" to avoid having multiple types here.\n@timabbott @Gittenburg \r\nHey there are two ways (a) either I write silent in the array \"available_notification_sounds\" or should (B) or should I add files \"silent.mp3 and silent .ogg\" in \"static/audio/notification.sounds\". \r\nwhich should I do ?\nI think adding a special value would be preferable to playing empty audio files (because it might confuse users if the browser indicates that the tab is playing some sounds when it's actually not).\n> I think adding a special value would be preferable to playing empty audio files (because it might confuse users if the browser indicates that the tab is playing some sounds when it's actually not).\r\n\r\nwhat do you mean by \"special value\".\nSomething like `\"silent\"`.\n> I think adding a special value would be preferable to playing empty audio files (because it might confuse users if the browser indicates that the tab is playing some sounds when it's actually not).\r\n\r\nBut why, when we know that it's an empty string and it makes the notification sound \"silent\" when mesage comes .so why it will create a confusion for user because they only want there notification sound \"silent\" or no-sound.\r\n\nIf we would play empty audio files browsers would probably still briefly display a speaker symbol in the tab. Don't worry about it you don't have any empty audio files in your PR anyway.\n> This seems worth supporting, and is likely quite easy. The main decision is how to represent \"no sound\" in the API -- maybe the empty string would be most consistent? I could also imagine the string \"none\" to avoid having multiple types here.\r\n\r\n> I think adding a special value would be preferable to playing empty audio files (because it might confuse users if the browser indicates that the tab is playing some sounds when it's actually not).\r\n\r\nWhat about a new checkbox called `Disable notification sounds` instead? Seems cleaner both in terms of implementation (no special strings) and the settings UI.\r\n\r\n![image](https://user-images.githubusercontent.com/15276828/96177920-3ec59780-0f4c-11eb-8075-528d89b8e148.png)\r\n\r\nChecking the box would either hide or disable the dropdown + notification sound label. I'd like to help out with this.\n@areebbeigh , we just want to have a option(silent) inside the noditfication-sound , as said by Tim above.\r\n\n@zulipbot claim\nSo I just realized we already have an independent mechanism for disabling notification sounds in Zulip:\r\n\r\n![image](https://user-images.githubusercontent.com/2746074/114898020-a018d700-9dc6-11eb-95da-71f27fce311e.png)\r\n\r\nSo I think the actual issue here is a documentation/communication issue, not a feature we need to add.\r\n\r\n@parthi2929 do you remember what you checked when trying to figure out how to disable sounds? I'm wondering if it'd be useful to add a Help Center article one could find via google on disabling notification sounds.\nI think since there is specific option about Notification sound, I went there to disable or looking for silence option. Yes, better documentation could help here. But UI could also be improvised so its more intuitive. \nHello @tushar912, you claimed this issue to work on it, but this issue and any referenced pull requests haven't been updated for 10 days. Are you still working on this issue?\n\nIf so, please update this issue by leaving a comment on this issue to let me know that you're still working on it. Otherwise, I'll automatically remove you from this issue in 4 days.\n\nIf you've decided to work on something else, simply comment `@zulipbot abandon` so that someone else can claim it and continue from where you left off.\n\nThank you for your valuable contributions to Zulip!\n\n"},"created_at":{"kind":"timestamp","value":"2021-04-27T04:30:38","string":"2021-04-27T04:30:38"}}},{"rowIdx":668,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18314,"string":"18,314"},"instance_id":{"kind":"string","value":"zulip__zulip-18314"},"issue_numbers":{"kind":"list like","value":["18310"],"string":"[\n \"18310\"\n]"},"base_commit":{"kind":"string","value":"8711ab7676a7f8e720bc6b070ce7fc2a76a8047f"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/events.py b/zerver/lib/events.py\n--- a/zerver/lib/events.py\n+++ b/zerver/lib/events.py\n@@ -1107,25 +1107,6 @@ def do_events_register(\n # clients cannot compute gravatars, so we force-set it to false.\n client_gravatar = False\n \n- # Note that we pass event_types, not fetch_event_types here, since\n- # that's what controls which future events are sent.\n- queue_id = request_event_queue(\n- user_profile,\n- user_client,\n- apply_markdown,\n- client_gravatar,\n- slim_presence,\n- queue_lifespan_secs,\n- event_types,\n- all_public_streams,\n- narrow=narrow,\n- bulk_message_deletion=bulk_message_deletion,\n- stream_typing_notifications=stream_typing_notifications,\n- )\n-\n- if queue_id is None:\n- raise JsonableError(_(\"Could not allocate event queue\"))\n-\n if fetch_event_types is not None:\n event_types_set: Optional[Set[str]] = set(fetch_event_types)\n elif event_types is not None:\n@@ -1136,52 +1117,58 @@ def do_events_register(\n # Fill up the UserMessage rows if a soft-deactivated user has returned\n reactivate_user_if_soft_deactivated(user_profile)\n \n- ret = fetch_initial_state_data(\n- user_profile,\n- event_types=event_types_set,\n- queue_id=queue_id,\n- client_gravatar=client_gravatar,\n- user_avatar_url_field_optional=user_avatar_url_field_optional,\n- slim_presence=slim_presence,\n- include_subscribers=include_subscribers,\n- include_streams=include_streams,\n- )\n-\n- # Apply events that came in while we were fetching initial data\n- events = get_user_events(user_profile, queue_id, -1)\n- try:\n- apply_events(\n- user_profile,\n- state=ret,\n- events=events,\n- fetch_event_types=fetch_event_types,\n- client_gravatar=client_gravatar,\n- slim_presence=slim_presence,\n- include_subscribers=include_subscribers,\n- )\n- except RestartEventException:\n- # This represents a rare race condition, where Tornado\n- # restarted (and sent `restart` events) while we were waiting\n- # for fetch_initial_state_data to return. To avoid the client\n- # needing to reload shortly after loading, we recursively call\n- # do_events_register here.\n- ret = do_events_register(\n+ while True:\n+ # Note that we pass event_types, not fetch_event_types here, since\n+ # that's what controls which future events are sent.\n+ queue_id = request_event_queue(\n user_profile,\n user_client,\n apply_markdown,\n client_gravatar,\n slim_presence,\n- event_types,\n queue_lifespan_secs,\n+ event_types,\n all_public_streams,\n- include_subscribers,\n- include_streams,\n- client_capabilities,\n- narrow,\n- fetch_event_types,\n+ narrow=narrow,\n+ bulk_message_deletion=bulk_message_deletion,\n+ stream_typing_notifications=stream_typing_notifications,\n )\n \n- return ret\n+ if queue_id is None:\n+ raise JsonableError(_(\"Could not allocate event queue\"))\n+\n+ ret = fetch_initial_state_data(\n+ user_profile,\n+ event_types=event_types_set,\n+ queue_id=queue_id,\n+ client_gravatar=client_gravatar,\n+ user_avatar_url_field_optional=user_avatar_url_field_optional,\n+ slim_presence=slim_presence,\n+ include_subscribers=include_subscribers,\n+ include_streams=include_streams,\n+ )\n+\n+ # Apply events that came in while we were fetching initial data\n+ events = get_user_events(user_profile, queue_id, -1)\n+ try:\n+ apply_events(\n+ user_profile,\n+ state=ret,\n+ events=events,\n+ fetch_event_types=fetch_event_types,\n+ client_gravatar=client_gravatar,\n+ slim_presence=slim_presence,\n+ include_subscribers=include_subscribers,\n+ )\n+ except RestartEventException:\n+ # This represents a rare race condition, where Tornado\n+ # restarted (and sent `restart` events) while we were waiting\n+ # for fetch_initial_state_data to return. To avoid the client\n+ # needing to reload shortly after loading, we recursively call\n+ # do_events_register here.\n+ continue\n+ else:\n+ break\n \n post_process_state(user_profile, ret, notification_settings_null)\n \n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Make it impossible for the do_events_register recursive call to have missing parameters\nThere's a high-value follow-up we need to do following https://github.com/zulip/zulip/pull/18208, which is making it impossible for someone to add new parameters to do_events_register without updating the recursive call, since that would introduce a new nasty bug.\r\n\r\nWe can perhaps use the \"mandatory kwargs\" technique from this commit 0a21476, at the cost of somewhat annoying repetition. Another idea might be to create some sort of decorator that handles doing this and takes `*args, **kwargs` as parameters.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-refactoring members, this issue was labeled with the \"area: refactoring\" label, so you may want to check it out!\n\n\nStarted a thread here: https://chat.zulip.org/#narrow/stream/49-development-help/topic/recursive.20call.20question/near/1171371"},"created_at":{"kind":"timestamp","value":"2021-04-29T21:06:28","string":"2021-04-29T21:06:28"}}},{"rowIdx":669,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18399,"string":"18,399"},"instance_id":{"kind":"string","value":"zulip__zulip-18399"},"issue_numbers":{"kind":"list like","value":["18393"],"string":"[\n \"18393\"\n]"},"base_commit":{"kind":"string","value":"ad0be6cea1db64d43a0e1f402a03632535ab9863"},"patch":{"kind":"string","value":"diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.py\n--- a/zerver/webhooks/github/view.py\n+++ b/zerver/webhooks/github/view.py\n@@ -466,10 +466,8 @@ def get_pull_request_review_requested_body(helper: Helper) -> str:\n payload = helper.payload\n include_title = helper.include_title\n requested_reviewer = [payload[\"requested_reviewer\"]] if \"requested_reviewer\" in payload else []\n- requested_reviewers = payload[\"pull_request\"][\"requested_reviewers\"] or requested_reviewer\n \n requested_team = [payload[\"requested_team\"]] if \"requested_team\" in payload else []\n- requested_team_reviewers = payload[\"pull_request\"][\"requested_teams\"] or requested_team\n \n sender = get_sender_name(payload)\n pr_number = payload[\"pull_request\"][\"number\"]\n@@ -482,17 +480,14 @@ def get_pull_request_review_requested_body(helper: Helper) -> str:\n \n all_reviewers = []\n \n- for reviewer in requested_reviewers:\n+ for reviewer in requested_reviewer:\n all_reviewers.append(\"[{login}]({html_url})\".format(**reviewer))\n \n- for team_reviewer in requested_team_reviewers:\n+ for team_reviewer in requested_team:\n all_reviewers.append(\"[{name}]({html_url})\".format(**team_reviewer))\n \n reviewers = \"\"\n- if len(all_reviewers) == 1:\n- reviewers = all_reviewers[0]\n- else:\n- reviewers = \"{} and {}\".format(\", \".join(all_reviewers[:-1]), all_reviewers[-1])\n+ reviewers = all_reviewers[0]\n \n return body.format(\n sender=sender,\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.py\n--- a/zerver/webhooks/github/tests.py\n+++ b/zerver/webhooks/github/tests.py\n@@ -320,24 +320,8 @@ def test_pull_request_review_requested_msg(self) -> None:\n expected_message,\n )\n \n- def test_pull_request_review_requested_singular_key_msg(self) -> None:\n- expected_message = \"**eeshangarg** requested [rishig](https://github.com/rishig) for a review on [PR #6](https://github.com/eeshangarg/Scheduler/pull/6).\"\n- self.check_webhook(\n- \"pull_request__review_requested_singular_key\",\n- \"Scheduler / PR #6 Mention how awesome this project is in ...\",\n- expected_message,\n- )\n-\n- def test_pull_request_review_requested_multiple_reviwers_msg(self) -> None:\n- expected_message = \"**eeshangarg** requested [showell](https://github.com/showell) and [timabbott](https://github.com/timabbott) for a review on [PR #1](https://github.com/eeshangarg/Scheduler/pull/1).\"\n- self.check_webhook(\n- \"pull_request__review_requested_multiple_reviewers\",\n- \"Scheduler / PR #1 This is just a test commit\",\n- expected_message,\n- )\n-\n def test_pull_request__review_requested_team_reviewer_msg(self) -> None:\n- expected_message = \"**singhsourabh** requested [shreyaskargit](https://github.com/shreyaskargit), [bajaj99prashant](https://github.com/bajaj99prashant), [review-team](https://github.com/orgs/test-org965/teams/review-team), [authority](https://github.com/orgs/test-org965/teams/authority) and [management](https://github.com/orgs/test-org965/teams/management) for a review on [PR #4](https://github.com/test-org965/webhook-test/pull/4).\"\n+ expected_message = \"**singhsourabh** requested [authority](https://github.com/orgs/test-org965/teams/authority) for a review on [PR #4](https://github.com/test-org965/webhook-test/pull/4).\"\n self.check_webhook(\n \"pull_request__review_requested_team_reviewer\",\n \"webhook-test / PR #4 testing webhook\",\n"},"problem_statement":{"kind":"string","value":"github integration: Duplicate requested_reviewer notifications when adding two reviewers in new PR\nWhen you open a new pull request with 2 requested reviewers, GitHub's outgoing webhook API sends you 3 events in immediate succession:\r\n* A new pull request event\r\n* A new reviewer 1 event\r\n* A new reviewer 2 event\r\n\r\nGitHub's `pull_request/review_requested` payloads appear to have two copies of the data; one inside the `pull_request` key and the other at top level. Only the one at top level tells you which one is new; the other is a summary of the overall state of the PR, and appears to have both reviewers in both events. Our current processing ends up with ugly duplicate output like this:\r\n\r\n![image](https://user-images.githubusercontent.com/2746074/117494186-db6f7700-af28-11eb-87cd-d07493e45cf0.png)\r\n\r\nHere is our code; I think the bug is that we should be ignoring the `pull_request` part of the event bodies.\r\n```\r\ndef get_pull_request_review_requested_body(helper: Helper) -> str: \r\n payload = helper.payload \r\n include_title = helper.include_title \r\n requested_reviewer = [payload[\"requested_reviewer\"]] if \"requested_reviewer\" in payload else [] \r\n requested_reviewers = payload[\"pull_request\"][\"requested_reviewers\"] or requested_reviewer \r\n \r\n requested_team = [payload[\"requested_team\"]] if \"requested_team\" in payload else [] \r\n requested_team_reviewers = payload[\"pull_request\"][\"requested_teams\"] or requested_team \r\n \r\n sender = get_sender_name(payload) \r\n pr_number = payload[\"pull_request\"][\"number\"] \r\n pr_url = payload[\"pull_request\"][\"html_url\"] \r\n message = \"**{sender}** requested {reviewers} for a review on [PR #{pr_number}]({pr_url}).\" \r\n message_with_title = ( \r\n \"**{sender}** requested {reviewers} for a review on [PR #{pr_number} {title}]({pr_url}).\" \r\n ) \r\n body = message_with_title if include_title else message \r\n```\r\n\r\nOur last functional change to this code was 1b3cfecf2acef7fa2fc0ce5f4eedbb488361af91; 4c0890e8b0e67e9fc38ec11512d45149d89b2924 is also relevant history. So I think my conclusion is that we can just stop looking at the `pull_request` key and that will fix this bug.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-integrations members, this issue was labeled with the \"area: integrations\" label, so you may want to check it out!\n\n\n@zulipbot claim"},"created_at":{"kind":"timestamp","value":"2021-05-08T02:13:46","string":"2021-05-08T02:13:46"}}},{"rowIdx":670,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18413,"string":"18,413"},"instance_id":{"kind":"string","value":"zulip__zulip-18413"},"issue_numbers":{"kind":"list like","value":["18390"],"string":"[\n \"18390\"\n]"},"base_commit":{"kind":"string","value":"27d964327496f4f6236db2f21fb580e4136e0a83"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.py\n--- a/zerver/lib/markdown/__init__.py\n+++ b/zerver/lib/markdown/__init__.py\n@@ -1570,7 +1570,7 @@ def sanitize_url(url: str) -> Optional[str]:\n if not scheme:\n return sanitize_url(\"http://\" + url)\n \n- locless_schemes = [\"mailto\", \"news\", \"file\", \"bitcoin\"]\n+ locless_schemes = [\"mailto\", \"news\", \"file\", \"bitcoin\", \"sms\", \"tel\"]\n if netloc == \"\" and scheme not in locless_schemes:\n # This fails regardless of anything else.\n # Return immediately to save additional processing\n@@ -1580,7 +1580,7 @@ def sanitize_url(url: str) -> Optional[str]:\n # appears to have a netloc. Additionally there are plenty of other\n # schemes that do weird things like launch external programs. To be\n # on the safe side, we whitelist the scheme.\n- if scheme not in (\"http\", \"https\", \"ftp\", \"mailto\", \"file\", \"bitcoin\"):\n+ if scheme not in (\"http\", \"https\", \"ftp\", \"mailto\", \"file\", \"bitcoin\", \"sms\", \"tel\"):\n return None\n \n # Upstream code scans path, parameters, and query for colon characters\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/fixtures/markdown_test_cases.json b/zerver/tests/fixtures/markdown_test_cases.json\n--- a/zerver/tests/fixtures/markdown_test_cases.json\n+++ b/zerver/tests/fixtures/markdown_test_cases.json\n@@ -948,6 +948,11 @@\n \"input\": \"

*

[

Static types in Python

](https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy)*\",\n \"expected_output\": \"

&lt;h1&gt;&lt;h1&gt;&lt;h2&gt;Static types in Python&lt;/h2&gt;&lt;/h1&gt;&lt;/h1&gt;

\",\n \"marked_expected_output\": \"

&lt;h1&gt;&lt;h1&gt;&lt;h2&gt;Static types in Python&lt;/h2&gt;&lt;/h1&gt;&lt;/h1&gt;\\n\\n

\"\n+ },\n+ {\n+ \"name\": \"telephone_sms_link\",\n+ \"input\": \"[call me](tel:+14155551234) [or maybe not](sms:+14155551234)\",\n+ \"expected_output\": \"

call me or maybe not

\"\n }\n ],\n \"linkify_tests\": [\n"},"problem_statement":{"kind":"string","value":"Support `tel:` and `sms:` schemes for Markdown links\nWhen using the Markdown format, I can embed links in my messages using Markdown syntax, like so:\r\n\r\n```\r\nIf you want to email me, [click here](mailto:username@example.com).\r\n\r\nIf you want to see our site, [click here](https://example.com).\r\n```\r\n\r\nThese links are then invoked in the relevant operating-system-specified handler for their relevant URL schemes. This is great, and I like it a lot!\r\n\r\nHowever, today I tried to send a message that contained my phone number, and wanted someone clicking it to invoke their operating-system-specified handler for the `tel` and `sms` schemes, which should prompt the user to start a call or compose a text message respectively. I wrote the following Markdown:\r\n\r\n```\r\nHey, I just met you, and this is crazy,\r\nbut here's my number, so [call me](tel:+14155551234), [maybe](sms:+14155551234).\r\n```\r\n\r\nImmediately after sending the message, the relevant pieces of text showed as links (I assume with the appropriate schemes), but shortly after, they fell back to showing my unformatted Markdown.\r\n\r\nI verified that this appears in both the current Zulip Desktop and the in-browser version. I did not check the mobile application.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-markdown members, this issue was labeled with the \"area: markdown\" label, so you may want to check it out!\n\n\nThanks for the feedback! This seems like a reasonable feature to have."},"created_at":{"kind":"timestamp","value":"2021-05-09T05:05:29","string":"2021-05-09T05:05:29"}}},{"rowIdx":671,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18589,"string":"18,589"},"instance_id":{"kind":"string","value":"zulip__zulip-18589"},"issue_numbers":{"kind":"list like","value":["18256"],"string":"[\n \"18256\"\n]"},"base_commit":{"kind":"string","value":"64bd461bad57a4bbacfe2b890628ea1247323bf7"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py\n--- a/zerver/lib/actions.py\n+++ b/zerver/lib/actions.py\n@@ -6480,11 +6480,9 @@ def do_send_confirmation_email(invitee: PreregistrationUser, referrer: UserProfi\n \"activate_url\": activation_url,\n \"referrer_realm_name\": referrer.realm.name,\n }\n- from_name = f\"{referrer.full_name} (via Zulip)\"\n send_email(\n \"zerver/emails/invitation\",\n to_emails=[invitee.email],\n- from_name=from_name,\n from_address=FromAddress.tokenized_no_reply_address(),\n language=referrer.realm.default_language,\n context=context,\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py\n--- a/zerver/tests/test_signup.py\n+++ b/zerver/tests/test_signup.py\n@@ -928,9 +928,7 @@ def test_zulip_default_context_does_not_load_inline_previews(self) -> None:\n \n \n class InviteUserBase(ZulipTestCase):\n- def check_sent_emails(\n- self, correct_recipients: List[str], custom_from_name: Optional[str] = None\n- ) -> None:\n+ def check_sent_emails(self, correct_recipients: List[str]) -> None:\n from django.core.mail import outbox\n \n self.assert_length(outbox, len(correct_recipients))\n@@ -939,8 +937,7 @@ def check_sent_emails(\n if len(outbox) == 0:\n return\n \n- if custom_from_name is not None:\n- self.assertIn(custom_from_name, self.email_display_from(outbox[0]))\n+ self.assertIn(\"Zulip\", self.email_display_from(outbox[0]))\n \n self.assertEqual(self.email_envelope_from(outbox[0]), settings.NOREPLY_EMAIL_ADDRESS)\n self.assertRegex(\n@@ -987,7 +984,7 @@ def test_successful_invite_user(self) -> None:\n invitee = \"alice-test@zulip.com\"\n self.assert_json_success(self.invite(invitee, [\"Denmark\"]))\n self.assertTrue(find_key_by_email(invitee))\n- self.check_sent_emails([invitee], custom_from_name=\"Hamlet\")\n+ self.check_sent_emails([invitee])\n \n def test_newbie_restrictions(self) -> None:\n user_profile = self.example_user(\"hamlet\")\n@@ -1274,7 +1271,7 @@ def test_successful_invite_user_with_name(self) -> None:\n invitee = f\"Alice Test <{email}>\"\n self.assert_json_success(self.invite(invitee, [\"Denmark\"]))\n self.assertTrue(find_key_by_email(email))\n- self.check_sent_emails([email], custom_from_name=\"Hamlet\")\n+ self.check_sent_emails([email])\n \n def test_successful_invite_user_with_name_and_normal_one(self) -> None:\n \"\"\"\n@@ -1288,7 +1285,7 @@ def test_successful_invite_user_with_name_and_normal_one(self) -> None:\n self.assert_json_success(self.invite(invitee, [\"Denmark\"]))\n self.assertTrue(find_key_by_email(email))\n self.assertTrue(find_key_by_email(email2))\n- self.check_sent_emails([email, email2], custom_from_name=\"Hamlet\")\n+ self.check_sent_emails([email, email2])\n \n def test_can_invite_others_to_realm(self) -> None:\n def validation_func(user_profile: UserProfile) -> bool:\n@@ -2230,7 +2227,7 @@ def test_successful_resend_invitation(self) -> None:\n prereg_user = PreregistrationUser.objects.get(email=invitee)\n \n # Verify and then clear from the outbox the original invite email\n- self.check_sent_emails([invitee], custom_from_name=\"Zulip\")\n+ self.check_sent_emails([invitee])\n from django.core.mail import outbox\n \n outbox.pop()\n@@ -2261,7 +2258,7 @@ def test_successful_resend_invitation(self) -> None:\n error_result = self.client_post(\"/json/invites/\" + str(9999) + \"/resend\")\n self.assert_json_error(error_result, \"No such invitation\")\n \n- self.check_sent_emails([invitee], custom_from_name=\"Zulip\")\n+ self.check_sent_emails([invitee])\n \n def test_successful_member_resend_invitation(self) -> None:\n \"\"\"A POST call from member a account to /json/invites//resend\n@@ -2278,7 +2275,7 @@ def test_successful_member_resend_invitation(self) -> None:\n prereg_user = PreregistrationUser.objects.get(email=invitee)\n \n # Verify and then clear from the outbox the original invite email\n- self.check_sent_emails([invitee], custom_from_name=\"Zulip\")\n+ self.check_sent_emails([invitee])\n from django.core.mail import outbox\n \n outbox.pop()\n@@ -2309,7 +2306,7 @@ def test_successful_member_resend_invitation(self) -> None:\n error_result = self.client_post(\"/json/invites/\" + str(9999) + \"/resend\")\n self.assert_json_error(error_result, \"No such invitation\")\n \n- self.check_sent_emails([invitee], custom_from_name=\"Zulip\")\n+ self.check_sent_emails([invitee])\n \n self.logout()\n self.login(\"othello\")\n@@ -2329,7 +2326,7 @@ def test_resend_owner_invitation(self) -> None:\n invitee, [\"Denmark\"], invite_as=PreregistrationUser.INVITE_AS[\"REALM_OWNER\"]\n )\n )\n- self.check_sent_emails([invitee], custom_from_name=\"Zulip\")\n+ self.check_sent_emails([invitee])\n scheduledemail_filter = ScheduledEmail.objects.filter(\n address__iexact=invitee, type=ScheduledEmail.INVITATION_REMINDER\n )\n"},"problem_statement":{"kind":"string","value":"Add a setting to disable sender names in email notifications\nWhen sending email notifications we currently, when relevant, put a user's name in the From header of the email message. E.g. if I trigger an invitation email to someone, my name will be put in the From header. For some organizations this can be undesirable, because some phishing detection systems (Google's Advanced phishing and malware protection system is the case we've run into) can mark such messages as suspicious - due to the fact that the name of the company's employee is indicated as the sender, even though the email is coming from an unrelated domain.\r\n\r\nWe should add an organizaton-level setting `Disable sender names in email notifications` that would disable this behavior and instead use a fixed, generic string in the From field - `Zulip` or `Zulip notifications` are the two ideas that popped up.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-development, @zulip/server-settings members, this issue was labeled with the \"area: emails\", \"area: settings (admin/org)\" labels, so you may want to check it out!\n\n\n@zulipbot claim\nHello @tushar912, you claimed this issue to work on it, but this issue and any referenced pull requests haven't been updated for 10 days. Are you still working on this issue?\n\nIf so, please update this issue by leaving a comment on this issue to let me know that you're still working on it. Otherwise, I'll automatically remove you from this issue in 4 days.\n\nIf you've decided to work on something else, simply comment `@zulipbot abandon` so that someone else can claim it and continue from where you left off.\n\nThank you for your valuable contributions to Zulip!\n\n\n@sahil839 this might be a good project for you to pick up -- we've been seeing this issue an increasing amount of late.\nOkay, will start working on this along with other issues.\r\n@zulipbot claim"},"created_at":{"kind":"timestamp","value":"2021-05-25T06:58:25","string":"2021-05-25T06:58:25"}}},{"rowIdx":672,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18598,"string":"18,598"},"instance_id":{"kind":"string","value":"zulip__zulip-18598"},"issue_numbers":{"kind":"list like","value":["18580"],"string":"[\n \"18580\"\n]"},"base_commit":{"kind":"string","value":"0e42a3f11729b61f5168a90ef903557c3d4265be"},"patch":{"kind":"string","value":"diff --git a/zerver/webhooks/pivotal/view.py b/zerver/webhooks/pivotal/view.py\n--- a/zerver/webhooks/pivotal/view.py\n+++ b/zerver/webhooks/pivotal/view.py\n@@ -72,6 +72,7 @@ def get_text(attrs: List[str]) -> str:\n \"story_delete_activity\",\n \"story_move_into_project_activity\",\n \"epic_update_activity\",\n+ \"label_create_activity\",\n ]\n \n \n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Pivotal integration exception\nHi, \r\nI've added Pivotal integration and from time to time I receive those two e-mails when working in Pivotal:\r\nI'm running ubuntu 20.04\r\n\r\nIf you need more information, I'd be happy to help.\r\n\r\n```\r\nLogger django.request, from module django.utils.log line 224:\r\nError generated by PivotalMessenger (Member) on *** deployment\r\n\r\nNo stack trace available\r\n\r\nDeployed code:\r\n- git: None\r\n- ZULIP_VERSION: 4.2\r\n\r\n\r\nRequest info:\r\n- path: /api/v1/external/pivotal\r\n- POST: {}\r\n- REMOTE_ADDR: \"35.184.18.147\"\r\n- QUERY_STRING: \"api_key=******&stream=******&topic=******\"\r\n- SERVER_NAME: \"\"\r\n```\r\n\r\n```\r\nLogger zerver.middleware.json_error_handler, from module zerver.middleware line 450:\r\nError generated by PivotalMessenger (Member) on *** deployment\r\n\r\nTraceback (most recent call last):\r\n File \"/usr/lib/python3.8/xml/etree/ElementTree.py\", line 1693, in feed\r\n self.parser.Parse(data, 0)\r\nxml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 0\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File \"./zerver/webhooks/pivotal/view.py\", line 172, in api_pivotal_webhook\r\n subject, content = api_pivotal_webhook_v3(request, user_profile)\r\n File \"./zerver/webhooks/pivotal/view.py\", line 19, in api_pivotal_webhook_v3\r\n payload = xml_fromstring(request.body)\r\n File \"/srv/zulip-venv-cache/9d0f5ac272f4e644b222ed65b0b5a996616a215f/zulip-py3-venv/lib/python3.8/site-packages/defusedxml/common.py\", line 131, in fromstring\r\n parser.feed(text)\r\n File \"/usr/lib/python3.8/xml/etree/ElementTree.py\", line 1695, in feed\r\n self._raiseerror(v)\r\n File \"/usr/lib/python3.8/xml/etree/ElementTree.py\", line 1602, in _raiseerror\r\n raise err\r\n File \"\", line None\r\nxml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File \"/srv/zulip-venv-cache/9d0f5ac272f4e644b222ed65b0b5a996616a215f/zulip-py3-venv/lib/python3.8/site-packages/django/core/handlers/base.py\", line 181, in _get_response\r\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\n File \"/srv/zulip-venv-cache/9d0f5ac272f4e644b222ed65b0b5a996616a215f/zulip-py3-venv/lib/python3.8/site-packages/django/views/decorators/csrf.py\", line 54, in wrapped_view\r\n return view_func(*args, **kwargs)\r\n File \"./zerver/lib/request.py\", line 390, in _wrapped_view_func\r\n return view_func(request, *args, **kwargs)\r\n File \"./zerver/decorator.py\", line 354, in _wrapped_func_arguments\r\n raise err\r\n File \"./zerver/decorator.py\", line 334, in _wrapped_func_arguments\r\n return view_func(request, user_profile, *args, **kwargs)\r\n File \"./zerver/lib/request.py\", line 390, in _wrapped_view_func\r\n return view_func(request, *args, **kwargs)\r\n File \"./zerver/webhooks/pivotal/view.py\", line 175, in api_pivotal_webhook\r\n subject, content = api_pivotal_webhook_v5(request, user_profile)\r\n File \"./zerver/webhooks/pivotal/view.py\", line 87, in api_pivotal_webhook_v5\r\n story_url = primary_resources[\"url\"]\r\nKeyError: 'url'\r\n\r\n\r\nDeployed code:\r\n- git: None\r\n- ZULIP_VERSION: 4.2\r\n\r\n\r\nRequest info:\r\n- path: /api/v1/external/pivotal\r\n- POST: {}\r\n- REMOTE_ADDR: \"35.184.18.147\"\r\n- QUERY_STRING: \"api_key=******&stream=******&topic=******\"\r\n- SERVER_NAME: \"\"\r\n\r\n\r\n```\n"},"hints_text":{"kind":"string","value":"Thanks for the report @vrozkovec! Error payloads from webhooks should be logged to `/var/log/zulip/webhooks_errors.log`; can you capture that to figure out what event type is causing the exception? \r\n\r\n(Sharing the whole payload, potentially after anonymizing any data with `example.com` type values, is ideal for being able to fix it quickly, but even just knowing the event type makes it a lot easier to reproduce)\nHello @zulip/server-integrations members, this issue was labeled with the \"area: integrations\" label, so you may want to check it out!\n\n\nHi @timabbott, here are few last payloads: \r\n[log.txt](https://github.com/zulip/zulip/files/6536711/log.txt)\r\n\n@vrozkovec thanks! That should make it possible for someone to investigate and fix this.\n@zulipbot claim\n@vrozkovec are you wanting to alert on this event or not? As we have a list of a bunch of unsupported events that we just ignore, we can just add to this if you aren't specifically wanting to alert on this event.\nAs the content of that payload seems pretty useless to be fair."},"created_at":{"kind":"timestamp","value":"2021-05-25T21:30:57","string":"2021-05-25T21:30:57"}}},{"rowIdx":673,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18606,"string":"18,606"},"instance_id":{"kind":"string","value":"zulip__zulip-18606"},"issue_numbers":{"kind":"list like","value":["18604"],"string":"[\n \"18604\"\n]"},"base_commit":{"kind":"string","value":"d37ddf13a42dee2e7b545dde0c02bebfeeef8608"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py\n--- a/zerver/lib/actions.py\n+++ b/zerver/lib/actions.py\n@@ -2703,6 +2703,39 @@ def check_schedule_message(\n return do_schedule_messages([send_request])[0]\n \n \n+def validate_message_edit_payload(\n+ message: Message,\n+ stream_id: Optional[int],\n+ topic_name: Optional[str],\n+ propagate_mode: Optional[str],\n+ content: Optional[str],\n+) -> None:\n+ \"\"\"\n+ Checks that the data sent is well-formed. Does not handle editability, permissions etc.\n+ \"\"\"\n+ if topic_name is None and content is None and stream_id is None:\n+ raise JsonableError(_(\"Nothing to change\"))\n+\n+ if not message.is_stream_message():\n+ if stream_id is not None:\n+ raise JsonableError(_(\"Private messages cannot be moved to streams.\"))\n+ if topic_name is not None:\n+ raise JsonableError(_(\"Private messages cannot have topics.\"))\n+\n+ if propagate_mode != \"change_one\" and topic_name is None and stream_id is None:\n+ raise JsonableError(_(\"Invalid propagate_mode without topic edit\"))\n+\n+ if topic_name == \"\":\n+ raise JsonableError(_(\"Topic can't be empty\"))\n+\n+ if stream_id is not None and content is not None:\n+ raise JsonableError(_(\"Cannot change message content while changing stream\"))\n+\n+ # Right now, we prevent users from editing widgets.\n+ if content is not None and is_widget_message(message):\n+ raise JsonableError(_(\"Widgets cannot be edited.\"))\n+\n+\n def check_update_message(\n user_profile: UserProfile,\n message_id: int,\n@@ -2718,13 +2751,19 @@ def check_update_message(\n and raises a JsonableError if otherwise.\n It returns the number changed.\n \"\"\"\n+ message, ignored_user_message = access_message(user_profile, message_id)\n+\n if not user_profile.realm.allow_message_editing:\n raise JsonableError(_(\"Your organization has turned off message editing\"))\n \n- if propagate_mode != \"change_one\" and topic_name is None and stream_id is None:\n- raise JsonableError(_(\"Invalid propagate_mode without topic edit\"))\n+ # The zerver/views/message_edit.py callpoint already strips this\n+ # via REQ_topic; so we can delete this line if we arrange a\n+ # contract where future callers in the embedded bots system strip\n+ # use REQ_topic as well (or otherwise are guaranteed to strip input).\n+ if topic_name is not None:\n+ topic_name = topic_name.strip()\n+ validate_message_edit_payload(message, stream_id, topic_name, propagate_mode, content)\n \n- message, ignored_user_message = access_message(user_profile, message_id)\n is_no_topic_msg = message.topic_name() == \"(no topic)\"\n \n # You only have permission to edit a message if:\n@@ -2744,10 +2783,6 @@ def check_update_message(\n else:\n raise JsonableError(_(\"You don't have permission to edit this message\"))\n \n- # Right now, we prevent users from editing widgets.\n- if content is not None and is_widget_message(message):\n- raise JsonableError(_(\"Widgets cannot be edited.\"))\n-\n # If there is a change to the content, check that it hasn't been too long\n # Allow an extra 20 seconds since we potentially allow editing 15 seconds\n # past the limit, and in case there are network issues, etc. The 15 comes\n@@ -2773,12 +2808,6 @@ def check_update_message(\n if (timezone_now() - message.date_sent) > datetime.timedelta(seconds=deadline_seconds):\n raise JsonableError(_(\"The time limit for editing this message has passed\"))\n \n- if topic_name is None and content is None and stream_id is None:\n- raise JsonableError(_(\"Nothing to change\"))\n- if topic_name is not None:\n- topic_name = topic_name.strip()\n- if topic_name == \"\":\n- raise JsonableError(_(\"Topic can't be empty\"))\n rendered_content = None\n links_for_embed: Set[str] = set()\n prior_mention_user_ids: Set[int] = set()\n@@ -2815,8 +2844,7 @@ def check_update_message(\n number_changed = 0\n \n if stream_id is not None:\n- if not message.is_stream_message():\n- raise JsonableError(_(\"Message must be a stream message\"))\n+ assert message.is_stream_message()\n if not user_profile.can_move_messages_between_streams():\n raise JsonableError(_(\"You don't have permission to move this message\"))\n try:\n@@ -2827,8 +2855,6 @@ def check_update_message(\n \"You don't have permission to move this message due to missing access to its stream\"\n )\n )\n- if content is not None:\n- raise JsonableError(_(\"Cannot change message content while changing stream\"))\n \n new_stream = access_stream_by_id(user_profile, stream_id, require_active=True)[0]\n check_stream_access_based_on_stream_post_policy(user_profile, new_stream)\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.py\n--- a/zerver/tests/test_message_edit.py\n+++ b/zerver/tests/test_message_edit.py\n@@ -22,7 +22,7 @@\n from zerver.models import Message, Realm, Stream, UserMessage, UserProfile, get_realm, get_stream\n \n \n-class EditMessageTest(ZulipTestCase):\n+class EditMessageTestCase(ZulipTestCase):\n def check_topic(self, msg_id: int, topic_name: str) -> None:\n msg = Message.objects.get(id=msg_id)\n self.assertEqual(msg.topic_name(), topic_name)\n@@ -74,6 +74,155 @@ def check_message(self, msg_id: int, topic_name: str, content: str) -> None:\n orjson.loads(msg.edit_history),\n )\n \n+ def prepare_move_topics(\n+ self, user_email: str, old_stream: str, new_stream: str, topic: str\n+ ) -> Tuple[UserProfile, Stream, Stream, int, int]:\n+ user_profile = self.example_user(user_email)\n+ self.login(user_email)\n+ stream = self.make_stream(old_stream)\n+ new_stream = self.make_stream(new_stream)\n+ self.subscribe(user_profile, stream.name)\n+ self.subscribe(user_profile, new_stream.name)\n+ msg_id = self.send_stream_message(\n+ user_profile, stream.name, topic_name=topic, content=\"First\"\n+ )\n+ msg_id_lt = self.send_stream_message(\n+ user_profile, stream.name, topic_name=topic, content=\"Second\"\n+ )\n+\n+ self.send_stream_message(user_profile, stream.name, topic_name=topic, content=\"third\")\n+\n+ return (user_profile, stream, new_stream, msg_id, msg_id_lt)\n+\n+\n+class EditMessagePayloadTest(EditMessageTestCase):\n+ def test_edit_message_no_changes(self) -> None:\n+ self.login(\"hamlet\")\n+ msg_id = self.send_stream_message(\n+ self.example_user(\"hamlet\"), \"Scotland\", topic_name=\"editing\", content=\"before edit\"\n+ )\n+ result = self.client_patch(\n+ \"/json/messages/\" + str(msg_id),\n+ {\n+ \"message_id\": msg_id,\n+ },\n+ )\n+ self.assert_json_error(result, \"Nothing to change\")\n+\n+ def test_move_message_cant_move_private_message(self) -> None:\n+ hamlet = self.example_user(\"hamlet\")\n+ self.login(\"hamlet\")\n+ cordelia = self.example_user(\"cordelia\")\n+ msg_id = self.send_personal_message(hamlet, cordelia)\n+\n+ verona = get_stream(\"Verona\", hamlet.realm)\n+\n+ result = self.client_patch(\n+ \"/json/messages/\" + str(msg_id),\n+ {\n+ \"message_id\": msg_id,\n+ \"stream_id\": verona.id,\n+ },\n+ )\n+\n+ self.assert_json_error(result, \"Private messages cannot be moved to streams.\")\n+\n+ def test_private_message_edit_topic(self) -> None:\n+ hamlet = self.example_user(\"hamlet\")\n+ self.login(\"hamlet\")\n+ cordelia = self.example_user(\"cordelia\")\n+ msg_id = self.send_personal_message(hamlet, cordelia)\n+\n+ result = self.client_patch(\n+ \"/json/messages/\" + str(msg_id),\n+ {\n+ \"message_id\": msg_id,\n+ \"topic\": \"Should not exist\",\n+ },\n+ )\n+\n+ self.assert_json_error(result, \"Private messages cannot have topics.\")\n+\n+ def test_propagate_invalid(self) -> None:\n+ self.login(\"hamlet\")\n+ id1 = self.send_stream_message(self.example_user(\"hamlet\"), \"Scotland\", topic_name=\"topic1\")\n+\n+ result = self.client_patch(\n+ \"/json/messages/\" + str(id1),\n+ {\n+ \"topic\": \"edited\",\n+ \"propagate_mode\": \"invalid\",\n+ },\n+ )\n+ self.assert_json_error(result, \"Invalid propagate_mode\")\n+ self.check_topic(id1, topic_name=\"topic1\")\n+\n+ result = self.client_patch(\n+ \"/json/messages/\" + str(id1),\n+ {\n+ \"content\": \"edited\",\n+ \"propagate_mode\": \"change_all\",\n+ },\n+ )\n+ self.assert_json_error(result, \"Invalid propagate_mode without topic edit\")\n+ self.check_topic(id1, topic_name=\"topic1\")\n+\n+ def test_edit_message_no_topic(self) -> None:\n+ self.login(\"hamlet\")\n+ msg_id = self.send_stream_message(\n+ self.example_user(\"hamlet\"), \"Scotland\", topic_name=\"editing\", content=\"before edit\"\n+ )\n+ result = self.client_patch(\n+ \"/json/messages/\" + str(msg_id),\n+ {\n+ \"message_id\": msg_id,\n+ \"topic\": \" \",\n+ },\n+ )\n+ self.assert_json_error(result, \"Topic can't be empty\")\n+\n+ def test_move_message_to_stream_with_content(self) -> None:\n+ (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(\n+ \"iago\", \"test move stream\", \"new stream\", \"test\"\n+ )\n+\n+ result = self.client_patch(\n+ \"/json/messages/\" + str(msg_id),\n+ {\n+ \"message_id\": msg_id,\n+ \"stream_id\": new_stream.id,\n+ \"propagate_mode\": \"change_all\",\n+ \"content\": \"Not allowed\",\n+ },\n+ )\n+ self.assert_json_error(result, \"Cannot change message content while changing stream\")\n+\n+ messages = get_topic_messages(user_profile, old_stream, \"test\")\n+ self.assert_length(messages, 3)\n+\n+ messages = get_topic_messages(user_profile, new_stream, \"test\")\n+ self.assert_length(messages, 0)\n+\n+ # Right now, we prevent users from editing widgets.\n+ def test_edit_submessage(self) -> None:\n+ self.login(\"hamlet\")\n+ msg_id = self.send_stream_message(\n+ self.example_user(\"hamlet\"),\n+ \"Scotland\",\n+ topic_name=\"editing\",\n+ content=\"/poll Games?\\nYES\\nNO\",\n+ )\n+ result = self.client_patch(\n+ \"/json/messages/\" + str(msg_id),\n+ {\n+ \"message_id\": msg_id,\n+ \"content\": \"/poll Games?\\nYES\\nNO\\nMaybe\",\n+ },\n+ )\n+ self.assert_json_error(result, \"Widgets cannot be edited.\")\n+\n+\n+class EditMessageTest(EditMessageTestCase):\n def test_query_count_on_to_dict_uncached(self) -> None:\n # `to_dict_uncached` method is used by the mechanisms\n # tested in this class. Hence, its performance is tested here.\n@@ -189,24 +338,6 @@ def test_fetch_raw_message_private_stream(self) -> None:\n result = self.client_get(\"/json/messages/\" + str(msg_id))\n self.assert_json_error(result, \"Invalid message(s)\")\n \n- # Right now, we prevent users from editing widgets.\n- def test_edit_submessage(self) -> None:\n- self.login(\"hamlet\")\n- msg_id = self.send_stream_message(\n- self.example_user(\"hamlet\"),\n- \"Scotland\",\n- topic_name=\"editing\",\n- content=\"/poll Games?\\nYES\\nNO\",\n- )\n- result = self.client_patch(\n- \"/json/messages/\" + str(msg_id),\n- {\n- \"message_id\": msg_id,\n- \"content\": \"/poll Games?\\nYES\\nNO\\nMaybe\",\n- },\n- )\n- self.assert_json_error(result, \"Widgets cannot be edited.\")\n-\n def test_edit_message_no_permission(self) -> None:\n self.login(\"hamlet\")\n msg_id = self.send_stream_message(\n@@ -221,33 +352,6 @@ def test_edit_message_no_permission(self) -> None:\n )\n self.assert_json_error(result, \"You don't have permission to edit this message\")\n \n- def test_edit_message_no_changes(self) -> None:\n- self.login(\"hamlet\")\n- msg_id = self.send_stream_message(\n- self.example_user(\"hamlet\"), \"Scotland\", topic_name=\"editing\", content=\"before edit\"\n- )\n- result = self.client_patch(\n- \"/json/messages/\" + str(msg_id),\n- {\n- \"message_id\": msg_id,\n- },\n- )\n- self.assert_json_error(result, \"Nothing to change\")\n-\n- def test_edit_message_no_topic(self) -> None:\n- self.login(\"hamlet\")\n- msg_id = self.send_stream_message(\n- self.example_user(\"hamlet\"), \"Scotland\", topic_name=\"editing\", content=\"before edit\"\n- )\n- result = self.client_patch(\n- \"/json/messages/\" + str(msg_id),\n- {\n- \"message_id\": msg_id,\n- \"topic\": \" \",\n- },\n- )\n- self.assert_json_error(result, \"Topic can't be empty\")\n-\n def test_edit_message_no_content(self) -> None:\n self.login(\"hamlet\")\n msg_id = self.send_stream_message(\n@@ -1072,50 +1176,6 @@ def test_propagate_all_topics_with_different_uppercase_letters(self) -> None:\n self.check_topic(id3, topic_name=\"topiC1\")\n self.check_topic(id4, topic_name=\"edited\")\n \n- def test_propagate_invalid(self) -> None:\n- self.login(\"hamlet\")\n- id1 = self.send_stream_message(self.example_user(\"hamlet\"), \"Scotland\", topic_name=\"topic1\")\n-\n- result = self.client_patch(\n- \"/json/messages/\" + str(id1),\n- {\n- \"topic\": \"edited\",\n- \"propagate_mode\": \"invalid\",\n- },\n- )\n- self.assert_json_error(result, \"Invalid propagate_mode\")\n- self.check_topic(id1, topic_name=\"topic1\")\n-\n- result = self.client_patch(\n- \"/json/messages/\" + str(id1),\n- {\n- \"content\": \"edited\",\n- \"propagate_mode\": \"change_all\",\n- },\n- )\n- self.assert_json_error(result, \"Invalid propagate_mode without topic edit\")\n- self.check_topic(id1, topic_name=\"topic1\")\n-\n- def prepare_move_topics(\n- self, user_email: str, old_stream: str, new_stream: str, topic: str\n- ) -> Tuple[UserProfile, Stream, Stream, int, int]:\n- user_profile = self.example_user(user_email)\n- self.login(user_email)\n- stream = self.make_stream(old_stream)\n- new_stream = self.make_stream(new_stream)\n- self.subscribe(user_profile, stream.name)\n- self.subscribe(user_profile, new_stream.name)\n- msg_id = self.send_stream_message(\n- user_profile, stream.name, topic_name=topic, content=\"First\"\n- )\n- msg_id_lt = self.send_stream_message(\n- user_profile, stream.name, topic_name=topic, content=\"Second\"\n- )\n-\n- self.send_stream_message(user_profile, stream.name, topic_name=topic, content=\"third\")\n-\n- return (user_profile, stream, new_stream, msg_id, msg_id_lt)\n-\n def test_move_message_to_stream(self) -> None:\n (user_profile, old_stream, new_stream, msg_id, msg_id_lt) = self.prepare_move_topics(\n \"iago\", \"test move stream\", \"new stream\", \"test\"\n@@ -1268,29 +1328,6 @@ def test_move_message_from_private_stream_message_access_checks(\n private_stream.recipient_id,\n )\n \n- def test_move_message_cant_move_private_message(\n- self,\n- ) -> None:\n- user_profile = self.example_user(\"iago\")\n- self.assertEqual(user_profile.role, UserProfile.ROLE_REALM_ADMINISTRATOR)\n- self.login(\"iago\")\n-\n- hamlet = self.example_user(\"hamlet\")\n- msg_id = self.send_personal_message(user_profile, hamlet)\n-\n- verona = get_stream(\"Verona\", user_profile.realm)\n-\n- result = self.client_patch(\n- \"/json/messages/\" + str(msg_id),\n- {\n- \"message_id\": msg_id,\n- \"stream_id\": verona.id,\n- \"propagate_mode\": \"change_all\",\n- },\n- )\n-\n- self.assert_json_error(result, \"Message must be a stream message\")\n-\n def test_move_message_to_stream_change_later(self) -> None:\n (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(\n \"iago\", \"test move stream\", \"new stream\", \"test\"\n@@ -1491,28 +1528,6 @@ def check_move_message_to_stream(role: int, error_msg: Optional[str] = None) ->\n )\n check_move_message_to_stream(UserProfile.ROLE_MEMBER)\n \n- def test_move_message_to_stream_with_content(self) -> None:\n- (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(\n- \"iago\", \"test move stream\", \"new stream\", \"test\"\n- )\n-\n- result = self.client_patch(\n- \"/json/messages/\" + str(msg_id),\n- {\n- \"message_id\": msg_id,\n- \"stream_id\": new_stream.id,\n- \"propagate_mode\": \"change_all\",\n- \"content\": \"Not allowed\",\n- },\n- )\n- self.assert_json_error(result, \"Cannot change message content while changing stream\")\n-\n- messages = get_topic_messages(user_profile, old_stream, \"test\")\n- self.assert_length(messages, 3)\n-\n- messages = get_topic_messages(user_profile, new_stream, \"test\")\n- self.assert_length(messages, 0)\n-\n def test_move_message_to_stream_and_topic(self) -> None:\n (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics(\n \"iago\", \"test move stream\", \"new stream\", \"test\"\n"},"problem_statement":{"kind":"string","value":"Passing a 'topic_name' when editing a private message using API raises AssertionError\nWhen a user tries to pass `topic_name` while editing a private message using the API, the below code raises AssertionError on `stream_being_edited` not being `None`.\r\n```python\r\nupdate_edit_history(target_message, timestamp, edit_history_event)\r\n\r\ndelete_event_notify_user_ids: List[int] = []\r\nif propagate_mode in [\"change_later\", \"change_all\"]:\r\n assert topic_name is not None or new_stream is not None\r\n assert stream_being_edited is not None\r\n```\n"},"hints_text":{"kind":"string","value":"Tagging as a priority because it's a 500 error in production, and we have a goal of having none of those."},"created_at":{"kind":"timestamp","value":"2021-05-26T10:37:19","string":"2021-05-26T10:37:19"}}},{"rowIdx":674,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18655,"string":"18,655"},"instance_id":{"kind":"string","value":"zulip__zulip-18655"},"issue_numbers":{"kind":"list like","value":["17786"],"string":"[\n \"17786\"\n]"},"base_commit":{"kind":"string","value":"bf179b7d2f04e8085277b9e6f6fc7651cea06d34"},"patch":{"kind":"string","value":"diff --git a/zerver/views/registration.py b/zerver/views/registration.py\n--- a/zerver/views/registration.py\n+++ b/zerver/views/registration.py\n@@ -534,7 +534,10 @@ def send_confirm_registration_email(\n to_emails=[email],\n from_address=FromAddress.tokenized_no_reply_address(),\n language=language,\n- context={\"activate_url\": activation_url},\n+ context={\n+ \"create_realm\": (realm is None),\n+ \"activate_url\": activation_url,\n+ },\n realm=realm,\n )\n \n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py\n--- a/zerver/lib/test_classes.py\n+++ b/zerver/lib/test_classes.py\n@@ -649,6 +649,8 @@ def get_confirmation_url_from_outbox(\n email_address: str,\n *,\n url_pattern: Optional[str] = None,\n+ email_subject_contains: Optional[str] = None,\n+ email_body_contains: Optional[str] = None,\n ) -> str:\n from django.core.mail import outbox\n \n@@ -661,6 +663,13 @@ def get_confirmation_url_from_outbox(\n ):\n match = re.search(url_pattern, message.body)\n assert match is not None\n+\n+ if email_subject_contains:\n+ self.assertIn(email_subject_contains, message.subject)\n+\n+ if email_body_contains:\n+ self.assertIn(email_body_contains, message.body)\n+\n [confirmation_url] = match.groups()\n return confirmation_url\n else:\ndiff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py\n--- a/zerver/tests/test_signup.py\n+++ b/zerver/tests/test_signup.py\n@@ -2769,8 +2769,13 @@ def check_able_to_create_realm(self, email: str, password: str = \"test\") -> None\n result = self.client_get(result[\"Location\"])\n self.assert_in_response(\"Check your email so we can get started.\", result)\n \n- # Visit the confirmation link.\n- confirmation_url = self.get_confirmation_url_from_outbox(email)\n+ # Check confirmation email has the correct subject and body, extract\n+ # confirmation link and visit it\n+ confirmation_url = self.get_confirmation_url_from_outbox(\n+ email,\n+ email_subject_contains=\"Create your Zulip organization\",\n+ email_body_contains=\"You have requested a new Zulip organization\",\n+ )\n result = self.client_get(confirmation_url)\n self.assertEqual(result.status_code, 200)\n \n"},"problem_statement":{"kind":"string","value":"Customize \"Activate your Zulip account\" email when creating a new org\nThe email generated for creating a new org does not say anywhere that you'll be creating a new org.\r\n\r\n![image](https://user-images.githubusercontent.com/2090066/112421854-cc8d8600-8d27-11eb-971b-88fe41fae868.png)\r\n\r\nWe should probably change:\r\n* subject line -> \"Create your Zulip organization\"\r\n* text above the button\r\n\r\nDraft text (minimally different from current version):\r\n> You have requested a new Zulip organization. Awesome!\r\n> Click the button below to create the organization and register your account.\r\n\r\n\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-development, @zulip/server-onboarding members, this issue was labeled with the \"area: emails\", \"area: onboarding\" labels, so you may want to check it out!\n\n\nThanks for the report! That'd be a nice improvement.\n@zulipbot claim\r\n\nWelcome to Zulip, @gupta-piyush19! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!\n\nHere's some tips to get you off to a good start:\n* Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.\n* [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.\n\nAs you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.\n\nSee you on the other side (that is, the pull request side)!\n@timabbott can you please help me in finding code for this? It is really a large codebase, not able to find the same.\n@gupta-piyush19 Zulip's only a medium-size codebase. But you can generally find anything in a codebase using `git grep` -- e.g. `git grep 'Complete registration'`:\r\n\r\n```\r\n...\r\ntemplates/zerver/emails/confirm_registration.source.html: {{ _('Complete registration') }}\r\ntemplates/zerver/emails/invitation.source.html: {{ _(\"Complete registration\") }}\r\ntemplates/zerver/emails/invitation_reminder.source.html: {{ _(\"Complete registration\") }}\r\n```\r\nCheck out our [GitHub guide](https://zulip.readthedocs.io/en/latest/git-guide.html) for more useful advice.\nHello Everyone, I am new here #newmember. I am Roushan Kumar from India. Please guide me, I am intereseted in working on this project.\n@zulipbot claim\nHello @weilirs, it looks like someone has already claimed this issue! Since we believe multiple assignments to the same issue may cause some confusion, we encourage you to search for other unclaimed issues to work on. However, you can always reclaim this issue if no one is working on it.\n\nWe look forward to your valuable contributions!\nHello @gupta-piyush19, you claimed this issue to work on it, but this issue and any referenced pull requests haven't been updated for 10 days. Are you still working on this issue?\n\nIf so, please update this issue by leaving a comment on this issue to let me know that you're still working on it. Otherwise, I'll automatically remove you from this issue in 4 days.\n\nIf you've decided to work on something else, simply comment `@zulipbot abandon` so that someone else can claim it and continue from where you left off.\n\nThank you for your valuable contributions to Zulip!\n\n\n@zulipbot claim\n@zulipbot claim\nHello @stefanieelling, it looks like we've already sent you a collaboration invite at https://github.com/zulip/zulip/invitations, but you haven't accepted it yet!\n\nPlease accept the invite and try to claim this issue again afterwards. We look forward to your contributions!\n> Hello @stefanieelling, it looks like we've already sent you a collaboration invite at https://github.com/zulip/zulip/invitations, but you haven't accepted it yet!\r\n> \r\n> Please accept the invite and try to claim this issue again afterwards. We look forward to your contributions!\r\n\r\n@zulipbot can you resend the invitation please?\n@zulipbot claim\nWelcome to Zulip, @lawynnj! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!\n\nHere's some tips to get you off to a good start:\n* Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.\n* [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.\n\nAs you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.\n\nSee you on the other side (that is, the pull request side)!\n@zulipbot claim\n@zulipbot claim\n@zulipbot claim\nWelcome to Zulip, @MayurDeshmukh10! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!\n\nHere's some tips to get you off to a good start:\n* Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.\n* [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.\n\nAs you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.\n\nSee you on the other side (that is, the pull request side)!\n@zulipbot claim\nWelcome to Zulip, @gilbertbw! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!\n\nHere's some tips to get you off to a good start:\n* Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.\n* [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.\n\nAs you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.\n\nSee you on the other side (that is, the pull request side)!"},"created_at":{"kind":"timestamp","value":"2021-05-31T17:39:01","string":"2021-05-31T17:39:01"}}},{"rowIdx":675,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18775,"string":"18,775"},"instance_id":{"kind":"string","value":"zulip__zulip-18775"},"issue_numbers":{"kind":"list like","value":["18687"],"string":"[\n \"18687\"\n]"},"base_commit":{"kind":"string","value":"0eb33b70ddc6eced84283581bb3509c6052cd563"},"patch":{"kind":"string","value":"diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py\n--- a/tools/linter_lib/custom_check.py\n+++ b/tools/linter_lib/custom_check.py\n@@ -212,6 +212,12 @@\n \"good_lines\": [\"#my-style {color: blue;}\"],\n \"bad_lines\": ['

Foo

', 'style = \"color: blue;\"'],\n },\n+ {\n+ \"pattern\": r\"assert\\(\",\n+ \"description\": \"Use 'assert.ok' instead of 'assert'. We avoid the use of 'assert' as it can easily be confused with 'assert.equal'.\",\n+ \"good_lines\": [\"assert.ok(...)\"],\n+ \"bad_lines\": [\"assert(...)\"],\n+ },\n *whitespace_rules,\n ],\n )\n"},"test_patch":{"kind":"string","value":"diff --git a/frontend_tests/node_tests/activity.js b/frontend_tests/node_tests/activity.js\n--- a/frontend_tests/node_tests/activity.js\n+++ b/frontend_tests/node_tests/activity.js\n@@ -340,7 +340,7 @@ test(\"handlers\", (override) => {\n narrowed = false;\n activity.user_cursor.go_to(alice.user_id);\n filter_key_handlers.Enter();\n- assert(narrowed);\n+ assert.ok(narrowed);\n \n // get line coverage for cleared case\n activity.user_cursor.clear();\n@@ -353,7 +353,7 @@ test(\"handlers\", (override) => {\n // so this just tests the called function.\n narrowed = false;\n activity.narrow_for_user({li: alice_li});\n- assert(narrowed);\n+ assert.ok(narrowed);\n })();\n \n (function test_blur_filter() {\n@@ -393,8 +393,8 @@ test(\"insert_one_user_into_empty_list\", (override) => {\n });\n \n activity.redraw_user(alice.user_id);\n- assert(appended_html.indexOf('data-user-id=\"1\"') > 0);\n- assert(appended_html.indexOf(\"user_circle_green\") > 0);\n+ assert.ok(appended_html.indexOf('data-user-id=\"1\"') > 0);\n+ assert.ok(appended_html.indexOf(\"user_circle_green\") > 0);\n });\n \n test(\"insert_alice_then_fred\", (override) => {\n@@ -405,12 +405,12 @@ test(\"insert_alice_then_fred\", (override) => {\n override(padded_widget, \"update_padding\", () => {});\n \n activity.redraw_user(alice.user_id);\n- assert(appended_html.indexOf('data-user-id=\"1\"') > 0);\n- assert(appended_html.indexOf(\"user_circle_green\") > 0);\n+ assert.ok(appended_html.indexOf('data-user-id=\"1\"') > 0);\n+ assert.ok(appended_html.indexOf(\"user_circle_green\") > 0);\n \n activity.redraw_user(fred.user_id);\n- assert(appended_html.indexOf('data-user-id=\"2\"') > 0);\n- assert(appended_html.indexOf(\"user_circle_green\") > 0);\n+ assert.ok(appended_html.indexOf('data-user-id=\"2\"') > 0);\n+ assert.ok(appended_html.indexOf(\"user_circle_green\") > 0);\n });\n \n test(\"insert_fred_then_alice_then_rename\", (override) => {\n@@ -421,8 +421,8 @@ test(\"insert_fred_then_alice_then_rename\", (override) => {\n override(padded_widget, \"update_padding\", () => {});\n \n activity.redraw_user(fred.user_id);\n- assert(appended_html.indexOf('data-user-id=\"2\"') > 0);\n- assert(appended_html.indexOf(\"user_circle_green\") > 0);\n+ assert.ok(appended_html.indexOf('data-user-id=\"2\"') > 0);\n+ assert.ok(appended_html.indexOf(\"user_circle_green\") > 0);\n \n const fred_stub = $.create(\"fred-first\");\n buddy_list_add(fred.user_id, fred_stub);\n@@ -438,8 +438,8 @@ test(\"insert_fred_then_alice_then_rename\", (override) => {\n };\n \n activity.redraw_user(alice.user_id);\n- assert(inserted_html.indexOf('data-user-id=\"1\"') > 0);\n- assert(inserted_html.indexOf(\"user_circle_green\") > 0);\n+ assert.ok(inserted_html.indexOf('data-user-id=\"1\"') > 0);\n+ assert.ok(inserted_html.indexOf(\"user_circle_green\") > 0);\n \n // Next rename fred to Aaron.\n const fred_with_new_name = {\n@@ -457,8 +457,8 @@ test(\"insert_fred_then_alice_then_rename\", (override) => {\n };\n \n activity.redraw_user(fred_with_new_name.user_id);\n- assert(fred_removed);\n- assert(appended_html.indexOf('data-user-id=\"2\"') > 0);\n+ assert.ok(fred_removed);\n+ assert.ok(appended_html.indexOf('data-user-id=\"2\"') > 0);\n \n // restore old Fred data\n people.add_active_user(fred);\n@@ -516,12 +516,12 @@ test(\"update_presence_info\", (override) => {\n \n presence.presence_info.delete(me.user_id);\n activity.update_presence_info(me.user_id, info, server_time);\n- assert(inserted);\n+ assert.ok(inserted);\n assert.deepEqual(presence.presence_info.get(me.user_id).status, \"active\");\n \n presence.presence_info.delete(alice.user_id);\n activity.update_presence_info(alice.user_id, info, server_time);\n- assert(inserted);\n+ assert.ok(inserted);\n \n const expected = {status: \"active\", last_active: 500};\n assert.deepEqual(presence.presence_info.get(alice.user_id), expected);\n@@ -563,9 +563,9 @@ test(\"initialize\", (override) => {\n $(window).trigger(\"focus\");\n clear();\n \n- assert(scroll_handler_started);\n- assert(!activity.new_user_input);\n- assert(!$(\"#zephyr-mirror-error\").hasClass(\"show\"));\n+ assert.ok(scroll_handler_started);\n+ assert.ok(!activity.new_user_input);\n+ assert.ok(!$(\"#zephyr-mirror-error\").hasClass(\"show\"));\n assert.equal(activity.compute_active_status(), \"active\");\n \n $(window).idle = (params) => {\n@@ -581,8 +581,8 @@ test(\"initialize\", (override) => {\n presences: {},\n });\n \n- assert($(\"#zephyr-mirror-error\").hasClass(\"show\"));\n- assert(!activity.new_user_input);\n+ assert.ok($(\"#zephyr-mirror-error\").hasClass(\"show\"));\n+ assert.ok(!activity.new_user_input);\n assert.equal(activity.compute_active_status(), \"idle\");\n \n // Exercise the mousemove handler, which just\n@@ -596,11 +596,11 @@ test(\"away_status\", (override) => {\n override(pm_list, \"update_private_messages\", () => {});\n override(buddy_list, \"insert_or_move\", () => {});\n \n- assert(!user_status.is_away(alice.user_id));\n+ assert.ok(!user_status.is_away(alice.user_id));\n activity.on_set_away(alice.user_id);\n- assert(user_status.is_away(alice.user_id));\n+ assert.ok(user_status.is_away(alice.user_id));\n activity.on_revoke_away(alice.user_id);\n- assert(!user_status.is_away(alice.user_id));\n+ assert.ok(!user_status.is_away(alice.user_id));\n });\n \n test(\"electron_bridge\", (override) => {\ndiff --git a/frontend_tests/node_tests/alert_words.js b/frontend_tests/node_tests/alert_words.js\n--- a/frontend_tests/node_tests/alert_words.js\n+++ b/frontend_tests/node_tests/alert_words.js\n@@ -88,15 +88,15 @@ const message_with_emoji = {\n };\n \n run_test(\"notifications\", () => {\n- assert(!alert_words.notifies(regular_message));\n- assert(!alert_words.notifies(own_message));\n- assert(alert_words.notifies(other_message));\n- assert(alert_words.notifies(caps_message));\n- assert(!alert_words.notifies(alertwordboundary_message));\n- assert(alert_words.notifies(multialert_message));\n- assert(alert_words.notifies(unsafe_word_message));\n- assert(alert_words.notifies(alert_domain_message));\n- assert(alert_words.notifies(message_with_emoji));\n+ assert.ok(!alert_words.notifies(regular_message));\n+ assert.ok(!alert_words.notifies(own_message));\n+ assert.ok(alert_words.notifies(other_message));\n+ assert.ok(alert_words.notifies(caps_message));\n+ assert.ok(!alert_words.notifies(alertwordboundary_message));\n+ assert.ok(alert_words.notifies(multialert_message));\n+ assert.ok(alert_words.notifies(unsafe_word_message));\n+ assert.ok(alert_words.notifies(alert_domain_message));\n+ assert.ok(alert_words.notifies(message_with_emoji));\n });\n \n run_test(\"munging\", () => {\n@@ -161,10 +161,10 @@ run_test(\"munging\", () => {\n \n run_test(\"basic get/set operations\", () => {\n alert_words.initialize({alert_words: []});\n- assert(!alert_words.has_alert_word(\"breakfast\"));\n- assert(!alert_words.has_alert_word(\"lunch\"));\n+ assert.ok(!alert_words.has_alert_word(\"breakfast\"));\n+ assert.ok(!alert_words.has_alert_word(\"lunch\"));\n alert_words.set_words([\"breakfast\", \"lunch\"]);\n- assert(alert_words.has_alert_word(\"breakfast\"));\n- assert(alert_words.has_alert_word(\"lunch\"));\n- assert(!alert_words.has_alert_word(\"dinner\"));\n+ assert.ok(alert_words.has_alert_word(\"breakfast\"));\n+ assert.ok(alert_words.has_alert_word(\"lunch\"));\n+ assert.ok(!alert_words.has_alert_word(\"dinner\"));\n });\ndiff --git a/frontend_tests/node_tests/alert_words_ui.js b/frontend_tests/node_tests/alert_words_ui.js\n--- a/frontend_tests/node_tests/alert_words_ui.js\n+++ b/frontend_tests/node_tests/alert_words_ui.js\n@@ -36,12 +36,12 @@ run_test(\"render_alert_words_ui\", () => {\n });\n \n const new_alert_word = $(\"#create_alert_word_name\");\n- assert(!new_alert_word.is_focused());\n+ assert.ok(!new_alert_word.is_focused());\n \n alert_words_ui.render_alert_words_ui();\n \n assert.deepEqual(appended, [\"stub-bar\", \"stub-foo\"]);\n- assert(new_alert_word.is_focused());\n+ assert.ok(new_alert_word.is_focused());\n });\n \n run_test(\"add_alert_word\", (override) => {\n@@ -60,17 +60,17 @@ run_test(\"add_alert_word\", (override) => {\n // add '' as alert word\n add_func();\n assert.equal(new_alert_word.val(), \"\");\n- assert(alert_word_status.hasClass(\"alert-danger\"));\n+ assert.ok(alert_word_status.hasClass(\"alert-danger\"));\n assert.equal(alert_word_status_text.text(), \"translated: Alert word can't be empty!\");\n- assert(alert_word_status.visible());\n+ assert.ok(alert_word_status.visible());\n \n // add 'foo' as alert word (existing word)\n new_alert_word.val(\"foo\");\n \n add_func();\n- assert(alert_word_status.hasClass(\"alert-danger\"));\n+ assert.ok(alert_word_status.hasClass(\"alert-danger\"));\n assert.equal(alert_word_status_text.text(), \"translated: Alert word already exists!\");\n- assert(alert_word_status.visible());\n+ assert.ok(alert_word_status.visible());\n \n // add 'zot' as alert word (new word)\n new_alert_word.val(\"zot\");\n@@ -88,15 +88,15 @@ run_test(\"add_alert_word\", (override) => {\n \n // test failure\n fail_func();\n- assert(alert_word_status.hasClass(\"alert-danger\"));\n+ assert.ok(alert_word_status.hasClass(\"alert-danger\"));\n assert.equal(alert_word_status_text.text(), \"translated: Error adding alert word!\");\n- assert(alert_word_status.visible());\n+ assert.ok(alert_word_status.visible());\n \n // test success\n success_func();\n- assert(alert_word_status.hasClass(\"alert-success\"));\n+ assert.ok(alert_word_status.hasClass(\"alert-success\"));\n assert.equal(alert_word_status_text.text(), 'translated: Alert word \"zot\" added successfully!');\n- assert(alert_word_status.visible());\n+ assert.ok(alert_word_status.visible());\n });\n \n run_test(\"add_alert_word_keypress\", (override) => {\n@@ -122,7 +122,7 @@ run_test(\"add_alert_word_keypress\", (override) => {\n };\n \n keypress_func(event);\n- assert(called);\n+ assert.ok(called);\n });\n \n run_test(\"remove_alert_word\", (override) => {\n@@ -161,15 +161,15 @@ run_test(\"remove_alert_word\", (override) => {\n \n // test failure\n fail_func();\n- assert(alert_word_status.hasClass(\"alert-danger\"));\n+ assert.ok(alert_word_status.hasClass(\"alert-danger\"));\n assert.equal(alert_word_status_text.text(), \"translated: Error removing alert word!\");\n- assert(alert_word_status.visible());\n+ assert.ok(alert_word_status.visible());\n \n // test success\n success_func();\n- assert(alert_word_status.hasClass(\"alert-success\"));\n+ assert.ok(alert_word_status.hasClass(\"alert-success\"));\n assert.equal(alert_word_status_text.text(), \"translated: Alert word removed successfully!\");\n- assert(alert_word_status.visible());\n+ assert.ok(alert_word_status.visible());\n });\n \n run_test(\"close_status_message\", (override) => {\n@@ -190,7 +190,7 @@ run_test(\"close_status_message\", (override) => {\n currentTarget: \".close-alert-word-status\",\n };\n \n- assert(alert.visible());\n+ assert.ok(alert.visible());\n close(event);\n- assert(!alert.visible());\n+ assert.ok(!alert.visible());\n });\ndiff --git a/frontend_tests/node_tests/billing.js b/frontend_tests/node_tests/billing.js\n--- a/frontend_tests/node_tests/billing.js\n+++ b/frontend_tests/node_tests/billing.js\n@@ -76,16 +76,16 @@ run_test(\"initialize\", (override) => {\n \n $.get_initialize_function()();\n \n- assert(set_tab_called);\n- assert(stripe_checkout_configure_called);\n+ assert.ok(set_tab_called);\n+ assert.ok(stripe_checkout_configure_called);\n const e = {\n preventDefault: () => {},\n };\n const update_card_click_handler = $(\"#update-card-button\").get_on_handler(\"click\");\n with_field(helpers, \"create_ajax_request\", card_change_ajax, () => {\n update_card_click_handler(e);\n- assert(create_ajax_request_called);\n- assert(open_func_called);\n+ assert.ok(create_ajax_request_called);\n+ assert.ok(open_func_called);\n });\n \n create_ajax_request_called = false;\n@@ -103,7 +103,7 @@ run_test(\"initialize\", (override) => {\n \n with_field(helpers, \"create_ajax_request\", plan_change_ajax, () => {\n change_plan_status_click_handler(e);\n- assert(create_ajax_request_called);\n+ assert.ok(create_ajax_request_called);\n });\n \n create_ajax_request_called = false;\n@@ -125,7 +125,7 @@ run_test(\"initialize\", (override) => {\n }\n with_field(helpers, \"create_ajax_request\", license_change_ajax, () => {\n billing.create_update_license_request();\n- assert(create_ajax_request_called);\n+ assert.ok(create_ajax_request_called);\n });\n \n let create_update_license_request_called = false;\n@@ -137,7 +137,7 @@ run_test(\"initialize\", (override) => {\n \"click\",\n );\n confirm_license_update_click_handler(e);\n- assert(create_update_license_request_called);\n+ assert.ok(create_update_license_request_called);\n \n let confirm_license_modal_shown = false;\n override(helpers, \"is_valid_input\", () => true);\n@@ -154,14 +154,14 @@ run_test(\"initialize\", (override) => {\n const update_licenses_button_click_handler =\n $(\"#update-licenses-button\").get_on_handler(\"click\");\n update_licenses_button_click_handler(e);\n- assert(create_update_license_request_called);\n- assert(!confirm_license_modal_shown);\n+ assert.ok(create_update_license_request_called);\n+ assert.ok(!confirm_license_modal_shown);\n \n $(\"#new_licenses_input\").val = () => 25;\n create_update_license_request_called = false;\n update_licenses_button_click_handler(e);\n- assert(!create_update_license_request_called);\n- assert(confirm_license_modal_shown);\n+ assert.ok(!create_update_license_request_called);\n+ assert.ok(confirm_license_modal_shown);\n \n override(helpers, \"is_valid_input\", () => false);\n let prevent_default_called = false;\n@@ -171,7 +171,7 @@ run_test(\"initialize\", (override) => {\n },\n };\n update_licenses_button_click_handler(event);\n- assert(!prevent_default_called);\n+ assert.ok(!prevent_default_called);\n \n const update_next_renewal_licenses_button_click_handler = $(\n \"#update-licenses-at-next-renewal-button\",\n@@ -195,26 +195,26 @@ run_test(\"initialize\", (override) => {\n }\n with_field(helpers, \"create_ajax_request\", licenses_at_next_renewal_change_ajax, () => {\n update_next_renewal_licenses_button_click_handler(e);\n- assert(create_ajax_request_called);\n+ assert.ok(create_ajax_request_called);\n });\n });\n \n run_test(\"billing_template\", () => {\n // Elements necessary for create_ajax_request\n- assert(document.querySelector(\"#cardchange-error\"));\n- assert(document.querySelector(\"#cardchange-loading\"));\n- assert(document.querySelector(\"#cardchange_loading_indicator\"));\n- assert(document.querySelector(\"#cardchange-success\"));\n-\n- assert(document.querySelector(\"#licensechange-error\"));\n- assert(document.querySelector(\"#licensechange-loading\"));\n- assert(document.querySelector(\"#licensechange_loading_indicator\"));\n- assert(document.querySelector(\"#licensechange-success\"));\n-\n- assert(document.querySelector(\"#planchange-error\"));\n- assert(document.querySelector(\"#planchange-loading\"));\n- assert(document.querySelector(\"#planchange_loading_indicator\"));\n- assert(document.querySelector(\"#planchange-success\"));\n-\n- assert(document.querySelector(\"input[name=csrfmiddlewaretoken]\"));\n+ assert.ok(document.querySelector(\"#cardchange-error\"));\n+ assert.ok(document.querySelector(\"#cardchange-loading\"));\n+ assert.ok(document.querySelector(\"#cardchange_loading_indicator\"));\n+ assert.ok(document.querySelector(\"#cardchange-success\"));\n+\n+ assert.ok(document.querySelector(\"#licensechange-error\"));\n+ assert.ok(document.querySelector(\"#licensechange-loading\"));\n+ assert.ok(document.querySelector(\"#licensechange_loading_indicator\"));\n+ assert.ok(document.querySelector(\"#licensechange-success\"));\n+\n+ assert.ok(document.querySelector(\"#planchange-error\"));\n+ assert.ok(document.querySelector(\"#planchange-loading\"));\n+ assert.ok(document.querySelector(\"#planchange_loading_indicator\"));\n+ assert.ok(document.querySelector(\"#planchange-success\"));\n+\n+ assert.ok(document.querySelector(\"input[name=csrfmiddlewaretoken]\"));\n });\ndiff --git a/frontend_tests/node_tests/billing_helpers.js b/frontend_tests/node_tests/billing_helpers.js\n--- a/frontend_tests/node_tests/billing_helpers.js\n+++ b/frontend_tests/node_tests/billing_helpers.js\n@@ -136,7 +136,7 @@ run_test(\"create_ajax_request\", (override) => {\n assert.equal(data.schedule, \"monthly\");\n assert.equal(data.licenses, \"\");\n \n- assert(!(\"license_management\" in data));\n+ assert.ok(!(\"license_management\" in data));\n \n history.pushState = (state_object, title, path) => {\n state.pushState += 1;\ndiff --git a/frontend_tests/node_tests/bot_data.js b/frontend_tests/node_tests/bot_data.js\n--- a/frontend_tests/node_tests/bot_data.js\n+++ b/frontend_tests/node_tests/bot_data.js\n@@ -116,7 +116,7 @@ test(\"test_basics\", () => {\n \n bot = bot_data.get(43);\n assert.equal(\"Bot 1\", bot.full_name);\n- assert(bot.is_active);\n+ assert.ok(bot.is_active);\n bot_data.deactivate(43);\n bot = bot_data.get(43);\n assert.equal(bot.is_active, false);\n@@ -135,7 +135,7 @@ test(\"test_basics\", () => {\n \n bot = bot_data.get(43);\n assert.equal(\"Bot 1\", bot.full_name);\n- assert(bot.is_active);\n+ assert.ok(bot.is_active);\n bot_data.del(43);\n bot = bot_data.get(43);\n assert.equal(bot, undefined);\ndiff --git a/frontend_tests/node_tests/browser_history.js b/frontend_tests/node_tests/browser_history.js\n--- a/frontend_tests/node_tests/browser_history.js\n+++ b/frontend_tests/node_tests/browser_history.js\n@@ -32,7 +32,7 @@ test(\"basics\", () => {\n assert.equal(browser_history.old_hash(), hash1);\n \n const was_internal_change = browser_history.save_old_hash();\n- assert(was_internal_change);\n+ assert.ok(was_internal_change);\n assert.equal(browser_history.old_hash(), hash2);\n });\n \ndiff --git a/frontend_tests/node_tests/buddy_data.js b/frontend_tests/node_tests/buddy_data.js\n--- a/frontend_tests/node_tests/buddy_data.js\n+++ b/frontend_tests/node_tests/buddy_data.js\n@@ -394,12 +394,12 @@ test(\"muted users excluded from search\", () => {\n assert.equal(user_ids.includes(selma.user_id), false);\n user_ids = buddy_data.get_filtered_and_sorted_user_ids(\"sel\");\n assert.deepEqual(user_ids, []);\n- assert(!buddy_data.matches_filter(\"sel\", selma.user_id));\n+ assert.ok(!buddy_data.matches_filter(\"sel\", selma.user_id));\n \n muting.remove_muted_user(selma.user_id);\n user_ids = buddy_data.get_filtered_and_sorted_user_ids(\"sel\");\n assert.deepEqual(user_ids, [selma.user_id]);\n- assert(buddy_data.matches_filter(\"sel\", selma.user_id));\n+ assert.ok(buddy_data.matches_filter(\"sel\", selma.user_id));\n });\n \n test(\"bulk_data_hacks\", () => {\ndiff --git a/frontend_tests/node_tests/buddy_list.js b/frontend_tests/node_tests/buddy_list.js\n--- a/frontend_tests/node_tests/buddy_list.js\n+++ b/frontend_tests/node_tests/buddy_list.js\n@@ -83,7 +83,7 @@ run_test(\"basics\", (override) => {\n buddy_list.populate({\n keys: [alice.user_id],\n });\n- assert(appended);\n+ assert.ok(appended);\n \n const alice_li = {length: 1};\n \n@@ -185,7 +185,7 @@ run_test(\"find_li w/force_render\", (override) => {\n key,\n });\n assert.equal(empty_li, stub_li);\n- assert(!shown);\n+ assert.ok(!shown);\n \n const li = buddy_list.find_li({\n key,\n@@ -193,7 +193,7 @@ run_test(\"find_li w/force_render\", (override) => {\n });\n \n assert.equal(li, stub_li);\n- assert(shown);\n+ assert.ok(shown);\n });\n \n run_test(\"find_li w/bad key\", (override) => {\n@@ -224,10 +224,10 @@ run_test(\"scrolling\", (override) => {\n tried_to_fill = true;\n });\n \n- assert(!tried_to_fill);\n+ assert.ok(!tried_to_fill);\n \n buddy_list.start_scroll_handler();\n $(buddy_list.scroll_container_sel).trigger(\"scroll\");\n \n- assert(tried_to_fill);\n+ assert.ok(tried_to_fill);\n });\ndiff --git a/frontend_tests/node_tests/channel.js b/frontend_tests/node_tests/channel.js\n--- a/frontend_tests/node_tests/channel.js\n+++ b/frontend_tests/node_tests/channel.js\n@@ -42,7 +42,7 @@ function test_with_mock_ajax(test_params) {\n };\n \n run_code();\n- assert(ajax_called);\n+ assert.ok(ajax_called);\n check_ajax_options(ajax_options);\n }\n \n@@ -176,10 +176,10 @@ test(\"normal_post\", () => {\n assert.equal(options.url, \"/json/endpoint\");\n \n options.simulate_success(\"response data\", \"success\");\n- assert(orig_success_called);\n+ assert.ok(orig_success_called);\n \n options.simulate_error();\n- assert(orig_error_called);\n+ assert.ok(orig_error_called);\n },\n });\n });\n@@ -201,7 +201,7 @@ test(\"patch_with_form_data\", () => {\n data,\n processData: false,\n });\n- assert(appended);\n+ assert.ok(appended);\n },\n \n check_ajax_options(options) {\n@@ -233,7 +233,7 @@ test(\"reload_on_403_error\", () => {\n });\n \n options.simulate_error();\n- assert(handler_called);\n+ assert.ok(handler_called);\n },\n });\n });\n@@ -339,11 +339,11 @@ test(\"while_reloading\", () => {\n check_ajax_options(options) {\n blueslip.expect(\"log\", \"Ignoring DELETE /json/endpoint response while reloading\");\n options.simulate_success();\n- assert(!orig_success_called);\n+ assert.ok(!orig_success_called);\n \n blueslip.expect(\"log\", \"Ignoring DELETE /json/endpoint error response while reloading\");\n options.simulate_error();\n- assert(!orig_error_called);\n+ assert.ok(!orig_error_called);\n },\n });\n });\ndiff --git a/frontend_tests/node_tests/common.js b/frontend_tests/node_tests/common.js\n--- a/frontend_tests/node_tests/common.js\n+++ b/frontend_tests/node_tests/common.js\n@@ -24,18 +24,18 @@ const common = zrequire(\"common\");\n run_test(\"basics\", () => {\n common.autofocus(\"#home\");\n $.get_initialize_function()();\n- assert($(\"#home\").is_focused());\n+ assert.ok($(\"#home\").is_focused());\n $.clear_initialize_function();\n });\n \n run_test(\"phrase_match\", () => {\n- assert(common.phrase_match(\"tes\", \"test\"));\n- assert(common.phrase_match(\"Tes\", \"test\"));\n- assert(common.phrase_match(\"Tes\", \"Test\"));\n- assert(common.phrase_match(\"tes\", \"Stream Test\"));\n+ assert.ok(common.phrase_match(\"tes\", \"test\"));\n+ assert.ok(common.phrase_match(\"Tes\", \"test\"));\n+ assert.ok(common.phrase_match(\"Tes\", \"Test\"));\n+ assert.ok(common.phrase_match(\"tes\", \"Stream Test\"));\n \n- assert(!common.phrase_match(\"tests\", \"test\"));\n- assert(!common.phrase_match(\"tes\", \"hostess\"));\n+ assert.ok(!common.phrase_match(\"tests\", \"test\"));\n+ assert.ok(!common.phrase_match(\"tes\", \"hostess\"));\n });\n \n run_test(\"copy_data_attribute_value\", (override) => {\n@@ -76,9 +76,9 @@ run_test(\"copy_data_attribute_value\", (override) => {\n faded_in = true;\n };\n common.copy_data_attribute_value(elem, \"admin-emails\");\n- assert(removed);\n- assert(faded_in);\n- assert(faded_out);\n+ assert.ok(removed);\n+ assert.ok(faded_in);\n+ assert.ok(faded_out);\n });\n \n run_test(\"adjust_mac_shortcuts non-mac\", (override) => {\n@@ -147,8 +147,8 @@ run_test(\"show password\", () => {\n \n function check_assertion(type, present_class, absent_class) {\n assert.equal($(\"#id_password\").attr(\"type\"), type);\n- assert($(password_selector).hasClass(present_class));\n- assert(!$(password_selector).hasClass(absent_class));\n+ assert.ok($(password_selector).hasClass(present_class));\n+ assert.ok(!$(password_selector).hasClass(absent_class));\n }\n \n const ev = {\ndiff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.js\n--- a/frontend_tests/node_tests/compose.js\n+++ b/frontend_tests/node_tests/compose.js\n@@ -124,39 +124,39 @@ test_ui(\"test_wildcard_mention_allowed\", () => {\n settings_config.wildcard_mention_policy_values.by_everyone.code;\n page_params.is_guest = true;\n page_params.is_admin = false;\n- assert(compose.wildcard_mention_allowed());\n+ assert.ok(compose.wildcard_mention_allowed());\n \n page_params.realm_wildcard_mention_policy =\n settings_config.wildcard_mention_policy_values.nobody.code;\n page_params.is_admin = true;\n- assert(!compose.wildcard_mention_allowed());\n+ assert.ok(!compose.wildcard_mention_allowed());\n \n page_params.realm_wildcard_mention_policy =\n settings_config.wildcard_mention_policy_values.by_members.code;\n page_params.is_guest = true;\n page_params.is_admin = false;\n- assert(!compose.wildcard_mention_allowed());\n+ assert.ok(!compose.wildcard_mention_allowed());\n \n page_params.is_guest = false;\n- assert(compose.wildcard_mention_allowed());\n+ assert.ok(compose.wildcard_mention_allowed());\n \n page_params.realm_wildcard_mention_policy =\n settings_config.wildcard_mention_policy_values.by_moderators_only.code;\n page_params.is_moderator = false;\n- assert(!compose.wildcard_mention_allowed());\n+ assert.ok(!compose.wildcard_mention_allowed());\n \n page_params.is_moderator = true;\n- assert(compose.wildcard_mention_allowed());\n+ assert.ok(compose.wildcard_mention_allowed());\n \n page_params.realm_wildcard_mention_policy =\n settings_config.wildcard_mention_policy_values.by_stream_admins_only.code;\n page_params.is_admin = false;\n- assert(!compose.wildcard_mention_allowed());\n+ assert.ok(!compose.wildcard_mention_allowed());\n \n // TODO: Add a by_admins_only case when we implement stream-level administrators.\n \n page_params.is_admin = true;\n- assert(compose.wildcard_mention_allowed());\n+ assert.ok(compose.wildcard_mention_allowed());\n \n page_params.realm_wildcard_mention_policy =\n settings_config.wildcard_mention_policy_values.by_full_members.code;\n@@ -164,9 +164,9 @@ test_ui(\"test_wildcard_mention_allowed\", () => {\n person.date_joined = new Date(Date.now());\n page_params.realm_waiting_period_threshold = 10;\n \n- assert(compose.wildcard_mention_allowed());\n+ assert.ok(compose.wildcard_mention_allowed());\n page_params.is_admin = false;\n- assert(!compose.wildcard_mention_allowed());\n+ assert.ok(!compose.wildcard_mention_allowed());\n });\n \n test_ui(\"right-to-left\", () => {\n@@ -370,12 +370,12 @@ test_ui(\"send_message_success\", (override) => {\n compose.send_message_success(\"1001\", 12, false);\n \n assert.equal($(\"#compose-textarea\").val(), \"\");\n- assert($(\"#compose-textarea\").is_focused());\n- assert(!$(\"#compose-send-status\").visible());\n+ assert.ok($(\"#compose-textarea\").is_focused());\n+ assert.ok(!$(\"#compose-send-status\").visible());\n assert.equal($(\"#compose-send-button\").prop(\"disabled\"), false);\n- assert(!$(\"#sending-indicator\").visible());\n+ assert.ok(!$(\"#sending-indicator\").visible());\n \n- assert(reify_message_id_checked);\n+ assert.ok(reify_message_id_checked);\n });\n \n test_ui(\"send_message\", (override) => {\n@@ -469,10 +469,10 @@ test_ui(\"send_message\", (override) => {\n };\n assert.deepEqual(stub_state, state);\n assert.equal($(\"#compose-textarea\").val(), \"\");\n- assert($(\"#compose-textarea\").is_focused());\n- assert(!$(\"#compose-send-status\").visible());\n+ assert.ok($(\"#compose-textarea\").is_focused());\n+ assert.ok(!$(\"#compose-send-status\").visible());\n assert.equal($(\"#compose-send-button\").prop(\"disabled\"), false);\n- assert(!$(\"#sending-indicator\").visible());\n+ assert.ok(!$(\"#sending-indicator\").visible());\n })();\n \n // This is the additional setup which is common to both the tests below.\n@@ -501,7 +501,7 @@ test_ui(\"send_message\", (override) => {\n send_msg_called: 1,\n };\n assert.deepEqual(stub_state, state);\n- assert(echo_error_msg_checked);\n+ assert.ok(echo_error_msg_checked);\n })();\n \n (function test_error_codepath_local_id_undefined() {\n@@ -525,14 +525,14 @@ test_ui(\"send_message\", (override) => {\n send_msg_called: 1,\n };\n assert.deepEqual(stub_state, state);\n- assert(!echo_error_msg_checked);\n+ assert.ok(!echo_error_msg_checked);\n assert.equal($(\"#compose-send-button\").prop(\"disabled\"), false);\n assert.equal($(\"#compose-error-msg\").html(), \"Error sending message: Server says 408\");\n assert.equal($(\"#compose-textarea\").val(), \"foobarfoobar\");\n- assert($(\"#compose-textarea\").is_focused());\n- assert($(\"#compose-send-status\").visible());\n+ assert.ok($(\"#compose-textarea\").is_focused());\n+ assert.ok($(\"#compose-send-status\").visible());\n assert.equal($(\"#compose-send-button\").prop(\"disabled\"), false);\n- assert(!$(\"#sending-indicator\").visible());\n+ assert.ok(!$(\"#sending-indicator\").visible());\n })();\n });\n \n@@ -558,16 +558,16 @@ test_ui(\"enter_with_preview_open\", (override) => {\n send_message_called = true;\n });\n compose.enter_with_preview_open();\n- assert($(\"#compose-textarea\").visible());\n- assert(!$(\"#compose .undo_markdown_preview\").visible());\n- assert(!$(\"#compose .preview_message_area\").visible());\n- assert($(\"#compose .markdown_preview\").visible());\n- assert(send_message_called);\n+ assert.ok($(\"#compose-textarea\").visible());\n+ assert.ok(!$(\"#compose .undo_markdown_preview\").visible());\n+ assert.ok(!$(\"#compose .preview_message_area\").visible());\n+ assert.ok($(\"#compose .markdown_preview\").visible());\n+ assert.ok(send_message_called);\n \n page_params.enter_sends = false;\n $(\"#compose-textarea\").trigger(\"blur\");\n compose.enter_with_preview_open();\n- assert($(\"#compose-textarea\").is_focused());\n+ assert.ok($(\"#compose-textarea\").is_focused());\n \n // Test sending a message without content.\n $(\"#compose-textarea\").val(\"\");\n@@ -577,7 +577,7 @@ test_ui(\"enter_with_preview_open\", (override) => {\n \n compose.enter_with_preview_open();\n \n- assert($(\"#enter_sends\").prop(\"checked\"));\n+ assert.ok($(\"#enter_sends\").prop(\"checked\"));\n assert.equal(\n $(\"#compose-error-msg\").html(),\n $t_html({defaultMessage: \"You have nothing to send!\"}),\n@@ -598,9 +598,9 @@ test_ui(\"finish\", (override) => {\n $(\"#compose-textarea\").val(\"\");\n const res = compose.finish();\n assert.equal(res, false);\n- assert(!$(\"#compose_invite_users\").visible());\n- assert(!$(\"#sending-indicator\").visible());\n- assert(!$(\"#compose-send-button\").is_focused());\n+ assert.ok(!$(\"#compose_invite_users\").visible());\n+ assert.ok(!$(\"#sending-indicator\").visible());\n+ assert.ok(!$(\"#compose-send-button\").is_focused());\n assert.equal($(\"#compose-send-button\").prop(\"disabled\"), false);\n assert.equal(\n $(\"#compose-error-msg\").html(),\n@@ -625,13 +625,13 @@ test_ui(\"finish\", (override) => {\n override(compose, \"send_message\", () => {\n send_message_called = true;\n });\n- assert(compose.finish());\n- assert($(\"#compose-textarea\").visible());\n- assert(!$(\"#compose .undo_markdown_preview\").visible());\n- assert(!$(\"#compose .preview_message_area\").visible());\n- assert($(\"#compose .markdown_preview\").visible());\n- assert(send_message_called);\n- assert(compose_finished_event_checked);\n+ assert.ok(compose.finish());\n+ assert.ok($(\"#compose-textarea\").visible());\n+ assert.ok(!$(\"#compose .undo_markdown_preview\").visible());\n+ assert.ok(!$(\"#compose .preview_message_area\").visible());\n+ assert.ok($(\"#compose .markdown_preview\").visible());\n+ assert.ok(send_message_called);\n+ assert.ok(compose_finished_event_checked);\n })();\n });\n \n@@ -677,7 +677,7 @@ test_ui(\"warn_if_private_stream_is_linked\", () => {\n return \"fake-compose_private_stream_alert-template\";\n });\n return function () {\n- assert(called);\n+ assert.ok(called);\n };\n })(),\n \n@@ -688,7 +688,7 @@ test_ui(\"warn_if_private_stream_is_linked\", () => {\n assert.equal(html, \"fake-compose_private_stream_alert-template\");\n };\n return function () {\n- assert(called);\n+ assert.ok(called);\n };\n })(),\n ];\n@@ -763,10 +763,10 @@ test_ui(\"initialize\", (override) => {\n \n compose.initialize();\n \n- assert(resize_watch_manual_resize_checked);\n- assert(xmlhttprequest_checked);\n- assert(!$(\"#compose .compose_upload_file\").hasClass(\"notdisplayed\"));\n- assert(setup_upload_called);\n+ assert.ok(resize_watch_manual_resize_checked);\n+ assert.ok(xmlhttprequest_checked);\n+ assert.ok(!$(\"#compose .compose_upload_file\").hasClass(\"notdisplayed\"));\n+ assert.ok(setup_upload_called);\n \n function set_up_compose_start_mock(expected_opts) {\n compose_actions_start_checked = false;\n@@ -781,7 +781,7 @@ test_ui(\"initialize\", (override) => {\n \n compose.initialize();\n \n- assert(compose_actions_start_checked);\n+ assert.ok(compose_actions_start_checked);\n })();\n \n (function test_page_params_narrow_topic() {\n@@ -792,7 +792,7 @@ test_ui(\"initialize\", (override) => {\n \n compose.initialize();\n \n- assert(compose_actions_start_checked);\n+ assert.ok(compose_actions_start_checked);\n })();\n \n (function test_abort_xhr() {\n@@ -804,7 +804,7 @@ test_ui(\"initialize\", (override) => {\n compose.abort_xhr();\n \n assert.equal($(\"#compose-send-button\").attr(), undefined);\n- assert(uppy_cancel_all_called);\n+ assert.ok(uppy_cancel_all_called);\n })();\n });\n \n@@ -829,13 +829,13 @@ test_ui(\"update_fade\", (override) => {\n \n compose_state.set_message_type(false);\n keyup_handler_func();\n- assert(!set_focused_recipient_checked);\n- assert(!update_all_called);\n+ assert.ok(!set_focused_recipient_checked);\n+ assert.ok(!update_all_called);\n \n compose_state.set_message_type(\"private\");\n keyup_handler_func();\n- assert(set_focused_recipient_checked);\n- assert(update_all_called);\n+ assert.ok(set_focused_recipient_checked);\n+ assert.ok(update_all_called);\n });\n \n test_ui(\"trigger_submit_compose_form\", (override) => {\n@@ -856,8 +856,8 @@ test_ui(\"trigger_submit_compose_form\", (override) => {\n \n submit_handler(e);\n \n- assert(prevent_default_checked);\n- assert(compose_finish_checked);\n+ assert.ok(prevent_default_checked);\n+ assert.ok(compose_finish_checked);\n });\n \n test_ui(\"needs_subscribe_warning\", () => {\n@@ -947,7 +947,7 @@ test_ui(\"warn_if_mentioning_unsubscribed_user\", (override) => {\n return true;\n });\n return function () {\n- assert(called);\n+ assert.ok(called);\n };\n })(),\n \n@@ -962,7 +962,7 @@ test_ui(\"warn_if_mentioning_unsubscribed_user\", (override) => {\n return \"fake-compose-invite-user-template\";\n });\n return function () {\n- assert(called);\n+ assert.ok(called);\n };\n })(),\n \n@@ -973,7 +973,7 @@ test_ui(\"warn_if_mentioning_unsubscribed_user\", (override) => {\n assert.equal(html, \"fake-compose-invite-user-template\");\n };\n return function () {\n- assert(called);\n+ assert.ok(called);\n };\n })(),\n ];\n@@ -1017,7 +1017,7 @@ test_ui(\"warn_if_mentioning_unsubscribed_user\", (override) => {\n stub_templates(noop);\n compose.warn_if_mentioning_unsubscribed_user(mentioned);\n assert.equal($(\"#compose_invite_users\").visible(), true);\n- assert(looked_for_existing);\n+ assert.ok(looked_for_existing);\n });\n \n test_ui(\"on_events\", (override) => {\n@@ -1074,10 +1074,10 @@ test_ui(\"on_events\", (override) => {\n \n handler(helper.event);\n \n- assert(helper.container_was_removed());\n- assert(compose_finish_checked);\n- assert(!$(\"#compose-all-everyone\").visible());\n- assert(!$(\"#compose-send-status\").visible());\n+ assert.ok(helper.container_was_removed());\n+ assert.ok(compose_finish_checked);\n+ assert.ok(!$(\"#compose-all-everyone\").visible());\n+ assert.ok(!$(\"#compose-send-status\").visible());\n })();\n \n (function test_compose_invite_users_clicked() {\n@@ -1131,10 +1131,10 @@ test_ui(\"on_events\", (override) => {\n \n handler(helper.event);\n \n- assert(helper.container_was_removed());\n- assert(!$(\"#compose_invite_users\").visible());\n- assert(invite_user_to_stream_called);\n- assert(all_invite_children_called);\n+ assert.ok(helper.container_was_removed());\n+ assert.ok(!$(\"#compose_invite_users\").visible());\n+ assert.ok(invite_user_to_stream_called);\n+ assert.ok(all_invite_children_called);\n })();\n \n (function test_compose_invite_close_clicked() {\n@@ -1155,9 +1155,9 @@ test_ui(\"on_events\", (override) => {\n \n handler(helper.event);\n \n- assert(helper.container_was_removed());\n- assert(all_invite_children_called);\n- assert(!$(\"#compose_invite_users\").visible());\n+ assert.ok(helper.container_was_removed());\n+ assert.ok(all_invite_children_called);\n+ assert.ok(!$(\"#compose_invite_users\").visible());\n })();\n \n (function test_compose_not_subscribed_clicked() {\n@@ -1180,7 +1180,7 @@ test_ui(\"on_events\", (override) => {\n \n handler(helper.event);\n \n- assert(compose_not_subscribed_called);\n+ assert.ok(compose_not_subscribed_called);\n \n stream_data.add_sub(subscription);\n $(\"#stream_message_recipient_stream\").val(\"test\");\n@@ -1188,7 +1188,7 @@ test_ui(\"on_events\", (override) => {\n \n handler(helper.event);\n \n- assert(!$(\"#compose-send-status\").visible());\n+ assert.ok(!$(\"#compose-send-status\").visible());\n })();\n \n (function test_compose_not_subscribed_close_clicked() {\n@@ -1207,13 +1207,13 @@ test_ui(\"on_events\", (override) => {\n \n handler(helper.event);\n \n- assert(!$(\"#compose-send-status\").visible());\n+ assert.ok(!$(\"#compose-send-status\").visible());\n })();\n \n (function test_attach_files_compose_clicked() {\n const handler = $(\"#compose\").get_on_handler(\"click\", \".compose_upload_file\");\n $(\"#compose .file_input\").clone = (param) => {\n- assert(param);\n+ assert.ok(param);\n };\n let compose_file_input_clicked = false;\n $(\"#compose .file_input\").on(\"click\", () => {\n@@ -1225,7 +1225,7 @@ test_ui(\"on_events\", (override) => {\n };\n \n handler(event);\n- assert(compose_file_input_clicked);\n+ assert.ok(compose_file_input_clicked);\n })();\n \n (function test_markdown_preview_compose_clicked() {\n@@ -1238,10 +1238,10 @@ test_ui(\"on_events\", (override) => {\n }\n \n function assert_visibilities() {\n- assert(!$(\"#compose-textarea\").visible());\n- assert(!$(\"#compose .markdown_preview\").visible());\n- assert($(\"#compose .undo_markdown_preview\").visible());\n- assert($(\"#compose .preview_message_area\").visible());\n+ assert.ok(!$(\"#compose-textarea\").visible());\n+ assert.ok(!$(\"#compose .markdown_preview\").visible());\n+ assert.ok($(\"#compose .undo_markdown_preview\").visible());\n+ assert.ok($(\"#compose .preview_message_area\").visible());\n }\n \n function setup_mock_markdown_contains_backend_only_syntax(msg_content, return_val) {\n@@ -1278,8 +1278,8 @@ test_ui(\"on_events\", (override) => {\n \n override(channel, \"post\", (payload) => {\n assert.equal(payload.url, \"/json/messages/render\");\n- assert(payload.idempotent);\n- assert(payload.data);\n+ assert.ok(payload.idempotent);\n+ assert.ok(payload.data);\n assert.deepEqual(payload.data.content, current_message);\n \n function test(func, param) {\n@@ -1292,7 +1292,7 @@ test_ui(\"on_events\", (override) => {\n \n func(param);\n \n- assert(destroy_indicator_called);\n+ assert.ok(destroy_indicator_called);\n }\n \n test(test_post_error, payload.error);\n@@ -1329,7 +1329,7 @@ test_ui(\"on_events\", (override) => {\n \n handler(event);\n \n- assert(make_indicator_called);\n+ assert.ok(make_indicator_called);\n assert_visibilities();\n \n let apply_markdown_called = false;\n@@ -1348,7 +1348,7 @@ test_ui(\"on_events\", (override) => {\n \n handler(event);\n \n- assert(apply_markdown_called);\n+ assert.ok(apply_markdown_called);\n assert_visibilities();\n assert.equal($(\"#compose .preview_content\").html(), \"Server: foobarfoobar\");\n })();\n@@ -1367,10 +1367,10 @@ test_ui(\"on_events\", (override) => {\n \n handler(event);\n \n- assert($(\"#compose-textarea\").visible());\n- assert(!$(\"#compose .undo_markdown_preview\").visible());\n- assert(!$(\"#compose .preview_message_area\").visible());\n- assert($(\"#compose .markdown_preview\").visible());\n+ assert.ok($(\"#compose-textarea\").visible());\n+ assert.ok(!$(\"#compose .undo_markdown_preview\").visible());\n+ assert.ok(!$(\"#compose .preview_message_area\").visible());\n+ assert.ok($(\"#compose .markdown_preview\").visible());\n })();\n });\n \ndiff --git a/frontend_tests/node_tests/compose_actions.js b/frontend_tests/node_tests/compose_actions.js\n--- a/frontend_tests/node_tests/compose_actions.js\n+++ b/frontend_tests/node_tests/compose_actions.js\n@@ -66,11 +66,11 @@ const reply_with_mention = compose_actions.reply_with_mention;\n const quote_and_reply = compose_actions.quote_and_reply;\n \n function assert_visible(sel) {\n- assert($(sel).visible());\n+ assert.ok($(sel).visible());\n }\n \n function assert_hidden(sel) {\n- assert(!$(sel).visible());\n+ assert.ok(!$(sel).visible());\n }\n \n function override_private_message_recipient(override) {\n@@ -137,7 +137,7 @@ test(\"start\", (override) => {\n assert.equal($(\"#stream_message_recipient_stream\").val(), \"stream1\");\n assert.equal($(\"#stream_message_recipient_topic\").val(), \"topic1\");\n assert.equal(compose_state.get_message_type(), \"stream\");\n- assert(compose_state.composing());\n+ assert.ok(compose_state.composing());\n \n // Autofill stream field for single subscription\n const denmark = {\n@@ -198,7 +198,7 @@ test(\"start\", (override) => {\n assert.equal(compose_state.private_message_recipient(), \"foo@example.com\");\n assert.equal($(\"#compose-textarea\").val(), \"hello\");\n assert.equal(compose_state.get_message_type(), \"private\");\n- assert(compose_state.composing());\n+ assert.ok(compose_state.composing());\n \n // Cancel compose.\n let pill_cleared;\n@@ -215,11 +215,11 @@ test(\"start\", (override) => {\n \n assert_hidden(\"#compose_controls\");\n cancel();\n- assert(abort_xhr_called);\n- assert(pill_cleared);\n+ assert.ok(abort_xhr_called);\n+ assert.ok(pill_cleared);\n assert_visible(\"#compose_controls\");\n assert_hidden(\"#private-message\");\n- assert(!compose_state.composing());\n+ assert.ok(!compose_state.composing());\n });\n \n test(\"respond_to_message\", (override) => {\n@@ -371,7 +371,7 @@ test(\"quote_and_reply\", (override) => {\n success_function({\n raw_content: \"Testing.\",\n });\n- assert(replaced);\n+ assert.ok(replaced);\n \n selected_message = {\n type: \"stream\",\n@@ -390,7 +390,7 @@ test(\"quote_and_reply\", (override) => {\n with_field(channel, \"get\", whiny_get, () => {\n quote_and_reply(opts);\n });\n- assert(replaced);\n+ assert.ok(replaced);\n \n selected_message = {\n type: \"stream\",\n@@ -405,7 +405,7 @@ test(\"quote_and_reply\", (override) => {\n expected_replacement =\n \"translated: @_**Steve Stephenson|90** [said](https://chat.zulip.org/#narrow/stream/92-learning/topic/Tornado):\\n````quote\\n```\\nmultiline code block\\nshoudln't mess with quotes\\n```\\n````\";\n quote_and_reply(opts);\n- assert(replaced);\n+ assert.ok(replaced);\n });\n \n test(\"get_focus_area\", () => {\n@@ -434,16 +434,16 @@ test(\"focus_in_empty_compose\", (override) => {\n override(compose_state, \"composing\", () => true);\n $(\"#compose-textarea\").val(\"\");\n $(\"#compose-textarea\").trigger(\"focus\");\n- assert(compose_state.focus_in_empty_compose());\n+ assert.ok(compose_state.focus_in_empty_compose());\n \n override(compose_state, \"composing\", () => false);\n- assert(!compose_state.focus_in_empty_compose());\n+ assert.ok(!compose_state.focus_in_empty_compose());\n \n $(\"#compose-textarea\").val(\"foo\");\n- assert(!compose_state.focus_in_empty_compose());\n+ assert.ok(!compose_state.focus_in_empty_compose());\n \n $(\"#compose-textarea\").trigger(\"blur\");\n- assert(!compose_state.focus_in_empty_compose());\n+ assert.ok(!compose_state.focus_in_empty_compose());\n });\n \n test(\"on_narrow\", (override) => {\n@@ -463,7 +463,7 @@ test(\"on_narrow\", (override) => {\n compose_actions.on_narrow({\n force_close: true,\n });\n- assert(cancel_called);\n+ assert.ok(cancel_called);\n \n let on_topic_narrow_called = false;\n override(compose_actions, \"on_topic_narrow\", () => {\n@@ -473,7 +473,7 @@ test(\"on_narrow\", (override) => {\n compose_actions.on_narrow({\n force_close: false,\n });\n- assert(on_topic_narrow_called);\n+ assert.ok(on_topic_narrow_called);\n \n let update_message_list_called = false;\n narrowed_by_topic_reply = false;\n@@ -484,7 +484,7 @@ test(\"on_narrow\", (override) => {\n compose_actions.on_narrow({\n force_close: false,\n });\n- assert(update_message_list_called);\n+ assert.ok(update_message_list_called);\n \n has_message_content = false;\n let start_called = false;\n@@ -497,7 +497,7 @@ test(\"on_narrow\", (override) => {\n trigger: \"not-search\",\n private_message_recipient: \"not@empty.com\",\n });\n- assert(start_called);\n+ assert.ok(start_called);\n \n start_called = false;\n compose_actions.on_narrow({\n@@ -505,12 +505,12 @@ test(\"on_narrow\", (override) => {\n trigger: \"search\",\n private_message_recipient: \"\",\n });\n- assert(!start_called);\n+ assert.ok(!start_called);\n \n narrowed_by_pm_reply = false;\n cancel_called = false;\n compose_actions.on_narrow({\n force_close: false,\n });\n- assert(cancel_called);\n+ assert.ok(cancel_called);\n });\ndiff --git a/frontend_tests/node_tests/compose_fade.js b/frontend_tests/node_tests/compose_fade.js\n--- a/frontend_tests/node_tests/compose_fade.js\n+++ b/frontend_tests/node_tests/compose_fade.js\n@@ -87,6 +87,6 @@ run_test(\"set_focused_recipient\", () => {\n stream_id: 999,\n topic: \"lunch\",\n };\n- assert(!compose_fade_helper.should_fade_message(good_msg));\n- assert(compose_fade_helper.should_fade_message(bad_msg));\n+ assert.ok(!compose_fade_helper.should_fade_message(good_msg));\n+ assert.ok(compose_fade_helper.should_fade_message(bad_msg));\n });\ndiff --git a/frontend_tests/node_tests/compose_pm_pill.js b/frontend_tests/node_tests/compose_pm_pill.js\n--- a/frontend_tests/node_tests/compose_pm_pill.js\n+++ b/frontend_tests/node_tests/compose_pm_pill.js\n@@ -49,7 +49,7 @@ run_test(\"pills\", (override) => {\n \n pills.appendValidatedData = (item) => {\n const id = item.user_id;\n- assert(!all_pills.has(id));\n+ assert.ok(!all_pills.has(id));\n all_pills.set(id, item);\n };\n pills.items = () => Array.from(all_pills.values());\n@@ -102,14 +102,14 @@ run_test(\"pills\", (override) => {\n function test_create_item(handler) {\n (function test_rejection_path() {\n const item = handler(othello.email, pills.items());\n- assert(get_by_email_called);\n+ assert.ok(get_by_email_called);\n assert.equal(item, undefined);\n })();\n \n (function test_success_path() {\n get_by_email_called = false;\n const res = handler(iago.email, pills.items());\n- assert(get_by_email_called);\n+ assert.ok(get_by_email_called);\n assert.equal(typeof res, \"object\");\n assert.equal(res.user_id, iago.user_id);\n assert.equal(res.display_value, iago.full_name);\n@@ -119,7 +119,7 @@ run_test(\"pills\", (override) => {\n function input_pill_stub(opts) {\n assert.equal(opts.container, pill_container_stub);\n create_item_handler = opts.create_item_from_text;\n- assert(create_item_handler);\n+ assert.ok(create_item_handler);\n return pills;\n }\n \n@@ -137,7 +137,7 @@ run_test(\"pills\", (override) => {\n };\n \n compose_pm_pill.initialize();\n- assert(compose_pm_pill.widget);\n+ assert.ok(compose_pm_pill.widget);\n \n compose_pm_pill.set_from_typeahead(othello);\n compose_pm_pill.set_from_typeahead(hamlet);\n@@ -158,12 +158,12 @@ run_test(\"pills\", (override) => {\n test_create_item(create_item_handler);\n \n compose_pm_pill.set_from_emails(\"othello@example.com\");\n- assert(compose_pm_pill.widget);\n+ assert.ok(compose_pm_pill.widget);\n \n- assert(get_by_user_id_called);\n- assert(pills_cleared);\n- assert(appendValue_called);\n- assert(text_cleared);\n+ assert.ok(get_by_user_id_called);\n+ assert.ok(pills_cleared);\n+ assert.ok(appendValue_called);\n+ assert.ok(text_cleared);\n });\n \n run_test(\"has_unconverted_data\", () => {\ndiff --git a/frontend_tests/node_tests/compose_ui.js b/frontend_tests/node_tests/compose_ui.js\n--- a/frontend_tests/node_tests/compose_ui.js\n+++ b/frontend_tests/node_tests/compose_ui.js\n@@ -93,7 +93,7 @@ run_test(\"autosize_textarea\", (override) => {\n const container = \"container-stub\";\n compose_ui.autosize_textarea(container);\n assert.equal(textarea_autosized.textarea, container);\n- assert(textarea_autosized.autosized);\n+ assert.ok(textarea_autosized.autosized);\n });\n \n run_test(\"insert_syntax_and_focus\", () => {\n@@ -108,7 +108,7 @@ run_test(\"insert_syntax_and_focus\", () => {\n compose_ui.insert_syntax_and_focus(\":octopus:\");\n assert.equal($(\"#compose-textarea\").caret(), 4);\n assert.equal($(\"#compose-textarea\").val(), \"xyz :octopus: \");\n- assert($(\"#compose-textarea\").is_focused());\n+ assert.ok($(\"#compose-textarea\").is_focused());\n });\n \n run_test(\"smart_insert\", () => {\n@@ -119,27 +119,27 @@ run_test(\"smart_insert\", () => {\n assert.equal(textbox.insert_pos, 4);\n assert.equal(textbox.insert_text, \" :smile: \");\n assert.equal(textbox.val(), \"abc :smile: \");\n- assert(textbox.focused);\n+ assert.ok(textbox.focused);\n \n textbox.trigger(\"blur\");\n compose_ui.smart_insert(textbox, \":airplane:\");\n assert.equal(textbox.insert_text, \":airplane: \");\n assert.equal(textbox.val(), \"abc :smile: :airplane: \");\n- assert(textbox.focused);\n+ assert.ok(textbox.focused);\n \n textbox.caret(0);\n textbox.trigger(\"blur\");\n compose_ui.smart_insert(textbox, \":octopus:\");\n assert.equal(textbox.insert_text, \":octopus: \");\n assert.equal(textbox.val(), \":octopus: abc :smile: :airplane: \");\n- assert(textbox.focused);\n+ assert.ok(textbox.focused);\n \n textbox.caret(textbox.val().length);\n textbox.trigger(\"blur\");\n compose_ui.smart_insert(textbox, \":heart:\");\n assert.equal(textbox.insert_text, \":heart: \");\n assert.equal(textbox.val(), \":octopus: abc :smile: :airplane: :heart: \");\n- assert(textbox.focused);\n+ assert.ok(textbox.focused);\n \n // Test handling of spaces for ```quote\n textbox = make_textbox(\"\");\n@@ -148,7 +148,7 @@ run_test(\"smart_insert\", () => {\n compose_ui.smart_insert(textbox, \"```quote\\nquoted message\\n```\\n\");\n assert.equal(textbox.insert_text, \"```quote\\nquoted message\\n```\\n\");\n assert.equal(textbox.val(), \"```quote\\nquoted message\\n```\\n\");\n- assert(textbox.focused);\n+ assert.ok(textbox.focused);\n \n textbox = make_textbox(\"\");\n textbox.caret(0);\n@@ -156,7 +156,7 @@ run_test(\"smart_insert\", () => {\n compose_ui.smart_insert(textbox, \"[Quoting…]\\n\");\n assert.equal(textbox.insert_text, \"[Quoting…]\\n\");\n assert.equal(textbox.val(), \"[Quoting…]\\n\");\n- assert(textbox.focused);\n+ assert.ok(textbox.focused);\n \n textbox = make_textbox(\"abc\");\n textbox.caret(3);\n@@ -164,7 +164,7 @@ run_test(\"smart_insert\", () => {\n compose_ui.smart_insert(textbox, \" test with space\");\n assert.equal(textbox.insert_text, \" test with space \");\n assert.equal(textbox.val(), \"abc test with space \");\n- assert(textbox.focused);\n+ assert.ok(textbox.focused);\n \n // Note that we don't have any special logic for strings that are\n // already surrounded by spaces, since we are usually inserting things\ndiff --git a/frontend_tests/node_tests/compose_validate.js b/frontend_tests/node_tests/compose_validate.js\n--- a/frontend_tests/node_tests/compose_validate.js\n+++ b/frontend_tests/node_tests/compose_validate.js\n@@ -65,7 +65,7 @@ test_ui(\"validate_stream_message_address_info\", () => {\n subscribed: true,\n };\n stream_data.add_sub(sub);\n- assert(compose.validate_stream_message_address_info(\"social\"));\n+ assert.ok(compose.validate_stream_message_address_info(\"social\"));\n \n sub.subscribed = false;\n stream_data.add_sub(sub);\n@@ -73,7 +73,7 @@ test_ui(\"validate_stream_message_address_info\", () => {\n assert.equal(template_name, \"compose_not_subscribed\");\n return \"compose_not_subscribed_stub\";\n });\n- assert(!compose.validate_stream_message_address_info(\"social\"));\n+ assert.ok(!compose.validate_stream_message_address_info(\"social\"));\n assert.equal($(\"#compose-error-msg\").html(), \"compose_not_subscribed_stub\");\n \n page_params.narrow_stream = false;\n@@ -82,7 +82,7 @@ test_ui(\"validate_stream_message_address_info\", () => {\n payload.data.subscribed = true;\n payload.success(payload.data);\n };\n- assert(compose.validate_stream_message_address_info(\"social\"));\n+ assert.ok(compose.validate_stream_message_address_info(\"social\"));\n \n sub.name = \"Frontend\";\n sub.stream_id = 102;\n@@ -92,14 +92,14 @@ test_ui(\"validate_stream_message_address_info\", () => {\n payload.data.subscribed = false;\n payload.success(payload.data);\n };\n- assert(!compose.validate_stream_message_address_info(\"Frontend\"));\n+ assert.ok(!compose.validate_stream_message_address_info(\"Frontend\"));\n assert.equal($(\"#compose-error-msg\").html(), \"compose_not_subscribed_stub\");\n \n channel.post = (payload) => {\n assert.equal(payload.data.stream, \"Frontend\");\n payload.error({status: 404});\n };\n- assert(!compose.validate_stream_message_address_info(\"Frontend\"));\n+ assert.ok(!compose.validate_stream_message_address_info(\"Frontend\"));\n assert.equal(\n $(\"#compose-error-msg\").html(),\n \"translated HTML:

The stream Frontend does not exist.

Manage your subscriptions on your Streams page.

\",\n@@ -109,7 +109,7 @@ test_ui(\"validate_stream_message_address_info\", () => {\n assert.equal(payload.data.stream, \"social\");\n payload.error({status: 500});\n };\n- assert(!compose.validate_stream_message_address_info(\"social\"));\n+ assert.ok(!compose.validate_stream_message_address_info(\"social\"));\n assert.equal(\n $(\"#compose-error-msg\").html(),\n $t_html({defaultMessage: \"Error checking subscription\"}),\n@@ -150,9 +150,9 @@ test_ui(\"validate\", (override) => {\n }\n \n initialize_pm_pill();\n- assert(!compose.validate());\n- assert(!$(\"#sending-indicator\").visible());\n- assert(!$(\"#compose-send-button\").is_focused());\n+ assert.ok(!compose.validate());\n+ assert.ok(!$(\"#sending-indicator\").visible());\n+ assert.ok(!$(\"#compose-send-button\").is_focused());\n assert.equal($(\"#compose-send-button\").prop(\"disabled\"), false);\n assert.equal(\n $(\"#compose-error-msg\").html(),\n@@ -173,8 +173,8 @@ test_ui(\"validate\", (override) => {\n }\n return false;\n };\n- assert(!compose.validate());\n- assert(zephyr_checked);\n+ assert.ok(!compose.validate());\n+ assert.ok(zephyr_checked);\n assert.equal(\n $(\"#compose-error-msg\").html(),\n $t_html({\n@@ -189,7 +189,7 @@ test_ui(\"validate\", (override) => {\n compose_state.set_message_type(\"private\");\n \n compose_state.private_message_recipient(\"\");\n- assert(!compose.validate());\n+ assert.ok(!compose.validate());\n assert.equal(\n $(\"#compose-error-msg\").html(),\n $t_html({defaultMessage: \"Please specify at least one valid recipient\"}),\n@@ -199,7 +199,7 @@ test_ui(\"validate\", (override) => {\n add_content_to_compose_box();\n compose_state.private_message_recipient(\"foo@zulip.com\");\n \n- assert(!compose.validate());\n+ assert.ok(!compose.validate());\n \n assert.equal(\n $(\"#compose-error-msg\").html(),\n@@ -207,7 +207,7 @@ test_ui(\"validate\", (override) => {\n );\n \n compose_state.private_message_recipient(\"foo@zulip.com,alice@zulip.com\");\n- assert(!compose.validate());\n+ assert.ok(!compose.validate());\n \n assert.equal(\n $(\"#compose-error-msg\").html(),\n@@ -216,15 +216,15 @@ test_ui(\"validate\", (override) => {\n \n people.add_active_user(bob);\n compose_state.private_message_recipient(\"bob@example.com\");\n- assert(compose.validate());\n+ assert.ok(compose.validate());\n \n page_params.realm_is_zephyr_mirror_realm = true;\n- assert(compose.validate());\n+ assert.ok(compose.validate());\n page_params.realm_is_zephyr_mirror_realm = false;\n \n compose_state.set_message_type(\"stream\");\n compose_state.stream_name(\"\");\n- assert(!compose.validate());\n+ assert.ok(!compose.validate());\n assert.equal(\n $(\"#compose-error-msg\").html(),\n $t_html({defaultMessage: \"Please specify a stream\"}),\n@@ -233,7 +233,7 @@ test_ui(\"validate\", (override) => {\n compose_state.stream_name(\"Denmark\");\n page_params.realm_mandatory_topics = true;\n compose_state.topic(\"\");\n- assert(!compose.validate());\n+ assert.ok(!compose.validate());\n assert.equal(\n $(\"#compose-error-msg\").html(),\n $t_html({defaultMessage: \"Please specify a topic\"}),\n@@ -276,9 +276,9 @@ test_ui(\"validate_stream_message\", (override) => {\n };\n stream_data.add_sub(sub);\n compose_state.stream_name(\"social\");\n- assert(compose.validate());\n- assert(!$(\"#compose-all-everyone\").visible());\n- assert(!$(\"#compose-send-status\").visible());\n+ assert.ok(compose.validate());\n+ assert.ok(!$(\"#compose-all-everyone\").visible());\n+ assert.ok(!$(\"#compose-send-status\").visible());\n \n peer_data.get_subscriber_count = (stream_id) => {\n assert.equal(stream_id, 101);\n@@ -296,14 +296,14 @@ test_ui(\"validate_stream_message\", (override) => {\n \n override(compose, \"wildcard_mention_allowed\", () => true);\n compose_state.message_content(\"Hey @**all**\");\n- assert(!compose.validate());\n+ assert.ok(!compose.validate());\n assert.equal($(\"#compose-send-button\").prop(\"disabled\"), false);\n- assert(!$(\"#compose-send-status\").visible());\n+ assert.ok(!$(\"#compose-send-status\").visible());\n assert.equal(compose_content, \"compose_all_everyone_stub\");\n- assert($(\"#compose-all-everyone\").visible());\n+ assert.ok($(\"#compose-all-everyone\").visible());\n \n override(compose, \"wildcard_mention_allowed\", () => false);\n- assert(!compose.validate());\n+ assert.ok(!compose.validate());\n assert.equal(\n $(\"#compose-error-msg\").html(),\n $t_html({\n@@ -330,7 +330,7 @@ test_ui(\"test_validate_stream_message_post_policy_admin_only\", (override) => {\n compose_state.topic(\"subject102\");\n compose_state.stream_name(\"stream102\");\n stream_data.add_sub(sub);\n- assert(!compose.validate());\n+ assert.ok(!compose.validate());\n assert.equal(\n $(\"#compose-error-msg\").html(),\n $t_html({defaultMessage: \"Only organization admins are allowed to post to this stream.\"}),\n@@ -344,7 +344,7 @@ test_ui(\"test_validate_stream_message_post_policy_admin_only\", (override) => {\n \n compose_state.topic(\"subject102\");\n compose_state.stream_name(\"stream102\");\n- assert(!compose.validate());\n+ assert.ok(!compose.validate());\n assert.equal(\n $(\"#compose-error-msg\").html(),\n $t_html({defaultMessage: \"Only organization admins are allowed to post to this stream.\"}),\n@@ -368,7 +368,7 @@ test_ui(\"test_validate_stream_message_post_policy_moderators_only\", (override) =\n compose_state.topic(\"subject104\");\n compose_state.stream_name(\"stream104\");\n stream_data.add_sub(sub);\n- assert(!compose.validate());\n+ assert.ok(!compose.validate());\n assert.equal(\n $(\"#compose-error-msg\").html(),\n $t_html({\n@@ -405,7 +405,7 @@ test_ui(\"test_validate_stream_message_post_policy_full_members_only\", (override)\n compose_state.topic(\"subject103\");\n compose_state.stream_name(\"stream103\");\n stream_data.add_sub(sub);\n- assert(!compose.validate());\n+ assert.ok(!compose.validate());\n assert.equal(\n $(\"#compose-error-msg\").html(),\n $t_html({defaultMessage: \"Guests are not allowed to post to this stream.\"}),\ndiff --git a/frontend_tests/node_tests/compose_video.js b/frontend_tests/node_tests/compose_video.js\n--- a/frontend_tests/node_tests/compose_video.js\n+++ b/frontend_tests/node_tests/compose_video.js\n@@ -102,7 +102,7 @@ test(\"videos\", (override) => {\n $(\"#compose-textarea\").val(\"\");\n \n handler(ev);\n- assert(!called);\n+ assert.ok(!called);\n })();\n \n (function test_jitsi_video_link_compose_clicked() {\n@@ -131,14 +131,14 @@ test(\"videos\", (override) => {\n \n page_params.jitsi_server_url = null;\n handler(ev);\n- assert(!called);\n+ assert.ok(!called);\n \n page_params.jitsi_server_url = \"https://meet.jit.si\";\n handler(ev);\n // video link ids consist of 15 random digits\n const video_link_regex =\n /\\[translated: Click to join video call]\\(https:\\/\\/meet.jit.si\\/\\d{15}\\)/;\n- assert(called);\n+ assert.ok(called);\n assert.match(syntax_to_insert, video_link_regex);\n })();\n \n@@ -168,7 +168,7 @@ test(\"videos\", (override) => {\n page_params.has_zoom_token = false;\n \n window.open = (url) => {\n- assert(url.endsWith(\"/calls/zoom/register\"));\n+ assert.ok(url.endsWith(\"/calls/zoom/register\"));\n \n // The event here has value=true. We keep it in events.js to\n // allow our tooling to verify its schema.\n@@ -183,7 +183,7 @@ test(\"videos\", (override) => {\n \n handler(ev);\n const video_link_regex = /\\[translated: Click to join video call]\\(example\\.zoom\\.com\\)/;\n- assert(called);\n+ assert.ok(called);\n assert.match(syntax_to_insert, video_link_regex);\n })();\n \n@@ -222,7 +222,7 @@ test(\"videos\", (override) => {\n handler(ev);\n const video_link_regex =\n /\\[translated: Click to join video call]\\(\\/calls\\/bigbluebutton\\/join\\?meeting_id=%22zulip-1%22&password=%22AAAAAAAAAA%22&checksum=%2232702220bff2a22a44aee72e96cfdb4c4091752e%22\\)/;\n- assert(called);\n+ assert.ok(called);\n assert.match(syntax_to_insert, video_link_regex);\n })();\n });\ndiff --git a/frontend_tests/node_tests/composebox_typeahead.js b/frontend_tests/node_tests/composebox_typeahead.js\n--- a/frontend_tests/node_tests/composebox_typeahead.js\n+++ b/frontend_tests/node_tests/composebox_typeahead.js\n@@ -401,7 +401,7 @@ test(\"content_typeahead_selected\", (override) => {\n actual_value = ct.content_typeahead_selected.call(fake_this, othello);\n expected_value = \"@**Othello, the Moor of Venice** \";\n assert.equal(actual_value, expected_value);\n- assert(warned_for_mention);\n+ assert.ok(warned_for_mention);\n \n fake_this.query = \"Hello @oth\";\n fake_this.token = \"oth\";\n@@ -565,11 +565,11 @@ test(\"content_typeahead_selected\", (override) => {\n expected_value = fake_this.query;\n assert.equal(actual_value, expected_value);\n \n- assert(caret_called1);\n- assert(caret_called2);\n- assert(autosize_called);\n- assert(set_timeout_called);\n- assert(warned_for_stream_link);\n+ assert.ok(caret_called1);\n+ assert.ok(caret_called2);\n+ assert.ok(autosize_called);\n+ assert.ok(set_timeout_called);\n+ assert.ok(warned_for_stream_link);\n });\n \n function sorted_names_from(subs) {\n@@ -831,14 +831,14 @@ test(\"initialize\", (override) => {\n options.query = \"hamletchar\";\n options.updater(hamletcharacters, event);\n assert.deepEqual(appended_names, [\"King Lear\"]);\n- assert(cleared);\n+ assert.ok(cleared);\n \n inserted_users = [lear.user_id];\n appended_names = [];\n cleared = false;\n options.updater(hamletcharacters, event);\n assert.deepEqual(appended_names, []);\n- assert(cleared);\n+ assert.ok(cleared);\n \n pm_recipient_typeahead_called = true;\n };\n@@ -862,7 +862,7 @@ test(\"initialize\", (override) => {\n fake_this.options = options;\n let actual_value = options.source.call(fake_this, \"test #s\");\n assert.deepEqual(sorted_names_from(actual_value), [\"Denmark\", \"Sweden\", \"The Netherlands\"]);\n- assert(caret_called);\n+ assert.ok(caret_called);\n \n // options.highlighter()\n //\n@@ -1048,7 +1048,7 @@ test(\"initialize\", (override) => {\n });\n \n $(\"form#send_message_form\").trigger(event);\n- assert(compose_finish_called);\n+ assert.ok(compose_finish_called);\n event.metaKey = false;\n event.ctrlKey = true;\n $(\"form#send_message_form\").trigger(event);\n@@ -1122,11 +1122,11 @@ test(\"initialize\", (override) => {\n \n // Now let's make sure that all the stub functions have been called\n // during the initialization.\n- assert(stream_typeahead_called);\n- assert(subject_typeahead_called);\n- assert(pm_recipient_typeahead_called);\n- assert(channel_post_called);\n- assert(compose_textarea_typeahead_called);\n+ assert.ok(stream_typeahead_called);\n+ assert.ok(subject_typeahead_called);\n+ assert.ok(pm_recipient_typeahead_called);\n+ assert.ok(channel_post_called);\n+ assert.ok(compose_textarea_typeahead_called);\n });\n \n test(\"begins_typeahead\", (override) => {\n@@ -1419,15 +1419,15 @@ test(\"content_highlighter\", (override) => {\n ct.content_highlighter.call(fake_this, \"py\");\n \n fake_this = {completing: \"something-else\"};\n- assert(!ct.content_highlighter.call(fake_this));\n+ assert.ok(!ct.content_highlighter.call(fake_this));\n \n // Verify that all stub functions have been called.\n- assert(th_render_typeahead_item_called);\n- assert(th_render_person_called);\n- assert(th_render_user_group_called);\n- assert(th_render_stream_called);\n- assert(th_render_typeahead_item_called);\n- assert(th_render_slash_command_called);\n+ assert.ok(th_render_typeahead_item_called);\n+ assert.ok(th_render_person_called);\n+ assert.ok(th_render_user_group_called);\n+ assert.ok(th_render_stream_called);\n+ assert.ok(th_render_typeahead_item_called);\n+ assert.ok(th_render_slash_command_called);\n });\n \n test(\"filter_and_sort_mentions (normal)\", () => {\ndiff --git a/frontend_tests/node_tests/copy_and_paste.js b/frontend_tests/node_tests/copy_and_paste.js\n--- a/frontend_tests/node_tests/copy_and_paste.js\n+++ b/frontend_tests/node_tests/copy_and_paste.js\n@@ -100,7 +100,7 @@ run_test(\"paste_handler\", () => {\n insert_syntax_and_focus_called = true;\n };\n copy_and_paste.paste_handler(event);\n- assert(insert_syntax_and_focus_called);\n+ assert.ok(insert_syntax_and_focus_called);\n \n data =\n '';\n@@ -108,5 +108,5 @@ run_test(\"paste_handler\", () => {\n event.originalEvent.clipboardData.setData(\"text/html\", data);\n insert_syntax_and_focus_called = false;\n copy_and_paste.paste_handler(event);\n- assert(!insert_syntax_and_focus_called);\n+ assert.ok(!insert_syntax_and_focus_called);\n });\ndiff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js\n--- a/frontend_tests/node_tests/dispatch.js\n+++ b/frontend_tests/node_tests/dispatch.js\n@@ -115,16 +115,16 @@ function assert_same(actual, expected) {\n \n run_test(\"alert_words\", (override) => {\n alert_words.initialize({alert_words: []});\n- assert(!alert_words.has_alert_word(\"fire\"));\n- assert(!alert_words.has_alert_word(\"lunch\"));\n+ assert.ok(!alert_words.has_alert_word(\"fire\"));\n+ assert.ok(!alert_words.has_alert_word(\"lunch\"));\n \n override(alert_words_ui, \"render_alert_words_ui\", noop);\n const event = event_fixtures.alert_words;\n dispatch(event);\n \n assert.deepEqual(alert_words.get_word_list(), [\"fire\", \"lunch\"]);\n- assert(alert_words.has_alert_word(\"fire\"));\n- assert(alert_words.has_alert_word(\"lunch\"));\n+ assert.ok(alert_words.has_alert_word(\"fire\"));\n+ assert.ok(alert_words.has_alert_word(\"lunch\"));\n });\n \n run_test(\"attachments\", (override) => {\n@@ -305,7 +305,7 @@ run_test(\"realm settings\", (override) => {\n called = true;\n });\n \n- assert(called);\n+ assert.ok(called);\n }\n \n // realm\n@@ -567,7 +567,7 @@ run_test(\"realm_user\", (override) => {\n // manipulation\n assert.deepEqual(added_person, event.person);\n \n- assert(people.is_active_user_for_popover(event.person.user_id));\n+ assert.ok(people.is_active_user_for_popover(event.person.user_id));\n \n event = event_fixtures.realm_user__remove;\n override(stream_events, \"remove_deactivated_user_from_all_streams\", noop);\n@@ -576,7 +576,7 @@ run_test(\"realm_user\", (override) => {\n // We don't actually remove the person, we just deactivate them.\n const removed_person = people.get_by_user_id(event.person.user_id);\n assert.equal(removed_person.full_name, \"Test User\");\n- assert(!people.is_active_user_for_popover(event.person.user_id));\n+ assert.ok(!people.is_active_user_for_popover(event.person.user_id));\n \n event = event_fixtures.realm_user__update;\n const stub = make_stub();\ndiff --git a/frontend_tests/node_tests/dispatch_subs.js b/frontend_tests/node_tests/dispatch_subs.js\n--- a/frontend_tests/node_tests/dispatch_subs.js\n+++ b/frontend_tests/node_tests/dispatch_subs.js\n@@ -88,14 +88,14 @@ test(\"peer add/remove\", (override) => {\n assert.equal(compose_fade_stub.num_calls, 1);\n assert.equal(subs_stub.num_calls, 1);\n \n- assert(peer_data.is_user_subscribed(event.stream_ids[0], event.user_ids[0]));\n+ assert.ok(peer_data.is_user_subscribed(event.stream_ids[0], event.user_ids[0]));\n \n event = event_fixtures.subscription__peer_remove;\n dispatch(event);\n assert.equal(compose_fade_stub.num_calls, 2);\n assert.equal(subs_stub.num_calls, 2);\n \n- assert(!peer_data.is_user_subscribed(event.stream_ids[0], event.user_ids[0]));\n+ assert.ok(!peer_data.is_user_subscribed(event.stream_ids[0], event.user_ids[0]));\n });\n \n test(\"remove\", (override) => {\ndiff --git a/frontend_tests/node_tests/drafts.js b/frontend_tests/node_tests/drafts.js\n--- a/frontend_tests/node_tests/drafts.js\n+++ b/frontend_tests/node_tests/drafts.js\n@@ -171,7 +171,7 @@ test(\"initialize\", (override) => {\n called = true;\n });\n f();\n- assert(called);\n+ assert.ok(called);\n };\n \n drafts.initialize();\ndiff --git a/frontend_tests/node_tests/dropdown_list_widget.js b/frontend_tests/node_tests/dropdown_list_widget.js\n--- a/frontend_tests/node_tests/dropdown_list_widget.js\n+++ b/frontend_tests/node_tests/dropdown_list_widget.js\n@@ -43,25 +43,25 @@ run_test(\"basic_functions\", () => {\n \n assert.equal(widget.value(), \"one\");\n assert.equal(updated_value, undefined); // We haven't 'updated' the widget yet.\n- assert(reset_button.visible());\n+ assert.ok(reset_button.visible());\n \n widget.update(\"two\");\n assert.equal($widget.text(), \"rendered: two\");\n assert.equal(widget.value(), \"two\");\n assert.equal(updated_value, \"two\");\n- assert(reset_button.visible());\n+ assert.ok(reset_button.visible());\n \n widget.update(null);\n assert.equal($widget.text(), \"translated: not set\");\n assert.equal(widget.value(), \"\");\n assert.equal(updated_value, null);\n- assert(!reset_button.visible());\n+ assert.ok(!reset_button.visible());\n \n widget.update(\"four\");\n assert.equal($widget.text(), \"translated: not set\");\n assert.equal(widget.value(), \"four\");\n assert.equal(updated_value, \"four\");\n- assert(!reset_button.visible());\n+ assert.ok(!reset_button.visible());\n });\n \n run_test(\"no_default_value\", () => {\ndiff --git a/frontend_tests/node_tests/echo.js b/frontend_tests/node_tests/echo.js\n--- a/frontend_tests/node_tests/echo.js\n+++ b/frontend_tests/node_tests/echo.js\n@@ -226,9 +226,9 @@ run_test(\"insert_local_message streams\", (override) => {\n };\n echo.insert_local_message(message_request, local_id_float);\n \n- assert(apply_markdown_called);\n- assert(add_topic_links_called);\n- assert(insert_message_called);\n+ assert.ok(apply_markdown_called);\n+ assert.ok(add_topic_links_called);\n+ assert.ok(insert_message_called);\n });\n \n run_test(\"insert_local_message PM\", (override) => {\n@@ -273,9 +273,9 @@ run_test(\"insert_local_message PM\", (override) => {\n sender_id: 123,\n };\n echo.insert_local_message(message_request, local_id_float);\n- assert(add_topic_links_called);\n- assert(apply_markdown_called);\n- assert(insert_message_called);\n+ assert.ok(add_topic_links_called);\n+ assert.ok(apply_markdown_called);\n+ assert.ok(insert_message_called);\n });\n \n MockDate.reset();\ndiff --git a/frontend_tests/node_tests/example1.js b/frontend_tests/node_tests/example1.js\n--- a/frontend_tests/node_tests/example1.js\n+++ b/frontend_tests/node_tests/example1.js\n@@ -25,8 +25,8 @@ const util = zrequire(\"util\");\n // The most basic unit tests load up code, call functions,\n // and assert truths:\n \n-assert(!util.find_wildcard_mentions(\"boring text\"));\n-assert(util.find_wildcard_mentions(\"mention @**everyone**\"));\n+assert.ok(!util.find_wildcard_mentions(\"boring text\"));\n+assert.ok(util.find_wildcard_mentions(\"mention @**everyone**\"));\n \n // Let's test with people.js next. We'll show this technique:\n // * get a false value\n@@ -44,9 +44,9 @@ const isaac = {\n // the tests in people.js in the same directory as this file.\n \n // Let's exercise the code and use assert to verify it works!\n-assert(!people.is_known_user_id(isaac.user_id));\n+assert.ok(!people.is_known_user_id(isaac.user_id));\n people.add_active_user(isaac);\n-assert(people.is_known_user_id(isaac.user_id));\n+assert.ok(people.is_known_user_id(isaac.user_id));\n \n // Let's look at stream_data next, and we will start by putting\n // some data at module scope. (You could also declare this inside\ndiff --git a/frontend_tests/node_tests/example4.js b/frontend_tests/node_tests/example4.js\n--- a/frontend_tests/node_tests/example4.js\n+++ b/frontend_tests/node_tests/example4.js\n@@ -79,13 +79,13 @@ run_test(\"add users with event\", () => {\n person: bob,\n };\n \n- assert(!people.is_known_user_id(bob.user_id));\n+ assert.ok(!people.is_known_user_id(bob.user_id));\n \n // Let's simulate dispatching our event!\n server_events_dispatch.dispatch_normal_event(event);\n \n // And it works!\n- assert(people.is_known_user_id(bob.user_id));\n+ assert.ok(people.is_known_user_id(bob.user_id));\n });\n \n /*\ndiff --git a/frontend_tests/node_tests/filter.js b/frontend_tests/node_tests/filter.js\n--- a/frontend_tests/node_tests/filter.js\n+++ b/frontend_tests/node_tests/filter.js\n@@ -78,20 +78,20 @@ test(\"basics\", () => {\n assert_same_operators(filter.operators(), operators);\n assert.deepEqual(filter.operands(\"stream\"), [\"foo\"]);\n \n- assert(filter.has_operator(\"stream\"));\n- assert(!filter.has_operator(\"search\"));\n+ assert.ok(filter.has_operator(\"stream\"));\n+ assert.ok(!filter.has_operator(\"search\"));\n \n- assert(filter.has_operand(\"stream\", \"foo\"));\n- assert(!filter.has_operand(\"stream\", \"exclude_stream\"));\n- assert(!filter.has_operand(\"stream\", \"nada\"));\n+ assert.ok(filter.has_operand(\"stream\", \"foo\"));\n+ assert.ok(!filter.has_operand(\"stream\", \"exclude_stream\"));\n+ assert.ok(!filter.has_operand(\"stream\", \"nada\"));\n \n- assert(!filter.is_search());\n- assert(!filter.can_mark_messages_read());\n- assert(!filter.contains_only_private_messages());\n- assert(!filter.allow_use_first_unread_when_narrowing());\n- assert(filter.includes_full_stream_history());\n- assert(filter.can_apply_locally());\n- assert(!filter.is_personal_filter());\n+ assert.ok(!filter.is_search());\n+ assert.ok(!filter.can_mark_messages_read());\n+ assert.ok(!filter.contains_only_private_messages());\n+ assert.ok(!filter.allow_use_first_unread_when_narrowing());\n+ assert.ok(filter.includes_full_stream_history());\n+ assert.ok(filter.can_apply_locally());\n+ assert.ok(!filter.is_personal_filter());\n \n operators = [\n {operator: \"stream\", operand: \"foo\"},\n@@ -100,184 +100,184 @@ test(\"basics\", () => {\n ];\n filter = new Filter(operators);\n \n- assert(filter.is_search());\n- assert(!filter.can_mark_messages_read());\n- assert(!filter.contains_only_private_messages());\n- assert(!filter.allow_use_first_unread_when_narrowing());\n- assert(!filter.can_apply_locally());\n- assert(!filter.is_personal_filter());\n- assert(filter.can_bucket_by(\"stream\"));\n- assert(filter.can_bucket_by(\"stream\", \"topic\"));\n+ assert.ok(filter.is_search());\n+ assert.ok(!filter.can_mark_messages_read());\n+ assert.ok(!filter.contains_only_private_messages());\n+ assert.ok(!filter.allow_use_first_unread_when_narrowing());\n+ assert.ok(!filter.can_apply_locally());\n+ assert.ok(!filter.is_personal_filter());\n+ assert.ok(filter.can_bucket_by(\"stream\"));\n+ assert.ok(filter.can_bucket_by(\"stream\", \"topic\"));\n \n // If our only stream operator is negated, then for all intents and purposes,\n // we don't consider ourselves to have a stream operator, because we don't\n // want to have the stream in the tab bar or unsubscribe messaging, etc.\n operators = [{operator: \"stream\", operand: \"exclude\", negated: true}];\n filter = new Filter(operators);\n- assert(!filter.contains_only_private_messages());\n- assert(!filter.has_operator(\"stream\"));\n- assert(!filter.can_mark_messages_read());\n- assert(!filter.is_personal_filter());\n+ assert.ok(!filter.contains_only_private_messages());\n+ assert.ok(!filter.has_operator(\"stream\"));\n+ assert.ok(!filter.can_mark_messages_read());\n+ assert.ok(!filter.is_personal_filter());\n \n // Negated searches are just like positive searches for our purposes, since\n // the search logic happens on the backend and we need to have can_apply_locally()\n // be false, and we want \"Search results\" in the tab bar.\n operators = [{operator: \"search\", operand: \"stop_word\", negated: true}];\n filter = new Filter(operators);\n- assert(!filter.contains_only_private_messages());\n- assert(filter.has_operator(\"search\"));\n- assert(!filter.can_apply_locally());\n- assert(!filter.can_mark_messages_read());\n- assert(!filter.is_personal_filter());\n+ assert.ok(!filter.contains_only_private_messages());\n+ assert.ok(filter.has_operator(\"search\"));\n+ assert.ok(!filter.can_apply_locally());\n+ assert.ok(!filter.can_mark_messages_read());\n+ assert.ok(!filter.is_personal_filter());\n \n // Similar logic applies to negated \"has\" searches.\n operators = [{operator: \"has\", operand: \"images\", negated: true}];\n filter = new Filter(operators);\n- assert(filter.has_operator(\"has\"));\n- assert(filter.can_apply_locally());\n- assert(!filter.can_apply_locally(true));\n- assert(!filter.includes_full_stream_history());\n- assert(!filter.can_mark_messages_read());\n- assert(!filter.is_personal_filter());\n+ assert.ok(filter.has_operator(\"has\"));\n+ assert.ok(filter.can_apply_locally());\n+ assert.ok(!filter.can_apply_locally(true));\n+ assert.ok(!filter.includes_full_stream_history());\n+ assert.ok(!filter.can_mark_messages_read());\n+ assert.ok(!filter.is_personal_filter());\n \n operators = [{operator: \"streams\", operand: \"public\", negated: true}];\n filter = new Filter(operators);\n- assert(!filter.contains_only_private_messages());\n- assert(!filter.has_operator(\"streams\"));\n- assert(!filter.can_mark_messages_read());\n- assert(filter.has_negated_operand(\"streams\", \"public\"));\n- assert(!filter.can_apply_locally());\n- assert(!filter.is_personal_filter());\n+ assert.ok(!filter.contains_only_private_messages());\n+ assert.ok(!filter.has_operator(\"streams\"));\n+ assert.ok(!filter.can_mark_messages_read());\n+ assert.ok(filter.has_negated_operand(\"streams\", \"public\"));\n+ assert.ok(!filter.can_apply_locally());\n+ assert.ok(!filter.is_personal_filter());\n \n operators = [{operator: \"streams\", operand: \"public\"}];\n filter = new Filter(operators);\n- assert(!filter.contains_only_private_messages());\n- assert(filter.has_operator(\"streams\"));\n- assert(!filter.can_mark_messages_read());\n- assert(!filter.has_negated_operand(\"streams\", \"public\"));\n- assert(!filter.can_apply_locally());\n- assert(filter.includes_full_stream_history());\n- assert(!filter.is_personal_filter());\n+ assert.ok(!filter.contains_only_private_messages());\n+ assert.ok(filter.has_operator(\"streams\"));\n+ assert.ok(!filter.can_mark_messages_read());\n+ assert.ok(!filter.has_negated_operand(\"streams\", \"public\"));\n+ assert.ok(!filter.can_apply_locally());\n+ assert.ok(filter.includes_full_stream_history());\n+ assert.ok(!filter.is_personal_filter());\n \n operators = [{operator: \"is\", operand: \"private\"}];\n filter = new Filter(operators);\n- assert(filter.contains_only_private_messages());\n- assert(filter.can_mark_messages_read());\n- assert(!filter.has_operator(\"search\"));\n- assert(filter.can_apply_locally());\n- assert(!filter.is_personal_filter());\n+ assert.ok(filter.contains_only_private_messages());\n+ assert.ok(filter.can_mark_messages_read());\n+ assert.ok(!filter.has_operator(\"search\"));\n+ assert.ok(filter.can_apply_locally());\n+ assert.ok(!filter.is_personal_filter());\n \n operators = [{operator: \"is\", operand: \"mentioned\"}];\n filter = new Filter(operators);\n- assert(!filter.contains_only_private_messages());\n- assert(filter.can_mark_messages_read());\n- assert(!filter.has_operator(\"search\"));\n- assert(filter.can_apply_locally());\n- assert(filter.is_personal_filter());\n+ assert.ok(!filter.contains_only_private_messages());\n+ assert.ok(filter.can_mark_messages_read());\n+ assert.ok(!filter.has_operator(\"search\"));\n+ assert.ok(filter.can_apply_locally());\n+ assert.ok(filter.is_personal_filter());\n \n operators = [{operator: \"is\", operand: \"starred\"}];\n filter = new Filter(operators);\n- assert(!filter.contains_only_private_messages());\n- assert(!filter.can_mark_messages_read());\n- assert(!filter.has_operator(\"search\"));\n- assert(filter.can_apply_locally());\n- assert(filter.is_personal_filter());\n+ assert.ok(!filter.contains_only_private_messages());\n+ assert.ok(!filter.can_mark_messages_read());\n+ assert.ok(!filter.has_operator(\"search\"));\n+ assert.ok(filter.can_apply_locally());\n+ assert.ok(filter.is_personal_filter());\n \n operators = [{operator: \"pm-with\", operand: \"joe@example.com\"}];\n filter = new Filter(operators);\n- assert(filter.is_non_huddle_pm());\n- assert(filter.contains_only_private_messages());\n- assert(!filter.has_operator(\"search\"));\n- assert(filter.can_apply_locally());\n- assert(!filter.is_personal_filter());\n+ assert.ok(filter.is_non_huddle_pm());\n+ assert.ok(filter.contains_only_private_messages());\n+ assert.ok(!filter.has_operator(\"search\"));\n+ assert.ok(filter.can_apply_locally());\n+ assert.ok(!filter.is_personal_filter());\n \n operators = [{operator: \"pm-with\", operand: \"joe@example.com,jack@example.com\"}];\n filter = new Filter(operators);\n- assert(!filter.is_non_huddle_pm());\n- assert(filter.contains_only_private_messages());\n+ assert.ok(!filter.is_non_huddle_pm());\n+ assert.ok(filter.contains_only_private_messages());\n \n operators = [{operator: \"group-pm-with\", operand: \"joe@example.com\"}];\n filter = new Filter(operators);\n- assert(!filter.is_non_huddle_pm());\n- assert(filter.contains_only_private_messages());\n- assert(!filter.has_operator(\"search\"));\n- assert(filter.can_apply_locally());\n+ assert.ok(!filter.is_non_huddle_pm());\n+ assert.ok(filter.contains_only_private_messages());\n+ assert.ok(!filter.has_operator(\"search\"));\n+ assert.ok(filter.can_apply_locally());\n });\n \n function assert_not_mark_read_with_has_operands(additional_operators_to_test) {\n additional_operators_to_test = additional_operators_to_test || [];\n let has_operator = [{operator: \"has\", operand: \"link\"}];\n let filter = new Filter(additional_operators_to_test.concat(has_operator));\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n has_operator = [{operator: \"has\", operand: \"link\", negated: true}];\n filter = new Filter(additional_operators_to_test.concat(has_operator));\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n has_operator = [{operator: \"has\", operand: \"image\"}];\n filter = new Filter(additional_operators_to_test.concat(has_operator));\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n has_operator = [{operator: \"has\", operand: \"image\", negated: true}];\n filter = new Filter(additional_operators_to_test.concat(has_operator));\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n has_operator = [{operator: \"has\", operand: \"attachment\", negated: true}];\n filter = new Filter(additional_operators_to_test.concat(has_operator));\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n has_operator = [{operator: \"has\", operand: \"attachment\"}];\n filter = new Filter(additional_operators_to_test.concat(has_operator));\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n }\n function assert_not_mark_read_with_is_operands(additional_operators_to_test) {\n additional_operators_to_test = additional_operators_to_test || [];\n let is_operator = [{operator: \"is\", operand: \"starred\"}];\n let filter = new Filter(additional_operators_to_test.concat(is_operator));\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n is_operator = [{operator: \"is\", operand: \"starred\", negated: true}];\n filter = new Filter(additional_operators_to_test.concat(is_operator));\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n is_operator = [{operator: \"is\", operand: \"mentioned\"}];\n filter = new Filter(additional_operators_to_test.concat(is_operator));\n if (additional_operators_to_test.length === 0) {\n- assert(filter.can_mark_messages_read());\n+ assert.ok(filter.can_mark_messages_read());\n } else {\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n }\n \n is_operator = [{operator: \"is\", operand: \"mentioned\", negated: true}];\n filter = new Filter(additional_operators_to_test.concat(is_operator));\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n is_operator = [{operator: \"is\", operand: \"alerted\"}];\n filter = new Filter(additional_operators_to_test.concat(is_operator));\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n is_operator = [{operator: \"is\", operand: \"alerted\", negated: true}];\n filter = new Filter(additional_operators_to_test.concat(is_operator));\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n is_operator = [{operator: \"is\", operand: \"unread\"}];\n filter = new Filter(additional_operators_to_test.concat(is_operator));\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n is_operator = [{operator: \"is\", operand: \"unread\", negated: true}];\n filter = new Filter(additional_operators_to_test.concat(is_operator));\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n }\n \n function assert_not_mark_read_when_searching(additional_operators_to_test) {\n additional_operators_to_test = additional_operators_to_test || [];\n let search_op = [{operator: \"search\", operand: \"keyword\"}];\n let filter = new Filter(additional_operators_to_test.concat(search_op));\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n search_op = [{operator: \"search\", operand: \"keyword\", negated: true}];\n filter = new Filter(additional_operators_to_test.concat(search_op));\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n }\n \n test(\"can_mark_messages_read\", () => {\n@@ -287,21 +287,21 @@ test(\"can_mark_messages_read\", () => {\n \n const stream_operator = [{operator: \"stream\", operand: \"foo\"}];\n let filter = new Filter(stream_operator);\n- assert(filter.can_mark_messages_read());\n+ assert.ok(filter.can_mark_messages_read());\n assert_not_mark_read_with_has_operands(stream_operator);\n assert_not_mark_read_with_is_operands(stream_operator);\n assert_not_mark_read_when_searching(stream_operator);\n \n const stream_negated_operator = [{operator: \"stream\", operand: \"foo\", negated: true}];\n filter = new Filter(stream_negated_operator);\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n const stream_topic_operators = [\n {operator: \"stream\", operand: \"foo\"},\n {operator: \"topic\", operand: \"bar\"},\n ];\n filter = new Filter(stream_topic_operators);\n- assert(filter.can_mark_messages_read());\n+ assert.ok(filter.can_mark_messages_read());\n assert_not_mark_read_with_has_operands(stream_topic_operators);\n assert_not_mark_read_with_is_operands(stream_topic_operators);\n assert_not_mark_read_when_searching(stream_topic_operators);\n@@ -311,7 +311,7 @@ test(\"can_mark_messages_read\", () => {\n {operator: \"topic\", operand: \"bar\", negated: true},\n ];\n filter = new Filter(stream_negated_topic_operators);\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n const pm_with = [{operator: \"pm-with\", operand: \"joe@example.com,\"}];\n \n@@ -319,11 +319,11 @@ test(\"can_mark_messages_read\", () => {\n \n const group_pm = [{operator: \"pm-with\", operand: \"joe@example.com,STEVE@foo.com\"}];\n filter = new Filter(pm_with);\n- assert(filter.can_mark_messages_read());\n+ assert.ok(filter.can_mark_messages_read());\n filter = new Filter(pm_with_negated);\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n filter = new Filter(group_pm);\n- assert(filter.can_mark_messages_read());\n+ assert.ok(filter.can_mark_messages_read());\n assert_not_mark_read_with_is_operands(group_pm);\n assert_not_mark_read_with_is_operands(pm_with);\n assert_not_mark_read_with_has_operands(group_pm);\n@@ -333,14 +333,14 @@ test(\"can_mark_messages_read\", () => {\n \n const is_private = [{operator: \"is\", operand: \"private\"}];\n filter = new Filter(is_private);\n- assert(filter.can_mark_messages_read());\n+ assert.ok(filter.can_mark_messages_read());\n assert_not_mark_read_with_is_operands(is_private);\n assert_not_mark_read_with_has_operands(is_private);\n assert_not_mark_read_when_searching(is_private);\n \n const in_all = [{operator: \"in\", operand: \"all\"}];\n filter = new Filter(in_all);\n- assert(filter.can_mark_messages_read());\n+ assert.ok(filter.can_mark_messages_read());\n assert_not_mark_read_with_is_operands(in_all);\n assert_not_mark_read_with_has_operands(in_all);\n assert_not_mark_read_when_searching(in_all);\n@@ -348,20 +348,20 @@ test(\"can_mark_messages_read\", () => {\n const in_home = [{operator: \"in\", operand: \"home\"}];\n const in_home_negated = [{operator: \"in\", operand: \"home\", negated: true}];\n filter = new Filter(in_home);\n- assert(filter.can_mark_messages_read());\n+ assert.ok(filter.can_mark_messages_read());\n assert_not_mark_read_with_is_operands(in_home);\n assert_not_mark_read_with_has_operands(in_home);\n assert_not_mark_read_when_searching(in_home);\n filter = new Filter(in_home_negated);\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n // Do not mark messages as read when in an unsupported 'in:*' filter.\n const in_random = [{operator: \"in\", operand: \"xxxxxxxxx\"}];\n const in_random_negated = [{operator: \"in\", operand: \"xxxxxxxxx\", negated: true}];\n filter = new Filter(in_random);\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n filter = new Filter(in_random_negated);\n- assert(!filter.can_mark_messages_read());\n+ assert.ok(!filter.can_mark_messages_read());\n \n // test caching of term types\n // init and stub\n@@ -374,33 +374,33 @@ test(\"can_mark_messages_read\", () => {\n \n // uncached trial\n filter.calc_can_mark_messages_read_called = false;\n- assert(filter.can_mark_messages_read());\n- assert(filter.calc_can_mark_messages_read_called);\n+ assert.ok(filter.can_mark_messages_read());\n+ assert.ok(filter.calc_can_mark_messages_read_called);\n \n // cached trial\n filter.calc_can_mark_messages_read_called = false;\n- assert(filter.can_mark_messages_read());\n- assert(!filter.calc_can_mark_messages_read_called);\n+ assert.ok(filter.can_mark_messages_read());\n+ assert.ok(!filter.calc_can_mark_messages_read_called);\n });\n \n test(\"show_first_unread\", () => {\n let operators = [{operator: \"is\", operand: \"any\"}];\n let filter = new Filter(operators);\n- assert(filter.allow_use_first_unread_when_narrowing());\n+ assert.ok(filter.allow_use_first_unread_when_narrowing());\n \n operators = [{operator: \"search\", operand: \"query to search\"}];\n filter = new Filter(operators);\n- assert(!filter.allow_use_first_unread_when_narrowing());\n+ assert.ok(!filter.allow_use_first_unread_when_narrowing());\n \n filter = new Filter();\n- assert(filter.can_mark_messages_read());\n- assert(filter.allow_use_first_unread_when_narrowing());\n+ assert.ok(filter.can_mark_messages_read());\n+ assert.ok(filter.allow_use_first_unread_when_narrowing());\n \n // Side case\n operators = [{operator: \"is\", operand: \"any\"}];\n filter = new Filter(operators);\n- assert(!filter.can_mark_messages_read());\n- assert(filter.allow_use_first_unread_when_narrowing());\n+ assert.ok(!filter.can_mark_messages_read());\n+ assert.ok(filter.allow_use_first_unread_when_narrowing());\n });\n \n test(\"filter_with_new_params_topic\", () => {\n@@ -410,9 +410,9 @@ test(\"filter_with_new_params_topic\", () => {\n ];\n const filter = new Filter(operators);\n \n- assert(filter.has_topic(\"foo\", \"old topic\"));\n- assert(!filter.has_topic(\"wrong\", \"old topic\"));\n- assert(!filter.has_topic(\"foo\", \"wrong\"));\n+ assert.ok(filter.has_topic(\"foo\", \"old topic\"));\n+ assert.ok(!filter.has_topic(\"wrong\", \"old topic\"));\n+ assert.ok(!filter.has_topic(\"foo\", \"wrong\"));\n \n const new_filter = filter.filter_with_new_params({\n operator: \"topic\",\n@@ -430,9 +430,9 @@ test(\"filter_with_new_params_stream\", () => {\n ];\n const filter = new Filter(operators);\n \n- assert(filter.has_topic(\"foo\", \"old topic\"));\n- assert(!filter.has_topic(\"wrong\", \"old topic\"));\n- assert(!filter.has_topic(\"foo\", \"wrong\"));\n+ assert.ok(filter.has_topic(\"foo\", \"old topic\"));\n+ assert.ok(!filter.has_topic(\"wrong\", \"old topic\"));\n+ assert.ok(!filter.has_topic(\"foo\", \"wrong\"));\n \n const new_filter = filter.filter_with_new_params({\n operator: \"stream\",\n@@ -452,7 +452,7 @@ test(\"new_style_operators\", () => {\n const filter = new Filter(operators);\n \n assert.deepEqual(filter.operands(\"stream\"), [\"foo\"]);\n- assert(filter.can_bucket_by(\"stream\"));\n+ assert.ok(filter.can_bucket_by(\"stream\"));\n });\n \n test(\"public_operators\", () => {\n@@ -467,7 +467,7 @@ test(\"public_operators\", () => {\n with_field(page_params, \"narrow_stream\", undefined, () => {\n assert_same_operators(filter.public_operators(), operators);\n });\n- assert(filter.can_bucket_by(\"stream\"));\n+ assert.ok(filter.can_bucket_by(\"stream\"));\n \n operators = [{operator: \"stream\", operand: \"default\"}];\n filter = new Filter(operators);\n@@ -485,14 +485,14 @@ test(\"redundancies\", () => {\n {operator: \"is\", operand: \"private\"},\n ];\n filter = new Filter(terms);\n- assert(filter.can_bucket_by(\"pm-with\"));\n+ assert.ok(filter.can_bucket_by(\"pm-with\"));\n \n terms = [\n {operator: \"pm-with\", operand: \"joe@example.com,\", negated: true},\n {operator: \"is\", operand: \"private\"},\n ];\n filter = new Filter(terms);\n- assert(filter.can_bucket_by(\"is-private\", \"not-pm-with\"));\n+ assert.ok(filter.can_bucket_by(\"is-private\", \"not-pm-with\"));\n });\n \n test(\"canonicalization\", () => {\n@@ -559,10 +559,10 @@ test(\"predicate_basics\", () => {\n [\"topic\", \"Bar\"],\n ]);\n \n- assert(predicate({type: \"stream\", stream_id, topic: \"bar\"}));\n- assert(!predicate({type: \"stream\", stream_id, topic: \"whatever\"}));\n- assert(!predicate({type: \"stream\", stream_id: 9999999}));\n- assert(!predicate({type: \"private\"}));\n+ assert.ok(predicate({type: \"stream\", stream_id, topic: \"bar\"}));\n+ assert.ok(!predicate({type: \"stream\", stream_id, topic: \"whatever\"}));\n+ assert.ok(!predicate({type: \"stream\", stream_id: 9999999}));\n+ assert.ok(!predicate({type: \"private\"}));\n \n // For old streams that we are no longer subscribed to, we may not have\n // a sub, but these should still match by stream name.\n@@ -570,92 +570,92 @@ test(\"predicate_basics\", () => {\n [\"stream\", \"old-Stream\"],\n [\"topic\", \"Bar\"],\n ]);\n- assert(predicate({type: \"stream\", stream: \"Old-stream\", topic: \"bar\"}));\n- assert(!predicate({type: \"stream\", stream: \"no-match\", topic: \"whatever\"}));\n+ assert.ok(predicate({type: \"stream\", stream: \"Old-stream\", topic: \"bar\"}));\n+ assert.ok(!predicate({type: \"stream\", stream: \"no-match\", topic: \"whatever\"}));\n \n predicate = get_predicate([[\"search\", \"emoji\"]]);\n- assert(predicate({}));\n+ assert.ok(predicate({}));\n \n predicate = get_predicate([[\"topic\", \"Bar\"]]);\n- assert(!predicate({type: \"private\"}));\n+ assert.ok(!predicate({type: \"private\"}));\n \n predicate = get_predicate([[\"is\", \"private\"]]);\n- assert(predicate({type: \"private\"}));\n- assert(!predicate({type: \"stream\"}));\n+ assert.ok(predicate({type: \"private\"}));\n+ assert.ok(!predicate({type: \"stream\"}));\n \n predicate = get_predicate([[\"streams\", \"public\"]]);\n- assert(predicate({}));\n+ assert.ok(predicate({}));\n \n predicate = get_predicate([[\"is\", \"starred\"]]);\n- assert(predicate({starred: true}));\n- assert(!predicate({starred: false}));\n+ assert.ok(predicate({starred: true}));\n+ assert.ok(!predicate({starred: false}));\n \n predicate = get_predicate([[\"is\", \"unread\"]]);\n- assert(predicate({unread: true}));\n- assert(!predicate({unread: false}));\n+ assert.ok(predicate({unread: true}));\n+ assert.ok(!predicate({unread: false}));\n \n predicate = get_predicate([[\"is\", \"alerted\"]]);\n- assert(predicate({alerted: true}));\n- assert(!predicate({alerted: false}));\n- assert(!predicate({}));\n+ assert.ok(predicate({alerted: true}));\n+ assert.ok(!predicate({alerted: false}));\n+ assert.ok(!predicate({}));\n \n predicate = get_predicate([[\"is\", \"mentioned\"]]);\n- assert(predicate({mentioned: true}));\n- assert(!predicate({mentioned: false}));\n+ assert.ok(predicate({mentioned: true}));\n+ assert.ok(!predicate({mentioned: false}));\n \n predicate = get_predicate([[\"in\", \"all\"]]);\n- assert(predicate({}));\n+ assert.ok(predicate({}));\n \n const unknown_stream_id = 999;\n predicate = get_predicate([[\"in\", \"home\"]]);\n- assert(!predicate({stream_id: unknown_stream_id, stream: \"unknown\"}));\n- assert(predicate({type: \"private\"}));\n+ assert.ok(!predicate({stream_id: unknown_stream_id, stream: \"unknown\"}));\n+ assert.ok(predicate({type: \"private\"}));\n \n with_field(page_params, \"narrow_stream\", \"kiosk\", () => {\n- assert(predicate({stream: \"kiosk\"}));\n+ assert.ok(predicate({stream: \"kiosk\"}));\n });\n \n predicate = get_predicate([[\"near\", 5]]);\n- assert(predicate({}));\n+ assert.ok(predicate({}));\n \n predicate = get_predicate([[\"id\", 5]]);\n- assert(predicate({id: 5}));\n- assert(!predicate({id: 6}));\n+ assert.ok(predicate({id: 5}));\n+ assert.ok(!predicate({id: 6}));\n \n predicate = get_predicate([\n [\"id\", 5],\n [\"topic\", \"lunch\"],\n ]);\n- assert(predicate({type: \"stream\", id: 5, topic: \"lunch\"}));\n- assert(!predicate({type: \"stream\", id: 5, topic: \"dinner\"}));\n+ assert.ok(predicate({type: \"stream\", id: 5, topic: \"lunch\"}));\n+ assert.ok(!predicate({type: \"stream\", id: 5, topic: \"dinner\"}));\n \n predicate = get_predicate([[\"sender\", \"Joe@example.com\"]]);\n- assert(predicate({sender_id: joe.user_id}));\n- assert(!predicate({sender_email: steve.user_id}));\n+ assert.ok(predicate({sender_id: joe.user_id}));\n+ assert.ok(!predicate({sender_email: steve.user_id}));\n \n predicate = get_predicate([[\"pm-with\", \"Joe@example.com\"]]);\n- assert(\n+ assert.ok(\n predicate({\n type: \"private\",\n display_recipient: [{id: joe.user_id}],\n }),\n );\n- assert(\n+ assert.ok(\n !predicate({\n type: \"private\",\n display_recipient: [{id: steve.user_id}],\n }),\n );\n- assert(\n+ assert.ok(\n !predicate({\n type: \"private\",\n display_recipient: [{id: 999999}],\n }),\n );\n- assert(!predicate({type: \"stream\"}));\n+ assert.ok(!predicate({type: \"stream\"}));\n \n predicate = get_predicate([[\"pm-with\", \"Joe@example.com,steve@foo.com\"]]);\n- assert(\n+ assert.ok(\n predicate({\n type: \"private\",\n display_recipient: [{id: joe.user_id}, {id: steve.user_id}],\n@@ -664,7 +664,7 @@ test(\"predicate_basics\", () => {\n \n // Make sure your own email is ignored\n predicate = get_predicate([[\"pm-with\", \"Joe@example.com,steve@foo.com,me@example.com\"]]);\n- assert(\n+ assert.ok(\n predicate({\n type: \"private\",\n display_recipient: [{id: joe.user_id}, {id: steve.user_id}],\n@@ -672,7 +672,7 @@ test(\"predicate_basics\", () => {\n );\n \n predicate = get_predicate([[\"pm-with\", \"nobody@example.com\"]]);\n- assert(\n+ assert.ok(\n !predicate({\n type: \"private\",\n display_recipient: [{id: joe.user_id}],\n@@ -680,7 +680,7 @@ test(\"predicate_basics\", () => {\n );\n \n predicate = get_predicate([[\"group-pm-with\", \"nobody@example.com\"]]);\n- assert(\n+ assert.ok(\n !predicate({\n type: \"private\",\n display_recipient: [{id: joe.user_id}],\n@@ -688,26 +688,26 @@ test(\"predicate_basics\", () => {\n );\n \n predicate = get_predicate([[\"group-pm-with\", \"Joe@example.com\"]]);\n- assert(\n+ assert.ok(\n predicate({\n type: \"private\",\n display_recipient: [{id: joe.user_id}, {id: steve.user_id}, {id: me.user_id}],\n }),\n );\n- assert(\n+ assert.ok(\n !predicate({\n // you must be a part of the group pm\n type: \"private\",\n display_recipient: [{id: joe.user_id}, {id: steve.user_id}],\n }),\n );\n- assert(\n+ assert.ok(\n !predicate({\n type: \"private\",\n display_recipient: [{id: steve.user_id}, {id: me.user_id}],\n }),\n );\n- assert(!predicate({type: \"stream\"}));\n+ assert.ok(!predicate({type: \"stream\"}));\n \n const img_msg = {\n content:\n@@ -727,10 +727,10 @@ test(\"predicate_basics\", () => {\n };\n \n predicate = get_predicate([[\"has\", \"non_valid_operand\"]]);\n- assert(!predicate(img_msg));\n- assert(!predicate(non_img_attachment_msg));\n- assert(!predicate(link_msg));\n- assert(!predicate(no_has_filter_matching_msg));\n+ assert.ok(!predicate(img_msg));\n+ assert.ok(!predicate(non_img_attachment_msg));\n+ assert.ok(!predicate(link_msg));\n+ assert.ok(!predicate(no_has_filter_matching_msg));\n \n // HTML content of message is used to determine if image have link, image or attachment.\n // We are using jquery to parse the html and find existence of relevant tags/elements.\n@@ -741,33 +741,33 @@ test(\"predicate_basics\", () => {\n \n const has_link = get_predicate([[\"has\", \"link\"]]);\n set_find_results_for_msg_content(img_msg, \"a\", [\"stub\"]);\n- assert(has_link(img_msg));\n+ assert.ok(has_link(img_msg));\n set_find_results_for_msg_content(non_img_attachment_msg, \"a\", [\"stub\"]);\n- assert(has_link(non_img_attachment_msg));\n+ assert.ok(has_link(non_img_attachment_msg));\n set_find_results_for_msg_content(link_msg, \"a\", [\"stub\"]);\n- assert(has_link(link_msg));\n+ assert.ok(has_link(link_msg));\n set_find_results_for_msg_content(no_has_filter_matching_msg, \"a\", false);\n- assert(!has_link(no_has_filter_matching_msg));\n+ assert.ok(!has_link(no_has_filter_matching_msg));\n \n const has_attachment = get_predicate([[\"has\", \"attachment\"]]);\n set_find_results_for_msg_content(img_msg, \"a[href^='/user_uploads']\", [\"stub\"]);\n- assert(has_attachment(img_msg));\n+ assert.ok(has_attachment(img_msg));\n set_find_results_for_msg_content(non_img_attachment_msg, \"a[href^='/user_uploads']\", [\"stub\"]);\n- assert(has_attachment(non_img_attachment_msg));\n+ assert.ok(has_attachment(non_img_attachment_msg));\n set_find_results_for_msg_content(link_msg, \"a[href^='/user_uploads']\", false);\n- assert(!has_attachment(link_msg));\n+ assert.ok(!has_attachment(link_msg));\n set_find_results_for_msg_content(no_has_filter_matching_msg, \"a[href^='/user_uploads']\", false);\n- assert(!has_attachment(no_has_filter_matching_msg));\n+ assert.ok(!has_attachment(no_has_filter_matching_msg));\n \n const has_image = get_predicate([[\"has\", \"image\"]]);\n set_find_results_for_msg_content(img_msg, \".message_inline_image\", [\"stub\"]);\n- assert(has_image(img_msg));\n+ assert.ok(has_image(img_msg));\n set_find_results_for_msg_content(non_img_attachment_msg, \".message_inline_image\", false);\n- assert(!has_image(non_img_attachment_msg));\n+ assert.ok(!has_image(non_img_attachment_msg));\n set_find_results_for_msg_content(link_msg, \".message_inline_image\", false);\n- assert(!has_image(link_msg));\n+ assert.ok(!has_image(link_msg));\n set_find_results_for_msg_content(no_has_filter_matching_msg, \".message_inline_image\", false);\n- assert(!has_image(no_has_filter_matching_msg));\n+ assert.ok(!has_image(no_has_filter_matching_msg));\n });\n \n test(\"negated_predicates\", () => {\n@@ -779,12 +779,12 @@ test(\"negated_predicates\", () => {\n \n narrow = [{operator: \"stream\", operand: \"social\", negated: true}];\n predicate = new Filter(narrow).predicate();\n- assert(predicate({type: \"stream\", stream_id: 999999}));\n- assert(!predicate({type: \"stream\", stream_id: social_stream_id}));\n+ assert.ok(predicate({type: \"stream\", stream_id: 999999}));\n+ assert.ok(!predicate({type: \"stream\", stream_id: social_stream_id}));\n \n narrow = [{operator: \"streams\", operand: \"public\", negated: true}];\n predicate = new Filter(narrow).predicate();\n- assert(predicate({}));\n+ assert.ok(predicate({}));\n });\n \n function test_mit_exceptions() {\n@@ -792,18 +792,18 @@ function test_mit_exceptions() {\n [\"stream\", \"Foo\"],\n [\"topic\", \"personal\"],\n ]);\n- assert(predicate({type: \"stream\", stream: \"foo\", topic: \"personal\"}));\n- assert(predicate({type: \"stream\", stream: \"foo.d\", topic: \"personal\"}));\n- assert(predicate({type: \"stream\", stream: \"foo.d\", topic: \"\"}));\n- assert(!predicate({type: \"stream\", stream: \"wrong\"}));\n- assert(!predicate({type: \"stream\", stream: \"foo\", topic: \"whatever\"}));\n- assert(!predicate({type: \"private\"}));\n+ assert.ok(predicate({type: \"stream\", stream: \"foo\", topic: \"personal\"}));\n+ assert.ok(predicate({type: \"stream\", stream: \"foo.d\", topic: \"personal\"}));\n+ assert.ok(predicate({type: \"stream\", stream: \"foo.d\", topic: \"\"}));\n+ assert.ok(!predicate({type: \"stream\", stream: \"wrong\"}));\n+ assert.ok(!predicate({type: \"stream\", stream: \"foo\", topic: \"whatever\"}));\n+ assert.ok(!predicate({type: \"private\"}));\n \n predicate = get_predicate([\n [\"stream\", \"Foo\"],\n [\"topic\", \"bar\"],\n ]);\n- assert(predicate({type: \"stream\", stream: \"foo\", topic: \"bar.d\"}));\n+ assert.ok(predicate({type: \"stream\", stream: \"foo\", topic: \"bar.d\"}));\n \n // Try to get the MIT regex to explode for an empty stream.\n let terms = [\n@@ -811,7 +811,7 @@ function test_mit_exceptions() {\n {operator: \"topic\", operand: \"bar\"},\n ];\n predicate = new Filter(terms).predicate();\n- assert(!predicate({type: \"stream\", stream: \"foo\", topic: \"bar\"}));\n+ assert.ok(!predicate({type: \"stream\", stream: \"foo\", topic: \"bar\"}));\n \n // Try to get the MIT regex to explode for an empty topic.\n terms = [\n@@ -819,7 +819,7 @@ function test_mit_exceptions() {\n {operator: \"topic\", operand: \"\"},\n ];\n predicate = new Filter(terms).predicate();\n- assert(!predicate({type: \"stream\", stream: \"foo\", topic: \"bar\"}));\n+ assert.ok(!predicate({type: \"stream\", stream: \"foo\", topic: \"bar\"}));\n }\n \n test(\"mit_exceptions\", () => {\n@@ -833,19 +833,19 @@ test(\"predicate_edge_cases\", () => {\n // The code supports undefined as an operator to Filter, which results\n // in a predicate that accepts any message.\n predicate = new Filter().predicate();\n- assert(predicate({}));\n+ assert.ok(predicate({}));\n \n // Upstream code should prevent Filter.predicate from being called with\n // invalid operator/operand combinations, but right now we just silently\n // return a function that accepts all messages.\n predicate = get_predicate([[\"in\", \"bogus\"]]);\n- assert(!predicate({}));\n+ assert.ok(!predicate({}));\n \n predicate = get_predicate([[\"bogus\", 33]]);\n- assert(predicate({}));\n+ assert.ok(predicate({}));\n \n predicate = get_predicate([[\"is\", \"bogus\"]]);\n- assert(!predicate({}));\n+ assert.ok(!predicate({}));\n \n // Exercise caching feature.\n const stream_id = 101;\n@@ -857,7 +857,7 @@ test(\"predicate_edge_cases\", () => {\n const filter = new Filter(terms);\n filter.predicate();\n predicate = filter.predicate(); // get cached version\n- assert(predicate({type: \"stream\", stream_id, topic: \"Mars\"}));\n+ assert.ok(predicate({type: \"stream\", stream_id, topic: \"Mars\"}));\n });\n \n test(\"parse\", () => {\n@@ -1254,13 +1254,13 @@ test(\"term_type\", () => {\n filter._build_sorted_term_types_called = false;\n const built_terms = filter.sorted_term_types();\n assert.deepEqual(built_terms, [\"stream\", \"topic\", \"sender\"]);\n- assert(filter._build_sorted_term_types_called);\n+ assert.ok(filter._build_sorted_term_types_called);\n \n // cached trial\n filter._build_sorted_term_types_called = false;\n const cached_terms = filter.sorted_term_types();\n assert.deepEqual(cached_terms, [\"stream\", \"topic\", \"sender\"]);\n- assert(!filter._build_sorted_term_types_called);\n+ assert.ok(!filter._build_sorted_term_types_called);\n });\n \n test(\"first_valid_id_from\", (override) => {\n@@ -1570,5 +1570,5 @@ test(\"error_cases\", (override) => {\n override(people, \"pm_with_user_ids\", () => {});\n \n const predicate = get_predicate([[\"pm-with\", \"Joe@example.com\"]]);\n- assert(!predicate({type: \"private\"}));\n+ assert.ok(!predicate({type: \"private\"}));\n });\ndiff --git a/frontend_tests/node_tests/fold_dict.js b/frontend_tests/node_tests/fold_dict.js\n--- a/frontend_tests/node_tests/fold_dict.js\n+++ b/frontend_tests/node_tests/fold_dict.js\n@@ -53,12 +53,12 @@ run_test(\"case insensitivity\", () => {\n \n assert.deepEqual(Array.from(d.keys()), []);\n \n- assert(!d.has(\"foo\"));\n+ assert.ok(!d.has(\"foo\"));\n d.set(\"fOO\", \"Hello world\");\n assert.equal(d.get(\"foo\"), \"Hello world\");\n- assert(d.has(\"foo\"));\n- assert(d.has(\"FOO\"));\n- assert(!d.has(\"not_a_key\"));\n+ assert.ok(d.has(\"foo\"));\n+ assert.ok(d.has(\"FOO\"));\n+ assert.ok(!d.has(\"not_a_key\"));\n \n assert.deepEqual(Array.from(d.keys()), [\"fOO\"]);\n \ndiff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.js\n--- a/frontend_tests/node_tests/hotkey.js\n+++ b/frontend_tests/node_tests/hotkey.js\n@@ -233,7 +233,7 @@ function process(s) {\n \n function assert_mapping(c, module, func_name, shiftKey) {\n stubbing(module, func_name, (stub) => {\n- assert(process(c, shiftKey));\n+ assert.ok(process(c, shiftKey));\n assert.equal(stub.num_calls, 1);\n });\n }\n@@ -432,7 +432,7 @@ run_test(\"motion_keys\", () => {\n \n function assert_mapping(key_name, module, func_name) {\n stubbing(module, func_name, (stub) => {\n- assert(process(key_name));\n+ assert.ok(process(key_name));\n assert.equal(stub.num_calls, 1);\n });\n }\ndiff --git a/frontend_tests/node_tests/i18n.js b/frontend_tests/node_tests/i18n.js\n--- a/frontend_tests/node_tests/i18n.js\n+++ b/frontend_tests/node_tests/i18n.js\n@@ -79,7 +79,7 @@ run_test(\"t_tag\", () => {\n };\n \n const html = require(\"../../static/templates/actions_popover_content.hbs\")(args);\n- assert(html.indexOf(\"Citer et répondre ou transférer\") > 0);\n+ assert.ok(html.indexOf(\"Citer et répondre ou transférer\") > 0);\n });\n \n run_test(\"tr_tag\", () => {\n@@ -103,5 +103,5 @@ run_test(\"tr_tag\", () => {\n };\n \n const html = require(\"../../static/templates/settings_tab.hbs\")(args);\n- assert(html.indexOf(\"Déclencheurs de notification\") > 0);\n+ assert.ok(html.indexOf(\"Déclencheurs de notification\") > 0);\n });\ndiff --git a/frontend_tests/node_tests/input_pill.js b/frontend_tests/node_tests/input_pill.js\n--- a/frontend_tests/node_tests/input_pill.js\n+++ b/frontend_tests/node_tests/input_pill.js\n@@ -93,7 +93,7 @@ run_test(\"basics\", (override) => {\n };\n \n widget.appendValidatedData(item);\n- assert(inserted_before);\n+ assert.ok(inserted_before);\n \n assert.deepEqual(widget.items(), [item]);\n });\n@@ -222,7 +222,7 @@ run_test(\"paste to input\", () => {\n });\n \n paste_handler(e);\n- assert(entered);\n+ assert.ok(entered);\n });\n \n run_test(\"arrows on pills\", () => {\n@@ -267,10 +267,10 @@ run_test(\"arrows on pills\", () => {\n // actually cause any real state changes here. We stub out\n // the only interaction, which is to move the focus.\n test_key(\"ArrowLeft\");\n- assert(prev_focused);\n+ assert.ok(prev_focused);\n \n test_key(\"ArrowRight\");\n- assert(next_focused);\n+ assert.ok(next_focused);\n });\n \n run_test(\"left arrow on input\", () => {\n@@ -299,7 +299,7 @@ run_test(\"left arrow on input\", () => {\n key: \"ArrowLeft\",\n });\n \n- assert(last_pill_focused);\n+ assert.ok(last_pill_focused);\n });\n \n run_test(\"comma\", () => {\n@@ -389,8 +389,8 @@ run_test(\"insert_remove\", (override) => {\n \n widget.appendValue(\"blue,chartreuse,red,yellow,mauve\");\n \n- assert(created);\n- assert(!removed);\n+ assert.ok(created);\n+ assert.ok(!removed);\n \n assert.deepEqual(inserted_html, [\n pill_html(\"BLUE\", \"some_id1\", example_img_link),\n@@ -429,7 +429,7 @@ run_test(\"insert_remove\", (override) => {\n preventDefault: noop,\n });\n \n- assert(removed);\n+ assert.ok(removed);\n assert.equal(color_removed, \"YELLOW\");\n \n assert.deepEqual(widget.items(), [items.blue, items.red]);\n@@ -461,7 +461,7 @@ run_test(\"insert_remove\", (override) => {\n });\n \n assert.equal(color_removed, \"BLUE\");\n- assert(next_pill_focused);\n+ assert.ok(next_pill_focused);\n });\n \n run_test(\"exit button on pill\", (override) => {\n@@ -515,7 +515,7 @@ run_test(\"exit button on pill\", (override) => {\n \n exit_click_handler.call(exit_button_stub, e);\n \n- assert(next_pill_focused);\n+ assert.ok(next_pill_focused);\n \n assert.deepEqual(widget.items(), [items.red]);\n });\n@@ -544,7 +544,7 @@ run_test(\"misc things\", () => {\n };\n \n animation_end_handler.call(input_stub);\n- assert(shake_class_removed);\n+ assert.ok(shake_class_removed);\n \n // bad data\n blueslip.expect(\"error\", \"no display_value returned\");\ndiff --git a/frontend_tests/node_tests/lazy_set.js b/frontend_tests/node_tests/lazy_set.js\n--- a/frontend_tests/node_tests/lazy_set.js\n+++ b/frontend_tests/node_tests/lazy_set.js\n@@ -27,5 +27,5 @@ run_test(\"conversions\", () => {\n blueslip.expect(\"error\", \"not a number\", 2);\n const ls = new LazySet([1, 2]);\n ls.add(\"3\");\n- assert(ls.has(\"3\"));\n+ assert.ok(ls.has(\"3\"));\n });\ndiff --git a/frontend_tests/node_tests/list_cursor.js b/frontend_tests/node_tests/list_cursor.js\n--- a/frontend_tests/node_tests/list_cursor.js\n+++ b/frontend_tests/node_tests/list_cursor.js\n@@ -112,30 +112,30 @@ run_test(\"multiple item list\", (override) => {\n \n cursor.go_to(2);\n assert.equal(cursor.get_key(), 2);\n- assert(!list_items[1].hasClass(\"highlight\"));\n- assert(list_items[2].hasClass(\"highlight\"));\n- assert(!list_items[3].hasClass(\"highlight\"));\n+ assert.ok(!list_items[1].hasClass(\"highlight\"));\n+ assert.ok(list_items[2].hasClass(\"highlight\"));\n+ assert.ok(!list_items[3].hasClass(\"highlight\"));\n \n cursor.next();\n cursor.next();\n cursor.next();\n \n assert.equal(cursor.get_key(), 3);\n- assert(!list_items[1].hasClass(\"highlight\"));\n- assert(!list_items[2].hasClass(\"highlight\"));\n- assert(list_items[3].hasClass(\"highlight\"));\n+ assert.ok(!list_items[1].hasClass(\"highlight\"));\n+ assert.ok(!list_items[2].hasClass(\"highlight\"));\n+ assert.ok(list_items[3].hasClass(\"highlight\"));\n \n cursor.prev();\n cursor.prev();\n cursor.prev();\n \n assert.equal(cursor.get_key(), 1);\n- assert(list_items[1].hasClass(\"highlight\"));\n- assert(!list_items[2].hasClass(\"highlight\"));\n- assert(!list_items[3].hasClass(\"highlight\"));\n+ assert.ok(list_items[1].hasClass(\"highlight\"));\n+ assert.ok(!list_items[2].hasClass(\"highlight\"));\n+ assert.ok(!list_items[3].hasClass(\"highlight\"));\n \n cursor.clear();\n assert.equal(cursor.get_key(), undefined);\n cursor.redraw();\n- assert(!list_items[1].hasClass(\"highlight\"));\n+ assert.ok(!list_items[1].hasClass(\"highlight\"));\n });\ndiff --git a/frontend_tests/node_tests/list_widget.js b/frontend_tests/node_tests/list_widget.js\n--- a/frontend_tests/node_tests/list_widget.js\n+++ b/frontend_tests/node_tests/list_widget.js\n@@ -435,8 +435,8 @@ run_test(\"sorting\", () => {\n \n sort_container.f.apply(button);\n \n- assert(cleared);\n- assert(button.siblings_deactivated);\n+ assert.ok(cleared);\n+ assert.ok(button.siblings_deactivated);\n \n expected_html = html_for([alice, bob, cal, dave, ellen]);\n assert.deepEqual(container.appended_data.html(), expected_html);\n@@ -444,18 +444,18 @@ run_test(\"sorting\", () => {\n // Hit same button again to reverse the data.\n cleared = false;\n sort_container.f.apply(button);\n- assert(cleared);\n+ assert.ok(cleared);\n expected_html = html_for([ellen, dave, cal, bob, alice]);\n assert.deepEqual(container.appended_data.html(), expected_html);\n- assert(button.hasClass(\"descend\"));\n+ assert.ok(button.hasClass(\"descend\"));\n \n // And then hit a third time to go back to the forward sort.\n cleared = false;\n sort_container.f.apply(button);\n- assert(cleared);\n+ assert.ok(cleared);\n expected_html = html_for([alice, bob, cal, dave, ellen]);\n assert.deepEqual(container.appended_data.html(), expected_html);\n- assert(!button.hasClass(\"descend\"));\n+ assert.ok(!button.hasClass(\"descend\"));\n \n // Now try a numeric sort.\n button_opts = {\n@@ -472,8 +472,8 @@ run_test(\"sorting\", () => {\n \n sort_container.f.apply(button);\n \n- assert(cleared);\n- assert(button.siblings_deactivated);\n+ assert.ok(cleared);\n+ assert.ok(button.siblings_deactivated);\n \n expected_html = html_for([dave, cal, bob, alice, ellen]);\n assert.deepEqual(container.appended_data.html(), expected_html);\n@@ -481,10 +481,10 @@ run_test(\"sorting\", () => {\n // Hit same button again to reverse the numeric sort.\n cleared = false;\n sort_container.f.apply(button);\n- assert(cleared);\n+ assert.ok(cleared);\n expected_html = html_for([ellen, alice, bob, cal, dave]);\n assert.deepEqual(container.appended_data.html(), expected_html);\n- assert(button.hasClass(\"descend\"));\n+ assert.ok(button.hasClass(\"descend\"));\n });\n \n run_test(\"custom sort\", () => {\n@@ -735,7 +735,7 @@ run_test(\"render item\", () => {\n const item = INITIAL_RENDER_COUNT - 1;\n const new_html = `updated: ${item}\\n`;\n const regex = new RegExp(`\\\\.*?<\\\\/tr\\\\>`);\n- assert(expected_queries.includes(query));\n+ assert.ok(expected_queries.includes(query));\n if (query.includes(`data-item='${INITIAL_RENDER_COUNT}'`)) {\n return undefined; // This item is not rendered, so we find nothing\n }\n@@ -765,17 +765,19 @@ run_test(\"render item\", () => {\n });\n const item = INITIAL_RENDER_COUNT - 1;\n \n- assert(container.appended_data.html().includes(\"initial: 2\"));\n- assert(container.appended_data.html().includes(\"initial: 3\"));\n+ assert.ok(container.appended_data.html().includes(\"initial: 2\"));\n+ assert.ok(container.appended_data.html().includes(\"initial: 3\"));\n text = \"updated\";\n called = false;\n widget.render_item(INITIAL_RENDER_COUNT - 1);\n- assert(called);\n- assert(container.appended_data.html().includes(\"initial: 2\"));\n- assert(container.appended_data.html().includes(`updated: ${item}`));\n+ assert.ok(called);\n+ assert.ok(container.appended_data.html().includes(\"initial: 2\"));\n+ assert.ok(\n+ container.appended_data.html().includes(`updated: ${item}`),\n+ );\n \n // Item 80 should not be in the rendered list. (0 indexed)\n- assert(\n+ assert.ok(\n !container.appended_data\n .html()\n .includes(\n@@ -784,9 +786,9 @@ run_test(\"render item\", () => {\n );\n called = false;\n widget.render_item(INITIAL_RENDER_COUNT);\n- assert(!called);\n+ assert.ok(!called);\n widget.render_item(INITIAL_RENDER_COUNT - 1);\n- assert(called);\n+ assert.ok(called);\n \n // Tests below this are for the corner cases, where we abort the rerender.\n \n@@ -813,7 +815,7 @@ run_test(\"render item\", () => {\n get_item_called = false;\n widget_2.render_item(item);\n // Test that we didn't try to render the item.\n- assert(!get_item_called);\n+ assert.ok(!get_item_called);\n \n let rendering_item = false;\n const widget_3 = ListWidget.create(container, list, {\ndiff --git a/frontend_tests/node_tests/markdown.js b/frontend_tests/node_tests/markdown.js\n--- a/frontend_tests/node_tests/markdown.js\n+++ b/frontend_tests/node_tests/markdown.js\n@@ -272,18 +272,18 @@ test(\"marked_shared\", () => {\n test(\"message_flags\", () => {\n let message = {raw_content: \"@**Leo**\"};\n markdown.apply_markdown(message);\n- assert(!message.mentioned);\n- assert(!message.mentioned_me_directly);\n+ assert.ok(!message.mentioned);\n+ assert.ok(!message.mentioned_me_directly);\n \n message = {raw_content: \"@**Cordelia, Lear's daughter**\"};\n markdown.apply_markdown(message);\n- assert(message.mentioned);\n- assert(message.mentioned_me_directly);\n+ assert.ok(message.mentioned);\n+ assert.ok(message.mentioned_me_directly);\n \n message = {raw_content: \"@**all**\"};\n markdown.apply_markdown(message);\n- assert(message.mentioned);\n- assert(!message.mentioned_me_directly);\n+ assert.ok(message.mentioned);\n+ assert.ok(!message.mentioned_me_directly);\n });\n \n test(\"marked\", () => {\n@@ -671,7 +671,7 @@ test(\"message_flags\", () => {\n markdown.apply_markdown(message);\n \n assert.equal(message.is_me_message, true);\n- assert(!message.unread);\n+ assert.ok(!message.unread);\n \n input = \"/me is testing\\nthis\";\n message = {topic: \"No links here\", raw_content: input};\ndiff --git a/frontend_tests/node_tests/message_events.js b/frontend_tests/node_tests/message_events.js\n--- a/frontend_tests/node_tests/message_events.js\n+++ b/frontend_tests/node_tests/message_events.js\n@@ -79,7 +79,7 @@ run_test(\"update_messages\", () => {\n assert.deepEqual(stream_topic_history.get_recent_topic_names(denmark.stream_id), [\"lunch\"]);\n \n unread.update_message_for_mention(original_message);\n- assert(unread.unread_mentions_counter.has(original_message.id));\n+ assert.ok(unread.unread_mentions_counter.has(original_message.id));\n \n const events = [\n {\n@@ -121,7 +121,7 @@ run_test(\"update_messages\", () => {\n // TEST THIS:\n message_events.update_messages(events);\n \n- assert(!unread.unread_mentions_counter.has(original_message.id));\n+ assert.ok(!unread.unread_mentions_counter.has(original_message.id));\n \n helper.verify();\n \ndiff --git a/frontend_tests/node_tests/message_fetch.js b/frontend_tests/node_tests/message_fetch.js\n--- a/frontend_tests/node_tests/message_fetch.js\n+++ b/frontend_tests/node_tests/message_fetch.js\n@@ -293,9 +293,9 @@ run_test(\"initialize\", () => {\n step2.prep();\n step1.finish();\n \n- assert(!home_loaded);\n+ assert.ok(!home_loaded);\n const idle_config = step2.finish();\n- assert(home_loaded);\n+ assert.ok(home_loaded);\n \n test_backfill_idle(idle_config);\n });\ndiff --git a/frontend_tests/node_tests/message_flags.js b/frontend_tests/node_tests/message_flags.js\n--- a/frontend_tests/node_tests/message_flags.js\n+++ b/frontend_tests/node_tests/message_flags.js\n@@ -35,7 +35,7 @@ run_test(\"starred\", (override) => {\n \n message_flags.toggle_starred_and_update_server(message);\n \n- assert(ui_updated);\n+ assert.ok(ui_updated);\n \n assert.deepEqual(posted_data, {\n messages: \"[50]\",\n@@ -52,7 +52,7 @@ run_test(\"starred\", (override) => {\n \n message_flags.toggle_starred_and_update_server(message);\n \n- assert(ui_updated);\n+ assert.ok(ui_updated);\n \n assert.deepEqual(posted_data, {\n messages: \"[50]\",\n@@ -236,7 +236,7 @@ run_test(\"read\", (override) => {\n messages: [3, 4, 5, 6, 7],\n };\n channel_post_opts.success(success_response_data);\n- assert(events.timer_set);\n+ assert.ok(events.timer_set);\n \n // Mark them non local\n local_msg_1.locally_echoed = false;\ndiff --git a/frontend_tests/node_tests/message_list_data.js b/frontend_tests/node_tests/message_list_data.js\n--- a/frontend_tests/node_tests/message_list_data.js\n+++ b/frontend_tests/node_tests/message_list_data.js\n@@ -46,7 +46,7 @@ run_test(\"basics\", () => {\n });\n \n assert.equal(mld.is_search(), false);\n- assert(mld.can_mark_messages_read());\n+ assert.ok(mld.can_mark_messages_read());\n mld.add_anywhere(make_msgs([35, 25, 15, 45]));\n \n assert_contents(mld, [15, 25, 35, 45]);\ndiff --git a/frontend_tests/node_tests/message_list_view.js b/frontend_tests/node_tests/message_list_view.js\n--- a/frontend_tests/node_tests/message_list_view.js\n+++ b/frontend_tests/node_tests/message_list_view.js\n@@ -282,7 +282,7 @@ test(\"merge_message_groups\", () => {\n function assert_message_list_equal(list1, list2) {\n const ids1 = extract_message_ids(list1);\n const ids2 = extract_message_ids(list2);\n- assert(ids1.length);\n+ assert.ok(ids1.length);\n assert.deepEqual(ids1, ids2);\n }\n \n@@ -293,7 +293,7 @@ test(\"merge_message_groups\", () => {\n function assert_message_groups_list_equal(list1, list2) {\n const ids1 = list1.map((group) => extract_group(group));\n const ids2 = list2.map((group) => extract_group(group));\n- assert(ids1.length);\n+ assert.ok(ids1.length);\n assert.deepEqual(ids1, ids2);\n }\n \n@@ -341,7 +341,7 @@ test(\"merge_message_groups\", () => {\n const list = build_list([message_group1]);\n const result = list.merge_message_groups([message_group2], \"bottom\");\n \n- assert(!message_group2.group_date_divider_html);\n+ assert.ok(!message_group2.group_date_divider_html);\n assert_message_groups_list_equal(list._message_groups, [message_group1, message_group2]);\n assert_message_groups_list_equal(result.append_groups, [message_group2]);\n assert.deepEqual(result.prepend_groups, []);\n@@ -385,7 +385,7 @@ test(\"merge_message_groups\", () => {\n assert.deepEqual(result.rerender_groups, []);\n assert.deepEqual(result.append_messages, [message2]);\n assert.deepEqual(result.rerender_messages_next_same_sender, [message1]);\n- assert(list._message_groups[0].message_containers[1].want_date_divider);\n+ assert.ok(list._message_groups[0].message_containers[1].want_date_divider);\n })();\n \n (function test_append_message_historical() {\n@@ -398,7 +398,7 @@ test(\"merge_message_groups\", () => {\n const list = build_list([message_group1]);\n const result = list.merge_message_groups([message_group2], \"bottom\");\n \n- assert(message_group2.bookend_top);\n+ assert.ok(message_group2.bookend_top);\n assert_message_groups_list_equal(list._message_groups, [message_group1, message_group2]);\n assert_message_groups_list_equal(result.append_groups, [message_group2]);\n assert.deepEqual(result.prepend_groups, []);\n@@ -417,7 +417,7 @@ test(\"merge_message_groups\", () => {\n const list = build_list([message_group1]);\n const result = list.merge_message_groups([message_group2], \"bottom\");\n \n- assert(message2.include_sender);\n+ assert.ok(message2.include_sender);\n assert_message_groups_list_equal(list._message_groups, [\n build_message_group([message1, message2]),\n ]);\n@@ -518,7 +518,7 @@ test(\"merge_message_groups\", () => {\n const list = build_list([message_group1]);\n const result = list.merge_message_groups([message_group2], \"top\");\n \n- assert(message_group1.bookend_top);\n+ assert.ok(message_group1.bookend_top);\n assert_message_groups_list_equal(list._message_groups, [message_group2, message_group1]);\n assert.deepEqual(result.append_groups, []);\n assert_message_groups_list_equal(result.prepend_groups, [message_group2]);\ndiff --git a/frontend_tests/node_tests/muting.js b/frontend_tests/node_tests/muting.js\n--- a/frontend_tests/node_tests/muting.js\n+++ b/frontend_tests/node_tests/muting.js\n@@ -50,46 +50,46 @@ function test(label, f) {\n \n test(\"edge_cases\", () => {\n // private messages\n- assert(!muting.is_topic_muted(undefined, undefined));\n+ assert.ok(!muting.is_topic_muted(undefined, undefined));\n \n // invalid user\n- assert(!muting.is_user_muted(undefined));\n+ assert.ok(!muting.is_user_muted(undefined));\n });\n \n test(\"add_and_remove_mutes\", () => {\n- assert(!muting.is_topic_muted(devel.stream_id, \"java\"));\n+ assert.ok(!muting.is_topic_muted(devel.stream_id, \"java\"));\n muting.add_muted_topic(devel.stream_id, \"java\");\n- assert(muting.is_topic_muted(devel.stream_id, \"java\"));\n+ assert.ok(muting.is_topic_muted(devel.stream_id, \"java\"));\n \n // test idempotentcy\n muting.add_muted_topic(devel.stream_id, \"java\");\n- assert(muting.is_topic_muted(devel.stream_id, \"java\"));\n+ assert.ok(muting.is_topic_muted(devel.stream_id, \"java\"));\n \n muting.remove_muted_topic(devel.stream_id, \"java\");\n- assert(!muting.is_topic_muted(devel.stream_id, \"java\"));\n+ assert.ok(!muting.is_topic_muted(devel.stream_id, \"java\"));\n \n // test idempotentcy\n muting.remove_muted_topic(devel.stream_id, \"java\");\n- assert(!muting.is_topic_muted(devel.stream_id, \"java\"));\n+ assert.ok(!muting.is_topic_muted(devel.stream_id, \"java\"));\n \n // test unknown stream is harmless too\n muting.remove_muted_topic(unknown.stream_id, \"java\");\n- assert(!muting.is_topic_muted(unknown.stream_id, \"java\"));\n+ assert.ok(!muting.is_topic_muted(unknown.stream_id, \"java\"));\n \n- assert(!muting.is_user_muted(1));\n+ assert.ok(!muting.is_user_muted(1));\n muting.add_muted_user(1);\n- assert(muting.is_user_muted(1));\n+ assert.ok(muting.is_user_muted(1));\n \n // test idempotentcy\n muting.add_muted_user(1);\n- assert(muting.is_user_muted(1));\n+ assert.ok(muting.is_user_muted(1));\n \n muting.remove_muted_user(1);\n- assert(!muting.is_user_muted(1));\n+ assert.ok(!muting.is_user_muted(1));\n \n // test idempotentcy\n muting.remove_muted_user(1);\n- assert(!muting.is_user_muted(1));\n+ assert.ok(!muting.is_user_muted(1));\n });\n \n test(\"get_unmuted_users\", () => {\n@@ -204,8 +204,8 @@ test(\"unknown streams\", () => {\n \n test(\"case_insensitivity\", () => {\n muting.set_muted_topics([]);\n- assert(!muting.is_topic_muted(social.stream_id, \"breakfast\"));\n+ assert.ok(!muting.is_topic_muted(social.stream_id, \"breakfast\"));\n muting.set_muted_topics([[\"SOCial\", \"breakfast\"]]);\n- assert(muting.is_topic_muted(social.stream_id, \"breakfast\"));\n- assert(muting.is_topic_muted(social.stream_id, \"breakFAST\"));\n+ assert.ok(muting.is_topic_muted(social.stream_id, \"breakfast\"));\n+ assert.ok(muting.is_topic_muted(social.stream_id, \"breakFAST\"));\n });\ndiff --git a/frontend_tests/node_tests/narrow.js b/frontend_tests/node_tests/narrow.js\n--- a/frontend_tests/node_tests/narrow.js\n+++ b/frontend_tests/node_tests/narrow.js\n@@ -101,83 +101,83 @@ run_test(\"show_empty_narrow_message\", () => {\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n assert.equal($(\".empty_feed_notice\").visible(), false);\n- assert($(\"#empty_narrow_message\").visible());\n+ assert.ok($(\"#empty_narrow_message\").visible());\n \n // for non-existent or private stream\n set_filter([[\"stream\", \"Foo\"]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#nonsubbed_private_nonexistent_stream_narrow_message\").visible());\n+ assert.ok($(\"#nonsubbed_private_nonexistent_stream_narrow_message\").visible());\n \n // for non sub public stream\n stream_data.add_sub({name: \"ROME\", stream_id: 99});\n set_filter([[\"stream\", \"Rome\"]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#nonsubbed_stream_narrow_message\").visible());\n+ assert.ok($(\"#nonsubbed_stream_narrow_message\").visible());\n \n set_filter([[\"is\", \"starred\"]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_star_narrow_message\").visible());\n+ assert.ok($(\"#empty_star_narrow_message\").visible());\n \n set_filter([[\"is\", \"mentioned\"]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_narrow_all_mentioned\").visible());\n+ assert.ok($(\"#empty_narrow_all_mentioned\").visible());\n \n set_filter([[\"is\", \"private\"]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_narrow_all_private_message\").visible());\n+ assert.ok($(\"#empty_narrow_all_private_message\").visible());\n \n set_filter([[\"is\", \"unread\"]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#no_unread_narrow_message\").visible());\n+ assert.ok($(\"#no_unread_narrow_message\").visible());\n \n set_filter([[\"pm-with\", [\"Yo\"]]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#non_existing_user\").visible());\n+ assert.ok($(\"#non_existing_user\").visible());\n \n people.add_active_user(alice);\n set_filter([[\"pm-with\", [\"alice@example.com\", \"Yo\"]]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#non_existing_users\").visible());\n+ assert.ok($(\"#non_existing_users\").visible());\n \n set_filter([[\"pm-with\", \"alice@example.com\"]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_narrow_private_message\").visible());\n+ assert.ok($(\"#empty_narrow_private_message\").visible());\n \n people.add_active_user(me);\n people.initialize_current_user(me.user_id);\n set_filter([[\"pm-with\", me.email]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_narrow_self_private_message\").visible());\n+ assert.ok($(\"#empty_narrow_self_private_message\").visible());\n \n set_filter([[\"pm-with\", me.email + \",\" + alice.email]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_narrow_multi_private_message\").visible());\n+ assert.ok($(\"#empty_narrow_multi_private_message\").visible());\n \n set_filter([[\"group-pm-with\", \"alice@example.com\"]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_narrow_group_private_message\").visible());\n+ assert.ok($(\"#empty_narrow_group_private_message\").visible());\n \n set_filter([[\"sender\", \"ray@example.com\"]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#silent_user\").visible());\n+ assert.ok($(\"#silent_user\").visible());\n \n set_filter([[\"sender\", \"sinwar@example.com\"]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#non_existing_user\").visible());\n+ assert.ok($(\"#non_existing_user\").visible());\n \n const display = $(\"#empty_search_stop_words_string\");\n \n@@ -189,7 +189,7 @@ run_test(\"show_empty_narrow_message\", () => {\n set_filter([[\"search\", \"grail\"]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_search_narrow_message\").visible());\n+ assert.ok($(\"#empty_search_narrow_message\").visible());\n \n assert.equal(items.length, 2);\n assert.equal(items[0], \" \");\n@@ -201,12 +201,12 @@ run_test(\"show_empty_narrow_message\", () => {\n ]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_narrow_message\").visible());\n+ assert.ok($(\"#empty_narrow_message\").visible());\n \n set_filter([[\"is\", \"invalid\"]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_narrow_message\").visible());\n+ assert.ok($(\"#empty_narrow_message\").visible());\n \n const my_stream = {\n name: \"my stream\",\n@@ -218,18 +218,18 @@ run_test(\"show_empty_narrow_message\", () => {\n set_filter([[\"stream\", \"my stream\"]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_narrow_message\").visible());\n+ assert.ok($(\"#empty_narrow_message\").visible());\n \n set_filter([[\"stream\", \"\"]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#nonsubbed_private_nonexistent_stream_narrow_message\").visible());\n+ assert.ok($(\"#nonsubbed_private_nonexistent_stream_narrow_message\").visible());\n });\n \n run_test(\"hide_empty_narrow_message\", () => {\n $(\".empty_feed_notice\").show();\n narrow_banner.hide_empty_narrow_message();\n- assert(!$(\".empty_feed_notice\").visible());\n+ assert.ok(!$(\".empty_feed_notice\").visible());\n });\n \n run_test(\"show_search_stopwords\", () => {\n@@ -249,7 +249,7 @@ run_test(\"show_search_stopwords\", () => {\n set_filter([[\"search\", \"what about grail\"]]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_search_narrow_message\").visible());\n+ assert.ok($(\"#empty_search_narrow_message\").visible());\n \n assert.equal(items.length, 3);\n assert.equal(items[0], \"what\");\n@@ -263,7 +263,7 @@ run_test(\"show_search_stopwords\", () => {\n ]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_search_narrow_message\").visible());\n+ assert.ok($(\"#empty_search_narrow_message\").visible());\n \n assert.equal(items.length, 4);\n assert.equal(items[0], \"stream: streamA\");\n@@ -279,7 +279,7 @@ run_test(\"show_search_stopwords\", () => {\n ]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_search_narrow_message\").visible());\n+ assert.ok($(\"#empty_search_narrow_message\").visible());\n \n assert.equal(items.length, 4);\n assert.equal(items[0], \"stream: streamA topic: topicA\");\n@@ -301,7 +301,7 @@ run_test(\"show_invalid_narrow_message\", () => {\n ]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_search_narrow_message\").visible());\n+ assert.ok($(\"#empty_search_narrow_message\").visible());\n assert.equal(\n display.text(),\n \"translated: You are searching for messages that belong to more than one stream, which is not possible.\",\n@@ -313,7 +313,7 @@ run_test(\"show_invalid_narrow_message\", () => {\n ]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_search_narrow_message\").visible());\n+ assert.ok($(\"#empty_search_narrow_message\").visible());\n assert.equal(\n display.text(),\n \"translated: You are searching for messages that belong to more than one topic, which is not possible.\",\n@@ -328,7 +328,7 @@ run_test(\"show_invalid_narrow_message\", () => {\n ]);\n hide_all_empty_narrow_messages();\n narrow_banner.show_empty_narrow_message();\n- assert($(\"#empty_search_narrow_message\").visible());\n+ assert.ok($(\"#empty_search_narrow_message\").visible());\n assert.equal(\n display.text(),\n \"translated: You are searching for messages that are sent by more than one person, which is not possible.\",\ndiff --git a/frontend_tests/node_tests/narrow_local.js b/frontend_tests/node_tests/narrow_local.js\n--- a/frontend_tests/node_tests/narrow_local.js\n+++ b/frontend_tests/node_tests/narrow_local.js\n@@ -22,7 +22,7 @@ function test_with(fixture) {\n if (fixture.unread_info.flavor === \"found\") {\n for (const msg of fixture.all_messages) {\n if (msg.id === fixture.unread_info.msg_id) {\n- assert(filter.predicate()(msg));\n+ assert.ok(filter.predicate()(msg));\n }\n }\n }\ndiff --git a/frontend_tests/node_tests/narrow_state.js b/frontend_tests/node_tests/narrow_state.js\n--- a/frontend_tests/node_tests/narrow_state.js\n+++ b/frontend_tests/node_tests/narrow_state.js\n@@ -28,24 +28,24 @@ function test(label, f) {\n \n test(\"stream\", () => {\n assert.equal(narrow_state.public_operators(), undefined);\n- assert(!narrow_state.active());\n+ assert.ok(!narrow_state.active());\n \n const test_stream = {name: \"Test\", stream_id: 15};\n stream_data.add_sub(test_stream);\n \n- assert(!narrow_state.is_for_stream_id(test_stream.stream_id));\n+ assert.ok(!narrow_state.is_for_stream_id(test_stream.stream_id));\n \n set_filter([\n [\"stream\", \"Test\"],\n [\"topic\", \"Bar\"],\n [\"search\", \"yo\"],\n ]);\n- assert(narrow_state.active());\n+ assert.ok(narrow_state.active());\n \n assert.equal(narrow_state.stream(), \"Test\");\n assert.equal(narrow_state.stream_sub().stream_id, test_stream.stream_id);\n assert.equal(narrow_state.topic(), \"Bar\");\n- assert(narrow_state.is_for_stream_id(test_stream.stream_id));\n+ assert.ok(narrow_state.is_for_stream_id(test_stream.stream_id));\n \n const expected_operators = [\n {negated: false, operator: \"stream\", operand: \"Test\"},\n@@ -59,68 +59,68 @@ test(\"stream\", () => {\n });\n \n test(\"narrowed\", () => {\n- assert(!narrow_state.narrowed_to_pms());\n- assert(!narrow_state.narrowed_by_reply());\n- assert(!narrow_state.narrowed_by_pm_reply());\n- assert(!narrow_state.narrowed_by_topic_reply());\n- assert(!narrow_state.narrowed_to_search());\n- assert(!narrow_state.narrowed_to_topic());\n- assert(!narrow_state.narrowed_by_stream_reply());\n+ assert.ok(!narrow_state.narrowed_to_pms());\n+ assert.ok(!narrow_state.narrowed_by_reply());\n+ assert.ok(!narrow_state.narrowed_by_pm_reply());\n+ assert.ok(!narrow_state.narrowed_by_topic_reply());\n+ assert.ok(!narrow_state.narrowed_to_search());\n+ assert.ok(!narrow_state.narrowed_to_topic());\n+ assert.ok(!narrow_state.narrowed_by_stream_reply());\n assert.equal(narrow_state.stream_sub(), undefined);\n- assert(!narrow_state.narrowed_to_starred());\n+ assert.ok(!narrow_state.narrowed_to_starred());\n \n set_filter([[\"stream\", \"Foo\"]]);\n- assert(!narrow_state.narrowed_to_pms());\n- assert(!narrow_state.narrowed_by_reply());\n- assert(!narrow_state.narrowed_by_pm_reply());\n- assert(!narrow_state.narrowed_by_topic_reply());\n- assert(!narrow_state.narrowed_to_search());\n- assert(!narrow_state.narrowed_to_topic());\n- assert(narrow_state.narrowed_by_stream_reply());\n- assert(!narrow_state.narrowed_to_starred());\n+ assert.ok(!narrow_state.narrowed_to_pms());\n+ assert.ok(!narrow_state.narrowed_by_reply());\n+ assert.ok(!narrow_state.narrowed_by_pm_reply());\n+ assert.ok(!narrow_state.narrowed_by_topic_reply());\n+ assert.ok(!narrow_state.narrowed_to_search());\n+ assert.ok(!narrow_state.narrowed_to_topic());\n+ assert.ok(narrow_state.narrowed_by_stream_reply());\n+ assert.ok(!narrow_state.narrowed_to_starred());\n \n set_filter([[\"pm-with\", \"steve@zulip.com\"]]);\n- assert(narrow_state.narrowed_to_pms());\n- assert(narrow_state.narrowed_by_reply());\n- assert(narrow_state.narrowed_by_pm_reply());\n- assert(!narrow_state.narrowed_by_topic_reply());\n- assert(!narrow_state.narrowed_to_search());\n- assert(!narrow_state.narrowed_to_topic());\n- assert(!narrow_state.narrowed_by_stream_reply());\n- assert(!narrow_state.narrowed_to_starred());\n+ assert.ok(narrow_state.narrowed_to_pms());\n+ assert.ok(narrow_state.narrowed_by_reply());\n+ assert.ok(narrow_state.narrowed_by_pm_reply());\n+ assert.ok(!narrow_state.narrowed_by_topic_reply());\n+ assert.ok(!narrow_state.narrowed_to_search());\n+ assert.ok(!narrow_state.narrowed_to_topic());\n+ assert.ok(!narrow_state.narrowed_by_stream_reply());\n+ assert.ok(!narrow_state.narrowed_to_starred());\n \n set_filter([\n [\"stream\", \"Foo\"],\n [\"topic\", \"bar\"],\n ]);\n- assert(!narrow_state.narrowed_to_pms());\n- assert(narrow_state.narrowed_by_reply());\n- assert(!narrow_state.narrowed_by_pm_reply());\n- assert(narrow_state.narrowed_by_topic_reply());\n- assert(!narrow_state.narrowed_to_search());\n- assert(narrow_state.narrowed_to_topic());\n- assert(!narrow_state.narrowed_by_stream_reply());\n- assert(!narrow_state.narrowed_to_starred());\n+ assert.ok(!narrow_state.narrowed_to_pms());\n+ assert.ok(narrow_state.narrowed_by_reply());\n+ assert.ok(!narrow_state.narrowed_by_pm_reply());\n+ assert.ok(narrow_state.narrowed_by_topic_reply());\n+ assert.ok(!narrow_state.narrowed_to_search());\n+ assert.ok(narrow_state.narrowed_to_topic());\n+ assert.ok(!narrow_state.narrowed_by_stream_reply());\n+ assert.ok(!narrow_state.narrowed_to_starred());\n \n set_filter([[\"search\", \"grail\"]]);\n- assert(!narrow_state.narrowed_to_pms());\n- assert(!narrow_state.narrowed_by_reply());\n- assert(!narrow_state.narrowed_by_pm_reply());\n- assert(!narrow_state.narrowed_by_topic_reply());\n- assert(narrow_state.narrowed_to_search());\n- assert(!narrow_state.narrowed_to_topic());\n- assert(!narrow_state.narrowed_by_stream_reply());\n- assert(!narrow_state.narrowed_to_starred());\n+ assert.ok(!narrow_state.narrowed_to_pms());\n+ assert.ok(!narrow_state.narrowed_by_reply());\n+ assert.ok(!narrow_state.narrowed_by_pm_reply());\n+ assert.ok(!narrow_state.narrowed_by_topic_reply());\n+ assert.ok(narrow_state.narrowed_to_search());\n+ assert.ok(!narrow_state.narrowed_to_topic());\n+ assert.ok(!narrow_state.narrowed_by_stream_reply());\n+ assert.ok(!narrow_state.narrowed_to_starred());\n \n set_filter([[\"is\", \"starred\"]]);\n- assert(!narrow_state.narrowed_to_pms());\n- assert(!narrow_state.narrowed_by_reply());\n- assert(!narrow_state.narrowed_by_pm_reply());\n- assert(!narrow_state.narrowed_by_topic_reply());\n- assert(!narrow_state.narrowed_to_search());\n- assert(!narrow_state.narrowed_to_topic());\n- assert(!narrow_state.narrowed_by_stream_reply());\n- assert(narrow_state.narrowed_to_starred());\n+ assert.ok(!narrow_state.narrowed_to_pms());\n+ assert.ok(!narrow_state.narrowed_by_reply());\n+ assert.ok(!narrow_state.narrowed_by_pm_reply());\n+ assert.ok(!narrow_state.narrowed_by_topic_reply());\n+ assert.ok(!narrow_state.narrowed_to_search());\n+ assert.ok(!narrow_state.narrowed_to_topic());\n+ assert.ok(!narrow_state.narrowed_by_stream_reply());\n+ assert.ok(narrow_state.narrowed_to_starred());\n });\n \n test(\"operators\", () => {\n@@ -147,25 +147,25 @@ test(\"operators\", () => {\n \n test(\"excludes_muted_topics\", () => {\n set_filter([[\"stream\", \"devel\"]]);\n- assert(narrow_state.excludes_muted_topics());\n+ assert.ok(narrow_state.excludes_muted_topics());\n \n narrow_state.reset_current_filter(); // not narrowed, basically\n- assert(narrow_state.excludes_muted_topics());\n+ assert.ok(narrow_state.excludes_muted_topics());\n \n set_filter([\n [\"stream\", \"devel\"],\n [\"topic\", \"mac\"],\n ]);\n- assert(!narrow_state.excludes_muted_topics());\n+ assert.ok(!narrow_state.excludes_muted_topics());\n \n set_filter([[\"search\", \"whatever\"]]);\n- assert(!narrow_state.excludes_muted_topics());\n+ assert.ok(!narrow_state.excludes_muted_topics());\n \n set_filter([[\"is\", \"private\"]]);\n- assert(!narrow_state.excludes_muted_topics());\n+ assert.ok(!narrow_state.excludes_muted_topics());\n \n set_filter([[\"is\", \"starred\"]]);\n- assert(!narrow_state.excludes_muted_topics());\n+ assert.ok(!narrow_state.excludes_muted_topics());\n });\n \n test(\"set_compose_defaults\", () => {\ndiff --git a/frontend_tests/node_tests/password.js b/frontend_tests/node_tests/password.js\n--- a/frontend_tests/node_tests/password.js\n+++ b/frontend_tests/node_tests/password.js\n@@ -50,7 +50,7 @@ run_test(\"basics w/progress bar\", () => {\n \n password = \"z!X4@S_&\";\n accepted = password_quality(password, bar, password_field(10, 80000));\n- assert(!accepted);\n+ assert.ok(!accepted);\n assert.equal(bar.w, \"39.7%\");\n assert.equal(bar.added_class, \"bar-danger\");\n warning = password_warning(password, password_field(10));\n@@ -58,7 +58,7 @@ run_test(\"basics w/progress bar\", () => {\n \n password = \"foo\";\n accepted = password_quality(password, bar, password_field(2, 200));\n- assert(accepted);\n+ assert.ok(accepted);\n assert.equal(bar.w, \"10.390277164940581%\");\n assert.equal(bar.added_class, \"bar-success\");\n warning = password_warning(password, password_field(2));\n@@ -66,7 +66,7 @@ run_test(\"basics w/progress bar\", () => {\n \n password = \"aaaaaaaa\";\n accepted = password_quality(password, bar, password_field(6, 1e100));\n- assert(!accepted);\n+ assert.ok(!accepted);\n assert.equal(bar.added_class, \"bar-danger\");\n warning = password_warning(password, password_field(6));\n assert.equal(warning, 'Repeats like \"aaa\" are easy to guess');\ndiff --git a/frontend_tests/node_tests/peer_data.js b/frontend_tests/node_tests/peer_data.js\n--- a/frontend_tests/node_tests/peer_data.js\n+++ b/frontend_tests/node_tests/peer_data.js\n@@ -66,25 +66,25 @@ test(\"unsubscribe\", () => {\n stream_data.add_sub(devel);\n \n // verify clean slate\n- assert(!stream_data.is_subscribed(\"devel\"));\n+ assert.ok(!stream_data.is_subscribed(\"devel\"));\n \n // set up our subscription\n devel.subscribed = true;\n peer_data.set_subscribers(devel.stream_id, [me.user_id]);\n \n // ensure our setup is accurate\n- assert(stream_data.is_subscribed(\"devel\"));\n+ assert.ok(stream_data.is_subscribed(\"devel\"));\n \n // DO THE UNSUBSCRIBE HERE\n stream_data.unsubscribe_myself(devel);\n- assert(!devel.subscribed);\n- assert(!stream_data.is_subscribed(\"devel\"));\n- assert(!contains_sub(stream_data.subscribed_subs(), devel));\n- assert(contains_sub(stream_data.unsubscribed_subs(), devel));\n+ assert.ok(!devel.subscribed);\n+ assert.ok(!stream_data.is_subscribed(\"devel\"));\n+ assert.ok(!contains_sub(stream_data.subscribed_subs(), devel));\n+ assert.ok(contains_sub(stream_data.unsubscribed_subs(), devel));\n \n // make sure subsequent calls work\n const sub = stream_data.get_sub(\"devel\");\n- assert(!sub.subscribed);\n+ assert.ok(!sub.subscribed);\n });\n \n test(\"subscribers\", () => {\n@@ -96,7 +96,7 @@ test(\"subscribers\", () => {\n people.add_active_user(george);\n \n // verify setup\n- assert(stream_data.is_subscribed(sub.name));\n+ assert.ok(stream_data.is_subscribed(sub.name));\n \n const stream_id = sub.stream_id;\n \n@@ -113,10 +113,10 @@ test(\"subscribers\", () => {\n ]);\n \n peer_data.set_subscribers(stream_id, [me.user_id, fred.user_id, george.user_id]);\n- assert(stream_data.is_user_subscribed(stream_id, me.user_id));\n- assert(stream_data.is_user_subscribed(stream_id, fred.user_id));\n- assert(stream_data.is_user_subscribed(stream_id, george.user_id));\n- assert(!stream_data.is_user_subscribed(stream_id, gail.user_id));\n+ assert.ok(stream_data.is_user_subscribed(stream_id, me.user_id));\n+ assert.ok(stream_data.is_user_subscribed(stream_id, fred.user_id));\n+ assert.ok(stream_data.is_user_subscribed(stream_id, george.user_id));\n+ assert.ok(!stream_data.is_user_subscribed(stream_id, gail.user_id));\n \n assert.deepEqual(potential_subscriber_ids(), [gail.user_id]);\n \n@@ -128,11 +128,11 @@ test(\"subscribers\", () => {\n user_id: 104,\n };\n people.add_active_user(brutus);\n- assert(!stream_data.is_user_subscribed(stream_id, brutus.user_id));\n+ assert.ok(!stream_data.is_user_subscribed(stream_id, brutus.user_id));\n \n // add\n peer_data.add_subscriber(stream_id, brutus.user_id);\n- assert(stream_data.is_user_subscribed(stream_id, brutus.user_id));\n+ assert.ok(stream_data.is_user_subscribed(stream_id, brutus.user_id));\n assert.equal(peer_data.get_subscriber_count(stream_id), 1);\n const sub_email = \"Rome:214125235@zulipdev.com:9991\";\n stream_data.update_stream_email_address(sub, sub_email);\n@@ -140,13 +140,13 @@ test(\"subscribers\", () => {\n \n // verify that adding an already-added subscriber is a noop\n peer_data.add_subscriber(stream_id, brutus.user_id);\n- assert(stream_data.is_user_subscribed(stream_id, brutus.user_id));\n+ assert.ok(stream_data.is_user_subscribed(stream_id, brutus.user_id));\n assert.equal(peer_data.get_subscriber_count(stream_id), 1);\n \n // remove\n let ok = peer_data.remove_subscriber(stream_id, brutus.user_id);\n- assert(ok);\n- assert(!stream_data.is_user_subscribed(stream_id, brutus.user_id));\n+ assert.ok(ok);\n+ assert.ok(!stream_data.is_user_subscribed(stream_id, brutus.user_id));\n assert.equal(peer_data.get_subscriber_count(stream_id), 0);\n \n // verify that checking subscription with undefined user id\n@@ -160,14 +160,14 @@ test(\"subscribers\", () => {\n blueslip.expect(\"warn\", \"We called get_user_set for an untracked stream: \" + bad_stream_id);\n blueslip.expect(\"warn\", \"We tried to remove invalid subscriber: 104\");\n ok = peer_data.remove_subscriber(bad_stream_id, brutus.user_id);\n- assert(!ok);\n+ assert.ok(!ok);\n blueslip.reset();\n \n // verify that removing an already-removed subscriber is a noop\n blueslip.expect(\"warn\", \"We tried to remove invalid subscriber: 104\");\n ok = peer_data.remove_subscriber(stream_id, brutus.user_id);\n- assert(!ok);\n- assert(!stream_data.is_user_subscribed(stream_id, brutus.user_id));\n+ assert.ok(!ok);\n+ assert.ok(!stream_data.is_user_subscribed(stream_id, brutus.user_id));\n assert.equal(peer_data.get_subscriber_count(stream_id), 0);\n blueslip.reset();\n \n@@ -176,7 +176,7 @@ test(\"subscribers\", () => {\n stream_data.add_sub(sub);\n peer_data.add_subscriber(stream_id, brutus.user_id);\n sub.subscribed = true;\n- assert(stream_data.is_user_subscribed(stream_id, brutus.user_id));\n+ assert.ok(stream_data.is_user_subscribed(stream_id, brutus.user_id));\n \n // Verify that we noop and don't crash when unsubscribed.\n sub.subscribed = false;\ndiff --git a/frontend_tests/node_tests/people.js b/frontend_tests/node_tests/people.js\n--- a/frontend_tests/node_tests/people.js\n+++ b/frontend_tests/node_tests/people.js\n@@ -279,19 +279,19 @@ test_people(\"basics\", () => {\n const full_name = \"Isaac Newton\";\n const email = \"isaac@example.com\";\n \n- assert(!people.is_known_user_id(32));\n- assert(!people.is_known_user(isaac));\n- assert(!people.is_known_user(undefined));\n- assert(!people.is_valid_full_name_and_user_id(full_name, 32));\n+ assert.ok(!people.is_known_user_id(32));\n+ assert.ok(!people.is_known_user(isaac));\n+ assert.ok(!people.is_known_user(undefined));\n+ assert.ok(!people.is_valid_full_name_and_user_id(full_name, 32));\n assert.equal(people.get_user_id_from_name(full_name), undefined);\n \n people.add_active_user(isaac);\n \n assert.equal(people.get_actual_name_from_user_id(32), full_name);\n \n- assert(people.is_valid_full_name_and_user_id(full_name, 32));\n- assert(people.is_known_user_id(32));\n- assert(people.is_known_user(isaac));\n+ assert.ok(people.is_valid_full_name_and_user_id(full_name, 32));\n+ assert.ok(people.is_known_user_id(32));\n+ assert.ok(people.is_known_user(isaac));\n assert.equal(people.get_active_human_count(), 2);\n \n assert.equal(people.get_user_id_from_name(full_name), 32);\n@@ -305,7 +305,7 @@ test_people(\"basics\", () => {\n const active_user_ids = people.get_active_user_ids().sort();\n assert.deepEqual(active_user_ids, [me.user_id, isaac.user_id]);\n assert.equal(people.is_active_user_for_popover(isaac.user_id), true);\n- assert(people.is_valid_email_for_compose(isaac.email));\n+ assert.ok(people.is_valid_email_for_compose(isaac.email));\n \n // Now deactivate isaac\n people.deactivate(isaac);\n@@ -606,40 +606,40 @@ test_people(\"filtered_users\", () => {\n const users = people.get_people_for_stream_create();\n let filtered_people = people.filter_people_by_search_terms(users, [search_term]);\n assert.equal(filtered_people.size, 2);\n- assert(filtered_people.has(ashton.user_id));\n- assert(filtered_people.has(maria.user_id));\n- assert(!filtered_people.has(charles.user_id));\n+ assert.ok(filtered_people.has(ashton.user_id));\n+ assert.ok(filtered_people.has(maria.user_id));\n+ assert.ok(!filtered_people.has(charles.user_id));\n \n filtered_people = people.filter_people_by_search_terms(users, []);\n assert.equal(filtered_people.size, 0);\n \n filtered_people = people.filter_people_by_search_terms(users, [\"ltorv\"]);\n assert.equal(filtered_people.size, 1);\n- assert(filtered_people.has(linus.user_id));\n+ assert.ok(filtered_people.has(linus.user_id));\n \n filtered_people = people.filter_people_by_search_terms(users, [\"ch di\", \"maria\"]);\n assert.equal(filtered_people.size, 2);\n- assert(filtered_people.has(charles.user_id));\n- assert(filtered_people.has(maria.user_id));\n+ assert.ok(filtered_people.has(charles.user_id));\n+ assert.ok(filtered_people.has(maria.user_id));\n \n // Test filtering of names with diacritics\n // This should match Nöôáàh by ignoring diacritics, and also match Nooaah\n filtered_people = people.filter_people_by_search_terms(users, [\"noOa\"]);\n assert.equal(filtered_people.size, 2);\n- assert(filtered_people.has(noah.user_id));\n- assert(filtered_people.has(plain_noah.user_id));\n+ assert.ok(filtered_people.has(noah.user_id));\n+ assert.ok(filtered_people.has(plain_noah.user_id));\n \n // This should match ëmerson, but not emerson\n filtered_people = people.filter_people_by_search_terms(users, [\"ëm\"]);\n assert.equal(filtered_people.size, 1);\n- assert(filtered_people.has(noah.user_id));\n+ assert.ok(filtered_people.has(noah.user_id));\n \n // Test filtering with undefined user\n users.push(unknown_user);\n \n filtered_people = people.filter_people_by_search_terms(users, [\"ltorv\"]);\n assert.equal(filtered_people.size, 1);\n- assert(filtered_people.has(linus.user_id));\n+ assert.ok(filtered_people.has(linus.user_id));\n });\n \n people.init();\n@@ -821,7 +821,7 @@ test_people(\"extract_people_from_message\", (override) => {\n sender_id: maria.user_id,\n sender_email: maria.email,\n };\n- assert(!people.is_known_user_id(maria.user_id));\n+ assert.ok(!people.is_known_user_id(maria.user_id));\n \n let reported;\n override(people, \"report_late_add\", (user_id, email) => {\n@@ -831,8 +831,8 @@ test_people(\"extract_people_from_message\", (override) => {\n });\n \n people.extract_people_from_message(message);\n- assert(people.is_known_user_id(maria.user_id));\n- assert(reported);\n+ assert.ok(people.is_known_user_id(maria.user_id));\n+ assert.ok(reported);\n \n // Get line coverage\n people.__Rewire__(\"report_late_add\", () => {\n@@ -947,7 +947,7 @@ test_people(\"updates\", () => {\n \n // Do sanity checks on our data.\n assert.equal(people.get_by_email(old_email).user_id, user_id);\n- assert(!people.is_cross_realm_email(old_email));\n+ assert.ok(!people.is_cross_realm_email(old_email));\n \n assert.equal(people.get_by_email(new_email), undefined);\n \n@@ -956,7 +956,7 @@ test_people(\"updates\", () => {\n \n // Now look up using the new email.\n assert.equal(people.get_by_email(new_email).user_id, user_id);\n- assert(!people.is_cross_realm_email(new_email));\n+ assert.ok(!people.is_cross_realm_email(new_email));\n \n const all_people = get_all_persons();\n assert.equal(all_people.length, 2);\n@@ -993,7 +993,7 @@ test_people(\"track_duplicate_full_names\", () => {\n people.add_active_user(maria);\n people.add_active_user(stephen1);\n \n- assert(!people.is_duplicate_full_name(\"Stephen King\"));\n+ assert.ok(!people.is_duplicate_full_name(\"Stephen King\"));\n assert.equal(people.get_user_id_from_name(\"Stephen King\"), stephen1.user_id);\n \n // Now duplicate the Stephen King name.\n@@ -1004,16 +1004,16 @@ test_people(\"track_duplicate_full_names\", () => {\n // other codepaths for disambiguation.\n assert.equal(people.get_user_id_from_name(\"Stephen King\"), undefined);\n \n- assert(people.is_duplicate_full_name(\"Stephen King\"));\n- assert(!people.is_duplicate_full_name(\"Maria Athens\"));\n- assert(!people.is_duplicate_full_name(\"Some Random Name\"));\n+ assert.ok(people.is_duplicate_full_name(\"Stephen King\"));\n+ assert.ok(!people.is_duplicate_full_name(\"Maria Athens\"));\n+ assert.ok(!people.is_duplicate_full_name(\"Some Random Name\"));\n \n // It is somewhat janky that we have to clone\n // stephen2 here. It would be nice if people.set_full_name\n // just took a user_id as the first parameter.\n people.set_full_name({...stephen2}, \"Stephen King JP\");\n- assert(!people.is_duplicate_full_name(\"Stephen King\"));\n- assert(!people.is_duplicate_full_name(\"Stephen King JP\"));\n+ assert.ok(!people.is_duplicate_full_name(\"Stephen King\"));\n+ assert.ok(!people.is_duplicate_full_name(\"Stephen King JP\"));\n });\n \n test_people(\"get_mention_syntax\", () => {\n@@ -1021,7 +1021,7 @@ test_people(\"get_mention_syntax\", () => {\n people.add_active_user(stephen2);\n people.add_active_user(maria);\n \n- assert(people.is_duplicate_full_name(\"Stephen King\"));\n+ assert.ok(people.is_duplicate_full_name(\"Stephen King\"));\n \n blueslip.expect(\"warn\", \"get_mention_syntax called without user_id.\");\n assert.equal(people.get_mention_syntax(\"Stephen King\"), \"@**Stephen King**\");\n@@ -1074,14 +1074,14 @@ test_people(\"initialize\", () => {\n people.initialize(my_user_id, params);\n \n assert.equal(people.is_active_user_for_popover(17), true);\n- assert(people.is_cross_realm_email(\"bot@example.com\"));\n- assert(people.is_valid_email_for_compose(\"bot@example.com\"));\n- assert(people.is_valid_email_for_compose(\"alice@example.com\"));\n- assert(!people.is_valid_email_for_compose(\"retiree@example.com\"));\n- assert(!people.is_valid_email_for_compose(\"totally-bogus-username@example.com\"));\n- assert(people.is_valid_bulk_emails_for_compose([\"bot@example.com\", \"alice@example.com\"]));\n- assert(!people.is_valid_bulk_emails_for_compose([\"not@valid.com\", \"alice@example.com\"]));\n- assert(people.is_my_user_id(42));\n+ assert.ok(people.is_cross_realm_email(\"bot@example.com\"));\n+ assert.ok(people.is_valid_email_for_compose(\"bot@example.com\"));\n+ assert.ok(people.is_valid_email_for_compose(\"alice@example.com\"));\n+ assert.ok(!people.is_valid_email_for_compose(\"retiree@example.com\"));\n+ assert.ok(!people.is_valid_email_for_compose(\"totally-bogus-username@example.com\"));\n+ assert.ok(people.is_valid_bulk_emails_for_compose([\"bot@example.com\", \"alice@example.com\"]));\n+ assert.ok(!people.is_valid_bulk_emails_for_compose([\"not@valid.com\", \"alice@example.com\"]));\n+ assert.ok(people.is_my_user_id(42));\n \n const fetched_retiree = people.get_by_user_id(15);\n assert.equal(fetched_retiree.full_name, \"Retiree\");\n@@ -1149,9 +1149,9 @@ test_people(\"matches_user_settings_search\", () => {\n });\n \n test_people(\"is_valid_full_name_and_user_id\", () => {\n- assert(!people.is_valid_full_name_and_user_id(\"bogus\", 99));\n- assert(!people.is_valid_full_name_and_user_id(me.full_name, 99));\n- assert(people.is_valid_full_name_and_user_id(me.full_name, me.user_id));\n+ assert.ok(!people.is_valid_full_name_and_user_id(\"bogus\", 99));\n+ assert.ok(!people.is_valid_full_name_and_user_id(me.full_name, 99));\n+ assert.ok(people.is_valid_full_name_and_user_id(me.full_name, me.user_id));\n });\n \n test_people(\"emails_strings_to_user_ids_array\", () => {\ndiff --git a/frontend_tests/node_tests/people_errors.js b/frontend_tests/node_tests/people_errors.js\n--- a/frontend_tests/node_tests/people_errors.js\n+++ b/frontend_tests/node_tests/people_errors.js\n@@ -102,7 +102,7 @@ run_test(\"blueslip\", (override) => {\n };\n blueslip.expect(\"error\", \"Unknown user id in message: 42\");\n const reply_to = people.pm_reply_to(message);\n- assert(reply_to.includes(\"?\"));\n+ assert.ok(reply_to.includes(\"?\"));\n \n override(people, \"pm_with_user_ids\", () => [42]);\n override(people, \"get_by_user_id\", () => {});\ndiff --git a/frontend_tests/node_tests/pill_typeahead.js b/frontend_tests/node_tests/pill_typeahead.js\n--- a/frontend_tests/node_tests/pill_typeahead.js\n+++ b/frontend_tests/node_tests/pill_typeahead.js\n@@ -17,9 +17,9 @@ run_test(\"set_up\", () => {\n const fake_input = $.create(\".input\");\n fake_input.typeahead = (config) => {\n assert.equal(config.items, 5);\n- assert(config.fixed);\n- assert(config.dropup);\n- assert(config.stopAdvance);\n+ assert.ok(config.fixed);\n+ assert.ok(config.dropup);\n+ assert.ok(config.stopAdvance);\n \n // Working of functions that are part of config\n // is tested separately based on the widgets that\n@@ -47,31 +47,31 @@ run_test(\"set_up\", () => {\n \n // call set_up with only user type in opts.\n pill_typeahead.set_up(fake_input, pill_widget, {user: true});\n- assert(input_pill_typeahead_called);\n+ assert.ok(input_pill_typeahead_called);\n \n // call set_up with only stream type in opts.\n input_pill_typeahead_called = false;\n pill_typeahead.set_up(fake_input, pill_widget, {stream: true});\n- assert(input_pill_typeahead_called);\n+ assert.ok(input_pill_typeahead_called);\n \n // call set_up with only user_group type in opts.\n input_pill_typeahead_called = false;\n pill_typeahead.set_up(fake_input, pill_widget, {user_group: true});\n- assert(input_pill_typeahead_called);\n+ assert.ok(input_pill_typeahead_called);\n \n // call set_up with combination two types in opts.\n input_pill_typeahead_called = false;\n pill_typeahead.set_up(fake_input, pill_widget, {user_group: true, stream: true});\n- assert(input_pill_typeahead_called);\n+ assert.ok(input_pill_typeahead_called);\n \n // call set_up with all three types in opts.\n input_pill_typeahead_called = false;\n pill_typeahead.set_up(fake_input, pill_widget, {user_group: true, stream: true, user: true});\n- assert(input_pill_typeahead_called);\n+ assert.ok(input_pill_typeahead_called);\n \n // call set_up without specifying type in opts.\n input_pill_typeahead_called = false;\n blueslip.expect(\"error\", \"Unspecified possible item types\");\n pill_typeahead.set_up(fake_input, pill_widget, {});\n- assert(!input_pill_typeahead_called);\n+ assert.ok(!input_pill_typeahead_called);\n });\ndiff --git a/frontend_tests/node_tests/pm_list.js b/frontend_tests/node_tests/pm_list.js\n--- a/frontend_tests/node_tests/pm_list.js\n+++ b/frontend_tests/node_tests/pm_list.js\n@@ -67,7 +67,7 @@ test(\"close\", () => {\n collapsed = true;\n };\n pm_list.close();\n- assert(collapsed);\n+ assert.ok(collapsed);\n });\n \n test(\"build_private_messages_list\", (override) => {\n@@ -167,7 +167,7 @@ test(\"update_dom_with_unread_counts\", (override) => {\n \n pm_list.update_dom_with_unread_counts(counts);\n assert.equal(total_count.text(), \"10\");\n- assert(total_count.visible());\n+ assert.ok(total_count.visible());\n \n counts = {\n private_message_count: 0,\n@@ -175,7 +175,7 @@ test(\"update_dom_with_unread_counts\", (override) => {\n \n pm_list.update_dom_with_unread_counts(counts);\n assert.equal(total_count.text(), \"\");\n- assert(!total_count.visible());\n+ assert.ok(!total_count.visible());\n });\n \n test(\"get_active_user_ids_string\", (override) => {\n@@ -230,11 +230,11 @@ test(\"expand\", (override) => {\n html_updated = true;\n });\n \n- assert(!$(\".top_left_private_messages\").hasClass(\"active-filter\"));\n+ assert.ok(!$(\".top_left_private_messages\").hasClass(\"active-filter\"));\n \n pm_list.expand();\n- assert(html_updated);\n- assert($(\".top_left_private_messages\").hasClass(\"active-filter\"));\n+ assert.ok(html_updated);\n+ assert.ok($(\".top_left_private_messages\").hasClass(\"active-filter\"));\n });\n \n test(\"update_private_messages\", (override) => {\n@@ -260,8 +260,8 @@ test(\"update_private_messages\", (override) => {\n \n pm_list.expand();\n pm_list.update_private_messages();\n- assert(html_updated);\n- assert(container_found);\n+ assert.ok(html_updated);\n+ assert.ok(container_found);\n });\n \n test(\"ensure coverage\", (override) => {\ndiff --git a/frontend_tests/node_tests/poll_widget.js b/frontend_tests/node_tests/poll_widget.js\n--- a/frontend_tests/node_tests/poll_widget.js\n+++ b/frontend_tests/node_tests/poll_widget.js\n@@ -233,14 +233,14 @@ run_test(\"activate another person poll\", () => {\n \n poll_widget.activate(opts);\n \n- assert(poll_option_container.visible());\n- assert(poll_question_header.visible());\n+ assert.ok(poll_option_container.visible());\n+ assert.ok(poll_question_header.visible());\n \n- assert(!poll_question_container.visible());\n- assert(!poll_question_submit.visible());\n- assert(!poll_edit_question.visible());\n- assert(!poll_please_wait.visible());\n- assert(!poll_author_help.visible());\n+ assert.ok(!poll_question_container.visible());\n+ assert.ok(!poll_question_submit.visible());\n+ assert.ok(!poll_edit_question.visible());\n+ assert.ok(!poll_please_wait.visible());\n+ assert.ok(!poll_author_help.visible());\n \n assert.equal(widget_elem.html(), \"widgets/poll_widget\");\n assert.equal(widget_option_container.html(), \"widgets/poll_widget_results\");\n@@ -352,18 +352,18 @@ run_test(\"activate own poll\", () => {\n set_widget_find_result(\"button.poll-question-remove\");\n \n function assert_visibility() {\n- assert(poll_option_container.visible());\n- assert(poll_question_header.visible());\n- assert(!poll_question_container.visible());\n- assert(poll_edit_question.visible());\n- assert(!poll_please_wait.visible());\n- assert(!poll_author_help.visible());\n+ assert.ok(poll_option_container.visible());\n+ assert.ok(poll_question_header.visible());\n+ assert.ok(!poll_question_container.visible());\n+ assert.ok(poll_edit_question.visible());\n+ assert.ok(!poll_please_wait.visible());\n+ assert.ok(!poll_author_help.visible());\n }\n \n poll_widget.activate(opts);\n \n assert_visibility();\n- assert(!poll_question_submit.visible());\n+ assert.ok(!poll_question_submit.visible());\n \n assert.equal(widget_elem.html(), \"widgets/poll_widget\");\n assert.equal(widget_option_container.html(), \"widgets/poll_widget_results\");\n@@ -377,7 +377,7 @@ run_test(\"activate own poll\", () => {\n assert.deepEqual(out_data, {type: \"question\", question: \"Is it new?\"});\n \n assert_visibility();\n- assert(poll_question_submit.visible());\n+ assert.ok(poll_question_submit.visible());\n \n poll_option_input.val(\"\");\n out_data = undefined;\ndiff --git a/frontend_tests/node_tests/presence.js b/frontend_tests/node_tests/presence.js\n--- a/frontend_tests/node_tests/presence.js\n+++ b/frontend_tests/node_tests/presence.js\n@@ -210,7 +210,7 @@ test(\"set_presence_info\", () => {\n assert.equal(presence.get_status(zoe.user_id), \"offline\");\n assert.equal(presence.last_active_date(zoe.user_id), undefined);\n \n- assert(!presence.presence_info.has(bot.user_id));\n+ assert.ok(!presence.presence_info.has(bot.user_id));\n assert.equal(presence.get_status(bot.user_id), \"offline\");\n \n assert.deepEqual(presence.presence_info.get(john.user_id), {\n@@ -279,8 +279,8 @@ test(\"big realms\", () => {\n const get_active_human_count = people.get_active_human_count;\n people.get_active_human_count = () => 1000;\n presence.set_info(presences, now);\n- assert(presence.presence_info.has(sally.user_id));\n- assert(!presence.presence_info.has(zoe.user_id));\n+ assert.ok(presence.presence_info.has(sally.user_id));\n+ assert.ok(!presence.presence_info.has(zoe.user_id));\n people.get_active_human_count = get_active_human_count;\n });\n \ndiff --git a/frontend_tests/node_tests/reactions.js b/frontend_tests/node_tests/reactions.js\n--- a/frontend_tests/node_tests/reactions.js\n+++ b/frontend_tests/node_tests/reactions.js\n@@ -134,8 +134,8 @@ test(\"open_reactions_popover (sent by me)\", () => {\n assert.equal(target, \"action-stub\");\n };\n \n- assert(reactions.open_reactions_popover());\n- assert(called);\n+ assert.ok(reactions.open_reactions_popover());\n+ assert.ok(called);\n });\n \n test(\"open_reactions_popover (not sent by me)\", () => {\n@@ -149,16 +149,16 @@ test(\"open_reactions_popover (not sent by me)\", () => {\n assert.equal(target, \"reaction-stub\");\n };\n \n- assert(reactions.open_reactions_popover());\n- assert(called);\n+ assert.ok(reactions.open_reactions_popover());\n+ assert.ok(called);\n });\n \n test(\"basics\", () => {\n const message = {...sample_message};\n \n const result = reactions.get_message_reactions(message);\n- assert(reactions.current_user_has_reacted_to_emoji(message, \"unicode_emoji,1f642\"));\n- assert(!reactions.current_user_has_reacted_to_emoji(message, \"bogus\"));\n+ assert.ok(reactions.current_user_has_reacted_to_emoji(message, \"unicode_emoji,1f642\"));\n+ assert.ok(!reactions.current_user_has_reacted_to_emoji(message, \"bogus\"));\n \n result.sort((a, b) => a.count - b.count);\n \n@@ -616,8 +616,8 @@ test(\"view.insert_new_reaction (me w/unicode emoji)\", (override) => {\n };\n \n reactions.view.insert_new_reaction(opts);\n- assert(template_called);\n- assert(insert_called);\n+ assert.ok(template_called);\n+ assert.ok(insert_called);\n });\n \n test(\"view.insert_new_reaction (them w/zulip emoji)\", (override) => {\n@@ -669,8 +669,8 @@ test(\"view.insert_new_reaction (them w/zulip emoji)\", (override) => {\n };\n \n reactions.view.insert_new_reaction(opts);\n- assert(template_called);\n- assert(insert_called);\n+ assert.ok(template_called);\n+ assert.ok(insert_called);\n });\n \n test(\"view.update_existing_reaction (me)\", (override) => {\n@@ -698,7 +698,7 @@ test(\"view.update_existing_reaction (me)\", (override) => {\n \n reactions.view.update_existing_reaction(opts);\n \n- assert(our_reaction.hasClass(\"reacted\"));\n+ assert.ok(our_reaction.hasClass(\"reacted\"));\n assert.equal(\n our_reaction.attr(\"aria-label\"),\n \"translated: You (click to remove) and Bob van Roberts reacted with :8ball:\",\n@@ -730,7 +730,7 @@ test(\"view.update_existing_reaction (them)\", (override) => {\n \n reactions.view.update_existing_reaction(opts);\n \n- assert(!our_reaction.hasClass(\"reacted\"));\n+ assert.ok(!our_reaction.hasClass(\"reacted\"));\n assert.equal(\n our_reaction.attr(\"aria-label\"),\n \"translated: You (click to remove), Bob van Roberts, Cali and Alexus reacted with :8ball:\",\n@@ -763,7 +763,7 @@ test(\"view.remove_reaction (me)\", (override) => {\n \n reactions.view.remove_reaction(opts);\n \n- assert(!our_reaction.hasClass(\"reacted\"));\n+ assert.ok(!our_reaction.hasClass(\"reacted\"));\n assert.equal(\n our_reaction.attr(\"aria-label\"),\n \"translated: Bob van Roberts and Cali reacted with :8ball:\",\n@@ -797,7 +797,7 @@ test(\"view.remove_reaction (them)\", (override) => {\n our_reaction.addClass(\"reacted\");\n reactions.view.remove_reaction(opts);\n \n- assert(our_reaction.hasClass(\"reacted\"));\n+ assert.ok(our_reaction.hasClass(\"reacted\"));\n assert.equal(\n our_reaction.attr(\"aria-label\"),\n \"translated: You (click to remove) reacted with :8ball:\",\n@@ -827,7 +827,7 @@ test(\"view.remove_reaction (last person)\", (override) => {\n removed = true;\n };\n reactions.view.remove_reaction(opts);\n- assert(removed);\n+ assert.ok(removed);\n });\n \n test(\"error_handling\", (override) => {\ndiff --git a/frontend_tests/node_tests/reload_state.js b/frontend_tests/node_tests/reload_state.js\n--- a/frontend_tests/node_tests/reload_state.js\n+++ b/frontend_tests/node_tests/reload_state.js\n@@ -15,13 +15,13 @@ function test(label, f) {\n }\n \n test(\"set_state_to_pending\", () => {\n- assert(!reload_state.is_pending());\n+ assert.ok(!reload_state.is_pending());\n reload_state.set_state_to_pending();\n- assert(reload_state.is_pending());\n+ assert.ok(reload_state.is_pending());\n });\n \n test(\"set_state_to_in_progress\", () => {\n- assert(!reload_state.is_in_progress());\n+ assert.ok(!reload_state.is_in_progress());\n reload_state.set_state_to_in_progress();\n- assert(reload_state.is_in_progress());\n+ assert.ok(reload_state.is_in_progress());\n });\ndiff --git a/frontend_tests/node_tests/rendered_markdown.js b/frontend_tests/node_tests/rendered_markdown.js\n--- a/frontend_tests/node_tests/rendered_markdown.js\n+++ b/frontend_tests/node_tests/rendered_markdown.js\n@@ -126,14 +126,14 @@ run_test(\"user-mention\", () => {\n $content.set_find_results(\".user-mention\", $array([$iago, $cordelia]));\n \n // Initial asserts\n- assert(!$iago.hasClass(\"user-mention-me\"));\n+ assert.ok(!$iago.hasClass(\"user-mention-me\"));\n assert.equal($iago.text(), \"never-been-set\");\n assert.equal($cordelia.text(), \"never-been-set\");\n \n rm.update_elements($content);\n \n // Final asserts\n- assert($iago.hasClass(\"user-mention-me\"));\n+ assert.ok($iago.hasClass(\"user-mention-me\"));\n assert.equal($iago.text(), `@${iago.full_name}`);\n assert.equal($cordelia.text(), `@${cordelia.full_name}`);\n });\n@@ -145,9 +145,9 @@ run_test(\"user-mention (wildcard)\", () => {\n $mention.attr(\"data-user-id\", \"*\");\n $content.set_find_results(\".user-mention\", $array([$mention]));\n \n- assert(!$mention.hasClass(\"user-mention-me\"));\n+ assert.ok(!$mention.hasClass(\"user-mention-me\"));\n rm.update_elements($content);\n- assert($mention.hasClass(\"user-mention-me\"));\n+ assert.ok($mention.hasClass(\"user-mention-me\"));\n });\n \n run_test(\"user-mention (email)\", () => {\n@@ -159,7 +159,7 @@ run_test(\"user-mention (email)\", () => {\n $content.set_find_results(\".user-mention\", $array([$mention]));\n \n rm.update_elements($content);\n- assert(!$mention.hasClass(\"user-mention-me\"));\n+ assert.ok(!$mention.hasClass(\"user-mention-me\"));\n assert.equal($mention.text(), \"@Cordelia Lear\");\n });\n \n@@ -169,7 +169,7 @@ run_test(\"user-mention (missing)\", () => {\n $content.set_find_results(\".user-mention\", $array([$mention]));\n \n rm.update_elements($content);\n- assert(!$mention.hasClass(\"user-mention-me\"));\n+ assert.ok(!$mention.hasClass(\"user-mention-me\"));\n });\n \n run_test(\"user-group-mention\", () => {\n@@ -184,14 +184,14 @@ run_test(\"user-group-mention\", () => {\n $content.set_find_results(\".user-group-mention\", $array([$group_me, $group_other]));\n \n // Initial asserts\n- assert(!$group_me.hasClass(\"user-mention-me\"));\n+ assert.ok(!$group_me.hasClass(\"user-mention-me\"));\n assert.equal($group_me.text(), \"never-been-set\");\n assert.equal($group_other.text(), \"never-been-set\");\n \n rm.update_elements($content);\n \n // Final asserts\n- assert($group_me.hasClass(\"user-mention-me\"));\n+ assert.ok($group_me.hasClass(\"user-mention-me\"));\n assert.equal($group_me.text(), `@${group_me.name}`);\n assert.equal($group_other.text(), `@${group_other.name}`);\n });\n@@ -204,7 +204,7 @@ run_test(\"user-group-mention (error)\", () => {\n \n rm.update_elements($content);\n \n- assert(!$group.hasClass(\"user-mention-me\"));\n+ assert.ok(!$group.hasClass(\"user-mention-me\"));\n });\n \n run_test(\"user-group-mention (missing)\", () => {\n@@ -214,7 +214,7 @@ run_test(\"user-group-mention (missing)\", () => {\n \n rm.update_elements($content);\n \n- assert(!$group.hasClass(\"user-mention-me\"));\n+ assert.ok(!$group.hasClass(\"user-mention-me\"));\n });\n \n run_test(\"stream-links\", () => {\n@@ -328,7 +328,7 @@ run_test(\"emoji\", () => {\n \n rm.update_elements($content);\n \n- assert(called);\n+ assert.ok(called);\n \n // Set page parameters back so that test run order is independent\n page_params.emojiset = \"apple\";\n@@ -476,7 +476,7 @@ run_test(\"rtl\", () => {\n \n $content.text(\"مرحبا\");\n \n- assert(!$content.hasClass(\"rtl\"));\n+ assert.ok(!$content.hasClass(\"rtl\"));\n rm.update_elements($content);\n- assert($content.hasClass(\"rtl\"));\n+ assert.ok($content.hasClass(\"rtl\"));\n });\ndiff --git a/frontend_tests/node_tests/rtl.js b/frontend_tests/node_tests/rtl.js\n--- a/frontend_tests/node_tests/rtl.js\n+++ b/frontend_tests/node_tests/rtl.js\n@@ -130,19 +130,19 @@ run_test(\"get_direction\", () => {\n \n run_test(\"set_rtl_class_for_textarea rtl\", () => {\n const textarea = $.create(\"some-textarea\");\n- assert(!textarea.hasClass(\"rtl\"));\n+ assert.ok(!textarea.hasClass(\"rtl\"));\n const text = \"```quote\\nمرحبا\";\n textarea.val(text);\n rtl.set_rtl_class_for_textarea(textarea);\n- assert(textarea.hasClass(\"rtl\"));\n+ assert.ok(textarea.hasClass(\"rtl\"));\n });\n \n run_test(\"set_rtl_class_for_textarea ltr\", () => {\n const textarea = $.create(\"some-textarea\");\n textarea.addClass(\"rtl\");\n- assert(textarea.hasClass(\"rtl\"));\n+ assert.ok(textarea.hasClass(\"rtl\"));\n const text = \"```quote\\nEnglish text\";\n textarea.val(text);\n rtl.set_rtl_class_for_textarea(textarea);\n- assert(!textarea.hasClass(\"rtl\"));\n+ assert.ok(!textarea.hasClass(\"rtl\"));\n });\ndiff --git a/frontend_tests/node_tests/search.js b/frontend_tests/node_tests/search.js\n--- a/frontend_tests/node_tests/search.js\n+++ b/frontend_tests/node_tests/search.js\n@@ -60,28 +60,28 @@ test(\"update_button_visibility\", () => {\n narrow_state.active = () => false;\n search_button.prop(\"disabled\", true);\n search.update_button_visibility();\n- assert(search_button.prop(\"disabled\"));\n+ assert.ok(search_button.prop(\"disabled\"));\n \n search_query.is = () => true;\n search_query.val(\"\");\n narrow_state.active = () => false;\n search_button.prop(\"disabled\", true);\n search.update_button_visibility();\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(!search_button.prop(\"disabled\"));\n \n search_query.is = () => false;\n search_query.val(\"Test search term\");\n narrow_state.active = () => false;\n search_button.prop(\"disabled\", true);\n search.update_button_visibility();\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(!search_button.prop(\"disabled\"));\n \n search_query.is = () => false;\n search_query.val(\"\");\n narrow_state.active = () => true;\n search_button.prop(\"disabled\", true);\n search.update_button_visibility();\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(!search_button.prop(\"disabled\"));\n });\n \n test(\"initialize\", () => {\n@@ -177,8 +177,8 @@ test(\"initialize\", () => {\n _setup(\"ver\");\n \n assert.equal(opts.updater(\"ver\"), \"ver\");\n- assert(!is_blurred);\n- assert(is_append_search_string_called);\n+ assert.ok(!is_blurred);\n+ assert.ok(is_append_search_string_called);\n \n operators = [\n {\n@@ -190,15 +190,15 @@ test(\"initialize\", () => {\n _setup(\"stream:Verona\");\n \n assert.equal(opts.updater(\"stream:Verona\"), \"stream:Verona\");\n- assert(!is_blurred);\n- assert(is_append_search_string_called);\n+ assert.ok(!is_blurred);\n+ assert.ok(is_append_search_string_called);\n \n search.__Rewire__(\"is_using_input_method\", true);\n _setup(\"stream:Verona\");\n \n assert.equal(opts.updater(\"stream:Verona\"), \"stream:Verona\");\n- assert(!is_blurred);\n- assert(is_append_search_string_called);\n+ assert.ok(!is_blurred);\n+ assert.ok(is_append_search_string_called);\n \n search_query_box.off(\"blur\");\n }\n@@ -225,7 +225,7 @@ test(\"initialize\", () => {\n \n search.__Rewire__(\"is_using_input_method\", false);\n searchbox_form.trigger(\"compositionend\");\n- assert(search.is_using_input_method);\n+ assert.ok(search.is_using_input_method);\n \n const keydown = searchbox_form.get_on_handler(\"keydown\");\n let default_prevented = false;\n@@ -238,16 +238,16 @@ test(\"initialize\", () => {\n };\n search_query_box.is = () => false;\n assert.equal(keydown(ev), undefined);\n- assert(!default_prevented);\n+ assert.ok(!default_prevented);\n \n ev.key = \"Enter\";\n assert.equal(keydown(ev), undefined);\n- assert(!default_prevented);\n+ assert.ok(!default_prevented);\n \n ev.key = \"Enter\";\n search_query_box.is = () => true;\n assert.equal(keydown(ev), undefined);\n- assert(default_prevented);\n+ assert.ok(default_prevented);\n \n let operators;\n let is_blurred;\n@@ -288,38 +288,38 @@ test(\"initialize\", () => {\n search_query_box.is = () => false;\n searchbox_form.trigger(ev);\n \n- assert(!is_blurred);\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(!is_blurred);\n+ assert.ok(!search_button.prop(\"disabled\"));\n \n ev.key = \"Enter\";\n search_query_box.is = () => false;\n searchbox_form.trigger(ev);\n \n- assert(!is_blurred);\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(!is_blurred);\n+ assert.ok(!search_button.prop(\"disabled\"));\n \n ev.key = \"Enter\";\n search_query_box.is = () => true;\n searchbox_form.trigger(ev);\n- assert(is_blurred);\n+ assert.ok(is_blurred);\n \n _setup(\"ver\");\n search.__Rewire__(\"is_using_input_method\", true);\n searchbox_form.trigger(ev);\n // No change on Enter keyup event when using input tool\n- assert(!is_blurred);\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(!is_blurred);\n+ assert.ok(!search_button.prop(\"disabled\"));\n \n _setup(\"ver\");\n ev.key = \"Enter\";\n search_query_box.is = () => true;\n searchbox_form.trigger(ev);\n- assert(is_blurred);\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(is_blurred);\n+ assert.ok(!search_button.prop(\"disabled\"));\n \n search_button.prop(\"disabled\", true);\n search_query_box.trigger(\"focus\");\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(!search_button.prop(\"disabled\"));\n });\n \n test(\"initiate_search\", () => {\n@@ -353,8 +353,8 @@ test(\"initiate_search\", () => {\n };\n \n search.initiate_search();\n- assert(typeahead_forced_open);\n- assert(is_searchbox_text_selected);\n- assert(is_searchbox_focused);\n+ assert.ok(typeahead_forced_open);\n+ assert.ok(is_searchbox_text_selected);\n+ assert.ok(is_searchbox_focused);\n assert.deepEqual(css_args, {\"box-shadow\": \"inset 0px 0px 0px 2px hsl(204, 20%, 74%)\"});\n });\ndiff --git a/frontend_tests/node_tests/search_legacy.js b/frontend_tests/node_tests/search_legacy.js\n--- a/frontend_tests/node_tests/search_legacy.js\n+++ b/frontend_tests/node_tests/search_legacy.js\n@@ -38,28 +38,28 @@ run_test(\"update_button_visibility\", () => {\n narrow_state.active = () => false;\n search_button.prop(\"disabled\", true);\n search.update_button_visibility();\n- assert(search_button.prop(\"disabled\"));\n+ assert.ok(search_button.prop(\"disabled\"));\n \n search_query.is = () => true;\n search_query.val(\"\");\n narrow_state.active = () => false;\n search_button.prop(\"disabled\", true);\n search.update_button_visibility();\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(!search_button.prop(\"disabled\"));\n \n search_query.is = () => false;\n search_query.val(\"Test search term\");\n narrow_state.active = () => false;\n search_button.prop(\"disabled\", true);\n search.update_button_visibility();\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(!search_button.prop(\"disabled\"));\n \n search_query.is = () => false;\n search_query.val(\"\");\n narrow_state.active = () => true;\n search_button.prop(\"disabled\", true);\n search.update_button_visibility();\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(!search_button.prop(\"disabled\"));\n });\n \n run_test(\"initialize\", () => {\n@@ -142,7 +142,7 @@ run_test(\"initialize\", () => {\n ];\n _setup(\"ver\");\n assert.equal(opts.updater(\"ver\"), \"ver\");\n- assert(is_blurred);\n+ assert.ok(is_blurred);\n \n operators = [\n {\n@@ -153,12 +153,12 @@ run_test(\"initialize\", () => {\n ];\n _setup(\"stream:Verona\");\n assert.equal(opts.updater(\"stream:Verona\"), \"stream:Verona\");\n- assert(is_blurred);\n+ assert.ok(is_blurred);\n \n search.__Rewire__(\"is_using_input_method\", true);\n _setup(\"stream:Verona\");\n assert.equal(opts.updater(\"stream:Verona\"), \"stream:Verona\");\n- assert(!is_blurred);\n+ assert.ok(!is_blurred);\n \n search_query_box.off(\"blur\");\n }\n@@ -168,7 +168,7 @@ run_test(\"initialize\", () => {\n \n search_button.prop(\"disabled\", true);\n search_query_box.trigger(\"focus\");\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(!search_button.prop(\"disabled\"));\n \n search_query_box.val(\"test string\");\n narrow_state.search_string = () => \"ver\";\n@@ -177,7 +177,7 @@ run_test(\"initialize\", () => {\n \n search.__Rewire__(\"is_using_input_method\", false);\n searchbox_form.trigger(\"compositionend\");\n- assert(search.is_using_input_method);\n+ assert.ok(search.is_using_input_method);\n \n const keydown = searchbox_form.get_on_handler(\"keydown\");\n let default_prevented = false;\n@@ -190,16 +190,16 @@ run_test(\"initialize\", () => {\n };\n search_query_box.is = () => false;\n assert.equal(keydown(ev), undefined);\n- assert(!default_prevented);\n+ assert.ok(!default_prevented);\n \n ev.key = \"Enter\";\n assert.equal(keydown(ev), undefined);\n- assert(!default_prevented);\n+ assert.ok(!default_prevented);\n \n ev.key = \"Enter\";\n search_query_box.is = () => true;\n assert.equal(keydown(ev), undefined);\n- assert(default_prevented);\n+ assert.ok(default_prevented);\n \n ev = {\n type: \"keyup\",\n@@ -239,34 +239,34 @@ run_test(\"initialize\", () => {\n search_query_box.is = () => false;\n searchbox_form.trigger(ev);\n \n- assert(!is_blurred);\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(!is_blurred);\n+ assert.ok(!search_button.prop(\"disabled\"));\n \n ev.key = \"Enter\";\n search_query_box.is = () => false;\n searchbox_form.trigger(ev);\n \n- assert(!is_blurred);\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(!is_blurred);\n+ assert.ok(!search_button.prop(\"disabled\"));\n \n ev.key = \"Enter\";\n search_query_box.is = () => true;\n searchbox_form.trigger(ev);\n- assert(is_blurred);\n+ assert.ok(is_blurred);\n \n _setup(\"ver\");\n search.__Rewire__(\"is_using_input_method\", true);\n searchbox_form.trigger(ev);\n // No change on Enter keyup event when using input tool\n- assert(!is_blurred);\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(!is_blurred);\n+ assert.ok(!search_button.prop(\"disabled\"));\n \n _setup(\"ver\");\n ev.key = \"Enter\";\n search_query_box.is = () => true;\n searchbox_form.trigger(ev);\n- assert(is_blurred);\n- assert(!search_button.prop(\"disabled\"));\n+ assert.ok(is_blurred);\n+ assert.ok(!search_button.prop(\"disabled\"));\n });\n \n run_test(\"initiate_search\", () => {\n@@ -294,8 +294,8 @@ run_test(\"initiate_search\", () => {\n };\n \n search.initiate_search();\n- assert(typeahead_forced_open);\n- assert(is_searchbox_text_selected);\n+ assert.ok(typeahead_forced_open);\n+ assert.ok(is_searchbox_text_selected);\n assert.equal($(\"#search_query\").val(), \"ver\");\n \n assert.deepEqual(searchbox_css_args, {\ndiff --git a/frontend_tests/node_tests/search_pill.js b/frontend_tests/node_tests/search_pill.js\n--- a/frontend_tests/node_tests/search_pill.js\n+++ b/frontend_tests/node_tests/search_pill.js\n@@ -51,8 +51,8 @@ run_test(\"append\", () => {\n \n search_pill.append_search_string(is_starred_item.display_value, pill_widget);\n \n- assert(appended);\n- assert(cleared);\n+ assert.ok(appended);\n+ assert.ok(cleared);\n });\n \n run_test(\"get_items\", () => {\n@@ -79,6 +79,6 @@ run_test(\"create_pills\", (override) => {\n });\n \n const pills = search_pill.create_pills({});\n- assert(input_pill_create_called);\n+ assert.ok(input_pill_create_called);\n assert.deepEqual(pills, {dummy: \"dummy\"});\n });\ndiff --git a/frontend_tests/node_tests/search_suggestion.js b/frontend_tests/node_tests/search_suggestion.js\n--- a/frontend_tests/node_tests/search_suggestion.js\n+++ b/frontend_tests/node_tests/search_suggestion.js\n@@ -558,7 +558,7 @@ test(\"sent_by_me_suggestions\", (override) => {\n \n let query = \"\";\n let suggestions = get_suggestions(\"\", query);\n- assert(suggestions.strings.includes(\"sender:myself@zulip.com\"));\n+ assert.ok(suggestions.strings.includes(\"sender:myself@zulip.com\"));\n assert.equal(suggestions.lookup_table.get(\"sender:myself@zulip.com\").description, \"Sent by me\");\n \n query = \"sender\";\ndiff --git a/frontend_tests/node_tests/search_suggestion_legacy.js b/frontend_tests/node_tests/search_suggestion_legacy.js\n--- a/frontend_tests/node_tests/search_suggestion_legacy.js\n+++ b/frontend_tests/node_tests/search_suggestion_legacy.js\n@@ -530,7 +530,7 @@ test(\"sent_by_me_suggestions\", (override) => {\n \n let query = \"\";\n let suggestions = get_suggestions(\"\", query);\n- assert(suggestions.strings.includes(\"sender:myself@zulip.com\"));\n+ assert.ok(suggestions.strings.includes(\"sender:myself@zulip.com\"));\n assert.equal(suggestions.lookup_table.get(\"sender:myself@zulip.com\").description, \"Sent by me\");\n \n query = \"sender\";\ndiff --git a/frontend_tests/node_tests/server_events.js b/frontend_tests/node_tests/server_events.js\n--- a/frontend_tests/node_tests/server_events.js\n+++ b/frontend_tests/node_tests/server_events.js\n@@ -82,7 +82,7 @@ run_test(\"message_event\", (override) => {\n });\n \n server_events._get_events_success([event]);\n- assert(inserted);\n+ assert.ok(inserted);\n });\n \n // Start blueslip tests here\ndiff --git a/frontend_tests/node_tests/settings_bots.js b/frontend_tests/node_tests/settings_bots.js\n--- a/frontend_tests/node_tests/settings_bots.js\n+++ b/frontend_tests/node_tests/settings_bots.js\n@@ -101,23 +101,23 @@ function test_create_bot_type_input_box_toggle(f) {\n \n $(\"#create_bot_type :selected\").val(EMBEDDED_BOT_TYPE);\n f();\n- assert(!create_payload_url.hasClass(\"required\"));\n- assert(!payload_url_inputbox.visible());\n- assert($(\"#select_service_name\").hasClass(\"required\"));\n- assert($(\"#service_name_list\").visible());\n- assert(config_inputbox.visible());\n+ assert.ok(!create_payload_url.hasClass(\"required\"));\n+ assert.ok(!payload_url_inputbox.visible());\n+ assert.ok($(\"#select_service_name\").hasClass(\"required\"));\n+ assert.ok($(\"#service_name_list\").visible());\n+ assert.ok(config_inputbox.visible());\n \n $(\"#create_bot_type :selected\").val(OUTGOING_WEBHOOK_BOT_TYPE);\n f();\n- assert(create_payload_url.hasClass(\"required\"));\n- assert(payload_url_inputbox.visible());\n- assert(!config_inputbox.visible());\n+ assert.ok(create_payload_url.hasClass(\"required\"));\n+ assert.ok(payload_url_inputbox.visible());\n+ assert.ok(!config_inputbox.visible());\n \n $(\"#create_bot_type :selected\").val(GENERIC_BOT_TYPE);\n f();\n- assert(!create_payload_url.hasClass(\"required\"));\n- assert(!payload_url_inputbox.visible());\n- assert(!config_inputbox.visible());\n+ assert.ok(!create_payload_url.hasClass(\"required\"));\n+ assert.ok(!payload_url_inputbox.visible());\n+ assert.ok(!config_inputbox.visible());\n }\n \n test(\"test tab clicks\", (override) => {\n@@ -162,41 +162,41 @@ test(\"test tab clicks\", (override) => {\n };\n \n click_on_tab(tabs.add);\n- assert(tabs.add.hasClass(\"active\"));\n- assert(!tabs.active.hasClass(\"active\"));\n- assert(!tabs.inactive.hasClass(\"active\"));\n+ assert.ok(tabs.add.hasClass(\"active\"));\n+ assert.ok(!tabs.active.hasClass(\"active\"));\n+ assert.ok(!tabs.inactive.hasClass(\"active\"));\n \n- assert(forms.add.visible());\n- assert(!forms.active.visible());\n- assert(!forms.inactive.visible());\n+ assert.ok(forms.add.visible());\n+ assert.ok(!forms.active.visible());\n+ assert.ok(!forms.inactive.visible());\n \n click_on_tab(tabs.active);\n- assert(!tabs.add.hasClass(\"active\"));\n- assert(tabs.active.hasClass(\"active\"));\n- assert(!tabs.inactive.hasClass(\"active\"));\n+ assert.ok(!tabs.add.hasClass(\"active\"));\n+ assert.ok(tabs.active.hasClass(\"active\"));\n+ assert.ok(!tabs.inactive.hasClass(\"active\"));\n \n- assert(!forms.add.visible());\n- assert(forms.active.visible());\n- assert(!forms.inactive.visible());\n+ assert.ok(!forms.add.visible());\n+ assert.ok(forms.active.visible());\n+ assert.ok(!forms.inactive.visible());\n \n click_on_tab(tabs.inactive);\n- assert(!tabs.add.hasClass(\"active\"));\n- assert(!tabs.active.hasClass(\"active\"));\n- assert(tabs.inactive.hasClass(\"active\"));\n+ assert.ok(!tabs.add.hasClass(\"active\"));\n+ assert.ok(!tabs.active.hasClass(\"active\"));\n+ assert.ok(tabs.inactive.hasClass(\"active\"));\n \n- assert(!forms.add.visible());\n- assert(!forms.active.visible());\n- assert(forms.inactive.visible());\n+ assert.ok(!forms.add.visible());\n+ assert.ok(!forms.active.visible());\n+ assert.ok(forms.inactive.visible());\n });\n \n test(\"can_create_new_bots\", () => {\n page_params.is_admin = true;\n- assert(settings_bots.can_create_new_bots());\n+ assert.ok(settings_bots.can_create_new_bots());\n \n page_params.is_admin = false;\n page_params.realm_bot_creation_policy = 1;\n- assert(settings_bots.can_create_new_bots());\n+ assert.ok(settings_bots.can_create_new_bots());\n \n page_params.realm_bot_creation_policy = 3;\n- assert(!settings_bots.can_create_new_bots());\n+ assert.ok(!settings_bots.can_create_new_bots());\n });\ndiff --git a/frontend_tests/node_tests/settings_emoji.js b/frontend_tests/node_tests/settings_emoji.js\n--- a/frontend_tests/node_tests/settings_emoji.js\n+++ b/frontend_tests/node_tests/settings_emoji.js\n@@ -27,5 +27,5 @@ run_test(\"build_emoji_upload_widget\", () => {\n build_widget_stub = true;\n };\n settings_emoji.build_emoji_upload_widget();\n- assert(build_widget_stub);\n+ assert.ok(build_widget_stub);\n });\ndiff --git a/frontend_tests/node_tests/settings_muted_topics.js b/frontend_tests/node_tests/settings_muted_topics.js\n--- a/frontend_tests/node_tests/settings_muted_topics.js\n+++ b/frontend_tests/node_tests/settings_muted_topics.js\n@@ -43,7 +43,7 @@ run_test(\"settings\", (override) => {\n \n settings_muted_topics.set_up();\n assert.equal(settings_muted_topics.loaded, true);\n- assert(populate_list_called);\n+ assert.ok(populate_list_called);\n \n const topic_click_handler = $(\"body\").get_on_handler(\"click\", \".settings-unmute-topic\");\n assert.equal(typeof topic_click_handler, \"function\");\n@@ -79,6 +79,6 @@ run_test(\"settings\", (override) => {\n unmute_topic_called = true;\n };\n topic_click_handler.call(topic_fake_this, event);\n- assert(unmute_topic_called);\n+ assert.ok(unmute_topic_called);\n assert.equal(topic_data_called, 2);\n });\ndiff --git a/frontend_tests/node_tests/settings_muted_users.js b/frontend_tests/node_tests/settings_muted_users.js\n--- a/frontend_tests/node_tests/settings_muted_users.js\n+++ b/frontend_tests/node_tests/settings_muted_users.js\n@@ -34,7 +34,7 @@ run_test(\"settings\", (override) => {\n \n settings_muted_users.set_up();\n assert.equal(settings_muted_users.loaded, true);\n- assert(populate_list_called);\n+ assert.ok(populate_list_called);\n \n const unmute_click_handler = $(\"body\").get_on_handler(\"click\", \".settings-unmute-user\");\n assert.equal(typeof unmute_click_handler, \"function\");\n@@ -66,6 +66,6 @@ run_test(\"settings\", (override) => {\n };\n \n unmute_click_handler.call(unmute_button, event);\n- assert(unmute_user_called);\n- assert(row_attribute_fetched);\n+ assert.ok(unmute_user_called);\n+ assert.ok(row_attribute_fetched);\n });\ndiff --git a/frontend_tests/node_tests/settings_org.js b/frontend_tests/node_tests/settings_org.js\n--- a/frontend_tests/node_tests/settings_org.js\n+++ b/frontend_tests/node_tests/settings_org.js\n@@ -23,7 +23,7 @@ const realm_icon = mock_esm(\"../../static/js/realm_icon\");\n \n stub_templates((name, data) => {\n if (name === \"settings/admin_realm_domains_list\") {\n- assert(data.realm_domain.domain);\n+ assert.ok(data.realm_domain.domain);\n return \"stub-domains-list\";\n }\n throw new Error(`Unknown template ${name}`);\n@@ -95,7 +95,7 @@ function simulate_realm_domains_table() {\n };\n \n return function verify() {\n- assert(appended);\n+ assert.ok(appended);\n };\n }\n \n@@ -124,7 +124,7 @@ function test_realms_domain_modal(override, add_realm_domain) {\n \n add_realm_domain();\n \n- assert(posted);\n+ assert.ok(posted);\n \n success_callback();\n assert.equal(info.val(), \"translated HTML: Added successfully!\");\n@@ -250,7 +250,7 @@ function test_submit_settings_form(override, submit_form) {\n \n patched = false;\n submit_form(ev);\n- assert(patched);\n+ assert.ok(patched);\n \n let expected_value = {\n bot_creation_policy: 1,\n@@ -284,7 +284,7 @@ function test_submit_settings_form(override, submit_form) {\n ]);\n \n submit_form(ev);\n- assert(patched);\n+ assert.ok(patched);\n \n expected_value = {\n default_language: \"en\",\n@@ -361,7 +361,7 @@ function test_upload_realm_icon(override, upload_realm_logo_or_icon) {\n });\n \n upload_realm_logo_or_icon(file_input, null, true);\n- assert(posted);\n+ assert.ok(posted);\n }\n \n function test_change_allow_subdomains(change_allow_subdomains) {\n@@ -842,64 +842,64 @@ test(\"misc\", (override) => {\n page_params.realm_name_changes_disabled = false;\n page_params.server_name_changes_disabled = false;\n settings_account.update_name_change_display();\n- assert(!$(\"#full_name\").prop(\"disabled\"));\n+ assert.ok(!$(\"#full_name\").prop(\"disabled\"));\n assert.equal($(\".change_name_tooltip\").is(\":visible\"), false);\n \n page_params.realm_name_changes_disabled = true;\n page_params.server_name_changes_disabled = false;\n settings_account.update_name_change_display();\n- assert($(\"#full_name\").prop(\"disabled\"));\n- assert($(\".change_name_tooltip\").is(\":visible\"));\n+ assert.ok($(\"#full_name\").prop(\"disabled\"));\n+ assert.ok($(\".change_name_tooltip\").is(\":visible\"));\n \n page_params.realm_name_changes_disabled = true;\n page_params.server_name_changes_disabled = true;\n settings_account.update_name_change_display();\n- assert($(\"#full_name\").prop(\"disabled\"));\n- assert($(\".change_name_tooltip\").is(\":visible\"));\n+ assert.ok($(\"#full_name\").prop(\"disabled\"));\n+ assert.ok($(\".change_name_tooltip\").is(\":visible\"));\n \n page_params.realm_name_changes_disabled = false;\n page_params.server_name_changes_disabled = true;\n settings_account.update_name_change_display();\n- assert($(\"#full_name\").prop(\"disabled\"));\n- assert($(\".change_name_tooltip\").is(\":visible\"));\n+ assert.ok($(\"#full_name\").prop(\"disabled\"));\n+ assert.ok($(\".change_name_tooltip\").is(\":visible\"));\n \n page_params.realm_email_changes_disabled = false;\n settings_account.update_email_change_display();\n- assert(!$(\"#change_email .button\").prop(\"disabled\"));\n+ assert.ok(!$(\"#change_email .button\").prop(\"disabled\"));\n \n page_params.realm_email_changes_disabled = true;\n settings_account.update_email_change_display();\n- assert($(\"#change_email .button\").prop(\"disabled\"));\n+ assert.ok($(\"#change_email .button\").prop(\"disabled\"));\n \n page_params.realm_avatar_changes_disabled = false;\n page_params.server_avatar_changes_disabled = false;\n settings_account.update_avatar_change_display();\n- assert(!$(\"#user-avatar-upload-widget .image_upload_button\").prop(\"disabled\"));\n- assert(!$(\"#user-avatar-upload-widget .image-delete-button .button\").prop(\"disabled\"));\n+ assert.ok(!$(\"#user-avatar-upload-widget .image_upload_button\").prop(\"disabled\"));\n+ assert.ok(!$(\"#user-avatar-upload-widget .image-delete-button .button\").prop(\"disabled\"));\n page_params.realm_avatar_changes_disabled = true;\n page_params.server_avatar_changes_disabled = false;\n settings_account.update_avatar_change_display();\n- assert($(\"#user-avatar-upload-widget .image_upload_button\").prop(\"disabled\"));\n- assert($(\"#user-avatar-upload-widget .image-delete-button .button\").prop(\"disabled\"));\n+ assert.ok($(\"#user-avatar-upload-widget .image_upload_button\").prop(\"disabled\"));\n+ assert.ok($(\"#user-avatar-upload-widget .image-delete-button .button\").prop(\"disabled\"));\n page_params.realm_avatar_changes_disabled = false;\n page_params.server_avatar_changes_disabled = true;\n settings_account.update_avatar_change_display();\n- assert($(\"#user-avatar-upload-widget .image_upload_button\").prop(\"disabled\"));\n- assert($(\"#user-avatar-upload-widget .image-delete-button .button\").prop(\"disabled\"));\n+ assert.ok($(\"#user-avatar-upload-widget .image_upload_button\").prop(\"disabled\"));\n+ assert.ok($(\"#user-avatar-upload-widget .image-delete-button .button\").prop(\"disabled\"));\n page_params.realm_avatar_changes_disabled = true;\n page_params.server_avatar_changes_disabled = true;\n settings_account.update_avatar_change_display();\n- assert($(\"#user-avatar-upload-widget .image_upload_button\").prop(\"disabled\"));\n- assert($(\"#user-avatar-upload-widget .image-delete-button .button\").prop(\"disabled\"));\n+ assert.ok($(\"#user-avatar-upload-widget .image_upload_button\").prop(\"disabled\"));\n+ assert.ok($(\"#user-avatar-upload-widget .image-delete-button .button\").prop(\"disabled\"));\n \n // If organization admin, these UI elements are never disabled.\n page_params.is_admin = true;\n settings_account.update_name_change_display();\n- assert(!$(\"#full_name\").prop(\"disabled\"));\n+ assert.ok(!$(\"#full_name\").prop(\"disabled\"));\n assert.equal($(\".change_name_tooltip\").is(\":visible\"), false);\n \n settings_account.update_email_change_display();\n- assert(!$(\"#change_email .button\").prop(\"disabled\"));\n+ assert.ok(!$(\"#change_email .button\").prop(\"disabled\"));\n \n override(stream_settings_data, \"get_streams_for_settings_page\", () => [\n {name: \"some_stream\", stream_id: 75},\n@@ -939,11 +939,11 @@ test(\"misc\", (override) => {\n });\n settings_org.notifications_stream_widget.render(42);\n assert.equal(elem.text(), \"#some_stream\");\n- assert(!elem.hasClass(\"text-warning\"));\n+ assert.ok(!elem.hasClass(\"text-warning\"));\n \n settings_org.notifications_stream_widget.render(undefined);\n assert.equal(elem.text(), \"translated: Disabled\");\n- assert(elem.hasClass(\"text-warning\"));\n+ assert.ok(elem.hasClass(\"text-warning\"));\n \n setting_name = \"realm_signup_notifications_stream_id\";\n elem = $(`#${CSS.escape(setting_name)}_widget #${CSS.escape(setting_name)}_name`);\n@@ -954,9 +954,9 @@ test(\"misc\", (override) => {\n });\n settings_org.signup_notifications_stream_widget.render(75);\n assert.equal(elem.text(), \"#some_stream\");\n- assert(!elem.hasClass(\"text-warning\"));\n+ assert.ok(!elem.hasClass(\"text-warning\"));\n \n settings_org.signup_notifications_stream_widget.render(undefined);\n assert.equal(elem.text(), \"translated: Disabled\");\n- assert(elem.hasClass(\"text-warning\"));\n+ assert.ok(elem.hasClass(\"text-warning\"));\n });\ndiff --git a/frontend_tests/node_tests/settings_user_groups.js b/frontend_tests/node_tests/settings_user_groups.js\n--- a/frontend_tests/node_tests/settings_user_groups.js\n+++ b/frontend_tests/node_tests/settings_user_groups.js\n@@ -41,7 +41,7 @@ function reset_test_setup(pill_container_stub) {\n function input_pill_stub(opts) {\n assert.equal(opts.container, pill_container_stub);\n create_item_handler = opts.create_item_from_text;\n- assert(create_item_handler);\n+ assert.ok(create_item_handler);\n return pills;\n }\n input_pill.create = input_pill_stub;\n@@ -55,11 +55,11 @@ function test_ui(label, f) {\n test_ui(\"can_edit\", () => {\n page_params.is_guest = false;\n page_params.is_admin = true;\n- assert(settings_user_groups.can_edit(1));\n+ assert.ok(settings_user_groups.can_edit(1));\n \n page_params.is_admin = false;\n page_params.is_guest = true;\n- assert(!settings_user_groups.can_edit(1));\n+ assert.ok(!settings_user_groups.can_edit(1));\n \n page_params.is_guest = false;\n page_params.is_admin = false;\n@@ -68,11 +68,11 @@ test_ui(\"can_edit\", () => {\n assert.equal(user_id, undefined);\n return false;\n };\n- assert(!settings_user_groups.can_edit(1));\n+ assert.ok(!settings_user_groups.can_edit(1));\n \n page_params.realm_user_group_edit_policy = 2;\n page_params.is_admin = true;\n- assert(settings_user_groups.can_edit(1));\n+ assert.ok(settings_user_groups.can_edit(1));\n \n page_params.is_admin = false;\n user_groups.is_member_of = (group_id, user_id) => {\n@@ -80,7 +80,7 @@ test_ui(\"can_edit\", () => {\n assert.equal(user_id, undefined);\n return true;\n };\n- assert(!settings_user_groups.can_edit(1));\n+ assert.ok(!settings_user_groups.can_edit(1));\n \n page_params.realm_user_group_edit_policy = 1;\n page_params.is_admin = false;\n@@ -89,7 +89,7 @@ test_ui(\"can_edit\", () => {\n assert.equal(user_id, undefined);\n return true;\n };\n- assert(settings_user_groups.can_edit(1));\n+ assert.ok(settings_user_groups.can_edit(1));\n });\n \n const user_group_selector = `#user-groups #${CSS.escape(1)}`;\n@@ -172,7 +172,7 @@ test_ui(\"populate_user_groups\", (override) => {\n const pill_container_stub = $(`.pill-container[data-group-pills=\"${CSS.escape(1)}\"]`);\n pills.appendValidatedData = (item) => {\n const id = item.user_id;\n- assert(!all_pills.has(id));\n+ assert.ok(!all_pills.has(id));\n all_pills.set(id, item);\n };\n pills.items = () => Array.from(all_pills.values());\n@@ -188,9 +188,9 @@ test_ui(\"populate_user_groups\", (override) => {\n let input_typeahead_called = false;\n input_field_stub.typeahead = (config) => {\n assert.equal(config.items, 5);\n- assert(config.fixed);\n- assert(config.dropup);\n- assert(config.stopAdvance);\n+ assert.ok(config.fixed);\n+ assert.ok(config.dropup);\n+ assert.ok(config.stopAdvance);\n assert.equal(typeof config.source, \"function\");\n assert.equal(typeof config.highlighter, \"function\");\n assert.equal(typeof config.matcher, \"function\");\n@@ -221,20 +221,20 @@ test_ui(\"populate_user_groups\", (override) => {\n /* Here the query doesn't begin with an '@' because typeahead is triggered\n by the '@' sign and thus removed in the query. */\n let result = config.matcher.call(fake_context, iago);\n- assert(!result);\n+ assert.ok(!result);\n \n result = config.matcher.call(fake_context, alice);\n- assert(result);\n+ assert.ok(result);\n \n page_params.realm_email_address_visibility =\n settings_config.email_address_visibility_values.admins_only.code;\n page_params.is_admin = false;\n result = config.matcher.call(fake_context_for_email, bob);\n- assert(!result);\n+ assert.ok(!result);\n \n page_params.is_admin = true;\n result = config.matcher.call(fake_context_for_email, bob);\n- assert(result);\n+ assert.ok(result);\n })();\n \n (function test_sorter() {\n@@ -243,7 +243,7 @@ test_ui(\"populate_user_groups\", (override) => {\n sort_recipients_typeahead_called = true;\n };\n config.sorter.call(fake_context, []);\n- assert(sort_recipients_typeahead_called);\n+ assert.ok(sort_recipients_typeahead_called);\n })();\n \n (function test_updater() {\n@@ -284,9 +284,9 @@ test_ui(\"populate_user_groups\", (override) => {\n text_cleared = false;\n config.updater(alice);\n // update_cancel_button is called.\n- assert(saved_fade_out_called);\n- assert(cancel_fade_to_called);\n- assert(instructions_fade_to_called);\n+ assert.ok(saved_fade_out_called);\n+ assert.ok(cancel_fade_to_called);\n+ assert.ok(instructions_fade_to_called);\n assert.equal(text_cleared, true);\n })();\n input_typeahead_called = true;\n@@ -311,14 +311,14 @@ test_ui(\"populate_user_groups\", (override) => {\n function test_create_item(handler) {\n (function test_rejection_path() {\n const item = handler(iago.email, pills.items());\n- assert(get_by_email_called);\n+ assert.ok(get_by_email_called);\n assert.equal(item, undefined);\n })();\n \n (function test_success_path() {\n get_by_email_called = false;\n const res = handler(bob.email, pills.items());\n- assert(get_by_email_called);\n+ assert.ok(get_by_email_called);\n assert.equal(typeof res, \"object\");\n assert.equal(res.user_id, bob.user_id);\n assert.equal(res.display_value, bob.full_name);\n@@ -335,10 +335,10 @@ test_ui(\"populate_user_groups\", (override) => {\n \n reset_test_setup(pill_container_stub);\n settings_user_groups.set_up();\n- assert(templates_render_called);\n- assert(user_groups_list_append_called);\n- assert(get_by_user_id_called);\n- assert(input_typeahead_called);\n+ assert.ok(templates_render_called);\n+ assert.ok(user_groups_list_append_called);\n+ assert.ok(get_by_user_id_called);\n+ assert.ok(input_typeahead_called);\n test_create_item(create_item_handler);\n \n // Tests for settings_user_groups.set_up workflow.\n@@ -478,7 +478,7 @@ test_ui(\"with_external_user\", (override) => {\n assert.equal(set_parents_result_called, 1);\n assert.equal(set_attributes_called, 1);\n assert.equal(can_edit_called, 9);\n- assert(exit_button_called);\n+ assert.ok(exit_button_called);\n assert.equal(user_group_find_called, 2);\n assert.equal(pill_container_find_called, 4);\n assert.equal(turned_off[\"keydown/.pill\"], true);\n@@ -493,7 +493,7 @@ test_ui(\"reload\", (override) => {\n populate_user_groups_called = true;\n });\n settings_user_groups.reload();\n- assert(populate_user_groups_called);\n+ assert.ok(populate_user_groups_called);\n assert.equal($(\"#user-groups\").html(), \"\");\n });\n \n@@ -542,7 +542,7 @@ test_ui(\"on_events\", (override) => {\n \n opts.success();\n \n- assert(!$(\"#admin-user-group-status\").visible());\n+ assert.ok(!$(\"#admin-user-group-status\").visible());\n assert.equal($(\"form.admin-user-group-form input[type='text']\").val(), \"\");\n })();\n \n@@ -561,7 +561,7 @@ test_ui(\"on_events\", (override) => {\n };\n opts.error(xhr);\n \n- assert(!$(\"#admin-user-group-status\").visible());\n+ assert.ok(!$(\"#admin-user-group-status\").visible());\n })();\n };\n \n@@ -603,7 +603,7 @@ test_ui(\"on_events\", (override) => {\n },\n };\n handler(event);\n- assert(default_action_for_enter_stopped);\n+ assert.ok(default_action_for_enter_stopped);\n })();\n \n (function test_do_not_blur() {\n@@ -635,7 +635,7 @@ test_ui(\"on_events\", (override) => {\n return [];\n };\n handler.call(fake_this, event);\n- assert(!api_endpoint_called);\n+ assert.ok(!api_endpoint_called);\n }\n \n api_endpoint_called = false;\n@@ -646,7 +646,7 @@ test_ui(\"on_events\", (override) => {\n return [];\n };\n handler.call(fake_this, event);\n- assert(!api_endpoint_called);\n+ assert.ok(!api_endpoint_called);\n \n // Cancel button triggers blur event.\n let settings_user_groups_reload_called = false;\n@@ -664,8 +664,8 @@ test_ui(\"on_events\", (override) => {\n return [];\n };\n handler.call(fake_this, event);\n- assert(!api_endpoint_called);\n- assert(settings_user_groups_reload_called);\n+ assert.ok(!api_endpoint_called);\n+ assert.ok(settings_user_groups_reload_called);\n }\n })();\n \n@@ -697,23 +697,23 @@ test_ui(\"on_events\", (override) => {\n // Cancel button removed if user group if user group has no changes.\n const fake_this = $.create(\"fake-#update_cancel_button\");\n handler_name.call(fake_this);\n- assert(cancel_fade_out_called);\n- assert(instructions_fade_out_called);\n+ assert.ok(cancel_fade_out_called);\n+ assert.ok(instructions_fade_out_called);\n \n // Check if cancel button removed if user group error is showing.\n $(user_group_selector + \" .user-group-status\").show();\n cancel_fade_out_called = false;\n instructions_fade_out_called = false;\n handler_name.call(fake_this);\n- assert(cancel_fade_out_called);\n- assert(instructions_fade_out_called);\n+ assert.ok(cancel_fade_out_called);\n+ assert.ok(instructions_fade_out_called);\n \n // Check for handler_desc to achieve 100% coverage.\n cancel_fade_out_called = false;\n instructions_fade_out_called = false;\n handler_desc.call(fake_this);\n- assert(cancel_fade_out_called);\n- assert(instructions_fade_out_called);\n+ assert.ok(cancel_fade_out_called);\n+ assert.ok(instructions_fade_out_called);\n })();\n \n (function test_user_groups_save_group_changes_triggered() {\n@@ -760,9 +760,9 @@ test_ui(\"on_events\", (override) => {\n func();\n });\n opts.success();\n- assert(cancel_fade_out_called);\n- assert(instructions_fade_out_called);\n- assert(saved_fade_to_called);\n+ assert.ok(cancel_fade_out_called);\n+ assert.ok(instructions_fade_out_called);\n+ assert.ok(saved_fade_to_called);\n })();\n (function test_post_error() {\n const user_group_error = $(user_group_selector + \" .user-group-status\");\n@@ -780,7 +780,7 @@ test_ui(\"on_events\", (override) => {\n };\n opts.error(xhr);\n \n- assert(user_group_error.visible());\n+ assert.ok(user_group_error.visible());\n })();\n };\n \n@@ -793,19 +793,19 @@ test_ui(\"on_events\", (override) => {\n \n api_endpoint_called = false;\n handler_name.call(fake_this, event);\n- assert(api_endpoint_called);\n+ assert.ok(api_endpoint_called);\n \n // Check API endpoint isn't called if name and desc haven't changed.\n group_data.name = \"translated: mobile\";\n group_data.description = \"translated: All mobile members\";\n api_endpoint_called = false;\n handler_name.call(fake_this, event);\n- assert(!api_endpoint_called);\n+ assert.ok(!api_endpoint_called);\n \n // Check for handler_desc to achieve 100% coverage.\n api_endpoint_called = false;\n handler_desc.call(fake_this, event);\n- assert(!api_endpoint_called);\n+ assert.ok(!api_endpoint_called);\n })();\n \n (function test_user_groups_save_member_changes_triggered() {\n@@ -846,9 +846,9 @@ test_ui(\"on_events\", (override) => {\n \n (function test_post_success() {\n opts.success();\n- assert(cancel_fade_out_called);\n- assert(instructions_fade_out_called);\n- assert(saved_fade_to_called);\n+ assert.ok(cancel_fade_out_called);\n+ assert.ok(instructions_fade_out_called);\n+ assert.ok(saved_fade_to_called);\n })();\n };\n \n@@ -861,6 +861,6 @@ test_ui(\"on_events\", (override) => {\n \n api_endpoint_called = false;\n handler.call(fake_this, event);\n- assert(api_endpoint_called);\n+ assert.ok(api_endpoint_called);\n })();\n });\ndiff --git a/frontend_tests/node_tests/stream_data.js b/frontend_tests/node_tests/stream_data.js\n--- a/frontend_tests/node_tests/stream_data.js\n+++ b/frontend_tests/node_tests/stream_data.js\n@@ -71,9 +71,9 @@ test(\"basics\", () => {\n };\n stream_data.add_sub(denmark);\n stream_data.add_sub(social);\n- assert(stream_data.all_subscribed_streams_are_in_home_view());\n+ assert.ok(stream_data.all_subscribed_streams_are_in_home_view());\n stream_data.add_sub(test);\n- assert(!stream_data.all_subscribed_streams_are_in_home_view());\n+ assert.ok(!stream_data.all_subscribed_streams_are_in_home_view());\n \n assert.equal(stream_data.get_sub(\"denmark\"), denmark);\n assert.equal(stream_data.get_sub(\"Social\"), social);\n@@ -83,10 +83,10 @@ test(\"basics\", () => {\n assert.deepEqual(stream_data.get_colors(), [\"red\", \"yellow\"]);\n assert.deepEqual(stream_data.subscribed_stream_ids(), [social.stream_id, test.stream_id]);\n \n- assert(stream_data.is_subscribed(\"social\"));\n- assert(stream_data.is_subscribed(\"Social\"));\n- assert(!stream_data.is_subscribed(\"Denmark\"));\n- assert(!stream_data.is_subscribed(\"Rome\"));\n+ assert.ok(stream_data.is_subscribed(\"social\"));\n+ assert.ok(stream_data.is_subscribed(\"Social\"));\n+ assert.ok(!stream_data.is_subscribed(\"Denmark\"));\n+ assert.ok(!stream_data.is_subscribed(\"Rome\"));\n \n assert.equal(stream_data.get_stream_privacy_policy(test.stream_id), \"public\");\n assert.equal(stream_data.get_stream_privacy_policy(social.stream_id), \"invite-only\");\n@@ -95,8 +95,8 @@ test(\"basics\", () => {\n \"invite-only-public-history\",\n );\n \n- assert(stream_data.get_invite_only(\"social\"));\n- assert(!stream_data.get_invite_only(\"unknown\"));\n+ assert.ok(stream_data.get_invite_only(\"social\"));\n+ assert.ok(!stream_data.get_invite_only(\"unknown\"));\n \n assert.equal(stream_data.get_color(\"social\"), \"red\");\n assert.equal(stream_data.get_color(\"unknown\"), \"#c2c2c2\");\n@@ -104,17 +104,17 @@ test(\"basics\", () => {\n assert.equal(stream_data.get_name(\"denMARK\"), \"Denmark\");\n assert.equal(stream_data.get_name(\"unknown Stream\"), \"unknown Stream\");\n \n- assert(!stream_data.is_muted(social.stream_id));\n- assert(stream_data.is_muted(denmark.stream_id));\n+ assert.ok(!stream_data.is_muted(social.stream_id));\n+ assert.ok(stream_data.is_muted(denmark.stream_id));\n \n assert.equal(stream_data.maybe_get_stream_name(), undefined);\n assert.equal(stream_data.maybe_get_stream_name(social.stream_id), \"social\");\n assert.equal(stream_data.maybe_get_stream_name(42), undefined);\n \n stream_data.set_realm_default_streams([denmark]);\n- assert(stream_data.is_default_stream_id(denmark.stream_id));\n- assert(!stream_data.is_default_stream_id(social.stream_id));\n- assert(!stream_data.is_default_stream_id(999999));\n+ assert.ok(stream_data.is_default_stream_id(denmark.stream_id));\n+ assert.ok(!stream_data.is_default_stream_id(social.stream_id));\n+ assert.ok(!stream_data.is_default_stream_id(999999));\n \n assert.equal(stream_data.slug_to_name(\"2-social\"), \"social\");\n assert.equal(stream_data.slug_to_name(\"2-whatever\"), \"social\");\n@@ -167,19 +167,19 @@ test(\"is_active\", () => {\n sub = {name: \"pets\", subscribed: false, stream_id: 111};\n stream_data.add_sub(sub);\n \n- assert(stream_data.is_active(sub));\n+ assert.ok(stream_data.is_active(sub));\n \n stream_data.subscribe_myself(sub);\n- assert(stream_data.is_active(sub));\n+ assert.ok(stream_data.is_active(sub));\n \n- assert(contains_sub(stream_data.subscribed_subs(), sub));\n- assert(!contains_sub(stream_data.unsubscribed_subs(), sub));\n+ assert.ok(contains_sub(stream_data.subscribed_subs(), sub));\n+ assert.ok(!contains_sub(stream_data.unsubscribed_subs(), sub));\n \n stream_data.unsubscribe_myself(sub);\n- assert(stream_data.is_active(sub));\n+ assert.ok(stream_data.is_active(sub));\n \n sub.pin_to_top = true;\n- assert(stream_data.is_active(sub));\n+ assert.ok(stream_data.is_active(sub));\n sub.pin_to_top = false;\n \n const opts = {\n@@ -189,7 +189,7 @@ test(\"is_active\", () => {\n };\n stream_topic_history.add_message(opts);\n \n- assert(stream_data.is_active(sub));\n+ assert.ok(stream_data.is_active(sub));\n \n page_params.demote_inactive_streams =\n settings_config.demote_inactive_streams_values.always.code;\n@@ -198,26 +198,26 @@ test(\"is_active\", () => {\n sub = {name: \"pets\", subscribed: false, stream_id: 111};\n stream_data.add_sub(sub);\n \n- assert(!stream_data.is_active(sub));\n+ assert.ok(!stream_data.is_active(sub));\n \n sub.pin_to_top = true;\n- assert(stream_data.is_active(sub));\n+ assert.ok(stream_data.is_active(sub));\n sub.pin_to_top = false;\n \n stream_data.subscribe_myself(sub);\n- assert(stream_data.is_active(sub));\n+ assert.ok(stream_data.is_active(sub));\n \n stream_data.unsubscribe_myself(sub);\n- assert(!stream_data.is_active(sub));\n+ assert.ok(!stream_data.is_active(sub));\n \n sub = {name: \"lunch\", subscribed: false, stream_id: 222};\n stream_data.add_sub(sub);\n \n- assert(stream_data.is_active(sub));\n+ assert.ok(stream_data.is_active(sub));\n \n stream_topic_history.add_message(opts);\n \n- assert(stream_data.is_active(sub));\n+ assert.ok(stream_data.is_active(sub));\n \n page_params.demote_inactive_streams = settings_config.demote_inactive_streams_values.never.code;\n stream_data.set_filter_out_inactives();\n@@ -225,20 +225,20 @@ test(\"is_active\", () => {\n sub = {name: \"pets\", subscribed: false, stream_id: 111};\n stream_data.add_sub(sub);\n \n- assert(stream_data.is_active(sub));\n+ assert.ok(stream_data.is_active(sub));\n \n stream_data.subscribe_myself(sub);\n- assert(stream_data.is_active(sub));\n+ assert.ok(stream_data.is_active(sub));\n \n stream_data.unsubscribe_myself(sub);\n- assert(stream_data.is_active(sub));\n+ assert.ok(stream_data.is_active(sub));\n \n sub.pin_to_top = true;\n- assert(stream_data.is_active(sub));\n+ assert.ok(stream_data.is_active(sub));\n \n stream_topic_history.add_message(opts);\n \n- assert(stream_data.is_active(sub));\n+ assert.ok(stream_data.is_active(sub));\n });\n \n test(\"admin_options\", () => {\n@@ -266,8 +266,8 @@ test(\"admin_options\", () => {\n // non-admins can't do anything\n page_params.is_admin = false;\n let sub = make_sub();\n- assert(!is_realm_admin(sub));\n- assert(!can_change_stream_permissions(sub));\n+ assert.ok(!is_realm_admin(sub));\n+ assert.ok(!can_change_stream_permissions(sub));\n \n // just a sanity check that we leave \"normal\" fields alone\n assert.equal(sub.color, \"blue\");\n@@ -277,22 +277,22 @@ test(\"admin_options\", () => {\n \n // admins can make public streams become private\n sub = make_sub();\n- assert(is_realm_admin(sub));\n- assert(can_change_stream_permissions(sub));\n+ assert.ok(is_realm_admin(sub));\n+ assert.ok(can_change_stream_permissions(sub));\n \n // admins can only make private streams become public\n // if they are subscribed\n sub = make_sub();\n sub.invite_only = true;\n sub.subscribed = false;\n- assert(is_realm_admin(sub));\n- assert(!can_change_stream_permissions(sub));\n+ assert.ok(is_realm_admin(sub));\n+ assert.ok(!can_change_stream_permissions(sub));\n \n sub = make_sub();\n sub.invite_only = true;\n sub.subscribed = true;\n- assert(is_realm_admin(sub));\n- assert(can_change_stream_permissions(sub));\n+ assert.ok(is_realm_admin(sub));\n+ assert.ok(can_change_stream_permissions(sub));\n });\n \n test(\"stream_settings\", () => {\n@@ -417,14 +417,14 @@ test(\"delete_sub\", () => {\n \n stream_data.add_sub(canada);\n \n- assert(stream_data.is_subscribed(\"Canada\"));\n+ assert.ok(stream_data.is_subscribed(\"Canada\"));\n assert.equal(stream_data.get_sub(\"Canada\").stream_id, canada.stream_id);\n assert.equal(sub_store.get(canada.stream_id).name, \"Canada\");\n \n stream_data.delete_sub(canada.stream_id);\n- assert(!stream_data.is_subscribed(\"Canada\"));\n- assert(!stream_data.get_sub(\"Canada\"));\n- assert(!sub_store.get(canada.stream_id));\n+ assert.ok(!stream_data.is_subscribed(\"Canada\"));\n+ assert.ok(!stream_data.get_sub(\"Canada\"));\n+ assert.ok(!sub_store.get(canada.stream_id));\n \n blueslip.expect(\"warn\", \"Failed to archive stream 99999\");\n stream_data.delete_sub(99999);\n@@ -445,60 +445,60 @@ test(\"notifications\", () => {\n };\n stream_data.add_sub(india);\n \n- assert(!stream_data.receives_notifications(india.stream_id, \"desktop_notifications\"));\n- assert(!stream_data.receives_notifications(india.stream_id, \"audible_notifications\"));\n+ assert.ok(!stream_data.receives_notifications(india.stream_id, \"desktop_notifications\"));\n+ assert.ok(!stream_data.receives_notifications(india.stream_id, \"audible_notifications\"));\n \n page_params.enable_stream_desktop_notifications = true;\n page_params.enable_stream_audible_notifications = true;\n- assert(stream_data.receives_notifications(india.stream_id, \"desktop_notifications\"));\n- assert(stream_data.receives_notifications(india.stream_id, \"audible_notifications\"));\n+ assert.ok(stream_data.receives_notifications(india.stream_id, \"desktop_notifications\"));\n+ assert.ok(stream_data.receives_notifications(india.stream_id, \"audible_notifications\"));\n \n page_params.enable_stream_desktop_notifications = false;\n page_params.enable_stream_audible_notifications = false;\n- assert(!stream_data.receives_notifications(india.stream_id, \"desktop_notifications\"));\n- assert(!stream_data.receives_notifications(india.stream_id, \"audible_notifications\"));\n+ assert.ok(!stream_data.receives_notifications(india.stream_id, \"desktop_notifications\"));\n+ assert.ok(!stream_data.receives_notifications(india.stream_id, \"audible_notifications\"));\n \n india.desktop_notifications = true;\n india.audible_notifications = true;\n- assert(stream_data.receives_notifications(india.stream_id, \"desktop_notifications\"));\n- assert(stream_data.receives_notifications(india.stream_id, \"audible_notifications\"));\n+ assert.ok(stream_data.receives_notifications(india.stream_id, \"desktop_notifications\"));\n+ assert.ok(stream_data.receives_notifications(india.stream_id, \"audible_notifications\"));\n \n india.desktop_notifications = false;\n india.audible_notifications = false;\n page_params.enable_stream_desktop_notifications = true;\n page_params.enable_stream_audible_notifications = true;\n- assert(!stream_data.receives_notifications(india.stream_id, \"desktop_notifications\"));\n- assert(!stream_data.receives_notifications(india.stream_id, \"audible_notifications\"));\n+ assert.ok(!stream_data.receives_notifications(india.stream_id, \"desktop_notifications\"));\n+ assert.ok(!stream_data.receives_notifications(india.stream_id, \"audible_notifications\"));\n \n page_params.wildcard_mentions_notify = true;\n- assert(stream_data.receives_notifications(india.stream_id, \"wildcard_mentions_notify\"));\n+ assert.ok(stream_data.receives_notifications(india.stream_id, \"wildcard_mentions_notify\"));\n page_params.wildcard_mentions_notify = false;\n- assert(!stream_data.receives_notifications(india.stream_id, \"wildcard_mentions_notify\"));\n+ assert.ok(!stream_data.receives_notifications(india.stream_id, \"wildcard_mentions_notify\"));\n india.wildcard_mentions_notify = true;\n- assert(stream_data.receives_notifications(india.stream_id, \"wildcard_mentions_notify\"));\n+ assert.ok(stream_data.receives_notifications(india.stream_id, \"wildcard_mentions_notify\"));\n page_params.wildcard_mentions_notify = true;\n india.wildcard_mentions_notify = false;\n- assert(!stream_data.receives_notifications(india.stream_id, \"wildcard_mentions_notify\"));\n+ assert.ok(!stream_data.receives_notifications(india.stream_id, \"wildcard_mentions_notify\"));\n \n page_params.enable_stream_push_notifications = true;\n- assert(stream_data.receives_notifications(india.stream_id, \"push_notifications\"));\n+ assert.ok(stream_data.receives_notifications(india.stream_id, \"push_notifications\"));\n page_params.enable_stream_push_notifications = false;\n- assert(!stream_data.receives_notifications(india.stream_id, \"push_notifications\"));\n+ assert.ok(!stream_data.receives_notifications(india.stream_id, \"push_notifications\"));\n india.push_notifications = true;\n- assert(stream_data.receives_notifications(india.stream_id, \"push_notifications\"));\n+ assert.ok(stream_data.receives_notifications(india.stream_id, \"push_notifications\"));\n page_params.enable_stream_push_notifications = true;\n india.push_notifications = false;\n- assert(!stream_data.receives_notifications(india.stream_id, \"push_notifications\"));\n+ assert.ok(!stream_data.receives_notifications(india.stream_id, \"push_notifications\"));\n \n page_params.enable_stream_email_notifications = true;\n- assert(stream_data.receives_notifications(india.stream_id, \"email_notifications\"));\n+ assert.ok(stream_data.receives_notifications(india.stream_id, \"email_notifications\"));\n page_params.enable_stream_email_notifications = false;\n- assert(!stream_data.receives_notifications(india.stream_id, \"email_notifications\"));\n+ assert.ok(!stream_data.receives_notifications(india.stream_id, \"email_notifications\"));\n india.email_notifications = true;\n- assert(stream_data.receives_notifications(india.stream_id, \"email_notifications\"));\n+ assert.ok(stream_data.receives_notifications(india.stream_id, \"email_notifications\"));\n page_params.enable_stream_email_notifications = true;\n india.email_notifications = false;\n- assert(!stream_data.receives_notifications(india.stream_id, \"email_notifications\"));\n+ assert.ok(!stream_data.receives_notifications(india.stream_id, \"email_notifications\"));\n \n const canada = {\n stream_id: 103,\n@@ -580,7 +580,7 @@ test(\"notifications\", () => {\n assert.deepEqual(unmatched_streams, expected_streams);\n \n // Get line coverage on defensive code with bogus stream_id.\n- assert(!stream_data.receives_notifications(999999));\n+ assert.ok(!stream_data.receives_notifications(999999));\n });\n \n const tony = {\n@@ -600,9 +600,9 @@ const jazy = {\n test(\"is_muted\", () => {\n stream_data.add_sub(tony);\n stream_data.add_sub(jazy);\n- assert(!stream_data.is_stream_muted_by_name(\"tony\"));\n- assert(stream_data.is_stream_muted_by_name(\"jazy\"));\n- assert(stream_data.is_stream_muted_by_name(\"EEXISTS\"));\n+ assert.ok(!stream_data.is_stream_muted_by_name(\"tony\"));\n+ assert.ok(stream_data.is_stream_muted_by_name(\"jazy\"));\n+ assert.ok(stream_data.is_stream_muted_by_name(\"EEXISTS\"));\n });\n \n test(\"is_notifications_stream_muted\", () => {\n@@ -610,17 +610,17 @@ test(\"is_notifications_stream_muted\", () => {\n stream_data.add_sub(jazy);\n \n page_params.realm_notifications_stream_id = tony.stream_id;\n- assert(!stream_data.is_notifications_stream_muted());\n+ assert.ok(!stream_data.is_notifications_stream_muted());\n \n page_params.realm_notifications_stream_id = jazy.stream_id;\n- assert(stream_data.is_notifications_stream_muted());\n+ assert.ok(stream_data.is_notifications_stream_muted());\n });\n \n test(\"realm_has_notifications_stream\", () => {\n page_params.realm_notifications_stream_id = 10;\n- assert(stream_data.realm_has_notifications_stream());\n+ assert.ok(stream_data.realm_has_notifications_stream());\n page_params.realm_notifications_stream_id = -1;\n- assert(!stream_data.realm_has_notifications_stream());\n+ assert.ok(!stream_data.realm_has_notifications_stream());\n });\n \n test(\"remove_default_stream\", () => {\n@@ -634,7 +634,7 @@ test(\"remove_default_stream\", () => {\n stream_data.add_sub(remove_me);\n stream_data.set_realm_default_streams([remove_me]);\n stream_data.remove_default_stream(remove_me.stream_id);\n- assert(!stream_data.is_default_stream_id(remove_me.stream_id));\n+ assert.ok(!stream_data.is_default_stream_id(remove_me.stream_id));\n });\n \n test(\"canonicalized_name\", () => {\n@@ -663,7 +663,7 @@ test(\"create_sub\", (override) => {\n override(color_data, \"pick_color\", () => \"#bd86e5\");\n \n const india_sub = stream_data.create_sub_from_server_data(india);\n- assert(india_sub);\n+ assert.ok(india_sub);\n assert.equal(india_sub.color, \"#bd86e5\");\n const new_sub = stream_data.create_sub_from_server_data(india);\n // make sure sub doesn't get created twice\n@@ -677,7 +677,7 @@ test(\"create_sub\", (override) => {\n );\n \n const antarctica_sub = stream_data.create_sub_from_server_data(antarctica);\n- assert(antarctica_sub);\n+ assert.ok(antarctica_sub);\n assert.equal(antarctica_sub.color, \"#76ce90\");\n });\n \n@@ -719,12 +719,12 @@ test(\"initialize\", () => {\n page_params.realm_notifications_stream_id = -1;\n \n initialize();\n- assert(!stream_data.is_filtering_inactives());\n+ assert.ok(!stream_data.is_filtering_inactives());\n \n const stream_names = new Set(stream_data.get_streams_for_admin().map((elem) => elem.name));\n- assert(stream_names.has(\"subscriptions\"));\n- assert(stream_names.has(\"unsubscribed\"));\n- assert(stream_names.has(\"never_subscribed\"));\n+ assert.ok(stream_names.has(\"subscriptions\"));\n+ assert.ok(stream_names.has(\"unsubscribed\"));\n+ assert.ok(stream_names.has(\"never_subscribed\"));\n assert.equal(stream_data.get_notifications_stream(), \"\");\n \n // Simulate a private stream the user isn't subscribed to\n@@ -755,7 +755,7 @@ test(\"filter inactives\", () => {\n params.realm_default_streams = [];\n \n stream_data.initialize(params);\n- assert(!stream_data.is_filtering_inactives());\n+ assert.ok(!stream_data.is_filtering_inactives());\n \n _.times(30, (i) => {\n const name = \"random\" + i.toString();\n@@ -770,7 +770,7 @@ test(\"filter inactives\", () => {\n stream_data.add_sub(sub);\n });\n stream_data.initialize(params);\n- assert(stream_data.is_filtering_inactives());\n+ assert.ok(stream_data.is_filtering_inactives());\n });\n \n test(\"edge_cases\", () => {\ndiff --git a/frontend_tests/node_tests/stream_edit.js b/frontend_tests/node_tests/stream_edit.js\n--- a/frontend_tests/node_tests/stream_edit.js\n+++ b/frontend_tests/node_tests/stream_edit.js\n@@ -155,9 +155,9 @@ test_ui(\"subscriber_pills\", (override) => {\n \n input_field_stub.typeahead = (config) => {\n assert.equal(config.items, 5);\n- assert(config.fixed);\n- assert(config.dropup);\n- assert(config.stopAdvance);\n+ assert.ok(config.fixed);\n+ assert.ok(config.dropup);\n+ assert.ok(config.stopAdvance);\n \n assert.equal(typeof config.source, \"function\");\n assert.equal(typeof config.highlighter, \"function\");\n@@ -191,19 +191,19 @@ test_ui(\"subscriber_pills\", (override) => {\n \n (function test_matcher() {\n let result = config.matcher.call(fake_stream_this, denmark);\n- assert(result);\n+ assert.ok(result);\n result = config.matcher.call(fake_stream_this, sweden);\n- assert(!result);\n+ assert.ok(!result);\n \n result = config.matcher.call(fake_group_this, testers);\n- assert(result);\n+ assert.ok(result);\n result = config.matcher.call(fake_group_this, admins);\n- assert(!result);\n+ assert.ok(!result);\n \n result = config.matcher.call(fake_person_this, me);\n- assert(result);\n+ assert.ok(result);\n result = config.matcher.call(fake_person_this, jill);\n- assert(!result);\n+ assert.ok(!result);\n })();\n \n (function test_sorter() {\n@@ -212,18 +212,18 @@ test_ui(\"subscriber_pills\", (override) => {\n sort_streams_called = true;\n };\n config.sorter.call(fake_stream_this);\n- assert(sort_streams_called);\n+ assert.ok(sort_streams_called);\n \n let sort_recipients_called = false;\n typeahead_helper.sort_recipients = function () {\n sort_recipients_called = true;\n };\n config.sorter.call(fake_group_this, [testers]);\n- assert(sort_recipients_called);\n+ assert.ok(sort_recipients_called);\n \n sort_recipients_called = false;\n config.sorter.call(fake_person_this, [me]);\n- assert(sort_recipients_called);\n+ assert.ok(sort_recipients_called);\n })();\n \n (function test_updater() {\n@@ -270,8 +270,8 @@ test_ui(\"subscriber_pills\", (override) => {\n let fake_this = $subscription_settings;\n let event = {target: fake_this};\n stream_row_handler.call(fake_this, event);\n- assert(template_rendered);\n- assert(input_typeahead_called);\n+ assert.ok(template_rendered);\n+ assert.ok(input_typeahead_called);\n \n let add_subscribers_handler = $(subscriptions_table_selector).get_on_handler(\n \"submit\",\n@@ -314,13 +314,13 @@ test_ui(\"subscriber_pills\", (override) => {\n stream_pill.get_user_ids = () => [];\n add_subscribers_request = false;\n add_subscribers_handler(event);\n- assert(!add_subscribers_request);\n+ assert.ok(!add_subscribers_request);\n \n // No request is sent if we try to subscribe ourselves\n // only and are already subscribed to the stream.\n override(user_pill, \"get_user_ids\", () => [me.user_id]);\n add_subscribers_handler(event);\n- assert(!add_subscribers_request);\n+ assert.ok(!add_subscribers_request);\n \n // Denmark stream pill and fred and mark user pills are created.\n // But only one request for mark is sent even though a mark user\ndiff --git a/frontend_tests/node_tests/stream_events.js b/frontend_tests/node_tests/stream_events.js\n--- a/frontend_tests/node_tests/stream_events.js\n+++ b/frontend_tests/node_tests/stream_events.js\n@@ -341,12 +341,12 @@ test(\"marked_subscribed (emails)\", (override) => {\n const subs_stub = make_stub();\n override(subs, \"update_settings_for_subscribed\", subs_stub.f);\n \n- assert(!stream_data.is_subscribed(sub.name));\n+ assert.ok(!stream_data.is_subscribed(sub.name));\n \n const user_ids = [15, 20, 25, me.user_id];\n stream_events.mark_subscribed(sub, user_ids, \"\");\n assert.deepEqual(new Set(peer_data.get_subscribers(sub.stream_id)), new Set(user_ids));\n- assert(stream_data.is_subscribed(sub.name));\n+ assert.ok(stream_data.is_subscribed(sub.name));\n \n const args = subs_stub.get_args(\"sub\");\n assert.deepEqual(sub, args.sub);\n@@ -355,7 +355,7 @@ test(\"marked_subscribed (emails)\", (override) => {\n test(\"mark_unsubscribed (update_settings_for_unsubscribed)\", (override) => {\n // Test unsubscribe\n const sub = {...dev_help};\n- assert(sub.subscribed);\n+ assert.ok(sub.subscribed);\n \n const stub = make_stub();\n \n@@ -394,11 +394,11 @@ test(\"remove_deactivated_user_from_all_streams\", () => {\n subs.update_subscribers_ui = subs_stub.f;\n \n // assert starting state\n- assert(!stream_data.is_user_subscribed(dev_help.stream_id, george.user_id));\n+ assert.ok(!stream_data.is_user_subscribed(dev_help.stream_id, george.user_id));\n \n // verify that deactivating user should unsubscribe user from all streams\n peer_data.add_subscriber(dev_help.stream_id, george.user_id);\n- assert(stream_data.is_user_subscribed(dev_help.stream_id, george.user_id));\n+ assert.ok(stream_data.is_user_subscribed(dev_help.stream_id, george.user_id));\n \n stream_events.remove_deactivated_user_from_all_streams(george.user_id);\n \ndiff --git a/frontend_tests/node_tests/stream_list.js b/frontend_tests/node_tests/stream_list.js\n--- a/frontend_tests/node_tests/stream_list.js\n+++ b/frontend_tests/node_tests/stream_list.js\n@@ -124,7 +124,7 @@ test_ui(\"create_sidebar_row\", (override) => {\n \n stream_list.build_stream_list();\n \n- assert(topic_list_cleared);\n+ assert.ok(topic_list_cleared);\n \n const expected_elems = [\n devel_sidebar, // pinned\n@@ -154,19 +154,19 @@ test_ui(\"create_sidebar_row\", (override) => {\n assert.equal(privacy_elem.html(), \"
privacy-html\");\n \n stream_list.set_in_home_view(stream_id, false);\n- assert(social_li.hasClass(\"out_of_home_view\"));\n+ assert.ok(social_li.hasClass(\"out_of_home_view\"));\n \n stream_list.set_in_home_view(stream_id, true);\n- assert(!social_li.hasClass(\"out_of_home_view\"));\n+ assert.ok(!social_li.hasClass(\"out_of_home_view\"));\n \n const row = stream_list.stream_sidebar.get_row(stream_id);\n override(stream_data, \"is_active\", () => true);\n row.update_whether_active();\n- assert(!social_li.hasClass(\"inactive_stream\"));\n+ assert.ok(!social_li.hasClass(\"inactive_stream\"));\n \n override(stream_data, \"is_active\", () => false);\n row.update_whether_active();\n- assert(social_li.hasClass(\"inactive_stream\"));\n+ assert.ok(social_li.hasClass(\"inactive_stream\"));\n \n let removed;\n social_li.remove = () => {\n@@ -174,7 +174,7 @@ test_ui(\"create_sidebar_row\", (override) => {\n };\n \n row.remove();\n- assert(removed);\n+ assert.ok(removed);\n });\n \n test_ui(\"pinned_streams_never_inactive\", (override) => {\n@@ -193,15 +193,15 @@ test_ui(\"pinned_streams_never_inactive\", (override) => {\n override(stream_data, \"is_active\", () => false);\n \n stream_list.build_stream_list();\n- assert(social_sidebar.hasClass(\"inactive_stream\"));\n+ assert.ok(social_sidebar.hasClass(\"inactive_stream\"));\n \n override(stream_data, \"is_active\", () => true);\n row.update_whether_active();\n- assert(!social_sidebar.hasClass(\"inactive_stream\"));\n+ assert.ok(!social_sidebar.hasClass(\"inactive_stream\"));\n \n override(stream_data, \"is_active\", () => false);\n row.update_whether_active();\n- assert(social_sidebar.hasClass(\"inactive_stream\"));\n+ assert.ok(social_sidebar.hasClass(\"inactive_stream\"));\n \n // pinned streams can never be made inactive\n const devel_sidebar = $(\"\");\n@@ -210,10 +210,10 @@ test_ui(\"pinned_streams_never_inactive\", (override) => {\n override(stream_data, \"is_active\", () => false);\n \n stream_list.build_stream_list();\n- assert(!devel_sidebar.hasClass(\"inactive_stream\"));\n+ assert.ok(!devel_sidebar.hasClass(\"inactive_stream\"));\n \n row.update_whether_active();\n- assert(!devel_sidebar.hasClass(\"inactive_stream\"));\n+ assert.ok(!devel_sidebar.hasClass(\"inactive_stream\"));\n });\n \n function add_row(sub) {\n@@ -303,8 +303,8 @@ test_ui(\"zoom_in_and_zoom_out\", () => {\n label1.show();\n label2.show();\n \n- assert(label1.visible());\n- assert(label2.visible());\n+ assert.ok(label1.visible());\n+ assert.ok(label2.visible());\n \n $.create(\".stream-filters-label\", {\n children: [elem(label1), elem(label2)],\n@@ -313,7 +313,7 @@ test_ui(\"zoom_in_and_zoom_out\", () => {\n const splitter = $.create(\"hr stub\");\n \n splitter.show();\n- assert(splitter.visible());\n+ assert.ok(splitter.visible());\n \n $.create(\".stream-split\", {\n children: [elem(splitter)],\n@@ -344,12 +344,12 @@ test_ui(\"zoom_in_and_zoom_out\", () => {\n \n stream_list.zoom_in_topics({stream_id: 42});\n \n- assert(!label1.visible());\n- assert(!label2.visible());\n- assert(!splitter.visible());\n- assert(stream_li1.visible());\n- assert(!stream_li2.visible());\n- assert($(\"#streams_list\").hasClass(\"zoom-in\"));\n+ assert.ok(!label1.visible());\n+ assert.ok(!label2.visible());\n+ assert.ok(!splitter.visible());\n+ assert.ok(stream_li1.visible());\n+ assert.ok(!stream_li2.visible());\n+ assert.ok($(\"#streams_list\").hasClass(\"zoom-in\"));\n \n $(\"#stream_filters li.narrow-filter\").show = () => {\n stream_li1.show();\n@@ -359,12 +359,12 @@ test_ui(\"zoom_in_and_zoom_out\", () => {\n stream_li1.length = 1;\n stream_list.zoom_out_topics({stream_li: stream_li1});\n \n- assert(label1.visible());\n- assert(label2.visible());\n- assert(splitter.visible());\n- assert(stream_li1.visible());\n- assert(stream_li2.visible());\n- assert($(\"#streams_list\").hasClass(\"zoom-out\"));\n+ assert.ok(label1.visible());\n+ assert.ok(label2.visible());\n+ assert.ok(splitter.visible());\n+ assert.ok(stream_li1.visible());\n+ assert.ok(stream_li2.visible());\n+ assert.ok($(\"#streams_list\").hasClass(\"zoom-out\"));\n });\n \n test_ui(\"narrowing\", (override) => {\n@@ -376,7 +376,7 @@ test_ui(\"narrowing\", (override) => {\n topic_list.get_stream_li = noop;\n override(scroll_util, \"scroll_element_into_container\", noop);\n \n- assert(!$(\"\").hasClass(\"active-filter\"));\n+ assert.ok(!$(\"\").hasClass(\"active-filter\"));\n \n stream_list.set_event_handlers();\n \n@@ -384,20 +384,20 @@ test_ui(\"narrowing\", (override) => {\n \n filter = new Filter([{operator: \"stream\", operand: \"devel\"}]);\n stream_list.handle_narrow_activated(filter);\n- assert($(\"\").hasClass(\"active-filter\"));\n+ assert.ok($(\"\").hasClass(\"active-filter\"));\n \n filter = new Filter([\n {operator: \"stream\", operand: \"cars\"},\n {operator: \"topic\", operand: \"sedans\"},\n ]);\n stream_list.handle_narrow_activated(filter);\n- assert(!$(\"ul.filters li\").hasClass(\"active-filter\"));\n- assert(!$(\"\").hasClass(\"active-filter\")); // false because of topic\n+ assert.ok(!$(\"ul.filters li\").hasClass(\"active-filter\"));\n+ assert.ok(!$(\"\").hasClass(\"active-filter\")); // false because of topic\n \n filter = new Filter([{operator: \"stream\", operand: \"cars\"}]);\n stream_list.handle_narrow_activated(filter);\n- assert(!$(\"ul.filters li\").hasClass(\"active-filter\"));\n- assert($(\"\").hasClass(\"active-filter\"));\n+ assert.ok(!$(\"ul.filters li\").hasClass(\"active-filter\"));\n+ assert.ok($(\"\").hasClass(\"active-filter\"));\n \n let removed_classes;\n $(\"ul#stream_filters li\").removeClass = (classes) => {\n@@ -411,7 +411,7 @@ test_ui(\"narrowing\", (override) => {\n \n stream_list.handle_narrow_deactivated();\n assert.equal(removed_classes, \"active-filter\");\n- assert(topics_closed);\n+ assert.ok(topics_closed);\n });\n \n test_ui(\"focusout_user_filter\", () => {\n@@ -482,9 +482,9 @@ test_ui(\"sort_streams\", (override) => {\n \n const denmark_sub = stream_data.get_sub(\"Denmark\");\n const stream_id = denmark_sub.stream_id;\n- assert(stream_list.stream_sidebar.has_row_for(stream_id));\n+ assert.ok(stream_list.stream_sidebar.has_row_for(stream_id));\n stream_list.remove_sidebar_row(stream_id);\n- assert(!stream_list.stream_sidebar.has_row_for(stream_id));\n+ assert.ok(!stream_list.stream_sidebar.has_row_for(stream_id));\n });\n \n test_ui(\"separators_only_pinned_and_dormant\", (override) => {\n@@ -621,7 +621,7 @@ test_ui(\"rename_stream\", (override) => {\n });\n \n stream_list.rename_stream(sub);\n- assert(count_updated);\n+ assert.ok(count_updated);\n });\n \n test_ui(\"refresh_pin\", (override) => {\n@@ -658,7 +658,7 @@ test_ui(\"refresh_pin\", (override) => {\n });\n \n stream_list.refresh_pinned_or_unpinned_stream(pinned_sub);\n- assert(scrolled);\n+ assert.ok(scrolled);\n });\n \n test_ui(\"create_initial_sidebar_rows\", (override) => {\ndiff --git a/frontend_tests/node_tests/stream_search.js b/frontend_tests/node_tests/stream_search.js\n--- a/frontend_tests/node_tests/stream_search.js\n+++ b/frontend_tests/node_tests/stream_search.js\n@@ -74,24 +74,24 @@ run_test(\"basics\", (override) => {\n cursor_helper = make_cursor_helper();\n \n function verify_expanded() {\n- assert(!section.hasClass(\"notdisplayed\"));\n+ assert.ok(!section.hasClass(\"notdisplayed\"));\n simulate_search_expanded();\n }\n \n function verify_focused() {\n- assert(stream_list.searching());\n- assert(input.is_focused());\n+ assert.ok(stream_list.searching());\n+ assert.ok(input.is_focused());\n }\n \n function verify_blurred() {\n- assert(stream_list.searching());\n- assert(input.is_focused());\n+ assert.ok(stream_list.searching());\n+ assert.ok(input.is_focused());\n }\n \n function verify_collapsed() {\n- assert(section.hasClass(\"notdisplayed\"));\n- assert(!input.is_focused());\n- assert(!stream_list.searching());\n+ assert.ok(section.hasClass(\"notdisplayed\"));\n+ assert.ok(!input.is_focused());\n+ assert.ok(!stream_list.searching());\n simulate_search_collapsed();\n }\n \n@@ -102,7 +102,7 @@ run_test(\"basics\", (override) => {\n });\n \n f();\n- assert(updated);\n+ assert.ok(updated);\n }\n \n // Initiate search (so expand widget).\ndiff --git a/frontend_tests/node_tests/stream_topic_history.js b/frontend_tests/node_tests/stream_topic_history.js\n--- a/frontend_tests/node_tests/stream_topic_history.js\n+++ b/frontend_tests/node_tests/stream_topic_history.js\n@@ -320,7 +320,7 @@ test(\"server_history_end_to_end\", () => {\n \n get_success_callback({topics});\n \n- assert(on_success_called);\n+ assert.ok(on_success_called);\n \n const history = stream_topic_history.get_recent_topic_names(stream_id);\n assert.deepEqual(history, [\"topic3\", \"topic2\", \"topic1\"]);\n@@ -335,7 +335,7 @@ test(\"server_history_end_to_end\", () => {\n stream_topic_history_util.get_server_history(stream_id, () => {\n on_success_called = true;\n });\n- assert(on_success_called);\n+ assert.ok(on_success_called);\n });\n \n test(\"all_topics_in_cache\", (override) => {\ndiff --git a/frontend_tests/node_tests/submessage.js b/frontend_tests/node_tests/submessage.js\n--- a/frontend_tests/node_tests/submessage.js\n+++ b/frontend_tests/node_tests/submessage.js\n@@ -63,7 +63,7 @@ run_test(\"make_server_callback\", () => {\n data: {foo: 32},\n });\n \n- assert(was_posted);\n+ assert.ok(was_posted);\n });\n \n run_test(\"handle_event\", () => {\ndiff --git a/frontend_tests/node_tests/subs.js b/frontend_tests/node_tests/subs.js\n--- a/frontend_tests/node_tests/subs.js\n+++ b/frontend_tests/node_tests/subs.js\n@@ -115,7 +115,7 @@ run_test(\"redraw_left_panel\", () => {\n // on our current stream, even if it doesn't match the filter.\n const denmark_row = $(`.stream-row[data-stream-id='${CSS.escape(denmark_stream_id)}']`);\n // sanity check it's not set to active\n- assert(!denmark_row.hasClass(\"active\"));\n+ assert.ok(!denmark_row.hasClass(\"active\"));\n \n function test_filter(params, expected_streams) {\n const stream_ids = subs.redraw_left_panel(params);\n@@ -127,10 +127,10 @@ run_test(\"redraw_left_panel\", () => {\n \n // Search with single keyword\n test_filter({input: \"Po\", subscribed_only: false}, [poland, pomona]);\n- assert(ui_called);\n+ assert.ok(ui_called);\n \n // The denmark row is active, even though it's not displayed.\n- assert(denmark_row.hasClass(\"active\"));\n+ assert.ok(denmark_row.hasClass(\"active\"));\n \n // Search with multiple keywords\n test_filter({input: \"Denmark, Pol\", subscribed_only: false}, [denmark, poland]);\n@@ -198,7 +198,7 @@ run_test(\"redraw_left_panel\", () => {\n };\n \n test_filter({input: \"d\", subscribed_only: true}, [poland]);\n- assert(!$(\".stream-row-denmark\").hasClass(\"active\"));\n- assert(!$(\".right .settings\").visible());\n- assert($(\".nothing-selected\").visible());\n+ assert.ok(!$(\".stream-row-denmark\").hasClass(\"active\"));\n+ assert.ok(!$(\".right .settings\").visible());\n+ assert.ok($(\".nothing-selected\").visible());\n });\ndiff --git a/frontend_tests/node_tests/support.js b/frontend_tests/node_tests/support.js\n--- a/frontend_tests/node_tests/support.js\n+++ b/frontend_tests/node_tests/support.js\n@@ -38,7 +38,7 @@ run_test(\"scrub_realm\", () => {\n \n window.prompt = () => \"zulip\";\n click_handler.call(fake_this, event);\n- assert(submit_form_called);\n+ assert.ok(submit_form_called);\n \n submit_form_called = false;\n window.prompt = () => \"invalid-string-id\";\n@@ -47,8 +47,8 @@ run_test(\"scrub_realm\", () => {\n alert_called = true;\n };\n click_handler.call(fake_this, event);\n- assert(!submit_form_called);\n- assert(alert_called);\n+ assert.ok(!submit_form_called);\n+ assert.ok(alert_called);\n \n assert.equal(typeof click_handler, \"function\");\n \ndiff --git a/frontend_tests/node_tests/top_left_corner.js b/frontend_tests/node_tests/top_left_corner.js\n--- a/frontend_tests/node_tests/top_left_corner.js\n+++ b/frontend_tests/node_tests/top_left_corner.js\n@@ -29,10 +29,10 @@ run_test(\"narrowing\", (override) => {\n pm_expanded = true;\n });\n \n- assert(!pm_expanded);\n+ assert.ok(!pm_expanded);\n let filter = new Filter([{operator: \"is\", operand: \"private\"}]);\n top_left_corner.handle_narrow_activated(filter);\n- assert(pm_expanded);\n+ assert.ok(pm_expanded);\n \n const alice = {\n email: \"alice@example.com\",\n@@ -51,51 +51,51 @@ run_test(\"narrowing\", (override) => {\n pm_expanded = false;\n filter = new Filter([{operator: \"pm-with\", operand: \"alice@example.com\"}]);\n top_left_corner.handle_narrow_activated(filter);\n- assert(pm_expanded);\n+ assert.ok(pm_expanded);\n \n pm_expanded = false;\n filter = new Filter([{operator: \"pm-with\", operand: \"bob@example.com,alice@example.com\"}]);\n top_left_corner.handle_narrow_activated(filter);\n- assert(pm_expanded);\n+ assert.ok(pm_expanded);\n \n pm_expanded = false;\n filter = new Filter([{operator: \"pm-with\", operand: \"not@valid.com\"}]);\n top_left_corner.handle_narrow_activated(filter);\n- assert(!pm_expanded);\n+ assert.ok(!pm_expanded);\n \n filter = new Filter([{operator: \"is\", operand: \"mentioned\"}]);\n top_left_corner.handle_narrow_activated(filter);\n- assert($(\".top_left_mentions\").hasClass(\"active-filter\"));\n+ assert.ok($(\".top_left_mentions\").hasClass(\"active-filter\"));\n \n filter = new Filter([{operator: \"is\", operand: \"starred\"}]);\n top_left_corner.handle_narrow_activated(filter);\n- assert($(\".top_left_starred_messages\").hasClass(\"active-filter\"));\n+ assert.ok($(\".top_left_starred_messages\").hasClass(\"active-filter\"));\n \n filter = new Filter([{operator: \"in\", operand: \"home\"}]);\n top_left_corner.handle_narrow_activated(filter);\n- assert($(\".top_left_all_messages\").hasClass(\"active-filter\"));\n+ assert.ok($(\".top_left_all_messages\").hasClass(\"active-filter\"));\n \n // deactivating narrow\n \n pm_closed = false;\n top_left_corner.handle_narrow_deactivated();\n \n- assert($(\".top_left_all_messages\").hasClass(\"active-filter\"));\n- assert(!$(\".top_left_mentions\").hasClass(\"active-filter\"));\n- assert(!$(\".top_left_private_messages\").hasClass(\"active-filter\"));\n- assert(!$(\".top_left_starred_messages\").hasClass(\"active-filter\"));\n- assert(!$(\".top_left_recent_topics\").hasClass(\"active-filter\"));\n- assert(pm_closed);\n+ assert.ok($(\".top_left_all_messages\").hasClass(\"active-filter\"));\n+ assert.ok(!$(\".top_left_mentions\").hasClass(\"active-filter\"));\n+ assert.ok(!$(\".top_left_private_messages\").hasClass(\"active-filter\"));\n+ assert.ok(!$(\".top_left_starred_messages\").hasClass(\"active-filter\"));\n+ assert.ok(!$(\".top_left_recent_topics\").hasClass(\"active-filter\"));\n+ assert.ok(pm_closed);\n \n set_global(\"setTimeout\", (f) => {\n f();\n });\n top_left_corner.narrow_to_recent_topics();\n- assert(!$(\".top_left_all_messages\").hasClass(\"active-filter\"));\n- assert(!$(\".top_left_mentions\").hasClass(\"active-filter\"));\n- assert(!$(\".top_left_private_messages\").hasClass(\"active-filter\"));\n- assert(!$(\".top_left_starred_messages\").hasClass(\"active-filter\"));\n- assert($(\".top_left_recent_topics\").hasClass(\"active-filter\"));\n+ assert.ok(!$(\".top_left_all_messages\").hasClass(\"active-filter\"));\n+ assert.ok(!$(\".top_left_mentions\").hasClass(\"active-filter\"));\n+ assert.ok(!$(\".top_left_private_messages\").hasClass(\"active-filter\"));\n+ assert.ok(!$(\".top_left_starred_messages\").hasClass(\"active-filter\"));\n+ assert.ok($(\".top_left_recent_topics\").hasClass(\"active-filter\"));\n });\n \n run_test(\"update_count_in_dom\", () => {\n@@ -129,7 +129,7 @@ run_test(\"update_count_in_dom\", () => {\n top_left_corner.update_dom_with_unread_counts(counts);\n top_left_corner.update_starred_count(0);\n \n- assert(!$(\"\").visible());\n+ assert.ok(!$(\"\").visible());\n assert.equal($(\"\").text(), \"\");\n assert.equal($(\"\").text(), \"\");\n });\ndiff --git a/frontend_tests/node_tests/transmit.js b/frontend_tests/node_tests/transmit.js\n--- a/frontend_tests/node_tests/transmit.js\n+++ b/frontend_tests/node_tests/transmit.js\n@@ -36,7 +36,7 @@ run_test(\"transmit_message_ajax\", () => {\n \n transmit.send_message(request, success);\n \n- assert(success_func_called);\n+ assert.ok(success_func_called);\n \n channel.xhr_error_message = (msg) => {\n assert.equal(msg, \"Error sending message\");\n@@ -56,7 +56,7 @@ run_test(\"transmit_message_ajax\", () => {\n error_func_called = true;\n };\n transmit.send_message(request, success, error);\n- assert(error_func_called);\n+ assert.ok(error_func_called);\n });\n \n run_test(\"transmit_message_ajax_reload_pending\", () => {\n@@ -94,8 +94,8 @@ run_test(\"transmit_message_ajax_reload_pending\", () => {\n opts.error(xhr, \"bad request\");\n };\n transmit.send_message(request, success, error);\n- assert(!error_func_called);\n- assert(reload_initiated);\n+ assert.ok(!error_func_called);\n+ assert.ok(reload_initiated);\n });\n \n run_test(\"reply_message_stream\", (override) => {\ndiff --git a/frontend_tests/node_tests/typeahead_helper.js b/frontend_tests/node_tests/typeahead_helper.js\n--- a/frontend_tests/node_tests/typeahead_helper.js\n+++ b/frontend_tests/node_tests/typeahead_helper.js\n@@ -612,7 +612,7 @@ test(\"render_person when emails hidden\", () => {\n return \"typeahead-item-stub\";\n });\n assert.equal(th.render_person(b_user_1), \"typeahead-item-stub\");\n- assert(rendered);\n+ assert.ok(rendered);\n });\n \n test(\"render_person\", () => {\n@@ -627,7 +627,7 @@ test(\"render_person\", () => {\n return \"typeahead-item-stub\";\n });\n assert.equal(th.render_person(a_user), \"typeahead-item-stub\");\n- assert(rendered);\n+ assert.ok(rendered);\n });\n \n test(\"render_person special_item_text\", () => {\n@@ -651,7 +651,7 @@ test(\"render_person special_item_text\", () => {\n return \"typeahead-item-stub\";\n });\n assert.equal(th.render_person(special_person), \"typeahead-item-stub\");\n- assert(rendered);\n+ assert.ok(rendered);\n });\n \n test(\"render_stream\", () => {\n@@ -671,7 +671,7 @@ test(\"render_stream\", () => {\n return \"typeahead-item-stub\";\n });\n assert.equal(th.render_stream(stream), \"typeahead-item-stub\");\n- assert(rendered);\n+ assert.ok(rendered);\n });\n \n test(\"render_stream w/long description\", () => {\n@@ -692,7 +692,7 @@ test(\"render_stream w/long description\", () => {\n return \"typeahead-item-stub\";\n });\n assert.equal(th.render_stream(stream), \"typeahead-item-stub\");\n- assert(rendered);\n+ assert.ok(rendered);\n });\n \n test(\"render_emoji\", () => {\n@@ -721,7 +721,7 @@ test(\"render_emoji\", () => {\n return \"typeahead-item-stub\";\n });\n assert.equal(th.render_emoji(test_emoji), \"typeahead-item-stub\");\n- assert(rendered);\n+ assert.ok(rendered);\n \n // Test render_emoji with normal emoji.\n rendered = false;\n@@ -743,7 +743,7 @@ test(\"render_emoji\", () => {\n return \"typeahead-item-stub\";\n });\n assert.equal(th.render_emoji(test_emoji), \"typeahead-item-stub\");\n- assert(rendered);\n+ assert.ok(rendered);\n });\n \n test(\"sort_slash_commands\", () => {\ndiff --git a/frontend_tests/node_tests/typing_data.js b/frontend_tests/node_tests/typing_data.js\n--- a/frontend_tests/node_tests/typing_data.js\n+++ b/frontend_tests/node_tests/typing_data.js\n@@ -39,21 +39,21 @@ test(\"basics\", () => {\n assert.deepEqual(typing_data.get_all_typists(), [7, 10, 15]);\n \n // test basic removal\n- assert(typing_data.remove_typist([15, 7], \"7\"));\n+ assert.ok(typing_data.remove_typist([15, 7], \"7\"));\n assert.deepEqual(typing_data.get_group_typists([7, 15]), [15]);\n \n // test removing an id that is not there\n- assert(!typing_data.remove_typist([15, 7], 7));\n+ assert.ok(!typing_data.remove_typist([15, 7], 7));\n assert.deepEqual(typing_data.get_group_typists([7, 15]), [15]);\n assert.deepEqual(typing_data.get_all_typists(), [10, 15]);\n \n // remove user from one group, but \"15\" will still be among\n // \"all typists\"\n- assert(typing_data.remove_typist([\"15\", 7], \"15\"));\n+ assert.ok(typing_data.remove_typist([\"15\", 7], \"15\"));\n assert.deepEqual(typing_data.get_all_typists(), [10, 15]);\n \n // now remove from the other group\n- assert(typing_data.remove_typist([5, 15, 10], 15));\n+ assert.ok(typing_data.remove_typist([5, 15, 10], 15));\n assert.deepEqual(typing_data.get_all_typists(), [10]);\n \n // test duplicate ids in a groups\ndiff --git a/frontend_tests/node_tests/typing_status.js b/frontend_tests/node_tests/typing_status.js\n--- a/frontend_tests/node_tests/typing_status.js\n+++ b/frontend_tests/node_tests/typing_status.js\n@@ -84,7 +84,7 @@ run_test(\"basics\", (override) => {\n stopped: false,\n timer_cleared: false,\n });\n- assert(events.idle_callback);\n+ assert.ok(events.idle_callback);\n \n // type again 3 seconds later\n worker.get_current_time = returns_time(8);\n@@ -100,7 +100,7 @@ run_test(\"basics\", (override) => {\n stopped: false,\n timer_cleared: true,\n });\n- assert(events.idle_callback);\n+ assert.ok(events.idle_callback);\n \n // type after 15 secs, so that we can notify the server\n // again\n@@ -162,7 +162,7 @@ run_test(\"basics\", (override) => {\n stopped: false,\n timer_cleared: false,\n });\n- assert(events.idle_callback);\n+ assert.ok(events.idle_callback);\n \n // Explicitly stop alice.\n call_handler(null);\n@@ -192,7 +192,7 @@ run_test(\"basics\", (override) => {\n stopped: false,\n timer_cleared: false,\n });\n- assert(events.idle_callback);\n+ assert.ok(events.idle_callback);\n \n // Switch to an invalid conversation.\n call_handler(null);\n@@ -236,7 +236,7 @@ run_test(\"basics\", (override) => {\n stopped: false,\n timer_cleared: false,\n });\n- assert(events.idle_callback);\n+ assert.ok(events.idle_callback);\n \n // Switch to bob now.\n worker.get_current_time = returns_time(171);\n@@ -258,7 +258,7 @@ run_test(\"basics\", (override) => {\n stopped: true,\n timer_cleared: true,\n });\n- assert(events.idle_callback);\n+ assert.ok(events.idle_callback);\n \n // test that we correctly detect if worker.get_recipient\n // and typing_status.state.current_recipient are the same\ndiff --git a/frontend_tests/node_tests/unread.js b/frontend_tests/node_tests/unread.js\n--- a/frontend_tests/node_tests/unread.js\n+++ b/frontend_tests/node_tests/unread.js\n@@ -119,9 +119,9 @@ test(\"changing_topics\", () => {\n \n count = unread.num_unread_for_topic(stream_id, \"Lunch\");\n assert.equal(count, 2);\n- assert(unread.topic_has_any_unread(stream_id, \"lunch\"));\n- assert(!unread.topic_has_any_unread(wrong_stream_id, \"lunch\"));\n- assert(!unread.topic_has_any_unread(stream_id, \"NOT lunch\"));\n+ assert.ok(unread.topic_has_any_unread(stream_id, \"lunch\"));\n+ assert.ok(!unread.topic_has_any_unread(wrong_stream_id, \"lunch\"));\n+ assert.ok(!unread.topic_has_any_unread(stream_id, \"NOT lunch\"));\n \n count = unread.num_unread_for_topic(stream_id, \"NOT lunch\");\n assert.equal(count, 0);\n@@ -149,13 +149,13 @@ test(\"changing_topics\", () => {\n \n count = unread.num_unread_for_topic(stream_id, \"lunch\");\n assert.equal(count, 0);\n- assert(!unread.topic_has_any_unread(stream_id, \"lunch\"));\n- assert(!unread.topic_has_any_unread(wrong_stream_id, \"lunch\"));\n+ assert.ok(!unread.topic_has_any_unread(stream_id, \"lunch\"));\n+ assert.ok(!unread.topic_has_any_unread(wrong_stream_id, \"lunch\"));\n \n count = unread.num_unread_for_topic(stream_id, \"snack\");\n assert.equal(count, 1);\n- assert(unread.topic_has_any_unread(stream_id, \"snack\"));\n- assert(!unread.topic_has_any_unread(wrong_stream_id, \"snack\"));\n+ assert.ok(unread.topic_has_any_unread(stream_id, \"snack\"));\n+ assert.ok(!unread.topic_has_any_unread(wrong_stream_id, \"snack\"));\n \n // Test defensive code. Trying to update a message we don't know\n // about should be a no-op.\n@@ -180,12 +180,12 @@ test(\"changing_topics\", () => {\n unread.process_loaded_messages([sticky_message]);\n count = unread.num_unread_for_topic(stream_id, \"sticky\");\n assert.equal(count, 1);\n- assert(sticky_message.unread);\n+ assert.ok(sticky_message.unread);\n \n unread.mark_as_read(sticky_message.id);\n count = unread.num_unread_for_topic(stream_id, \"sticky\");\n assert.equal(count, 0);\n- assert(!sticky_message.unread);\n+ assert.ok(!sticky_message.unread);\n \n event = {\n topic: \"sticky\",\n@@ -594,9 +594,9 @@ test(\"declare_bankruptcy\", () => {\n \n test(\"message_unread\", () => {\n // Test some code that might be overly defensive, for line coverage sake.\n- assert(!unread.message_unread(undefined));\n- assert(unread.message_unread({unread: true}));\n- assert(!unread.message_unread({unread: false}));\n+ assert.ok(!unread.message_unread(undefined));\n+ assert.ok(unread.message_unread({unread: true}));\n+ assert.ok(!unread.message_unread({unread: false}));\n });\n \n test(\"server_counts\", () => {\ndiff --git a/frontend_tests/node_tests/upgrade.js b/frontend_tests/node_tests/upgrade.js\n--- a/frontend_tests/node_tests/upgrade.js\n+++ b/frontend_tests/node_tests/upgrade.js\n@@ -227,15 +227,15 @@ run_test(\"autopay_form_fields\", () => {\n assert.equal(schedule_options[0].value, \"monthly\");\n assert.equal(schedule_options[1].value, \"annual\");\n \n- assert(document.querySelector(\"#autopay-error\"));\n- assert(document.querySelector(\"#autopay-loading\"));\n- assert(document.querySelector(\"#autopay\"));\n- assert(document.querySelector(\"#autopay-success\"));\n- assert(document.querySelector(\"#autopay_loading_indicator\"));\n+ assert.ok(document.querySelector(\"#autopay-error\"));\n+ assert.ok(document.querySelector(\"#autopay-loading\"));\n+ assert.ok(document.querySelector(\"#autopay\"));\n+ assert.ok(document.querySelector(\"#autopay-success\"));\n+ assert.ok(document.querySelector(\"#autopay_loading_indicator\"));\n \n- assert(document.querySelector(\"input[name=csrfmiddlewaretoken]\"));\n+ assert.ok(document.querySelector(\"input[name=csrfmiddlewaretoken]\"));\n \n- assert(document.querySelector(\"#free-trial-alert-message\"));\n+ assert.ok(document.querySelector(\"#free-trial-alert-message\"));\n });\n \n run_test(\"invoice_form_fields\", () => {\n@@ -259,13 +259,13 @@ run_test(\"invoice_form_fields\", () => {\n assert.equal(schedule_options.length, 1);\n assert.equal(schedule_options[0].value, \"annual\");\n \n- assert(document.querySelector(\"#invoice-error\"));\n- assert(document.querySelector(\"#invoice-loading\"));\n- assert(document.querySelector(\"#invoice\"));\n- assert(document.querySelector(\"#invoice-success\"));\n- assert(document.querySelector(\"#invoice_loading_indicator\"));\n+ assert.ok(document.querySelector(\"#invoice-error\"));\n+ assert.ok(document.querySelector(\"#invoice-loading\"));\n+ assert.ok(document.querySelector(\"#invoice\"));\n+ assert.ok(document.querySelector(\"#invoice-success\"));\n+ assert.ok(document.querySelector(\"#invoice_loading_indicator\"));\n \n- assert(document.querySelector(\"input[name=csrfmiddlewaretoken]\"));\n+ assert.ok(document.querySelector(\"input[name=csrfmiddlewaretoken]\"));\n \n- assert(document.querySelector(\"#free-trial-alert-message\"));\n+ assert.ok(document.querySelector(\"#free-trial-alert-message\"));\n });\ndiff --git a/frontend_tests/node_tests/upload.js b/frontend_tests/node_tests/upload.js\n--- a/frontend_tests/node_tests/upload.js\n+++ b/frontend_tests/node_tests/upload.js\n@@ -49,11 +49,11 @@ test(\"feature_check\", (override) => {\n const upload_button = $.create(\"upload-button-stub\");\n upload_button.addClass(\"notdisplayed\");\n upload.feature_check(upload_button);\n- assert(upload_button.hasClass(\"notdisplayed\"));\n+ assert.ok(upload_button.hasClass(\"notdisplayed\"));\n \n override(window, \"XMLHttpRequest\", () => ({upload: true}));\n upload.feature_check(upload_button);\n- assert(!upload_button.hasClass(\"notdisplayed\"));\n+ assert.ok(!upload_button.hasClass(\"notdisplayed\"));\n });\n \n test(\"make_upload_absolute\", () => {\n@@ -197,9 +197,9 @@ test(\"show_error_message\", () => {\n \n upload.show_error_message({mode: \"compose\"}, \"Error message\");\n assert.equal($(\"#compose-send-button\").prop(\"disabled\"), false);\n- assert($(\"#compose-send-status\").hasClass(\"alert-error\"));\n+ assert.ok($(\"#compose-send-status\").hasClass(\"alert-error\"));\n assert.equal($(\"#compose-send-status\").hasClass(\"alert-info\"), false);\n- assert($(\"#compose-send-status\").visible());\n+ assert.ok($(\"#compose-send-status\").visible());\n assert.equal($(\"#compose-error-msg\").text(), \"Error message\");\n \n upload.show_error_message({mode: \"compose\"});\n@@ -236,7 +236,7 @@ test(\"upload_files\", (override) => {\n const config = {mode: \"compose\"};\n $(\"#compose-send-button\").prop(\"disabled\", false);\n upload.upload_files(uppy, config, []);\n- assert(!$(\"#compose-send-button\").prop(\"disabled\"));\n+ assert.ok(!$(\"#compose-send-button\").prop(\"disabled\"));\n \n page_params.max_file_upload_size_mib = 0;\n let show_error_message_called = false;\n@@ -249,7 +249,7 @@ test(\"upload_files\", (override) => {\n );\n });\n upload.upload_files(uppy, config, files);\n- assert(show_error_message_called);\n+ assert.ok(show_error_message_called);\n \n page_params.max_file_upload_size_mib = 25;\n let on_click_close_button_callback;\n@@ -275,14 +275,14 @@ test(\"upload_files\", (override) => {\n $(\"#compose-send-status\").removeClass(\"alert-info\").hide();\n $(\"#compose .undo_markdown_preview\").show();\n upload.upload_files(uppy, config, files);\n- assert($(\"#compose-send-button\").prop(\"disabled\"));\n- assert($(\"#compose-send-status\").hasClass(\"alert-info\"));\n- assert($(\"#compose-send-status\").visible());\n+ assert.ok($(\"#compose-send-button\").prop(\"disabled\"));\n+ assert.ok($(\"#compose-send-status\").hasClass(\"alert-info\"));\n+ assert.ok($(\"#compose-send-status\").visible());\n assert.equal($(\"

\").text(), \"translated: Uploading…\");\n- assert(compose_ui_insert_syntax_and_focus_called);\n- assert(compose_ui_autosize_textarea_called);\n- assert(markdown_preview_hide_button_clicked);\n- assert(uppy_add_file_called);\n+ assert.ok(compose_ui_insert_syntax_and_focus_called);\n+ assert.ok(compose_ui_autosize_textarea_called);\n+ assert.ok(markdown_preview_hide_button_clicked);\n+ assert.ok(uppy_add_file_called);\n \n files = [\n {\n@@ -322,17 +322,17 @@ test(\"upload_files\", (override) => {\n assert.equal(textarea, $(\"#compose-textarea\"));\n });\n on_click_close_button_callback();\n- assert(uppy_cancel_all_called);\n- assert(hide_upload_status_called);\n- assert(compose_ui_autosize_textarea_called);\n- assert(compose_ui_replace_syntax_called);\n+ assert.ok(uppy_cancel_all_called);\n+ assert.ok(hide_upload_status_called);\n+ assert.ok(compose_ui_autosize_textarea_called);\n+ assert.ok(compose_ui_replace_syntax_called);\n hide_upload_status_called = false;\n compose_ui_replace_syntax_called = false;\n $(\"#compose-textarea\").val(\"user modified text\");\n on_click_close_button_callback();\n- assert(hide_upload_status_called);\n- assert(compose_ui_autosize_textarea_called);\n- assert(compose_ui_replace_syntax_called);\n+ assert.ok(hide_upload_status_called);\n+ assert.ok(compose_ui_autosize_textarea_called);\n+ assert.ok(compose_ui_replace_syntax_called);\n assert.equal($(\"#compose-textarea\").val(), \"user modified text\");\n });\n \n@@ -348,7 +348,7 @@ test(\"uppy_config\", () => {\n assert.equal(config.autoProceed, true);\n assert.equal(config.restrictions.maxFileSize, 25 * 1024 * 1024);\n assert.equal(Object.keys(config.locale.strings).length, 2);\n- assert(\"exceedsSize\" in config.locale.strings);\n+ assert.ok(\"exceedsSize\" in config.locale.strings);\n \n return {\n setMeta: (params) => {\n@@ -364,7 +364,7 @@ test(\"uppy_config\", () => {\n assert.equal(params.fieldName, \"file\");\n assert.equal(params.limit, 5);\n assert.equal(Object.keys(params.locale.strings).length, 1);\n- assert(\"timedOut\" in params.locale.strings);\n+ assert.ok(\"timedOut\" in params.locale.strings);\n } else if (func_name === \"ProgressBar\") {\n uppy_used_progressbar = true;\n assert.equal(params.target, \"#compose-send-status\");\n@@ -403,7 +403,7 @@ test(\"file_input\", (override) => {\n upload_files_called = true;\n });\n change_handler(event);\n- assert(upload_files_called);\n+ assert.ok(upload_files_called);\n });\n \n test(\"file_drop\", (override) => {\n@@ -472,8 +472,8 @@ test(\"copy_paste\", (override) => {\n });\n \n paste_handler(event);\n- assert(get_as_file_called);\n- assert(upload_files_called);\n+ assert.ok(get_as_file_called);\n+ assert.ok(upload_files_called);\n \n upload_files_called = false;\n event = {\n@@ -543,9 +543,9 @@ test(\"uppy_events\", (override) => {\n compose_ui_autosize_textarea_called = true;\n });\n on_upload_success_callback(file, response);\n- assert(compose_actions_start_called);\n- assert(compose_ui_replace_syntax_called);\n- assert(compose_ui_autosize_textarea_called);\n+ assert.ok(compose_actions_start_called);\n+ assert.ok(compose_ui_replace_syntax_called);\n+ assert.ok(compose_ui_autosize_textarea_called);\n \n response = {\n body: {\n@@ -584,13 +584,13 @@ test(\"uppy_events\", (override) => {\n },\n ];\n on_complete_callback();\n- assert(hide_upload_status_called);\n+ assert.ok(hide_upload_status_called);\n assert.equal(files.length, 0);\n \n hide_upload_status_called = false;\n $(\"#compose-send-status\").addClass(\"alert-error\");\n on_complete_callback();\n- assert(!hide_upload_status_called);\n+ assert.ok(!hide_upload_status_called);\n \n $(\"#compose-send-status\").removeClass(\"alert-error\");\n hide_upload_status_called = false;\n@@ -609,7 +609,7 @@ test(\"uppy_events\", (override) => {\n },\n ];\n on_complete_callback();\n- assert(!hide_upload_status_called);\n+ assert.ok(!hide_upload_status_called);\n assert.equal(files.length, 1);\n \n state = {\n@@ -628,8 +628,8 @@ test(\"uppy_events\", (override) => {\n assert.equal(message, \"Some error message\");\n });\n on_info_visible_callback();\n- assert(uppy_cancel_all_called);\n- assert(show_error_message_called);\n+ assert.ok(uppy_cancel_all_called);\n+ assert.ok(show_error_message_called);\n override(compose_ui, \"replace_syntax\", (old_syntax, new_syntax, textarea) => {\n compose_ui_replace_syntax_called = true;\n assert.equal(old_syntax, \"[translated: Uploading copenhagen.png…]()\");\n@@ -637,11 +637,11 @@ test(\"uppy_events\", (override) => {\n assert.equal(textarea, $(\"#compose-textarea\"));\n });\n on_restriction_failed_callback(file, null, null);\n- assert(compose_ui_replace_syntax_called);\n+ assert.ok(compose_ui_replace_syntax_called);\n compose_ui_replace_syntax_called = false;\n $(\"#compose-textarea\").val(\"user modified text\");\n on_restriction_failed_callback(file, null, null);\n- assert(compose_ui_replace_syntax_called);\n+ assert.ok(compose_ui_replace_syntax_called);\n assert.equal($(\"#compose-textarea\").val(), \"user modified text\");\n \n state = {\n@@ -673,9 +673,9 @@ test(\"uppy_events\", (override) => {\n };\n uppy_cancel_all_called = false;\n on_upload_error_callback(file, null, response);\n- assert(uppy_cancel_all_called);\n- assert(show_error_message_called);\n- assert(compose_ui_replace_syntax_called);\n+ assert.ok(uppy_cancel_all_called);\n+ assert.ok(show_error_message_called);\n+ assert.ok(compose_ui_replace_syntax_called);\n \n compose_ui_replace_syntax_called = false;\n override(upload, \"show_error_message\", (config, message) => {\n@@ -685,15 +685,15 @@ test(\"uppy_events\", (override) => {\n });\n uppy_cancel_all_called = false;\n on_upload_error_callback(file, null, null);\n- assert(uppy_cancel_all_called);\n- assert(show_error_message_called);\n- assert(compose_ui_replace_syntax_called);\n+ assert.ok(uppy_cancel_all_called);\n+ assert.ok(show_error_message_called);\n+ assert.ok(compose_ui_replace_syntax_called);\n show_error_message_called = false;\n $(\"#compose-textarea\").val(\"user modified text\");\n uppy_cancel_all_called = false;\n on_upload_error_callback(file, null);\n- assert(uppy_cancel_all_called);\n- assert(show_error_message_called);\n- assert(compose_ui_replace_syntax_called);\n+ assert.ok(uppy_cancel_all_called);\n+ assert.ok(show_error_message_called);\n+ assert.ok(compose_ui_replace_syntax_called);\n assert.equal($(\"#compose-textarea\").val(), \"user modified text\");\n });\ndiff --git a/frontend_tests/node_tests/user_events.js b/frontend_tests/node_tests/user_events.js\n--- a/frontend_tests/node_tests/user_events.js\n+++ b/frontend_tests/node_tests/user_events.js\n@@ -83,14 +83,14 @@ run_test(\"updates\", () => {\n role: settings_config.user_role_values.guest.code,\n });\n person = people.get_by_email(isaac.email);\n- assert(person.is_guest);\n+ assert.ok(person.is_guest);\n assert.equal(person.role, settings_config.user_role_values.guest.code);\n user_events.update_person({\n user_id: isaac.user_id,\n role: settings_config.user_role_values.member.code,\n });\n person = people.get_by_email(isaac.email);\n- assert(!person.is_guest);\n+ assert.ok(!person.is_guest);\n assert.equal(person.role, settings_config.user_role_values.member.code);\n \n user_events.update_person({\n@@ -121,23 +121,23 @@ run_test(\"updates\", () => {\n \n user_events.update_person({user_id: me.user_id, is_billing_admin: true});\n person = people.get_by_email(me.email);\n- assert(person.is_billing_admin);\n+ assert.ok(person.is_billing_admin);\n assert.equal(person.role, settings_config.user_role_values.member.code);\n- assert(page_params.is_billing_admin);\n+ assert.ok(page_params.is_billing_admin);\n \n user_events.update_person({user_id: me.user_id, is_billing_admin: false});\n person = people.get_by_email(me.email);\n assert.equal(person.user_id, me.user_id);\n- assert(!person.is_billing_admin);\n+ assert.ok(!person.is_billing_admin);\n assert.equal(person.role, settings_config.user_role_values.member.code);\n- assert(!page_params.is_billing_admin);\n+ assert.ok(!page_params.is_billing_admin);\n \n user_events.update_person({user_id: isaac.user_id, is_billing_admin: false});\n person = people.get_by_email(isaac.email);\n assert.equal(person.user_id, isaac.user_id);\n- assert(!person.is_billing_admin);\n+ assert.ok(!person.is_billing_admin);\n assert.equal(person.role, settings_config.user_role_values.owner.code);\n- assert(!page_params.is_billing_admin);\n+ assert.ok(!page_params.is_billing_admin);\n \n let user_id;\n let full_name;\n@@ -157,7 +157,7 @@ run_test(\"updates\", () => {\n user_id: me.user_id,\n role: settings_config.user_role_values.member.code,\n });\n- assert(!page_params.is_admin);\n+ assert.ok(!page_params.is_admin);\n \n user_events.update_person({user_id: me.user_id, full_name: \"Me V2\"});\n assert.equal(people.my_full_name(), \"Me V2\");\n@@ -201,11 +201,11 @@ run_test(\"updates\", () => {\n \n user_events.update_person({user_id: me.user_id, timezone: \"UTC\"});\n person = people.get_by_email(me.email);\n- assert(person.timezone);\n+ assert.ok(person.timezone);\n \n blueslip.expect(\"error\", \"Got update_person event for unexpected user 29\");\n blueslip.expect(\"error\", \"Unknown user_id in get_by_user_id: 29\");\n- assert(!user_events.update_person({user_id: 29, full_name: \"Sir Isaac Newton\"}));\n+ assert.ok(!user_events.update_person({user_id: 29, full_name: \"Sir Isaac Newton\"}));\n \n me.profile_data = {};\n user_events.update_person({\n@@ -223,7 +223,7 @@ run_test(\"updates\", () => {\n };\n \n user_events.update_person({user_id: me.user_id, delivery_email: \"you@example.org\"});\n- assert(updated);\n+ assert.ok(updated);\n \n const test_bot = {\n email: \"test-bot@example.com\",\ndiff --git a/frontend_tests/node_tests/user_groups.js b/frontend_tests/node_tests/user_groups.js\n--- a/frontend_tests/node_tests/user_groups.js\n+++ b/frontend_tests/node_tests/user_groups.js\n@@ -80,8 +80,8 @@ run_test(\"user_groups\", () => {\n const groups_of_users_nomatch = user_groups.get_user_groups_of_user(user_id_not_in_any_group);\n assert.equal(groups_of_users_nomatch.length, 0);\n \n- assert(!user_groups.is_member_of(admins.id, 4));\n- assert(user_groups.is_member_of(admins.id, 3));\n+ assert.ok(!user_groups.is_member_of(admins.id, 4));\n+ assert.ok(user_groups.is_member_of(admins.id, 3));\n \n user_groups.add_members(all.id, [5, 4]);\n assert.deepEqual(user_groups.get_user_group_from_id(all.id).members, new Set([1, 2, 3, 5, 4]));\n@@ -89,12 +89,12 @@ run_test(\"user_groups\", () => {\n user_groups.remove_members(all.id, [1, 4]);\n assert.deepEqual(user_groups.get_user_group_from_id(all.id).members, new Set([2, 3, 5]));\n \n- assert(user_groups.is_user_group(admins));\n+ assert.ok(user_groups.is_user_group(admins));\n const object = {\n name: \"core\",\n id: 3,\n };\n- assert(!user_groups.is_user_group(object));\n+ assert.ok(!user_groups.is_user_group(object));\n \n user_groups.init();\n assert.equal(user_groups.get_realm_user_groups().length, 0);\ndiff --git a/frontend_tests/node_tests/user_pill.js b/frontend_tests/node_tests/user_pill.js\n--- a/frontend_tests/node_tests/user_pill.js\n+++ b/frontend_tests/node_tests/user_pill.js\n@@ -96,8 +96,8 @@ test(\"append\", () => {\n pill_widget,\n });\n \n- assert(appended);\n- assert(cleared);\n+ assert.ok(appended);\n+ assert.ok(cleared);\n });\n \n test(\"get_items\", () => {\ndiff --git a/frontend_tests/node_tests/user_search.js b/frontend_tests/node_tests/user_search.js\n--- a/frontend_tests/node_tests/user_search.js\n+++ b/frontend_tests/node_tests/user_search.js\n@@ -87,11 +87,11 @@ test(\"clear_search\", (override) => {\n override(resize, \"resize_sidebars\", () => {});\n \n $(\".user-list-filter\").val(\"somevalue\");\n- assert(!$(\"#user_search_section\").hasClass(\"notdisplayed\"));\n+ assert.ok(!$(\"#user_search_section\").hasClass(\"notdisplayed\"));\n $(\"#clear_search_people_button\").trigger(\"click\");\n assert.equal($(\".user-list-filter\").val(), \"\");\n $(\"#clear_search_people_button\").trigger(\"click\");\n- assert($(\"#user_search_section\").hasClass(\"notdisplayed\"));\n+ assert.ok($(\"#user_search_section\").hasClass(\"notdisplayed\"));\n });\n \n test(\"escape_search\", (override) => {\n@@ -104,7 +104,7 @@ test(\"escape_search\", (override) => {\n activity.escape_search();\n assert.equal($(\".user-list-filter\").val(), \"\");\n activity.escape_search();\n- assert($(\"#user_search_section\").hasClass(\"notdisplayed\"));\n+ assert.ok($(\"#user_search_section\").hasClass(\"notdisplayed\"));\n });\n \n test(\"blur search right\", (override) => {\n@@ -205,12 +205,12 @@ test(\"click on user header to toggle display\", (override) => {\n \n page_params.realm_presence_disabled = true;\n \n- assert(!$(\"#user_search_section\").hasClass(\"notdisplayed\"));\n+ assert.ok(!$(\"#user_search_section\").hasClass(\"notdisplayed\"));\n \n user_filter.val(\"bla\");\n \n $(\"#userlist-header\").trigger(\"click\");\n- assert($(\"#user_search_section\").hasClass(\"notdisplayed\"));\n+ assert.ok($(\"#user_search_section\").hasClass(\"notdisplayed\"));\n assert.equal(user_filter.val(), \"\");\n \n $(\".user-list-filter\").closest = (selector) => {\ndiff --git a/frontend_tests/node_tests/user_status.js b/frontend_tests/node_tests/user_status.js\n--- a/frontend_tests/node_tests/user_status.js\n+++ b/frontend_tests/node_tests/user_status.js\n@@ -22,14 +22,14 @@ function initialize() {\n \n run_test(\"basics\", () => {\n initialize();\n- assert(user_status.is_away(2));\n- assert(!user_status.is_away(99));\n+ assert.ok(user_status.is_away(2));\n+ assert.ok(!user_status.is_away(99));\n \n- assert(!user_status.is_away(4));\n+ assert.ok(!user_status.is_away(4));\n user_status.set_away(4);\n- assert(user_status.is_away(4));\n+ assert.ok(user_status.is_away(4));\n user_status.revoke_away(4);\n- assert(!user_status.is_away(4));\n+ assert.ok(!user_status.is_away(4));\n \n assert.equal(user_status.get_status_text(1), \"in a meeting\");\n \n@@ -76,7 +76,7 @@ run_test(\"server\", () => {\n });\n \n success();\n- assert(called);\n+ assert.ok(called);\n });\n \n run_test(\"defensive checks\", () => {\ndiff --git a/frontend_tests/node_tests/util.js b/frontend_tests/node_tests/util.js\n--- a/frontend_tests/node_tests/util.js\n+++ b/frontend_tests/node_tests/util.js\n@@ -41,9 +41,9 @@ run_test(\"extract_pm_recipients\", () => {\n \n run_test(\"is_pm_recipient\", () => {\n const message = {to_user_ids: \"31,32,33\"};\n- assert(util.is_pm_recipient(31, message));\n- assert(util.is_pm_recipient(32, message));\n- assert(!util.is_pm_recipient(34, message));\n+ assert.ok(util.is_pm_recipient(31, message));\n+ assert.ok(util.is_pm_recipient(32, message));\n+ assert.ok(!util.is_pm_recipient(34, message));\n });\n \n run_test(\"lower_bound\", () => {\n@@ -67,43 +67,45 @@ run_test(\"lower_bound\", () => {\n });\n \n run_test(\"same_recipient\", () => {\n- assert(\n+ assert.ok(\n util.same_recipient(\n {type: \"stream\", stream_id: 101, topic: \"Bar\"},\n {type: \"stream\", stream_id: 101, topic: \"bar\"},\n ),\n );\n \n- assert(\n+ assert.ok(\n !util.same_recipient(\n {type: \"stream\", stream_id: 101, topic: \"Bar\"},\n {type: \"stream\", stream_id: 102, topic: \"whatever\"},\n ),\n );\n \n- assert(\n+ assert.ok(\n util.same_recipient(\n {type: \"private\", to_user_ids: \"101,102\"},\n {type: \"private\", to_user_ids: \"101,102\"},\n ),\n );\n \n- assert(\n+ assert.ok(\n !util.same_recipient(\n {type: \"private\", to_user_ids: \"101,102\"},\n {type: \"private\", to_user_ids: \"103\"},\n ),\n );\n \n- assert(!util.same_recipient({type: \"stream\", stream_id: 101, topic: \"Bar\"}, {type: \"private\"}));\n+ assert.ok(\n+ !util.same_recipient({type: \"stream\", stream_id: 101, topic: \"Bar\"}, {type: \"private\"}),\n+ );\n \n- assert(!util.same_recipient({type: \"private\", to_user_ids: undefined}, {type: \"private\"}));\n+ assert.ok(!util.same_recipient({type: \"private\", to_user_ids: undefined}, {type: \"private\"}));\n \n- assert(!util.same_recipient({type: \"unknown type\"}, {type: \"unknown type\"}));\n+ assert.ok(!util.same_recipient({type: \"unknown type\"}, {type: \"unknown type\"}));\n \n- assert(!util.same_recipient(undefined, {type: \"private\"}));\n+ assert.ok(!util.same_recipient(undefined, {type: \"private\"}));\n \n- assert(!util.same_recipient(undefined, undefined));\n+ assert.ok(!util.same_recipient(undefined, undefined));\n });\n \n run_test(\"robust_uri_decode\", () => {\n@@ -148,18 +150,18 @@ run_test(\"get_edit_event_prev_topic\", () => {\n \n run_test(\"is_mobile\", () => {\n window.navigator = {userAgent: \"Android\"};\n- assert(util.is_mobile());\n+ assert.ok(util.is_mobile());\n \n window.navigator = {userAgent: \"Not mobile\"};\n- assert(!util.is_mobile());\n+ assert.ok(!util.is_mobile());\n });\n \n run_test(\"array_compare\", () => {\n- assert(util.array_compare([], []));\n- assert(util.array_compare([1, 2, 3], [1, 2, 3]));\n- assert(!util.array_compare([1, 2], [1, 2, 3]));\n- assert(!util.array_compare([1, 2, 3], [1, 2]));\n- assert(!util.array_compare([1, 2, 3, 4], [1, 2, 3, 5]));\n+ assert.ok(util.array_compare([], []));\n+ assert.ok(util.array_compare([1, 2, 3], [1, 2, 3]));\n+ assert.ok(!util.array_compare([1, 2], [1, 2, 3]));\n+ assert.ok(!util.array_compare([1, 2, 3], [1, 2]));\n+ assert.ok(!util.array_compare([1, 2, 3, 4], [1, 2, 3, 5]));\n });\n \n run_test(\"normalize_recipients\", () => {\n@@ -175,8 +177,8 @@ run_test(\"random_int\", () => {\n \n _.times(500, () => {\n const val = util.random_int(min, max);\n- assert(min <= val);\n- assert(val <= max);\n+ assert.ok(min <= val);\n+ assert.ok(val <= max);\n assert.equal(val, Math.floor(val));\n });\n });\n@@ -232,27 +234,27 @@ run_test(\"all_and_everyone_mentions_regexp\", () => {\n \n let i;\n for (i = 0; i < messages_with_all_mentions.length; i += 1) {\n- assert(util.find_wildcard_mentions(messages_with_all_mentions[i]));\n+ assert.ok(util.find_wildcard_mentions(messages_with_all_mentions[i]));\n }\n \n for (i = 0; i < messages_with_everyone_mentions.length; i += 1) {\n- assert(util.find_wildcard_mentions(messages_with_everyone_mentions[i]));\n+ assert.ok(util.find_wildcard_mentions(messages_with_everyone_mentions[i]));\n }\n \n for (i = 0; i < messages_with_stream_mentions.length; i += 1) {\n- assert(util.find_wildcard_mentions(messages_with_stream_mentions[i]));\n+ assert.ok(util.find_wildcard_mentions(messages_with_stream_mentions[i]));\n }\n \n for (i = 0; i < messages_without_all_mentions.length; i += 1) {\n- assert(!util.find_wildcard_mentions(messages_without_everyone_mentions[i]));\n+ assert.ok(!util.find_wildcard_mentions(messages_without_everyone_mentions[i]));\n }\n \n for (i = 0; i < messages_without_everyone_mentions.length; i += 1) {\n- assert(!util.find_wildcard_mentions(messages_without_everyone_mentions[i]));\n+ assert.ok(!util.find_wildcard_mentions(messages_without_everyone_mentions[i]));\n }\n \n for (i = 0; i < messages_without_stream_mentions.length; i += 1) {\n- assert(!util.find_wildcard_mentions(messages_without_stream_mentions[i]));\n+ assert.ok(!util.find_wildcard_mentions(messages_without_stream_mentions[i]));\n }\n });\n \ndiff --git a/frontend_tests/node_tests/vdom.js b/frontend_tests/node_tests/vdom.js\n--- a/frontend_tests/node_tests/vdom.js\n+++ b/frontend_tests/node_tests/vdom.js\n@@ -97,8 +97,8 @@ run_test(\"attribute updates\", () => {\n \n vdom.update(replace_content, find, new_ul, ul);\n \n- assert(updated);\n- assert(removed);\n+ assert.ok(updated);\n+ assert.ok(removed);\n });\n \n function make_child(i, name) {\ndiff --git a/frontend_tests/node_tests/watchdog.js b/frontend_tests/node_tests/watchdog.js\n--- a/frontend_tests/node_tests/watchdog.js\n+++ b/frontend_tests/node_tests/watchdog.js\n@@ -62,10 +62,10 @@ run_test(\"basics\", () => {\n \n run_test(\"suspect_offline\", () => {\n watchdog.set_suspect_offline(true);\n- assert(watchdog.suspects_user_is_offline());\n+ assert.ok(watchdog.suspects_user_is_offline());\n \n watchdog.set_suspect_offline(false);\n- assert(!watchdog.suspects_user_is_offline());\n+ assert.ok(!watchdog.suspects_user_is_offline());\n });\n \n MockDate.reset();\ndiff --git a/frontend_tests/node_tests/widgetize.js b/frontend_tests/node_tests/widgetize.js\n--- a/frontend_tests/node_tests/widgetize.js\n+++ b/frontend_tests/node_tests/widgetize.js\n@@ -45,7 +45,7 @@ const fake_poll_widget = {\n activate(data) {\n is_widget_activated = true;\n widget_elem = data.elem;\n- assert(widget_elem.hasClass(\"widget-content\"));\n+ assert.ok(widget_elem.hasClass(\"widget-content\"));\n widget_elem.handle_events = (e) => {\n is_event_handled = true;\n assert.notDeepStrictEqual(e, events);\n@@ -105,19 +105,19 @@ test(\"activate\", (override) => {\n message_content.append = (elem) => {\n is_widget_elem_inserted = true;\n assert.equal(elem, widget_elem);\n- assert(elem.hasClass(\"widget-content\"));\n+ assert.ok(elem.hasClass(\"widget-content\"));\n };\n \n is_widget_elem_inserted = false;\n is_widget_activated = false;\n is_event_handled = false;\n- assert(!widgetize.widget_contents.has(opts.message.id));\n+ assert.ok(!widgetize.widget_contents.has(opts.message.id));\n \n widgetize.activate(opts);\n \n- assert(is_widget_elem_inserted);\n- assert(is_widget_activated);\n- assert(is_event_handled);\n+ assert.ok(is_widget_elem_inserted);\n+ assert.ok(is_widget_activated);\n+ assert.ok(is_event_handled);\n assert.equal(widgetize.widget_contents.get(opts.message.id), widget_elem);\n \n is_widget_elem_inserted = false;\n@@ -126,9 +126,9 @@ test(\"activate\", (override) => {\n \n widgetize.activate(opts);\n \n- assert(is_widget_elem_inserted);\n- assert(!is_widget_activated);\n- assert(!is_event_handled);\n+ assert.ok(is_widget_elem_inserted);\n+ assert.ok(!is_widget_activated);\n+ assert.ok(!is_event_handled);\n \n narrow_active = true;\n is_widget_elem_inserted = false;\n@@ -137,9 +137,9 @@ test(\"activate\", (override) => {\n \n widgetize.activate(opts);\n \n- assert(!is_widget_elem_inserted);\n- assert(!is_widget_activated);\n- assert(!is_event_handled);\n+ assert.ok(!is_widget_elem_inserted);\n+ assert.ok(!is_widget_activated);\n+ assert.ok(!is_event_handled);\n \n blueslip.expect(\"warn\", \"unknown widget_type\");\n narrow_active = false;\n@@ -149,17 +149,17 @@ test(\"activate\", (override) => {\n opts.widget_type = \"invalid_widget\";\n \n widgetize.activate(opts);\n- assert(!is_widget_elem_inserted);\n- assert(!is_widget_activated);\n- assert(!is_event_handled);\n+ assert.ok(!is_widget_elem_inserted);\n+ assert.ok(!is_widget_activated);\n+ assert.ok(!is_event_handled);\n assert.equal(blueslip.get_test_logs(\"warn\")[0].more_info, \"invalid_widget\");\n \n opts.widget_type = \"tictactoe\";\n \n widgetize.activate(opts);\n- assert(!is_widget_elem_inserted);\n- assert(!is_widget_activated);\n- assert(!is_event_handled);\n+ assert.ok(!is_widget_elem_inserted);\n+ assert.ok(!is_widget_activated);\n+ assert.ok(!is_event_handled);\n \n /* Testing widgetize.handle_events */\n const post_activate_event = {\n@@ -176,12 +176,12 @@ test(\"activate\", (override) => {\n };\n is_event_handled = false;\n widgetize.handle_event(post_activate_event);\n- assert(is_event_handled);\n+ assert.ok(is_event_handled);\n \n is_event_handled = false;\n post_activate_event.message_id = 1000;\n widgetize.handle_event(post_activate_event);\n- assert(!is_event_handled);\n+ assert.ok(!is_event_handled);\n \n /* Test narrow change message update */\n override(message_lists.current, \"get\", (idx) => {\ndiff --git a/frontend_tests/node_tests/zjquery.js b/frontend_tests/node_tests/zjquery.js\n--- a/frontend_tests/node_tests/zjquery.js\n+++ b/frontend_tests/node_tests/zjquery.js\n@@ -37,11 +37,11 @@ run_test(\"basics\", () => {\n }\n \n // Before we call show_my_form, we can assert that my-form is hidden:\n- assert(!$(\"#my-form\").visible());\n+ assert.ok(!$(\"#my-form\").visible());\n \n // Then calling show_my_form() should make it visible.\n show_my_form();\n- assert($(\"#my-form\").visible());\n+ assert.ok($(\"#my-form\").visible());\n \n // Next, look at how several functions correctly simulate setting\n // and getting for you.\n@@ -108,7 +108,7 @@ run_test(\"finding_related_objects\", () => {\n \n elem.set_parents_result(\".folder\", my_parents);\n elem.parents(\".folder\").addClass(\"active\");\n- assert(my_parents.hasClass(\"active\"));\n+ assert.ok(my_parents.hasClass(\"active\"));\n });\n \n run_test(\"clicks\", () => {\n@@ -128,8 +128,8 @@ run_test(\"clicks\", () => {\n \n // Setting up the click handlers doesn't change state right away.\n set_up_click_handlers();\n- assert(!state.clicked);\n- assert(!state.keydown);\n+ assert.ok(!state.clicked);\n+ assert.ok(!state.keydown);\n \n // But we can simulate clicks.\n $(\"#widget1\").trigger(\"click\");\n@@ -192,8 +192,8 @@ run_test(\"create\", () => {\n const obj2 = $.create(\"the collection of rows in the table\");\n \n obj1.show();\n- assert(obj1.visible());\n+ assert.ok(obj1.visible());\n \n obj2.addClass(\".striped\");\n- assert(obj2.hasClass(\".striped\"));\n+ assert.ok(obj2.hasClass(\".striped\"));\n });\ndiff --git a/frontend_tests/puppeteer_lib/common.ts b/frontend_tests/puppeteer_lib/common.ts\n--- a/frontend_tests/puppeteer_lib/common.ts\n+++ b/frontend_tests/puppeteer_lib/common.ts\n@@ -261,7 +261,7 @@ class CommonUtils {\n // Wait for a email input in login page so we know login\n // page is loaded. Then check that we are at the login url.\n await page.waitForSelector('input[name=\"username\"]');\n- assert(page.url().includes(\"/login/\"));\n+ assert.ok(page.url().includes(\"/login/\"));\n }\n \n async ensure_enter_does_not_send(page: Page): Promise {\ndiff --git a/frontend_tests/puppeteer_tests/mention.ts b/frontend_tests/puppeteer_tests/mention.ts\n--- a/frontend_tests/puppeteer_tests/mention.ts\n+++ b/frontend_tests/puppeteer_tests/mention.ts\n@@ -26,7 +26,7 @@ async function test_mention(page: Page): Promise {\n zulip_test.set_wildcard_mention_large_stream_threshold(5);\n return zulip_test.wildcard_mention_large_stream_threshold;\n });\n- assert(stream_size > threshold);\n+ assert.ok(stream_size > threshold);\n await page.click(\"#compose-send-button\");\n \n await page.waitForXPath(\ndiff --git a/frontend_tests/puppeteer_tests/navigation.ts b/frontend_tests/puppeteer_tests/navigation.ts\n--- a/frontend_tests/puppeteer_tests/navigation.ts\n+++ b/frontend_tests/puppeteer_tests/navigation.ts\n@@ -71,7 +71,7 @@ async function test_reload_hash(page: Page): Promise {\n await page.waitForSelector(\"#zfilt\", {visible: true});\n \n const page_load_time = await page.evaluate(() => zulip_test.page_params.page_load_time);\n- assert(page_load_time > initial_page_load_time, \"Page not reloaded.\");\n+ assert.ok(page_load_time > initial_page_load_time, \"Page not reloaded.\");\n \n const hash = await page.evaluate(() => window.location.hash);\n assert.strictEqual(hash, initial_hash, \"Hash not preserved.\");\ndiff --git a/frontend_tests/puppeteer_tests/realm-creation.ts b/frontend_tests/puppeteer_tests/realm-creation.ts\n--- a/frontend_tests/puppeteer_tests/realm-creation.ts\n+++ b/frontend_tests/puppeteer_tests/realm-creation.ts\n@@ -21,7 +21,7 @@ async function realm_creation_tests(page: Page): Promise {\n ]);\n \n // Make sure onfirmation email is sent.\n- assert(page.url().includes(\"/accounts/new/send_confirm/\" + email));\n+ assert.ok(page.url().includes(\"/accounts/new/send_confirm/\" + email));\n \n // Special endpoint enabled only during tests for extracting confirmation key\n await page.goto(\"http://\" + host + \"/confirmation_key/\");\ndiff --git a/frontend_tests/puppeteer_tests/settings.ts b/frontend_tests/puppeteer_tests/settings.ts\n--- a/frontend_tests/puppeteer_tests/settings.ts\n+++ b/frontend_tests/puppeteer_tests/settings.ts\n@@ -29,7 +29,10 @@ async function open_settings(page: Page): Promise {\n \n await page.waitForSelector(\"#settings_content .account-settings-form\", {visible: true});\n const page_url = await common.page_url_with_fragment(page);\n- assert(page_url.includes(\"/#settings/\"), `Page url: ${page_url} does not contain /#settings/`);\n+ assert.ok(\n+ page_url.includes(\"/#settings/\"),\n+ `Page url: ${page_url} does not contain /#settings/`,\n+ );\n }\n \n async function test_change_full_name(page: Page): Promise {\ndiff --git a/frontend_tests/puppeteer_tests/subscriptions.ts b/frontend_tests/puppeteer_tests/subscriptions.ts\n--- a/frontend_tests/puppeteer_tests/subscriptions.ts\n+++ b/frontend_tests/puppeteer_tests/subscriptions.ts\n@@ -45,7 +45,7 @@ async function open_streams_modal(page: Page): Promise {\n \n await page.waitForSelector(\"#subscription_overlay.new-style\", {visible: true});\n const url = await common.page_url_with_fragment(page);\n- assert(url.includes(\"#streams/all\"));\n+ assert.ok(url.includes(\"#streams/all\"));\n }\n \n async function test_subscription_button_verona_stream(page: Page): Promise {\n@@ -239,7 +239,7 @@ async function test_streams_search_feature(page: Page): Promise {\n ),\n \"Verona\",\n );\n- assert(\n+ assert.ok(\n !(await common.get_text_from_selector(page, hidden_streams_selector)).includes(\"Verona\"),\n \"#Verona is hidden\",\n );\n@@ -249,11 +249,11 @@ async function test_streams_search_feature(page: Page): Promise {\n await common.get_text_from_selector(page, \".stream-row:not(.notdisplayed) .stream-name\"),\n \"Puppeteer\",\n );\n- assert(\n+ assert.ok(\n (await common.get_text_from_selector(page, hidden_streams_selector)).includes(\"Verona\"),\n \"#Verona is not hidden\",\n );\n- assert(\n+ assert.ok(\n !(await common.get_text_from_selector(page, hidden_streams_selector)).includes(\"Puppeteer\"),\n \"Puppeteer is hidden after searching.\",\n );\ndiff --git a/frontend_tests/zjsunit/zjquery.js b/frontend_tests/zjsunit/zjquery.js\n--- a/frontend_tests/zjsunit/zjquery.js\n+++ b/frontend_tests/zjsunit/zjquery.js\n@@ -305,7 +305,7 @@ function make_new_elem(selector, opts) {\n },\n parents(parents_selector) {\n const result = parents_result.get(parents_selector);\n- assert(\n+ assert.ok(\n result,\n \"You need to call set_parents_result for \" + parents_selector + \" in \" + selector,\n );\n@@ -385,7 +385,7 @@ function make_new_elem(selector, opts) {\n return text;\n },\n toggle(show) {\n- assert([true, false].includes(show));\n+ assert.ok([true, false].includes(show));\n shown = show;\n return self;\n },\n@@ -549,7 +549,7 @@ function make_zjquery() {\n };\n \n zjquery.create = function (name, opts) {\n- assert(!elems.has(name), \"You already created an object with this name!!\");\n+ assert.ok(!elems.has(name), \"You already created an object with this name!!\");\n const elem = new_elem(name, opts);\n elems.set(name, elem);\n \n"},"problem_statement":{"kind":"string","value":"node tests: Add a lint rule to make sure that assert is not used incorrectly\nWe had a lot of places in codebase where assert was used accidentally instead of asert.equal.\r\n\r\nSee https://github.com/zulip/zulip/pull/18684 for example.\r\n\r\nWe need to add a lint rule to make sure that this does not happen again.\r\n\r\n\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-testing members, this issue was labeled with the \"area: testing-infrastructure\" label, so you may want to check it out!\n\n\n@zulipbot claim"},"created_at":{"kind":"timestamp","value":"2021-06-10T07:09:27","string":"2021-06-10T07:09:27"}}},{"rowIdx":676,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18821,"string":"18,821"},"instance_id":{"kind":"string","value":"zulip__zulip-18821"},"issue_numbers":{"kind":"list like","value":["18770"],"string":"[\n \"18770\"\n]"},"base_commit":{"kind":"string","value":"1b517924598bcb0035a2c1fb64901ca98ecfd22d"},"patch":{"kind":"string","value":"diff --git a/analytics/management/commands/stream_stats.py b/analytics/management/commands/stream_stats.py\ndeleted file mode 100644\n--- a/analytics/management/commands/stream_stats.py\n+++ /dev/null\n@@ -1,61 +0,0 @@\n-from argparse import ArgumentParser\n-from typing import Any\n-\n-from django.core.management.base import BaseCommand, CommandError\n-from django.db.models import Q\n-\n-from zerver.models import Message, Realm, Recipient, Stream, Subscription, get_realm\n-\n-\n-class Command(BaseCommand):\n- help = \"Generate statistics on the streams for a realm.\"\n-\n- def add_arguments(self, parser: ArgumentParser) -> None:\n- parser.add_argument(\n- \"realms\", metavar=\"\", nargs=\"*\", help=\"realm to generate statistics for\"\n- )\n-\n- def handle(self, *args: Any, **options: str) -> None:\n- if options[\"realms\"]:\n- try:\n- realms = [get_realm(string_id) for string_id in options[\"realms\"]]\n- except Realm.DoesNotExist as e:\n- raise CommandError(e)\n- else:\n- realms = Realm.objects.all()\n-\n- for realm in realms:\n- streams = Stream.objects.filter(realm=realm).exclude(Q(name__istartswith=\"tutorial-\"))\n- # private stream count\n- private_count = 0\n- # public stream count\n- public_count = 0\n- for stream in streams:\n- if stream.invite_only:\n- private_count += 1\n- else:\n- public_count += 1\n- print(\"------------\")\n- print(realm.string_id, end=\" \")\n- print(\"{:>10} {} public streams and\".format(\"(\", public_count), end=\" \")\n- print(f\"{private_count} private streams )\")\n- print(\"------------\")\n- print(\"{:>25} {:>15} {:>10} {:>12}\".format(\"stream\", \"subscribers\", \"messages\", \"type\"))\n-\n- for stream in streams:\n- if stream.invite_only:\n- stream_type = \"private\"\n- else:\n- stream_type = \"public\"\n- print(f\"{stream.name:>25}\", end=\" \")\n- recipient = Recipient.objects.filter(type=Recipient.STREAM, type_id=stream.id)\n- print(\n- \"{:10}\".format(\n- len(Subscription.objects.filter(recipient=recipient, active=True))\n- ),\n- end=\" \",\n- )\n- num_messages = len(Message.objects.filter(recipient=recipient))\n- print(f\"{num_messages:12}\", end=\" \")\n- print(f\"{stream_type:>15}\")\n- print(\"\")\ndiff --git a/manage.py b/manage.py\n--- a/manage.py\n+++ b/manage.py\n@@ -2,6 +2,7 @@\n import configparser\n import os\n import sys\n+from typing import Dict, List, Optional\n \n if sys.version_info <= (3, 0):\n print(\"Error: Zulip is a Python 3 project, and cannot be run with Python 2.\")\n@@ -14,8 +15,112 @@\n \n setup_path()\n \n+from collections import defaultdict\n+\n+from django.core.management import ManagementUtility, get_commands\n+from django.core.management.color import color_style\n+\n from scripts.lib.zulip_tools import assert_not_running_as_root\n \n+\n+def get_filtered_commands() -> Dict[str, str]:\n+ \"\"\"Because Zulip uses management commands in production, `manage.py\n+ help` is a form of documentation for users. Here we exclude from\n+ that documentation built-in commands that are not constructive for\n+ end users or even Zulip developers to run.\n+\n+ Ideally, we'd do further customization to display management\n+ commands with more organization in the help text, and also hide\n+ development-focused management commands in production.\n+ \"\"\"\n+ all_commands = get_commands()\n+ documented_commands = dict()\n+ documented_apps = [\n+ # \"auth\" removed because its commands are not applicable to Zulip.\n+ # \"contenttypes\" removed because we don't use that subsystem, and\n+ # even if we did.\n+ \"django.core\",\n+ \"analytics\",\n+ # \"otp_static\" removed because it's a 2FA internals detail.\n+ # \"sessions\" removed because it's just a cron job with a misleading\n+ # name, since all it does is delete expired sessions.\n+ # \"social_django\" removed for similar reasons to sessions.\n+ # \"staticfiles\" removed because its commands are only usefully run when\n+ # wrapped by Zulip tooling.\n+ # \"two_factor\" removed because it's a 2FA internals detail.\n+ \"zerver\",\n+ \"zilencer\",\n+ ]\n+ documented_command_subsets = {\n+ \"django.core\": {\n+ \"dbshell\",\n+ \"makemigrations\",\n+ \"migrate\",\n+ \"shell\",\n+ \"showmigrations\",\n+ },\n+ }\n+ for command, app in all_commands.items():\n+ if app not in documented_apps:\n+ continue\n+ if app in documented_command_subsets:\n+ if command not in documented_command_subsets[app]:\n+ continue\n+\n+ documented_commands[command] = app\n+ return documented_commands\n+\n+\n+class FilteredManagementUtility(ManagementUtility):\n+ \"\"\"Replaces the main_help_text function of ManagementUtility with one\n+ that calls our get_filtered_commands(), rather than the default\n+ get_commands() function.\n+\n+ All other change are just code style differences to pass the Zulip linter.\n+ \"\"\"\n+\n+ def main_help_text(self, commands_only: bool = False) -> str:\n+ \"\"\"Return the script's main help text, as a string.\"\"\"\n+ if commands_only:\n+ usage = sorted(get_filtered_commands())\n+ else:\n+ usage = [\n+ \"\",\n+ f\"Type '{self.prog_name} help ' for help on a specific subcommand.\",\n+ \"\",\n+ \"Available subcommands:\",\n+ ]\n+ commands_dict = defaultdict(lambda: [])\n+ for name, app in get_filtered_commands().items():\n+ if app == \"django.core\":\n+ app = \"django\"\n+ else:\n+ app = app.rpartition(\".\")[-1]\n+ commands_dict[app].append(name)\n+ style = color_style()\n+ for app in sorted(commands_dict):\n+ usage.append(\"\")\n+ usage.append(style.NOTICE(f\"[{app}]\"))\n+ for name in sorted(commands_dict[app]):\n+ usage.append(f\" {name}\")\n+ # Output an extra note if settings are not properly configured\n+ if self.settings_exception is not None:\n+ usage.append(\n+ style.NOTICE(\n+ \"Note that only Django core commands are listed \"\n+ f\"as settings are not properly configured (error: {self.settings_exception}).\"\n+ )\n+ )\n+\n+ return \"\\n\".join(usage)\n+\n+\n+def execute_from_command_line(argv: Optional[List[str]] = None) -> None:\n+ \"\"\"Run a FilteredManagementUtility.\"\"\"\n+ utility = FilteredManagementUtility(argv)\n+ utility.execute()\n+\n+\n if __name__ == \"__main__\":\n assert_not_running_as_root()\n \n@@ -38,7 +143,6 @@\n \n os.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"zproject.settings\")\n from django.conf import settings\n- from django.core.management import execute_from_command_line\n from django.core.management.base import CommandError\n \n from scripts.lib.zulip_tools import log_management_command\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Disable various Django internal management commands that sysadmins should never run\nIf you run just `./manage.py help`, it prints out all the supported management commands for a Zulip server. This ends up being pretty awkward, in that it lists various built-in Django management commands that sound relevant but are neither used by Zulip not things that are a good idea to try to run (usually they just give confusing errors).\r\n\r\nThe main `./manage.py` script in the Zulip repository does some setup and then calls this:\r\n```\r\ndef execute_from_command_line(argv=None): \r\n \"\"\"Run a ManagementUtility.\"\"\" \r\n utility = ManagementUtility(argv) \r\n utility.execute() \r\n```\r\n\r\nSo I think we implement do this by subclassing `ManagementUtility` to override the `main_help_text` function with a variant that effectively filters the `get_commands` function to remove some commands.\r\n\r\nA first version of this should remove everything in the `[django]` block except these 5, probably most simply implemented as an allowlist:\r\n```\r\n[django]\r\n dbshell\r\n makemigrations\r\n migrate\r\n shell\r\n showmigrations\r\n```\r\n\r\nBut we will probably want to extend that once implemented.\r\n\r\n\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-dependencies, @zulip/server-production members, this issue was labeled with the \"area: dependencies\", \"area: production\" labels, so you may want to check it out!\n\n\n@zulipbot claim"},"created_at":{"kind":"timestamp","value":"2021-06-13T13:04:56","string":"2021-06-13T13:04:56"}}},{"rowIdx":677,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18822,"string":"18,822"},"instance_id":{"kind":"string","value":"zulip__zulip-18822"},"issue_numbers":{"kind":"list like","value":["18796"],"string":"[\n \"18796\"\n]"},"base_commit":{"kind":"string","value":"bcc89c80a29166b487620cb84728a9324f66b227"},"patch":{"kind":"string","value":"diff --git a/zerver/views/home.py b/zerver/views/home.py\n--- a/zerver/views/home.py\n+++ b/zerver/views/home.py\n@@ -205,11 +205,7 @@ def home_real(request: HttpRequest) -> HttpResponse:\n \"user_profile\": user_profile,\n \"page_params\": page_params,\n \"csp_nonce\": csp_nonce,\n- \"is_owner\": user_permission_info.is_realm_owner,\n- \"is_admin\": user_permission_info.is_realm_admin,\n- \"is_guest\": user_permission_info.is_guest,\n \"color_scheme\": user_permission_info.color_scheme,\n- \"max_file_upload_size_mib\": settings.MAX_FILE_UPLOAD_SIZE,\n },\n )\n patch_cache_control(response, no_cache=True, no_store=True, must_revalidate=True)\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"templates: Migrate settings_overlay.html to be a handlebars template\nThis issue is a part of #18792. We'd like to migrate settings_overlay.html to be a handlebars template `static/templates/settings_overlay.hbs`. This will require a bit of care with translation tags and also with the many variables that will need to be access from `page_params` when rendering the template. (Some may need to be moved from the rendering `context` in `zerver/views/home.py` to the extra `page_params` fields in `zerver/lib/home.py`, though I think the vast majority are already available in `page_params`)\r\n\r\n@sahil839 do you want to claim this one as our settings maintainer?\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-refactoring members, this issue was labeled with the \"area: refactoring\" label, so you may want to check it out!\n\n"},"created_at":{"kind":"timestamp","value":"2021-06-13T18:23:43","string":"2021-06-13T18:23:43"}}},{"rowIdx":678,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18885,"string":"18,885"},"instance_id":{"kind":"string","value":"zulip__zulip-18885"},"issue_numbers":{"kind":"list like","value":["18860"],"string":"[\n \"18860\"\n]"},"base_commit":{"kind":"string","value":"ab380b122b4217cb52e67a78796b607f365c9688"},"patch":{"kind":"string","value":"diff --git a/zerver/views/realm_emoji.py b/zerver/views/realm_emoji.py\n--- a/zerver/views/realm_emoji.py\n+++ b/zerver/views/realm_emoji.py\n@@ -4,7 +4,7 @@\n \n from zerver.decorator import require_member_or_admin\n from zerver.lib.actions import check_add_realm_emoji, do_remove_realm_emoji\n-from zerver.lib.emoji import check_emoji_admin, check_valid_emoji_name\n+from zerver.lib.emoji import check_emoji_admin, check_valid_emoji_name, name_to_codepoint\n from zerver.lib.request import REQ, JsonableError, has_request_variables\n from zerver.lib.response import json_success\n from zerver.models import RealmEmoji, UserProfile\n@@ -23,6 +23,7 @@ def upload_emoji(\n request: HttpRequest, user_profile: UserProfile, emoji_name: str = REQ(path_only=True)\n ) -> HttpResponse:\n emoji_name = emoji_name.strip().replace(\" \", \"_\")\n+ valid_built_in_emoji = name_to_codepoint.keys()\n check_valid_emoji_name(emoji_name)\n check_emoji_admin(user_profile)\n if RealmEmoji.objects.filter(\n@@ -31,6 +32,9 @@ def upload_emoji(\n raise JsonableError(_(\"A custom emoji with this name already exists.\"))\n if len(request.FILES) != 1:\n raise JsonableError(_(\"You must upload exactly one file.\"))\n+ if emoji_name in valid_built_in_emoji:\n+ if not user_profile.is_realm_admin:\n+ raise JsonableError(_(\"Only administrators can override built-in emoji.\"))\n emoji_file = list(request.FILES.values())[0]\n if (settings.MAX_EMOJI_FILE_SIZE_MIB * 1024 * 1024) < emoji_file.size:\n raise JsonableError(\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_realm_emoji.py b/zerver/tests/test_realm_emoji.py\n--- a/zerver/tests/test_realm_emoji.py\n+++ b/zerver/tests/test_realm_emoji.py\n@@ -79,6 +79,28 @@ def test_upload(self) -> None:\n author = UserProfile.objects.get(id=test_emoji[\"author_id\"])\n self.assertEqual(author.email, email)\n \n+ def test_override_built_in_emoji_by_admin(self) -> None:\n+ # Test that only administrators can override built-in emoji.\n+ self.login(\"othello\")\n+ with get_test_image_file(\"img.png\") as fp1:\n+ emoji_data = {\"f1\": fp1}\n+ result = self.client_post(\"/json/realm/emoji/laughing\", info=emoji_data)\n+ self.assert_json_error(\n+ result,\n+ \"Only administrators can override built-in emoji.\",\n+ )\n+\n+ user = self.example_user(\"iago\")\n+ email = user.email\n+ self.login_user(user)\n+ with get_test_image_file(\"img.png\") as fp1:\n+ emoji_data = {\"f1\": fp1}\n+ result = self.client_post(\"/json/realm/emoji/smile\", info=emoji_data)\n+ self.assert_json_success(result)\n+ self.assertEqual(200, result.status_code)\n+ realm_emoji = RealmEmoji.objects.get(name=\"smile\")\n+ self.assertEqual(realm_emoji.author.email, email)\n+\n def test_realm_emoji_repr(self) -> None:\n realm_emoji = RealmEmoji.objects.get(name=\"green_tick\")\n file_name = str(realm_emoji.id) + \".png\"\n"},"problem_statement":{"kind":"string","value":"Permissions and warning for custom emoji overriding unicode emoji\nOnly administrators/owners should be able to override unicode emoji\r\n\r\n1. If an administrator attempts to override a unicode emoji with a custom emoji, they should get a warning. #16937 attempts to fix this, but it is currently not working in production.\r\n\r\nWe should also shorten the warning message and avoid referring to \"unicode\" to avoid confusing non-technical users:\r\n>**Override built-in emoji?**\r\n> Uploading a custom emoji with the name **** will override the built-in **** emoji. Continue?\r\n\r\n2. If a non-administrator attempts to override an emoji, show an error in the same style as the error for overriding custom emoji (screenshot below). Text: \"Failed: An emoji with this name already exists. Only administrators can override built-in emoji.\"\r\n\r\nError for overriding custom emoji:\r\n\"Screen\r\n\r\nRelated issue: #18269\r\n[Related CZO thread](https://chat.zulip.org/#narrow/stream/2-general/topic/ok.20emoji)\r\n\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-emoji, @zulip/server-settings members, this issue was labeled with the \"area: emoji\", \"area: settings (admin/org)\" labels, so you may want to check it out!\n\n\n@aryanshridhar FYI\nThanks alya!\r\n@zulipbot claim"},"created_at":{"kind":"timestamp","value":"2021-06-16T19:17:11","string":"2021-06-16T19:17:11"}}},{"rowIdx":679,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":18920,"string":"18,920"},"instance_id":{"kind":"string","value":"zulip__zulip-18920"},"issue_numbers":{"kind":"list like","value":["18915"],"string":"[\n \"18915\"\n]"},"base_commit":{"kind":"string","value":"043b0c6ef302b43aecd40f6c102f990332681aac"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/upload.py b/zerver/lib/upload.py\n--- a/zerver/lib/upload.py\n+++ b/zerver/lib/upload.py\n@@ -386,11 +386,11 @@ def __init__(self) -> None:\n self.avatar_bucket = get_bucket(settings.S3_AVATAR_BUCKET, self.session)\n self.uploads_bucket = get_bucket(settings.S3_AUTH_UPLOADS_BUCKET, self.session)\n \n- def get_public_upload_url(\n- self,\n- key: str,\n- ) -> str:\n- # Return the public URL for a key in the S3 Avatar bucket.\n+ self._boto_client = None\n+ self.public_upload_url_pattern = self.construct_public_upload_url_pattern()\n+\n+ def construct_public_upload_url_pattern(self) -> str:\n+ # Return the pattern for public URL for a key in the S3 Avatar bucket.\n # For Amazon S3 itself, this will return the following:\n # f\"https://{self.avatar_bucket.name}.{network_location}/{key}\"\n #\n@@ -399,20 +399,49 @@ def get_public_upload_url(\n # different URL format. Configuring no signature and providing\n # no access key makes `generate_presigned_url` just return the\n # normal public URL for a key.\n- config = Config(signature_version=botocore.UNSIGNED)\n- return self.session.client(\n- \"s3\",\n- region_name=settings.S3_REGION,\n- endpoint_url=settings.S3_ENDPOINT_URL,\n- config=config,\n- ).generate_presigned_url(\n+ #\n+ # It unfortunately takes 2ms per query to call\n+ # generate_presigned_url, even with our cached boto\n+ # client. Since we need to potentially compute hundreds of\n+ # avatar URLs in single `GET /messages` request, we instead\n+ # back-compute the URL pattern here.\n+\n+ DUMMY_KEY = \"dummy_key_ignored\"\n+ foo_url = self.get_boto_client().generate_presigned_url(\n ClientMethod=\"get_object\",\n Params={\n \"Bucket\": self.avatar_bucket.name,\n- \"Key\": key,\n+ \"Key\": DUMMY_KEY,\n },\n ExpiresIn=0,\n )\n+ parsed = urllib.parse.urlparse(foo_url)\n+ base_path = os.path.dirname(parsed.path)\n+\n+ url_pattern = urllib.parse.urlunparse(\n+ parsed._replace(path=os.path.join(base_path, \"{key}\"))\n+ )\n+ return url_pattern\n+\n+ def get_public_upload_url(\n+ self,\n+ key: str,\n+ ) -> str:\n+ return self.public_upload_url_pattern.format(key=key)\n+\n+ def get_boto_client(self) -> botocore.client.BaseClient:\n+ \"\"\"\n+ Creating the client takes a long time so we need to cache it.\n+ \"\"\"\n+ if self._boto_client is None:\n+ config = Config(signature_version=botocore.UNSIGNED)\n+ self._boto_client = self.session.client(\n+ \"s3\",\n+ region_name=settings.S3_REGION,\n+ endpoint_url=settings.S3_ENDPOINT_URL,\n+ config=config,\n+ )\n+ return self._boto_client\n \n def delete_file_from_s3(self, path_id: str, bucket: ServiceResource) -> bool:\n key = bucket.Object(path_id)\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Performance issue fetching messages with S3 backend enabled\nThis is a bug introduced in Zulip 4.0: getting URLs for avatar images is very expensive due to this helper function:\r\n\r\n```\r\nIn [10]: t = time.time()\r\n ...: for i in range(1000): x = upload_backend.get_public_upload_url(\"foo\")\r\n ...: print (time.time() - t)\r\n4.389735460281372\r\n```\r\n\r\nThis is a regression introduced in https://github.com/zulip/zulip/commit/5a4aecfc40f6c57324a703b74b0b74dc4df3e652\r\n\r\n@ryanreh99 @mateuszmandera FYI.\r\n\r\nThe right fix is to only call the `boto` library function once to get the URL prefix, and then do the rest with URL manipulations.\r\n\r\nOnce this is fixed, I'll release Zulip 4.4 with the fix, since this is a pretty serious issue.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-misc members, this issue was labeled with the \"area: uploads\" label, so you may want to check it out!\n\n"},"created_at":{"kind":"timestamp","value":"2021-06-19T10:04:10","string":"2021-06-19T10:04:10"}}},{"rowIdx":680,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":19012,"string":"19,012"},"instance_id":{"kind":"string","value":"zulip__zulip-19012"},"issue_numbers":{"kind":"list like","value":["18713"],"string":"[\n \"18713\"\n]"},"base_commit":{"kind":"string","value":"2ac5ba0bf8bb7df03ae986820619f3adf1d1150a"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py\n--- a/zerver/lib/push_notifications.py\n+++ b/zerver/lib/push_notifications.py\n@@ -14,6 +14,7 @@\n from django.db.models import F\n from django.utils.timezone import now as timezone_now\n from django.utils.translation import gettext as _\n+from django.utils.translation import override as override_language\n \n from zerver.decorator import statsd_increment\n from zerver.lib.avatar import absolute_avatar_url\n@@ -629,7 +630,13 @@ def process(elem: lxml.html.HtmlElement) -> str:\n return plain_text\n \n if settings.PUSH_NOTIFICATION_REDACT_CONTENT:\n- return \"***REDACTED***\"\n+ return (\n+ \"*\"\n+ + _(\n+ \"This organization has disabled including message content in mobile push notifications\"\n+ )\n+ + \"*\"\n+ )\n \n elem = lxml.html.fromstring(rendered_content)\n plain_text = process(elem)\n@@ -744,17 +751,18 @@ def get_message_payload_apns(user_profile: UserProfile, message: Message) -> Dic\n )\n \n assert message.rendered_content is not None\n- content, _ = truncate_content(get_mobile_push_content(message.rendered_content))\n- apns_data = {\n- \"alert\": {\n- \"title\": get_apns_alert_title(message),\n- \"subtitle\": get_apns_alert_subtitle(message),\n- \"body\": content,\n- },\n- \"sound\": \"default\",\n- \"badge\": get_apns_badge_count(user_profile),\n- \"custom\": {\"zulip\": zulip_data},\n- }\n+ with override_language(user_profile.default_language):\n+ content, _ = truncate_content(get_mobile_push_content(message.rendered_content))\n+ apns_data = {\n+ \"alert\": {\n+ \"title\": get_apns_alert_title(message),\n+ \"subtitle\": get_apns_alert_subtitle(message),\n+ \"body\": content,\n+ },\n+ \"sound\": \"default\",\n+ \"badge\": get_apns_badge_count(user_profile),\n+ \"custom\": {\"zulip\": zulip_data},\n+ }\n return apns_data\n \n \n@@ -765,17 +773,18 @@ def get_message_payload_gcm(\n \"\"\"A `message` payload + options, for Android via GCM/FCM.\"\"\"\n data = get_message_payload(user_profile, message)\n assert message.rendered_content is not None\n- content, truncated = truncate_content(get_mobile_push_content(message.rendered_content))\n- data.update(\n- event=\"message\",\n- alert=get_gcm_alert(message),\n- zulip_message_id=message.id, # message_id is reserved for CCS\n- time=datetime_to_timestamp(message.date_sent),\n- content=content,\n- content_truncated=truncated,\n- sender_full_name=message.sender.full_name,\n- sender_avatar_url=absolute_avatar_url(message.sender),\n- )\n+ with override_language(user_profile.default_language):\n+ content, truncated = truncate_content(get_mobile_push_content(message.rendered_content))\n+ data.update(\n+ event=\"message\",\n+ alert=get_gcm_alert(message),\n+ zulip_message_id=message.id, # message_id is reserved for CCS\n+ time=datetime_to_timestamp(message.date_sent),\n+ content=content,\n+ content_truncated=truncated,\n+ sender_full_name=message.sender.full_name,\n+ sender_avatar_url=absolute_avatar_url(message.sender),\n+ )\n gcm_options = {\"priority\": \"high\"}\n return data, gcm_options\n \n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py\n--- a/zerver/tests/test_push_notifications.py\n+++ b/zerver/tests/test_push_notifications.py\n@@ -1661,7 +1661,7 @@ def test_get_message_payload_apns_redacted_content(self) -> None:\n \"alert\": {\n \"title\": \"Cordelia, Lear's daughter, King Hamlet, Othello, the Moor of Venice\",\n \"subtitle\": \"King Hamlet:\",\n- \"body\": \"***REDACTED***\",\n+ \"body\": \"*This organization has disabled including message content in mobile push notifications*\",\n },\n \"sound\": \"default\",\n \"badge\": 0,\n@@ -1807,7 +1807,7 @@ def test_get_message_payload_gcm_redacted_content(self) -> None:\n \"alert\": \"New stream message from King Hamlet in Denmark\",\n \"zulip_message_id\": message.id,\n \"time\": datetime_to_timestamp(message.date_sent),\n- \"content\": \"***REDACTED***\",\n+ \"content\": \"*This organization has disabled including message content in mobile push notifications*\",\n \"content_truncated\": False,\n \"server\": settings.EXTERNAL_HOST,\n \"realm_id\": hamlet.realm.id,\n"},"problem_statement":{"kind":"string","value":"internationalization or configuration of ***REDACTED*** message in push notifications\nfor now, redacted message in push notifications does not honour internationalization and also is not configurable. \r\n\r\napparently it's hard-coded string in \r\n\r\n```\r\n# cat zerver/lib/push_notifications.py |grep -C3 REDACTED\r\n return plain_text\r\n\r\n if settings.PUSH_NOTIFICATION_REDACT_CONTENT:\r\n return \"***REDACTED***\"\r\n\r\n elem = lxml.html.fromstring(rendered_content)\r\n plain_text = process(elem)\r\n```\r\n\r\nplease make that string at least configurable via /etc/zulip config files, so non-english speaking users get a better clue what that really means. \r\n\r\nit would also be good to explain, why it's being redacted at all, so i would like to replace that message with something like \"Inhalt aus Datenschutzgründen nicht übermittelt\" (content not transmitted for reason of data protection).\r\n\r\ni'm no native english speaker, but i know english to some degree and even me needed to consult a dictionary to get the proper meaning of this word. dict.cc telling redacted is \"euphemism for: censored\" , and nobody likes censorship....\r\n\r\n\r\n\r\n\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-i18n members, this issue was labeled with the \"area: i18n\" label, so you may want to check it out!\n\n\nYeah, this should just be tagged for translation. I'd also consider just changing the string; I'm not sure \"redacted\" is what I'd choose."},"created_at":{"kind":"timestamp","value":"2021-06-25T19:07:48","string":"2021-06-25T19:07:48"}}},{"rowIdx":681,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":19023,"string":"19,023"},"instance_id":{"kind":"string","value":"zulip__zulip-19023"},"issue_numbers":{"kind":"list like","value":["18778"],"string":"[\n \"18778\"\n]"},"base_commit":{"kind":"string","value":"5e824a6d6da5cb40b8d987f1df19f5f80139fbda"},"patch":{"kind":"string","value":"diff --git a/zerver/views/home.py b/zerver/views/home.py\n--- a/zerver/views/home.py\n+++ b/zerver/views/home.py\n@@ -1,6 +1,6 @@\n import logging\n import secrets\n-from typing import Any, Dict, List, Optional, Tuple\n+from typing import List, Optional, Tuple\n \n from django.conf import settings\n from django.http import HttpRequest, HttpResponse, HttpResponseRedirect\n@@ -99,17 +99,6 @@ def update_last_reminder(user_profile: Optional[UserProfile]) -> None:\n user_profile.save(update_fields=[\"last_reminder\"])\n \n \n-def compute_navbar_logo_url(page_params: Dict[str, Any]) -> str:\n- if (\n- page_params[\"color_scheme\"] == 2\n- and page_params[\"realm_night_logo_source\"] != Realm.LOGO_DEFAULT\n- ):\n- navbar_logo_url = page_params[\"realm_night_logo_url\"]\n- else:\n- navbar_logo_url = page_params[\"realm_logo_url\"]\n- return navbar_logo_url\n-\n-\n def home(request: HttpRequest) -> HttpResponse:\n if not settings.ROOT_DOMAIN_LANDING_PAGE:\n return home_real(request)\n@@ -209,8 +198,6 @@ def home_real(request: HttpRequest) -> HttpResponse:\n \n user_permission_info = get_user_permission_info(user_profile)\n \n- navbar_logo_url = compute_navbar_logo_url(page_params)\n-\n response = render(\n request,\n \"zerver/app/index.html\",\n@@ -225,7 +212,6 @@ def home_real(request: HttpRequest) -> HttpResponse:\n \"is_admin\": user_permission_info.is_realm_admin,\n \"is_guest\": user_permission_info.is_guest,\n \"color_scheme\": user_permission_info.color_scheme,\n- \"navbar_logo_url\": navbar_logo_url,\n \"embedded\": narrow_stream is not None,\n \"max_file_upload_size_mib\": settings.MAX_FILE_UPLOAD_SIZE,\n },\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py\n--- a/zerver/tests/test_home.py\n+++ b/zerver/tests/test_home.py\n@@ -11,14 +11,8 @@\n from django.utils.timezone import now as timezone_now\n \n from corporate.models import Customer, CustomerPlan\n-from zerver.lib.actions import (\n- change_user_is_active,\n- do_change_logo_source,\n- do_change_plan_type,\n- do_create_user,\n-)\n+from zerver.lib.actions import change_user_is_active, do_change_plan_type, do_create_user\n from zerver.lib.compatibility import LAST_SERVER_UPGRADE_TIME, is_outdated_server\n-from zerver.lib.events import add_realm_logo_fields\n from zerver.lib.home import (\n get_billing_info,\n get_furthest_read_time,\n@@ -39,7 +33,6 @@\n get_system_bot,\n get_user,\n )\n-from zerver.views.home import compute_navbar_logo_url\n from zerver.worker.queue_processors import UserActivityWorker\n \n logger_string = \"zulip.soft_deactivation\"\n@@ -860,73 +853,6 @@ def test_desktop_home(self) -> None:\n path = urllib.parse.urlparse(result[\"Location\"]).path\n self.assertEqual(path, \"/\")\n \n- def test_compute_navbar_logo_url(self) -> None:\n- user_profile = self.example_user(\"hamlet\")\n-\n- page_params = {\"color_scheme\": user_profile.COLOR_SCHEME_NIGHT}\n- add_realm_logo_fields(page_params, user_profile.realm)\n- self.assertEqual(\n- compute_navbar_logo_url(page_params), \"/static/images/logo/zulip-org-logo.svg?version=0\"\n- )\n-\n- page_params = {\"color_scheme\": user_profile.COLOR_SCHEME_LIGHT}\n- add_realm_logo_fields(page_params, user_profile.realm)\n- self.assertEqual(\n- compute_navbar_logo_url(page_params), \"/static/images/logo/zulip-org-logo.svg?version=0\"\n- )\n-\n- do_change_logo_source(\n- user_profile.realm, Realm.LOGO_UPLOADED, night=False, acting_user=user_profile\n- )\n- page_params = {\"color_scheme\": user_profile.COLOR_SCHEME_NIGHT}\n- add_realm_logo_fields(page_params, user_profile.realm)\n- self.assertEqual(\n- compute_navbar_logo_url(page_params),\n- f\"/user_avatars/{user_profile.realm_id}/realm/logo.png?version=2\",\n- )\n-\n- page_params = {\"color_scheme\": user_profile.COLOR_SCHEME_LIGHT}\n- add_realm_logo_fields(page_params, user_profile.realm)\n- self.assertEqual(\n- compute_navbar_logo_url(page_params),\n- f\"/user_avatars/{user_profile.realm_id}/realm/logo.png?version=2\",\n- )\n-\n- do_change_logo_source(\n- user_profile.realm, Realm.LOGO_UPLOADED, night=True, acting_user=user_profile\n- )\n- page_params = {\"color_scheme\": user_profile.COLOR_SCHEME_NIGHT}\n- add_realm_logo_fields(page_params, user_profile.realm)\n- self.assertEqual(\n- compute_navbar_logo_url(page_params),\n- f\"/user_avatars/{user_profile.realm_id}/realm/night_logo.png?version=2\",\n- )\n-\n- page_params = {\"color_scheme\": user_profile.COLOR_SCHEME_LIGHT}\n- add_realm_logo_fields(page_params, user_profile.realm)\n- self.assertEqual(\n- compute_navbar_logo_url(page_params),\n- f\"/user_avatars/{user_profile.realm_id}/realm/logo.png?version=2\",\n- )\n-\n- # This configuration isn't super supported in the UI and is a\n- # weird choice, but we have a test for it anyway.\n- do_change_logo_source(\n- user_profile.realm, Realm.LOGO_DEFAULT, night=False, acting_user=user_profile\n- )\n- page_params = {\"color_scheme\": user_profile.COLOR_SCHEME_NIGHT}\n- add_realm_logo_fields(page_params, user_profile.realm)\n- self.assertEqual(\n- compute_navbar_logo_url(page_params),\n- f\"/user_avatars/{user_profile.realm_id}/realm/night_logo.png?version=2\",\n- )\n-\n- page_params = {\"color_scheme\": user_profile.COLOR_SCHEME_LIGHT}\n- add_realm_logo_fields(page_params, user_profile.realm)\n- self.assertEqual(\n- compute_navbar_logo_url(page_params), \"/static/images/logo/zulip-org-logo.svg?version=0\"\n- )\n-\n @override_settings(SERVER_UPGRADE_NAG_DEADLINE_DAYS=365)\n def test_is_outdated_server(self) -> None:\n # Check when server_upgrade_nag_deadline > last_server_upgrade_time\n"},"problem_statement":{"kind":"string","value":"Wrong Organization Logo in Automatic color scheme\nI have two separate Organization Logos configured for day mode and night mode. When I select in my settings color scheme \"automatic\", on page load always the organization logo for day mode is selected although the rest of the page is in night mode. When I go to settings and select day mode or night mode, the logo is changed to the correct one. When I change color scheme back to \"automatic\", also the correct logo is shown, until the page is reloaded with CMD+R (in browser or macOS app) or when restarting the macOS app.\r\n\r\nThis bug occurs in the macOS app, as well as all tested browsers: Safari, Brave (Chromium), Firefox, Google Chrome. All browsers are updated to their latest stable release version.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-settings members, this issue was labeled with the \"area: settings (admin/org)\", \"area: settings UI\" labels, so you may want to check it out!\n\n\n@Lumrenion thanks for the report!\r\n\r\n@sahil839 can you reproduce this? It seems like a very plausible bug, and probably has an easy fix.\nYes I can reproduce. The bug here is that we pass the url directly from backend considering only day and night mode, and for we can check the browser's color scheme in the frontend only, so I think the correct fix is to decide the correct logo url in frontend. \n@zulipbot claim"},"created_at":{"kind":"timestamp","value":"2021-06-27T11:31:59","string":"2021-06-27T11:31:59"}}},{"rowIdx":682,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":19038,"string":"19,038"},"instance_id":{"kind":"string","value":"zulip__zulip-19038"},"issue_numbers":{"kind":"list like","value":["18848"],"string":"[\n \"18848\"\n]"},"base_commit":{"kind":"string","value":"5f74e78beeac0a101c7998a669b2fb93cacfb759"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/markdown/help_relative_links.py b/zerver/lib/markdown/help_relative_links.py\n--- a/zerver/lib/markdown/help_relative_links.py\n+++ b/zerver/lib/markdown/help_relative_links.py\n@@ -17,7 +17,7 @@\n # name is what the item is called in the gear menu: `Select **name**.`\n # link is used for relative links: `Select [name](link).`\n \"manage-streams\": [\"Manage streams\", \"/#streams/subscribed\"],\n- \"settings\": [\"Settings\", \"/#settings/your-account\"],\n+ \"settings\": [\"Settings\", \"/#settings/profile\"],\n \"manage-organization\": [\"Manage organization\", \"/#organization/organization-profile\"],\n \"integrations\": [\"Integrations\", \"/integrations\"],\n \"stats\": [\"Usage statistics\", \"/stats\"],\ndiff --git a/zerver/lib/markdown/help_settings_links.py b/zerver/lib/markdown/help_settings_links.py\n--- a/zerver/lib/markdown/help_settings_links.py\n+++ b/zerver/lib/markdown/help_settings_links.py\n@@ -16,7 +16,8 @@\n # breadcrumb to that setting to the name of its setting type, the setting\n # name as it appears in the user interface, and a relative link that can\n # be used to get to that setting\n- \"your-account\": [\"Settings\", \"Your account\", \"/#settings/your-account\"],\n+ \"profile\": [\"Settings\", \"Profile\", \"/#settings/profile\"],\n+ \"account-and-privacy\": [\"Settings\", \"Account & privacy\", \"/#settings/account-and-privacy\"],\n \"display-settings\": [\"Settings\", \"Display settings\", \"/#settings/display-settings\"],\n \"notifications\": [\"Settings\", \"Notifications\", \"/#settings/notifications\"],\n \"your-bots\": [\"Settings\", \"Your bots\", \"/#settings/your-bots\"],\n"},"test_patch":{"kind":"string","value":"diff --git a/frontend_tests/node_tests/browser_history.js b/frontend_tests/node_tests/browser_history.js\n--- a/frontend_tests/node_tests/browser_history.js\n+++ b/frontend_tests/node_tests/browser_history.js\n@@ -22,7 +22,7 @@ function test(label, f) {\n }\n \n test(\"basics\", () => {\n- const hash1 = \"#settings/your-account\";\n+ const hash1 = \"#settings/profile\";\n const hash2 = \"#narrow/is/private\";\n browser_history.go_to_location(hash1);\n assert.equal(location.hash, hash1);\ndiff --git a/frontend_tests/node_tests/hash_util.js b/frontend_tests/node_tests/hash_util.js\n--- a/frontend_tests/node_tests/hash_util.js\n+++ b/frontend_tests/node_tests/hash_util.js\n@@ -86,26 +86,26 @@ run_test(\"test_get_hash_category\", () => {\n assert.deepEqual(hash_util.get_hash_category(\"#drafts\"), \"drafts\");\n assert.deepEqual(hash_util.get_hash_category(\"invites\"), \"invites\");\n \n- location.hash = \"#settings/your-account\";\n+ location.hash = \"#settings/profile\";\n assert.deepEqual(hash_util.get_current_hash_category(), \"settings\");\n });\n \n run_test(\"test_get_hash_section\", () => {\n assert.equal(hash_util.get_hash_section(\"streams/subscribed\"), \"subscribed\");\n- assert.equal(hash_util.get_hash_section(\"#settings/your-account\"), \"your-account\");\n+ assert.equal(hash_util.get_hash_section(\"#settings/profile\"), \"profile\");\n \n assert.equal(hash_util.get_hash_section(\"settings/10/general/\"), \"10\");\n \n assert.equal(hash_util.get_hash_section(\"#drafts\"), \"\");\n assert.equal(hash_util.get_hash_section(\"\"), \"\");\n \n- location.hash = \"#settings/your-account\";\n- assert.deepEqual(hash_util.get_current_hash_section(), \"your-account\");\n+ location.hash = \"#settings/profile\";\n+ assert.deepEqual(hash_util.get_current_hash_section(), \"profile\");\n });\n \n run_test(\"build_reload_url\", () => {\n- location.hash = \"#settings/your-account\";\n- assert.equal(hash_util.build_reload_url(), \"+oldhash=settings%2Fyour-account\");\n+ location.hash = \"#settings/profile\";\n+ assert.equal(hash_util.build_reload_url(), \"+oldhash=settings%2Fprofile\");\n \n location.hash = \"#test\";\n assert.equal(hash_util.build_reload_url(), \"+oldhash=test\");\ndiff --git a/frontend_tests/puppeteer_tests/settings.ts b/frontend_tests/puppeteer_tests/settings.ts\n--- a/frontend_tests/puppeteer_tests/settings.ts\n+++ b/frontend_tests/puppeteer_tests/settings.ts\n@@ -27,7 +27,7 @@ async function open_settings(page: Page): Promise {\n await page.waitForSelector(settings_selector, {visible: true});\n await page.click(settings_selector);\n \n- await page.waitForSelector(\"#settings_content .account-settings-form\", {visible: true});\n+ await page.waitForSelector(\"#settings_content .profile-settings-form\", {visible: true});\n const page_url = await common.page_url_with_fragment(page);\n assert.ok(\n page_url.includes(\"/#settings/\"),\n@@ -36,23 +36,18 @@ async function open_settings(page: Page): Promise {\n }\n \n async function test_change_full_name(page: Page): Promise {\n- await page.click(\"#change_full_name\");\n-\n- const change_full_name_button_selector = \"#change_full_name_button\";\n- await page.waitForSelector(change_full_name_button_selector, {visible: true});\n+ await page.click(\"#full_name\");\n \n const full_name_input_selector = 'input[name=\"full_name\"]';\n- await page.$eval(full_name_input_selector, (el) => {\n- (el as HTMLInputElement).value = \"\";\n- });\n- await page.waitForFunction(() => $(\":focus\").attr(\"id\") === \"change_full_name_modal\");\n- await page.type(full_name_input_selector, \"New name\");\n- await page.click(change_full_name_button_selector);\n- await page.waitForFunction(() => $(\"#change_full_name\").text().trim() === \"New name\");\n- await common.wait_for_modal_to_close(page);\n+ await common.clear_and_type(page, full_name_input_selector, \"New name\");\n+\n+ await page.click(\"#settings_content .profile-settings-form\");\n+ await page.waitForSelector(\".full-name-change-form .alert-success\", {visible: true});\n+ await page.waitForFunction(() => $(\"#full_name\").val() === \"New name\");\n }\n \n async function test_change_password(page: Page): Promise {\n+ await page.click('[data-section=\"account-and-privacy\"]');\n await page.click(\"#change_password\");\n \n const change_password_button_selector = \"#change_password_button\";\ndiff --git a/zerver/tests/test_middleware.py b/zerver/tests/test_middleware.py\n--- a/zerver/tests/test_middleware.py\n+++ b/zerver/tests/test_middleware.py\n@@ -98,7 +98,7 @@ def test_admonition_and_link(self) -> None:\n )\n \n def test_settings_tab(self) -> None:\n- # deactivate-your-account starts with {settings_tab|your-account}\n+ # deactivate-your-account starts with {settings_tab|account-and-privacy}\n self.check_title_and_description(\n \"/help/deactivate-your-account\",\n \"Deactivate your account (Zulip Help Center)\",\n"},"problem_statement":{"kind":"string","value":"Add \"Privacy and security\" section to personal Settings menu \nSome personal settings are hard to find right now, and some settings pages have too many different kinds of settings. We should make the settings easier to navigate by splitting \"Your account\" into two sections:\r\n\r\n1. **Profile** (1st on the list). We can try removing all the section headers and see if it's OK or confusing.\r\nSettings (in order): Full name, Profile picture, \"Deactivate account\" button, everything currently under **Your account > Profile** (custom fields).\r\n\r\nI'm not entirely sure about the \"Deactivate account\" button placement; we can play with it.\r\n\r\n2. **Privacy and security** (2nd on the list) \r\nSettings (in order):\r\n a. **User settings**: Email, password, role\r\n b. **Presence** (currently under **Notifications**)\r\n c. **API key**\r\n\r\n\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-settings members, this issue was labeled with the \"area: settings (user)\" label, so you may want to check it out!\n\n\n@zulipbot claim"},"created_at":{"kind":"timestamp","value":"2021-06-28T14:22:00","string":"2021-06-28T14:22:00"}}},{"rowIdx":683,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":19155,"string":"19,155"},"instance_id":{"kind":"string","value":"zulip__zulip-19155"},"issue_numbers":{"kind":"list like","value":["19141"],"string":"[\n \"19141\"\n]"},"base_commit":{"kind":"string","value":"5872af340ff69a904cc30efaf4115e83e6afd97c"},"patch":{"kind":"string","value":"diff --git a/zerver/views/muting.py b/zerver/views/muting.py\n--- a/zerver/views/muting.py\n+++ b/zerver/views/muting.py\n@@ -94,7 +94,9 @@ def mute_user(request: HttpRequest, user_profile: UserProfile, muted_user_id: in\n if user_profile.id == muted_user_id:\n raise JsonableError(_(\"Cannot mute self\"))\n \n- muted_user = access_user_by_id(user_profile, muted_user_id, allow_bots=False, for_admin=False)\n+ muted_user = access_user_by_id(\n+ user_profile, muted_user_id, allow_bots=False, allow_deactivated=True, for_admin=False\n+ )\n date_muted = timezone_now()\n \n if get_mute_object(user_profile, muted_user) is not None:\n@@ -107,7 +109,9 @@ def mute_user(request: HttpRequest, user_profile: UserProfile, muted_user_id: in\n def unmute_user(\n request: HttpRequest, user_profile: UserProfile, muted_user_id: int\n ) -> HttpResponse:\n- muted_user = access_user_by_id(user_profile, muted_user_id, allow_bots=False, for_admin=False)\n+ muted_user = access_user_by_id(\n+ user_profile, muted_user_id, allow_bots=False, allow_deactivated=True, for_admin=False\n+ )\n mute_object = get_mute_object(user_profile, muted_user)\n \n if mute_object is None:\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_muting_users.py b/zerver/tests/test_muting_users.py\n--- a/zerver/tests/test_muting_users.py\n+++ b/zerver/tests/test_muting_users.py\n@@ -3,6 +3,7 @@\n \n import orjson\n \n+from zerver.lib.actions import do_deactivate_user\n from zerver.lib.cache import cache_get, get_muting_users_cache_key\n from zerver.lib.test_classes import ZulipTestCase\n from zerver.lib.timestamp import datetime_to_timestamp\n@@ -76,12 +77,15 @@ def test_add_muted_user_mute_twice(self) -> None:\n result = self.api_post(hamlet, url)\n self.assert_json_error(result, \"User already muted\")\n \n- def test_add_muted_user_valid_data(self) -> None:\n+ def _test_add_muted_user_valid_data(self, deactivate_user: bool = False) -> None:\n hamlet = self.example_user(\"hamlet\")\n self.login_user(hamlet)\n cordelia = self.example_user(\"cordelia\")\n mute_time = datetime(2021, 1, 1, tzinfo=timezone.utc)\n \n+ if deactivate_user:\n+ do_deactivate_user(cordelia, acting_user=None)\n+\n with mock.patch(\"zerver.views.muting.timezone_now\", return_value=mute_time):\n url = \"/api/v1/users/me/muted_users/{}\".format(cordelia.id)\n result = self.api_post(hamlet, url)\n@@ -112,6 +116,12 @@ def test_add_muted_user_valid_data(self) -> None:\n ),\n )\n \n+ def test_add_muted_user_valid_data(self) -> None:\n+ self._test_add_muted_user_valid_data()\n+\n+ def test_add_muted_user_deactivated_user(self) -> None:\n+ self._test_add_muted_user_valid_data(deactivate_user=True)\n+\n def test_remove_muted_user_unmute_before_muting(self) -> None:\n hamlet = self.example_user(\"hamlet\")\n self.login_user(hamlet)\n@@ -121,12 +131,15 @@ def test_remove_muted_user_unmute_before_muting(self) -> None:\n result = self.api_delete(hamlet, url)\n self.assert_json_error(result, \"User is not muted\")\n \n- def test_remove_muted_user_valid_data(self) -> None:\n+ def _test_remove_muted_user_valid_data(self, deactivate_user: bool = False) -> None:\n hamlet = self.example_user(\"hamlet\")\n self.login_user(hamlet)\n cordelia = self.example_user(\"cordelia\")\n mute_time = datetime(2021, 1, 1, tzinfo=timezone.utc)\n \n+ if deactivate_user:\n+ do_deactivate_user(cordelia, acting_user=None)\n+\n with mock.patch(\"zerver.views.muting.timezone_now\", return_value=mute_time):\n url = \"/api/v1/users/me/muted_users/{}\".format(cordelia.id)\n result = self.api_post(hamlet, url)\n@@ -163,6 +176,12 @@ def test_remove_muted_user_valid_data(self) -> None:\n ),\n )\n \n+ def test_remove_muted_user_valid_data(self) -> None:\n+ self._test_remove_muted_user_valid_data()\n+\n+ def test_remove_muted_user_deactivated_user(self) -> None:\n+ self._test_remove_muted_user_valid_data(deactivate_user=True)\n+\n def test_get_muting_users(self) -> None:\n hamlet = self.example_user(\"hamlet\")\n self.login_user(hamlet)\n"},"problem_statement":{"kind":"string","value":"Make muting work for deactivated users\nEven after a user deactivated, it may be helpful to hide that user's messages, avatar, etc. We should therefore make it possible to mute deactivated users.\r\n\r\nThis will also fix a bug where if a user tries to mute a deactivated user, the action silently fails.\n"},"hints_text":{"kind":"string","value":""},"created_at":{"kind":"timestamp","value":"2021-07-07T17:17:54","string":"2021-07-07T17:17:54"}}},{"rowIdx":684,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":19392,"string":"19,392"},"instance_id":{"kind":"string","value":"zulip__zulip-19392"},"issue_numbers":{"kind":"list like","value":["15331"],"string":"[\n \"15331\"\n]"},"base_commit":{"kind":"string","value":"cb998f7147842a38c33ee0418255948e4d1a7821"},"patch":{"kind":"string","value":"diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.py\n--- a/zilencer/management/commands/populate_db.py\n+++ b/zilencer/management/commands/populate_db.py\n@@ -118,10 +118,6 @@ def clear_database() -> None:\n Session.objects.all().delete()\n \n \n-# Suppress spammy output from the push notifications logger\n-push_notifications_logger.disabled = True\n-\n-\n def subscribe_users_to_streams(realm: Realm, stream_dict: Dict[str, Dict[str, Any]]) -> None:\n subscriptions_to_add = []\n event_time = timezone_now()\n@@ -273,6 +269,9 @@ def add_arguments(self, parser: CommandParser) -> None:\n )\n \n def handle(self, **options: Any) -> None:\n+ # Suppress spammy output from the push notifications logger\n+ push_notifications_logger.disabled = True\n+\n if options[\"percent_huddles\"] + options[\"percent_personals\"] > 100:\n self.stderr.write(\"Error! More than 100% of messages allocated.\\n\")\n return\n@@ -899,6 +898,8 @@ def handle(self, **options: Any) -> None:\n mark_all_messages_as_read()\n self.stdout.write(\"Successfully populated test database.\\n\")\n \n+ push_notifications_logger.disabled = False\n+\n \n def mark_all_messages_as_read() -> None:\n \"\"\"\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py\n--- a/zerver/lib/test_classes.py\n+++ b/zerver/lib/test_classes.py\n@@ -1104,7 +1104,9 @@ def simulated_markdown_failure(self) -> Iterator[None]:\n \"\"\"\n with self.settings(ERROR_BOT=None), mock.patch(\n \"zerver.lib.markdown.timeout\", side_effect=subprocess.CalledProcessError(1, [])\n- ), mock.patch(\"zerver.lib.markdown.markdown_logger\"):\n+ ), self.assertLogs(\n+ level=\"ERROR\"\n+ ): # For markdown_logger.exception\n yield\n \n def create_default_device(\ndiff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py\n--- a/zerver/tests/test_decorators.py\n+++ b/zerver/tests/test_decorators.py\n@@ -475,11 +475,11 @@ def my_webhook_raises_exception(request: HttpRequest, user_profile: UserProfile)\n request.body = b\"{}\"\n request.content_type = \"text/plain\"\n \n- with mock.patch(\"zerver.decorator.webhook_logger.exception\") as mock_exception:\n+ with self.assertLogs(\"zulip.zerver.webhooks\") as logger:\n with self.assertRaisesRegex(Exception, \"raised by webhook function\"):\n my_webhook_raises_exception(request)\n \n- mock_exception.assert_called_with(\"raised by webhook function\", stack_info=True)\n+ self.assertIn(\"raised by webhook function\", logger.output[0])\n \n def test_authenticated_rest_api_view_logging_unsupported_event(self) -> None:\n @authenticated_rest_api_view(webhook_client_name=\"ClientName\")\ndiff --git a/zerver/tests/test_middleware.py b/zerver/tests/test_middleware.py\n--- a/zerver/tests/test_middleware.py\n+++ b/zerver/tests/test_middleware.py\n@@ -35,9 +35,11 @@ def test_is_slow_query(self) -> None:\n \n def test_slow_query_log(self) -> None:\n self.log_data[\"time_started\"] = time.time() - self.SLOW_QUERY_TIME\n- with patch(\"zerver.middleware.slow_query_logger\") as mock_slow_query_logger, patch(\n- \"zerver.middleware.logger\"\n- ) as mock_normal_logger:\n+ with self.assertLogs(\n+ \"zulip.slow_queries\", level=\"INFO\"\n+ ) as slow_query_logger, self.assertLogs(\n+ \"zulip.requests\", level=\"INFO\"\n+ ) as middleware_normal_logger:\n \n write_log_line(\n self.log_data,\n@@ -47,12 +49,11 @@ def test_slow_query_log(self) -> None:\n requestor_for_logs=\"unknown\",\n client_name=\"?\",\n )\n- mock_slow_query_logger.info.assert_called_once()\n- mock_normal_logger.info.assert_called_once()\n+ self.assert_length(middleware_normal_logger.output, 1)\n+ self.assert_length(slow_query_logger.output, 1)\n \n- logged_line = mock_slow_query_logger.info.call_args_list[0][0][0]\n self.assertRegex(\n- logged_line,\n+ slow_query_logger.output[0],\n r\"123\\.456\\.789\\.012 GET 200 10\\.\\ds .* \\(unknown via \\?\\)\",\n )\n \ndiff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py\n--- a/zerver/tests/test_push_notifications.py\n+++ b/zerver/tests/test_push_notifications.py\n@@ -8,7 +8,6 @@\n from contextlib import contextmanager\n from typing import Any, Dict, Iterator, List, Optional, Tuple\n from unittest import mock, skipUnless\n-from unittest.mock import call\n from urllib import parse\n \n import orjson\n@@ -825,11 +824,9 @@ def test_end_to_end(self) -> None:\n }\n with mock.patch(\n \"zerver.lib.push_notifications.gcm_client\"\n- ) as mock_gcm, self.mock_apns() as mock_apns, mock.patch(\n- \"zerver.lib.push_notifications.logger.info\"\n- ) as mock_info, mock.patch(\n- \"zerver.lib.push_notifications.logger.warning\"\n- ):\n+ ) as mock_gcm, self.mock_apns() as mock_apns, self.assertLogs(\n+ \"zerver.lib.push_notifications\", level=\"INFO\"\n+ ) as logger:\n apns_devices = [\n (b64_to_hex(device.token), device.ios_app_id, device.token)\n for device in RemotePushDeviceToken.objects.filter(kind=PushDeviceToken.APNS)\n@@ -845,14 +842,15 @@ def test_end_to_end(self) -> None:\n mock_apns.send_notification.return_value.set_result(result)\n handle_push_notification(self.user_profile.id, missed_message)\n for _, _, token in apns_devices:\n- mock_info.assert_any_call(\n- \"APNs: Success sending for user %d to device %s\", self.user_profile.id, token\n+ self.assertIn(\n+ \"INFO:zerver.lib.push_notifications:\"\n+ f\"APNs: Success sending for user {self.user_profile.id} to device {token}\",\n+ logger.output,\n )\n for _, _, token in gcm_devices:\n- mock_info.assert_any_call(\n- \"GCM: Sent %s as %s\",\n- token,\n- message.id,\n+ self.assertIn(\n+ \"INFO:zerver.lib.push_notifications:\" f\"GCM: Sent {token} as {message.id}\",\n+ logger.output,\n )\n \n @override_settings(PUSH_NOTIFICATION_BOUNCER_URL=\"https://push.zulip.org.example.com\")\n@@ -874,11 +872,9 @@ def test_unregistered_client(self) -> None:\n }\n with mock.patch(\n \"zerver.lib.push_notifications.gcm_client\"\n- ) as mock_gcm, self.mock_apns() as mock_apns, mock.patch(\n- \"zerver.lib.push_notifications.logger.info\"\n- ) as mock_info, mock.patch(\n- \"zerver.lib.push_notifications.logger.warning\"\n- ):\n+ ) as mock_gcm, self.mock_apns() as mock_apns, self.assertLogs(\n+ \"zerver.lib.push_notifications\", level=\"INFO\"\n+ ) as logger:\n apns_devices = [\n (b64_to_hex(device.token), device.ios_app_id, device.token)\n for device in RemotePushDeviceToken.objects.filter(kind=PushDeviceToken.APNS)\n@@ -895,10 +891,10 @@ def test_unregistered_client(self) -> None:\n mock_apns.send_notification.return_value.set_result(result)\n handle_push_notification(self.user_profile.id, missed_message)\n for _, _, token in apns_devices:\n- mock_info.assert_any_call(\n- \"APNs: Removing invalid/expired token %s (%s)\",\n- token,\n- \"Unregistered\",\n+ self.assertIn(\n+ \"INFO:zerver.lib.push_notifications:\"\n+ f\"APNs: Removing invalid/expired token {token} (Unregistered)\",\n+ logger.output,\n )\n self.assertEqual(\n RemotePushDeviceToken.objects.filter(kind=PushDeviceToken.APNS).count(), 0\n@@ -1217,15 +1213,15 @@ def test_user_message_does_not_exist(self) -> None:\n sender = self.example_user(\"iago\")\n message_id = self.send_stream_message(sender, \"public_stream\", \"test\")\n missed_message = {\"message_id\": message_id}\n- with mock.patch(\"zerver.lib.push_notifications.logger.error\") as mock_logger, mock.patch(\n+ with self.assertLogs(\"zerver.lib.push_notifications\", level=\"ERROR\") as logger, mock.patch(\n \"zerver.lib.push_notifications.push_notifications_enabled\", return_value=True\n ) as mock_push_notifications:\n handle_push_notification(self.user_profile.id, missed_message)\n- mock_logger.assert_called_with(\n- \"Could not find UserMessage with message_id %s and user_id %s\",\n- message_id,\n- self.user_profile.id,\n- exc_info=True,\n+ self.assertEqual(\n+ \"ERROR:zerver.lib.push_notifications:\"\n+ f\"Could not find UserMessage with message_id {message_id} and user_id {self.user_profile.id}\"\n+ \"\\nNoneType: None\", # This is an effect of using `exc_info=True` in the actual logger.\n+ logger.output[0],\n )\n mock_push_notifications.assert_called_once()\n \n@@ -1338,49 +1334,53 @@ def test_get_apns_context(self) -> None:\n \n def test_not_configured(self) -> None:\n self.setup_apns_tokens()\n- with mock.patch(\"zerver.lib.push_notifications.get_apns_context\") as mock_get, mock.patch(\n- \"zerver.lib.push_notifications.logger\"\n- ) as mock_logging:\n+ with mock.patch(\n+ \"zerver.lib.push_notifications.get_apns_context\"\n+ ) as mock_get, self.assertLogs(\"zerver.lib.push_notifications\", level=\"DEBUG\") as logger:\n mock_get.return_value = None\n self.send()\n- mock_logging.debug.assert_called_once_with(\n+ notification_drop_log = (\n+ \"DEBUG:zerver.lib.push_notifications:\"\n \"APNs: Dropping a notification because nothing configured. \"\n \"Set PUSH_NOTIFICATION_BOUNCER_URL (or APNS_CERT_FILE).\"\n )\n- mock_logging.warning.assert_not_called()\n+\n from zerver.lib.push_notifications import initialize_push_notifications\n \n initialize_push_notifications()\n- mock_logging.warning.assert_called_once_with(\n+ mobile_notifications_not_configured_log = (\n+ \"WARNING:zerver.lib.push_notifications:\"\n \"Mobile push notifications are not configured.\\n \"\n \"See https://zulip.readthedocs.io/en/latest/production/mobile-push-notifications.html\"\n )\n \n+ self.assertEqual(\n+ [notification_drop_log, mobile_notifications_not_configured_log], logger.output\n+ )\n+\n def test_success(self) -> None:\n self.setup_apns_tokens()\n- with self.mock_apns() as mock_apns, mock.patch(\n- \"zerver.lib.push_notifications.logger\"\n- ) as mock_logging:\n+ with self.mock_apns() as mock_apns, self.assertLogs(\n+ \"zerver.lib.push_notifications\", level=\"INFO\"\n+ ) as logger:\n result = mock.Mock()\n result.is_successful = True\n mock_apns.send_notification.return_value = asyncio.Future()\n mock_apns.send_notification.return_value.set_result(result)\n self.send()\n- mock_logging.warning.assert_not_called()\n for device in self.devices():\n- mock_logging.info.assert_any_call(\n- \"APNs: Success sending for user %d to device %s\",\n- self.user_profile.id,\n- device.token,\n+ self.assertIn(\n+ f\"INFO:zerver.lib.push_notifications:APNs: Success sending for user {self.user_profile.id} to device {device.token}\",\n+ logger.output,\n )\n \n def test_http_retry(self) -> None:\n import aioapns\n \n self.setup_apns_tokens()\n- with self.mock_apns() as mock_apns, mock.patch(\n- \"zerver.lib.push_notifications.logger\"\n- ) as mock_logging:\n+ with self.mock_apns() as mock_apns, self.assertLogs(\n+ \"zerver.lib.push_notifications\", level=\"INFO\"\n+ ) as logger:\n exception: asyncio.Future[object] = asyncio.Future()\n exception.set_exception(aioapns.exceptions.ConnectionError())\n result = mock.Mock()\n@@ -1391,26 +1391,23 @@ def test_http_retry(self) -> None:\n [exception], itertools.repeat(future)\n )\n self.send()\n- mock_logging.warning.assert_called_once_with(\n- \"APNs: ConnectionError sending for user %d to device %s: %s\",\n- self.user_profile.id,\n- self.devices()[0].token,\n- \"ConnectionError\",\n+ self.assertIn(\n+ f\"WARNING:zerver.lib.push_notifications:APNs: ConnectionError sending for user {self.user_profile.id} to device {self.devices()[0].token}: ConnectionError\",\n+ logger.output,\n )\n for device in self.devices():\n- mock_logging.info.assert_any_call(\n- \"APNs: Success sending for user %d to device %s\",\n- self.user_profile.id,\n- device.token,\n+ self.assertIn(\n+ f\"INFO:zerver.lib.push_notifications:APNs: Success sending for user {self.user_profile.id} to device {device.token}\",\n+ logger.output,\n )\n \n def test_http_retry_closed(self) -> None:\n import aioapns\n \n self.setup_apns_tokens()\n- with self.mock_apns() as mock_apns, mock.patch(\n- \"zerver.lib.push_notifications.logger\"\n- ) as mock_logging:\n+ with self.mock_apns() as mock_apns, self.assertLogs(\n+ \"zerver.lib.push_notifications\", level=\"INFO\"\n+ ) as logger:\n exception: asyncio.Future[object] = asyncio.Future()\n exception.set_exception(aioapns.exceptions.ConnectionClosed())\n result = mock.Mock()\n@@ -1421,39 +1418,40 @@ def test_http_retry_closed(self) -> None:\n [exception], itertools.repeat(future)\n )\n self.send()\n- mock_logging.warning.assert_called_once_with(\n- \"APNs: ConnectionClosed sending for user %d to device %s: %s\",\n- self.user_profile.id,\n- self.devices()[0].token,\n- \"ConnectionClosed\",\n+ self.assertIn(\n+ f\"WARNING:zerver.lib.push_notifications:APNs: ConnectionClosed sending for user {self.user_profile.id} to device {self.devices()[0].token}: ConnectionClosed\",\n+ logger.output,\n )\n for device in self.devices():\n- mock_logging.info.assert_any_call(\n- \"APNs: Success sending for user %d to device %s\",\n- self.user_profile.id,\n- device.token,\n+ self.assertIn(\n+ f\"INFO:zerver.lib.push_notifications:APNs: Success sending for user {self.user_profile.id} to device {device.token}\",\n+ logger.output,\n )\n \n def test_http_retry_eventually_fails(self) -> None:\n import aioapns\n \n self.setup_apns_tokens()\n- with self.mock_apns() as mock_apns, mock.patch(\n- \"zerver.lib.push_notifications.logger\"\n- ) as mock_logging:\n+ with self.mock_apns() as mock_apns, self.assertLogs(\n+ \"zerver.lib.push_notifications\", level=\"INFO\"\n+ ) as logger:\n exception: asyncio.Future[object] = asyncio.Future()\n exception.set_exception(aioapns.exceptions.ConnectionError())\n mock_apns.send_notification.side_effect = iter([exception] * 5)\n \n self.send(devices=self.devices()[0:1])\n- self.assertEqual(mock_logging.warning.call_count, 5)\n- mock_logging.warning.assert_called_with(\n- \"APNs: Failed to send for user %d to device %s: %s\",\n- self.user_profile.id,\n- self.devices()[0].token,\n- \"HTTP error, retries exhausted\",\n+ self.assert_length(\n+ [log_record for log_record in logger.records if log_record.levelname == \"WARNING\"],\n+ 5,\n+ )\n+ self.assertIn(\n+ f\"WARNING:zerver.lib.push_notifications:APNs: Failed to send for user {self.user_profile.id} to device {self.devices()[0].token}: HTTP error, retries exhausted\",\n+ logger.output,\n+ )\n+ self.assert_length(\n+ [log_record for log_record in logger.records if log_record.levelname == \"INFO\"],\n+ 1,\n )\n- self.assertEqual(mock_logging.info.call_count, 1)\n \n def test_modernize_apns_payload(self) -> None:\n payload = {\n@@ -2159,57 +2157,55 @@ def get_gcm_data(self, **kwargs: Any) -> Dict[str, Any]:\n data.update(kwargs)\n return data\n \n- @mock.patch(\"zerver.lib.push_notifications.logger.debug\")\n- def test_gcm_is_none(self, mock_debug: mock.MagicMock, mock_gcm: mock.MagicMock) -> None:\n+ def test_gcm_is_none(self, mock_gcm: mock.MagicMock) -> None:\n mock_gcm.__bool__.return_value = False\n- send_android_push_notification_to_user(self.user_profile, {}, {})\n- mock_debug.assert_called_with(\n- \"Skipping sending a GCM push notification since PUSH_NOTIFICATION_BOUNCER_URL \"\n- \"and ANDROID_GCM_API_KEY are both unset\"\n- )\n+ with self.assertLogs(\"zerver.lib.push_notifications\", level=\"DEBUG\") as logger:\n+ send_android_push_notification_to_user(self.user_profile, {}, {})\n+ self.assertEqual(\n+ \"DEBUG:zerver.lib.push_notifications:\"\n+ \"Skipping sending a GCM push notification since PUSH_NOTIFICATION_BOUNCER_URL \"\n+ \"and ANDROID_GCM_API_KEY are both unset\",\n+ logger.output[0],\n+ )\n \n- @mock.patch(\"zerver.lib.push_notifications.logger.warning\")\n- def test_json_request_raises_ioerror(\n- self, mock_warn: mock.MagicMock, mock_gcm: mock.MagicMock\n- ) -> None:\n+ def test_json_request_raises_ioerror(self, mock_gcm: mock.MagicMock) -> None:\n mock_gcm.json_request.side_effect = IOError(\"error\")\n- send_android_push_notification_to_user(self.user_profile, {}, {})\n- mock_warn.assert_called_with(\"Error while pushing to GCM\", exc_info=True)\n+ with self.assertLogs(\"zerver.lib.push_notifications\", level=\"WARNING\") as logger:\n+ send_android_push_notification_to_user(self.user_profile, {}, {})\n+ self.assertIn(\n+ \"WARNING:zerver.lib.push_notifications:Error while pushing to GCM\\nTraceback \",\n+ logger.output[0],\n+ )\n \n @mock.patch(\"zerver.lib.push_notifications.logger.warning\")\n- @mock.patch(\"zerver.lib.push_notifications.logger.info\")\n- def test_success(\n- self, mock_info: mock.MagicMock, mock_warning: mock.MagicMock, mock_gcm: mock.MagicMock\n- ) -> None:\n+ def test_success(self, mock_warning: mock.MagicMock, mock_gcm: mock.MagicMock) -> None:\n res = {}\n res[\"success\"] = {token: ind for ind, token in enumerate(self.gcm_tokens)}\n mock_gcm.json_request.return_value = res\n \n data = self.get_gcm_data()\n- send_android_push_notification_to_user(self.user_profile, data, {})\n- self.assertEqual(mock_info.call_count, 2)\n- c1 = call(\"GCM: Sent %s as %s\", \"1111\", 0)\n- c2 = call(\"GCM: Sent %s as %s\", \"2222\", 1)\n- mock_info.assert_has_calls([c1, c2], any_order=True)\n+ with self.assertLogs(\"zerver.lib.push_notifications\", level=\"INFO\") as logger:\n+ send_android_push_notification_to_user(self.user_profile, data, {})\n+ self.assert_length(logger.output, 2)\n+ log_msg1 = f\"INFO:zerver.lib.push_notifications:GCM: Sent {1111} as {0}\"\n+ log_msg2 = f\"INFO:zerver.lib.push_notifications:GCM: Sent {2222} as {1}\"\n+ self.assertEqual([log_msg1, log_msg2], logger.output)\n mock_warning.assert_not_called()\n \n- @mock.patch(\"zerver.lib.push_notifications.logger.warning\")\n- def test_canonical_equal(self, mock_warning: mock.MagicMock, mock_gcm: mock.MagicMock) -> None:\n+ def test_canonical_equal(self, mock_gcm: mock.MagicMock) -> None:\n res = {}\n res[\"canonical\"] = {1: 1}\n mock_gcm.json_request.return_value = res\n \n data = self.get_gcm_data()\n- send_android_push_notification_to_user(self.user_profile, data, {})\n- mock_warning.assert_called_once_with(\n- \"GCM: Got canonical ref but it already matches our ID %s!\",\n- 1,\n+ with self.assertLogs(\"zerver.lib.push_notifications\", level=\"WARNING\") as logger:\n+ send_android_push_notification_to_user(self.user_profile, data, {})\n+ self.assertEqual(\n+ f\"WARNING:zerver.lib.push_notifications:GCM: Got canonical ref but it already matches our ID {1}!\",\n+ logger.output[0],\n )\n \n- @mock.patch(\"zerver.lib.push_notifications.logger.warning\")\n- def test_canonical_pushdevice_not_present(\n- self, mock_warning: mock.MagicMock, mock_gcm: mock.MagicMock\n- ) -> None:\n+ def test_canonical_pushdevice_not_present(self, mock_gcm: mock.MagicMock) -> None:\n res = {}\n t1 = hex_to_b64(\"1111\")\n t2 = hex_to_b64(\"3333\")\n@@ -2224,17 +2220,15 @@ def get_count(hex_token: str) -> int:\n self.assertEqual(get_count(\"3333\"), 0)\n \n data = self.get_gcm_data()\n- send_android_push_notification_to_user(self.user_profile, data, {})\n- msg = \"GCM: Got canonical ref %s replacing %s but new ID not registered! Updating.\"\n- mock_warning.assert_called_once_with(msg, t2, t1)\n+ with self.assertLogs(\"zerver.lib.push_notifications\", level=\"WARNING\") as logger:\n+ send_android_push_notification_to_user(self.user_profile, data, {})\n+ msg = f\"WARNING:zerver.lib.push_notifications:GCM: Got canonical ref {t2} replacing {t1} but new ID not registered! Updating.\"\n+ self.assertEqual(msg, logger.output[0])\n \n self.assertEqual(get_count(\"1111\"), 0)\n self.assertEqual(get_count(\"3333\"), 1)\n \n- @mock.patch(\"zerver.lib.push_notifications.logger.info\")\n- def test_canonical_pushdevice_different(\n- self, mock_info: mock.MagicMock, mock_gcm: mock.MagicMock\n- ) -> None:\n+ def test_canonical_pushdevice_different(self, mock_gcm: mock.MagicMock) -> None:\n res = {}\n old_token = hex_to_b64(\"1111\")\n new_token = hex_to_b64(\"2222\")\n@@ -2249,18 +2243,17 @@ def get_count(hex_token: str) -> int:\n self.assertEqual(get_count(\"2222\"), 1)\n \n data = self.get_gcm_data()\n- send_android_push_notification_to_user(self.user_profile, data, {})\n- mock_info.assert_called_once_with(\n- \"GCM: Got canonical ref %s, dropping %s\",\n- new_token,\n- old_token,\n- )\n+ with self.assertLogs(\"zerver.lib.push_notifications\", level=\"INFO\") as logger:\n+ send_android_push_notification_to_user(self.user_profile, data, {})\n+ self.assertEqual(\n+ f\"INFO:zerver.lib.push_notifications:GCM: Got canonical ref {new_token}, dropping {old_token}\",\n+ logger.output[0],\n+ )\n \n self.assertEqual(get_count(\"1111\"), 0)\n self.assertEqual(get_count(\"2222\"), 1)\n \n- @mock.patch(\"zerver.lib.push_notifications.logger.info\")\n- def test_not_registered(self, mock_info: mock.MagicMock, mock_gcm: mock.MagicMock) -> None:\n+ def test_not_registered(self, mock_gcm: mock.MagicMock) -> None:\n res = {}\n token = hex_to_b64(\"1111\")\n res[\"errors\"] = {\"NotRegistered\": [token]}\n@@ -2273,21 +2266,24 @@ def get_count(hex_token: str) -> int:\n self.assertEqual(get_count(\"1111\"), 1)\n \n data = self.get_gcm_data()\n- send_android_push_notification_to_user(self.user_profile, data, {})\n- mock_info.assert_called_once_with(\"GCM: Removing %s\", token)\n+ with self.assertLogs(\"zerver.lib.push_notifications\", level=\"INFO\") as logger:\n+ send_android_push_notification_to_user(self.user_profile, data, {})\n+ self.assertEqual(\n+ f\"INFO:zerver.lib.push_notifications:GCM: Removing {token}\", logger.output[0]\n+ )\n self.assertEqual(get_count(\"1111\"), 0)\n \n- @mock.patch(\"zerver.lib.push_notifications.logger.warning\")\n- def test_failure(self, mock_warn: mock.MagicMock, mock_gcm: mock.MagicMock) -> None:\n+ def test_failure(self, mock_gcm: mock.MagicMock) -> None:\n res = {}\n token = hex_to_b64(\"1111\")\n res[\"errors\"] = {\"Failed\": [token]}\n mock_gcm.json_request.return_value = res\n \n data = self.get_gcm_data()\n- send_android_push_notification_to_user(self.user_profile, data, {})\n- c1 = call(\"GCM: Delivery to %s failed: %s\", token, \"Failed\")\n- mock_warn.assert_has_calls([c1], any_order=True)\n+ with self.assertLogs(\"zerver.lib.push_notifications\", level=\"WARNING\") as logger:\n+ send_android_push_notification_to_user(self.user_profile, data, {})\n+ msg = f\"WARNING:zerver.lib.push_notifications:GCM: Delivery to {token} failed: Failed\"\n+ self.assertEqual(msg, logger.output[0])\n \n \n class TestClearOnRead(ZulipTestCase):\n"},"problem_statement":{"kind":"string","value":"Migrate all backend tests to use `assertLogs`.\nWe currently use `mock.patch` approach to verify log outputs. `assertLogs` is a better option than `mock.patch`.\r\nFor info on `assertLogs`, see https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertLogs\r\n\r\nSeeing how `assertLogs` are used in `test_auth_backends.py`, added in [this commit](https://github.com/zulip/zulip/commit/d30f11888a009dea59711d24696e140d905488c6), might be helpful.\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-testing members, this issue was labeled with the \"area: testing-infrastructure\" label, so you may want to check it out!\n\n\n@zulipbot claim\nWelcome to Zulip, @agupta01! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!\n\nHere's some tips to get you off to a good start:\n* Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.\n* [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.\n\nAs you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.\n\nSee you on the other side (that is, the pull request side)!\nHello @palashcode, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 14 days.\n\nYou can reclaim this issue or claim any other issue by commenting `@zulipbot claim` on that issue.\n\nThanks for your contributions, and hope to see you again soon!\n@zulipbot abandon\n@zulipbot claim\nWelcome to Zulip, @palashcode! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!\n\nHere's some tips to get you off to a good start:\n* Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.\n* [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.\n\nAs you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.\n\nSee you on the other side (that is, the pull request side)!\n@zulipbot claim\n@chdinesh1089 I am using your [https://github.com/zulip/zulip/commit/d30f11888a009dea59711d24696e140d905488c6](url) commit as a reference to replace mock.patch with assertLogs. I made some changes as shown in code below and tested. The test is failing with \"AssertionError: no logs of level WARNING or higher triggered on logging.warning\". Can you please guide me on what I am doing wrong?\r\n\r\n```python\r\n # with mock.patch(\"logging.warning\") as mock_warn:\r\n with self.assertLogs(\"logging.warning\", level='WARNING') as m:\r\n result = self.get_log_into_subdomain(data, force_token='nonsense')\r\n # mock_warn.assert_called_once_with(\"log_into_subdomain: Malformed token given: %s\", \"nonsense\")\r\n self.assertEqual(m.output, [self.logger_output(\"log_into_subdomain: Malformed token given: nonsense\", 'warning')])\r\n self.assertEqual(result.status_code, 400)\r\n```\n`logging.warning` uses root logger, so we do not need to add `\"logging.warning\"` in `assertLogs` as it defaults to root logger as stated [here](https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertLogs).\r\nSo I think it'll work if we remove `\"logging.warning\"` and make it ` with self.assertLogs(\"logging.warning\", level='WARNING') as m:`.\r\n\r\n\r\n\r\n> \"AssertionError: no logs of level WARNING or higher triggered on logging.warning\".\r\n\r\n(From this, we can see that `assertLogs` is looking for a logging call with a logger named `logging.warning`, but our actual call is to the root logger)\r\nThis could help with any confusion you might probably have https://stackoverflow.com/questions/11225846/what-is-the-difference-between-logging-info-and-logging-getlogger-info \n@chdinesh1089 Thanks. Created a PR [https://github.com/zulip/zulip/pull/15708](url). Please have a look. \n@zulipbot claim\nHello @palashcode, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 14 days.\n\nYou can reclaim this issue or claim any other issue by commenting `@zulipbot claim` on that issue.\n\nThanks for your contributions, and hope to see you again soon!\n@zulipbot claim\n**ERROR:** You have already claimed this issue.\nFollowing #15708, we're about 180/250 converted:\r\n```\r\ntabbott@coset:~/zulip$ git grep mock[.]patch | grep log | wc\r\n 69 292 7866\r\ntabbott@coset:~/zulip$ git grep assertLogs | wc\r\n 180 992 19059\r\n```\n@timabbott are all `mock.patch` migrated to `assertLogs`? If not I would like to work on it.\n@shubham00jain are you working on it, because I saw that you have assigned yourself for other issue.\r\n\n@timabbott from your previous comment I think there is still work to be done on this issue, I have gone through some of the previous commits referencing this issue, from which I think I could work on it.\r\nSo I wanted to ask,can I start working on it?\nYeah, go for it!\n@zulipbot claim\nHello @m-e-l-u-h-a-n, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 14 days.\n\nYou can reclaim this issue or claim any other issue by commenting `@zulipbot claim` on that issue.\n\nThanks for your contributions, and hope to see you again soon!\nHello, I would like to work on this feature! Can I claim this?\n@zulipbot claim\nHello @noabenefraim, it looks like someone has already claimed this issue! Since we believe multiple assignments to the same issue may cause some confusion, we encourage you to search for other unclaimed issues to work on. However, you can always reclaim this issue if no one is working on it.\n\nWe look forward to your valuable contributions!\n@zulipbot claim\n@zulipbot abandon\n@zulipbot claim\n@zulipbot claim\nHi, @noabenefraim I am continuing to work on this issue even now, I had made some changes which you can refer in pr #16619 and after getting some more reference from [this comment](https://github.com/zulip/zulip/pull/16619#issuecomment-719064732), I have made more changes to other tests and only 2-3 files are remaining for which I will create a pr soon, so I don't think there would be much to work on it. If you wanted to work on it I would make a pull request with the changes I have made till now. So you may continue over the remaining part, otherwise that may create a confusion on the state of work. I was not able to focus on it as I am having exams these days and they will be over by tomorrow :smiley: .\n@m-e-l-u-h-a-n if you're not currently working on this issue, can I continue from where you've left off?\n@zulipbot claim\nHello @cmunaco, it looks like you've currently claimed 1 issue in this repository. We encourage new contributors to focus their efforts on at most 1 issue at a time, so please complete your work on your other claimed issues before trying to claim this issue again.\n\nWe look forward to your valuable contributions!\n@zulipbot claim\n@zulipbot claim\n@chdinesh1089 \r\nI think this issue should be closed \r\ncan you look into this?\r\ngit grep mock[.]patch | grep log | wc \r\n0 0 0 \r\ngit grep assertLogs | wc\r\n271 1478 26981\nHi @gvarun1,\r\nYou can use `git grep -n patch | grep '\\(logger\\|logging\\)'`. It will output a lot of lines but I think out of those only:\r\n* `zerver/tests/test_push_notifications.py`\r\n* `zerver/webhooks/github/tests.py`\r\nrequire migration although if you need to discuss about others you can ask here or in [chat.zulip.org](https://chat.zulip.org). \r\n\r\nYou can use #16619 and #16818 for reference.\n@m-e-l-u-h-a-n thanks a lot for the references, I will do my best to get my first PR\nYeah, I think @m-e-l-u-h-a-n is right. All the best with your first PR @gvarun1 !\nHello @gvarun1, you claimed this issue to work on it, but this issue and any referenced pull requests haven't been updated for 10 days. Are you still working on this issue?\n\nIf so, please update this issue by leaving a comment on this issue to let me know that you're still working on it. Otherwise, I'll automatically remove you from this issue in 4 days.\n\nIf you've decided to work on something else, simply comment `@zulipbot abandon` so that someone else can claim it and continue from where you left off.\n\nThank you for your valuable contributions to Zulip!\n\n\n@zulipbot abandon\r\nDue to some unexpected emergency, I stopped working\n@zulipbot claim\n@chdinesh1089 Do you need mock.path to be replaced with assertLogs in all the test files?\n@chdinesh1089 Can you help me out here? I just need a start.\n@zulipbot abandon\n@manavdesai27 sorry about the delay. Yes, we want to replace logging mocks(which are done with `mock.patch`) with `assertLogs`. There are only a few as @m-e-l-u-h-a-n [said above](https://github.com/zulip/zulip/issues/15331#issuecomment-862088818).\nIt would be super nice to finish off those last few and close this out, not least of which because this issue has a bunch of cruft on it (100+ comments, etc.) that make it not super great for new folks to work on. @chdinesh1089 @m-e-l-u-h-a-n would either of you be up for finishing this? \nI’ll do it."},"created_at":{"kind":"timestamp","value":"2021-07-26T18:01:52","string":"2021-07-26T18:01:52"}}},{"rowIdx":685,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":19415,"string":"19,415"},"instance_id":{"kind":"string","value":"zulip__zulip-19415"},"issue_numbers":{"kind":"list like","value":["18677"],"string":"[\n \"18677\"\n]"},"base_commit":{"kind":"string","value":"c16d0414797f380c14859fa63454befed113a4d4"},"patch":{"kind":"string","value":"diff --git a/zerver/models.py b/zerver/models.py\n--- a/zerver/models.py\n+++ b/zerver/models.py\n@@ -1716,6 +1716,15 @@ def has_billing_access(self) -> bool:\n def is_realm_owner(self) -> bool:\n return self.role == UserProfile.ROLE_REALM_OWNER\n \n+ @is_realm_owner.setter\n+ def is_realm_owner(self, value: bool) -> None:\n+ if value:\n+ self.role = UserProfile.ROLE_REALM_OWNER\n+ elif self.role == UserProfile.ROLE_REALM_OWNER:\n+ # We need to be careful to not accidentally change\n+ # ROLE_GUEST to ROLE_MEMBER here.\n+ self.role = UserProfile.ROLE_MEMBER\n+\n @property\n def is_guest(self) -> bool:\n return self.role == UserProfile.ROLE_GUEST\n@@ -1733,6 +1742,15 @@ def is_guest(self, value: bool) -> None:\n def is_moderator(self) -> bool:\n return self.role == UserProfile.ROLE_MODERATOR\n \n+ @is_moderator.setter\n+ def is_moderator(self, value: bool) -> None:\n+ if value:\n+ self.role = UserProfile.ROLE_MODERATOR\n+ elif self.role == UserProfile.ROLE_MODERATOR:\n+ # We need to be careful to not accidentally change\n+ # ROLE_GUEST to ROLE_MEMBER here.\n+ self.role = UserProfile.ROLE_MEMBER\n+\n @property\n def is_incoming_webhook(self) -> bool:\n return self.bot_type == UserProfile.INCOMING_WEBHOOK_BOT\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.py\n--- a/zerver/tests/test_users.py\n+++ b/zerver/tests/test_users.py\n@@ -95,6 +95,14 @@ def test_role_setters(self) -> None:\n self.assertEqual(user_profile.is_guest, False)\n self.assertEqual(user_profile.role, UserProfile.ROLE_REALM_ADMINISTRATOR)\n \n+ user_profile.is_realm_owner = False\n+ self.assertEqual(user_profile.is_realm_owner, False)\n+ self.assertEqual(user_profile.role, UserProfile.ROLE_REALM_ADMINISTRATOR)\n+\n+ user_profile.is_moderator = False\n+ self.assertEqual(user_profile.is_moderator, False)\n+ self.assertEqual(user_profile.role, UserProfile.ROLE_REALM_ADMINISTRATOR)\n+\n user_profile.is_realm_admin = False\n self.assertEqual(user_profile.is_realm_admin, False)\n self.assertEqual(user_profile.role, UserProfile.ROLE_MEMBER)\n@@ -111,6 +119,22 @@ def test_role_setters(self) -> None:\n self.assertEqual(user_profile.is_guest, False)\n self.assertEqual(user_profile.role, UserProfile.ROLE_MEMBER)\n \n+ user_profile.is_realm_owner = True\n+ self.assertEqual(user_profile.is_realm_owner, True)\n+ self.assertEqual(user_profile.role, UserProfile.ROLE_REALM_OWNER)\n+\n+ user_profile.is_realm_owner = False\n+ self.assertEqual(user_profile.is_realm_owner, False)\n+ self.assertEqual(user_profile.role, UserProfile.ROLE_MEMBER)\n+\n+ user_profile.is_moderator = True\n+ self.assertEqual(user_profile.is_moderator, True)\n+ self.assertEqual(user_profile.role, UserProfile.ROLE_MODERATOR)\n+\n+ user_profile.is_moderator = False\n+ self.assertEqual(user_profile.is_moderator, False)\n+ self.assertEqual(user_profile.role, UserProfile.ROLE_MEMBER)\n+\n def test_get_admin_users(self) -> None:\n user_profile = self.example_user(\"hamlet\")\n do_change_user_role(user_profile, UserProfile.ROLE_MEMBER, acting_user=None)\n"},"problem_statement":{"kind":"string","value":"Problem with AUTH_LDAP_USER_FLAGS_BY_GROUP on Zulip >= 4.0 \nUpdating Zulip from 3.4 zu 4.2 broke my ldap sync, upon closer investigation I found the cause to be the extended set of roles:\r\nbecause I was using\r\n\r\n```\r\nAUTH_LDAP_USER_FLAGS_BY_GROUP = {\r\n \"is_realm_admin\": \"cn=someGroup,ou=filterGroups,dc=mydomain,dc=com\",\r\n}\r\n```\r\n\r\nI got the message\r\n\r\n```\r\nException: Ldap sync would have deactivated all owners of realm . This is most likely due to a misconfiguration of LDAP settings. Rolling back...\r\nUse the --force option if the mass deactivation is intended.\r\n```\r\n\r\nCommenting out the above config block was not enough, I had to manually promote at least one user to OWNER for the sync to work again because there wasn't any owner.\r\n\r\nThen I tried adjusting my above config snippet from \"is_realm_admin\" to \"is_realm_owner\" - that did not work and completely broke the ldap sync right at the start (`AttributeError: can't set attribute`).\r\n\r\nHow can I get back the feature of having an LDAP group whose members are automatically assigned the highest possible role?\r\nThe [relevant docs](https://zulip.readthedocs.io/en/stable/production/authentication-methods.html#other-fields) are rather spartanic.\r\n\r\n\n"},"hints_text":{"kind":"string","value":"Hello @zulip/server-authentication members, this issue was labeled with the \"area: authentication\" label, so you may want to check it out!\n\n\nThanks for the report @debalance! I can confirm the regression.\r\n\r\nI think this needs a code change to add an `is_realm_owner` setter similar to this function:\r\n```\r\n @is_realm_admin.setter \r\n def is_realm_admin(self, value: bool) -> None: \r\n if value: \r\n self.role = UserProfile.ROLE_REALM_ADMINISTRATOR \r\n elif self.role == UserProfile.ROLE_REALM_ADMINISTRATOR: \r\n # We need to be careful to not accidentally change \r\n # ROLE_GUEST to ROLE_MEMBER here. \r\n self.role = UserProfile.ROLE_MEMBER \r\n```\r\n\r\ni.e. this:\r\n```\r\ndiff --git a/zerver/models.py b/zerver/models.py\r\nindex 46e73f6590..103e861461 100644\r\n--- a/zerver/models.py\r\n+++ b/zerver/models.py\r\n@@ -1498,6 +1498,15 @@ class UserProfile(AbstractBaseUser, PermissionsMixin):\r\n # ROLE_GUEST to ROLE_MEMBER here.\r\n self.role = UserProfile.ROLE_MEMBER\r\n \r\n+ @is_realm_owner.setter\r\n+ def is_realm_owner(self, value: bool) -> None:\r\n+ if value:\r\n+ self.role = UserProfile.ROLE_REALM_OWNER\r\n+ elif self.role == UserProfile.ROLE_REALM_OWNER:\r\n+ # We need to be careful to not accidentally change\r\n+ # ROLE_REALM_OWNER to ROLE_MEMBER here.\r\n+ self.role = UserProfile.ROLE_MEMBER\r\n+\r\n @property\r\n def has_billing_access(self) -> bool:\r\n return self.is_realm_owner or self.is_billing_admin\r\n```\r\n\r\n@debalance you're welcome to apply that patch to `zerver/models.py` in your installation and use `is_realm_owner`, though it's at present totally untested.\r\n\r\n@mateuszmandera FYI; can you do a proper PR for this with tests and documentation, which should presumably cover `is_guest` as well? And I guess we might want to do the similar work to make `is_realm_moderator` supported as well.\nThx @timabbott , I tested your patch - it seems to be incomplete (or I missed a required step after changing the file):\r\n\r\n```\r\nzulip@zulip:~/deployments/current/zerver$ /home/zulip/deployments/current/manage.py sync_ldap_user_data\r\nTraceback (most recent call last):\r\n File \"/home/zulip/deployments/current/manage.py\", line 52, in \r\n execute_from_command_line(sys.argv)\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/zulip-py3-venv/lib/python3.7/site-packages/django/core/management/__init__.py\", line 419, in execute_from_command_line\r\n utility.execute()\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/zulip-py3-venv/lib/python3.7/site-packages/django/core/management/__init__.py\", line 395, in execute\r\n django.setup()\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/zulip-py3-venv/lib/python3.7/site-packages/django/__init__.py\", line 24, in setup\r\n apps.populate(settings.INSTALLED_APPS)\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/zulip-py3-venv/lib/python3.7/site-packages/django/apps/registry.py\", line 114, in populate\r\n app_config.import_models()\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/zulip-py3-venv/lib/python3.7/site-packages/django/apps/config.py\", line 301, in import_models\r\n self.models_module = import_module(models_module_name)\r\n File \"/usr/lib/python3.7/importlib/__init__.py\", line 127, in import_module\r\n return _bootstrap._gcd_import(name[level:], package, level)\r\n File \"\", line 1006, in _gcd_import\r\n File \"\", line 983, in _find_and_load\r\n File \"\", line 967, in _find_and_load_unlocked\r\n File \"\", line 677, in _load_unlocked\r\n File \"\", line 728, in exec_module\r\n File \"\", line 219, in _call_with_frames_removed\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/confirmation/models.py\", line 20, in \r\n from zerver.models import EmailChangeStatus, MultiuseInvite, PreregistrationUser, Realm, UserProfile\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/zerver/models.py\", line 1092, in \r\n class UserProfile(AbstractBaseUser, PermissionsMixin):\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/zerver/models.py\", line 1498, in UserProfile\r\n @is_realm_owner.setter\r\nNameError: name 'is_realm_owner' is not defined\r\n```\r\n\r\n```\r\nzulip@zulip:~/deployments/current$ /home/zulip/deployments/current/scripts/restart-server\r\nTraceback (most recent call last):\r\n File \"./manage.py\", line 52, in \r\n execute_from_command_line(sys.argv)\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/zulip-py3-venv/lib/python3.7/site-packages/django/core/management/__init__.py\", line 419, in execute_from_command_line\r\n utility.execute()\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/zulip-py3-venv/lib/python3.7/site-packages/django/core/management/__init__.py\", line 395, in execute\r\n django.setup()\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/zulip-py3-venv/lib/python3.7/site-packages/django/__init__.py\", line 24, in setup\r\n apps.populate(settings.INSTALLED_APPS)\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/zulip-py3-venv/lib/python3.7/site-packages/django/apps/registry.py\", line 114, in populate\r\n app_config.import_models()\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/zulip-py3-venv/lib/python3.7/site-packages/django/apps/config.py\", line 301, in import_models\r\n self.models_module = import_module(models_module_name)\r\n File \"/usr/lib/python3.7/importlib/__init__.py\", line 127, in import_module\r\n return _bootstrap._gcd_import(name[level:], package, level)\r\n File \"\", line 1006, in _gcd_import\r\n File \"\", line 983, in _find_and_load\r\n File \"\", line 967, in _find_and_load_unlocked\r\n File \"\", line 677, in _load_unlocked\r\n File \"\", line 728, in exec_module\r\n File \"\", line 219, in _call_with_frames_removed\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/confirmation/models.py\", line 20, in \r\n from zerver.models import EmailChangeStatus, MultiuseInvite, PreregistrationUser, Realm, UserProfile\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/zerver/models.py\", line 1092, in \r\n class UserProfile(AbstractBaseUser, PermissionsMixin):\r\n File \"/home/zulip/deployments/2021-06-02-22-13-46/zerver/models.py\", line 1498, in UserProfile\r\n @is_realm_owner.setter\r\nNameError: name 'is_realm_owner' is not defined\r\nTraceback (most recent call last):\r\n File \"/home/zulip/deployments/current/scripts/restart-server\", line 51, in \r\n [\"./manage.py\", \"send_stats\", \"incr\", \"events.server_restart\", str(int(time.time()))]\r\n File \"/usr/lib/python3.7/subprocess.py\", line 347, in check_call\r\n raise CalledProcessError(retcode, cmd)\r\nsubprocess.CalledProcessError: Command '['./manage.py', 'send_stats', 'incr', 'events.server_restart', '1622715924']' returned non-zero exit status 1.\r\n```\nI am not sure but I think the lines should be added after the code mentioned below to fix the `NameError` -\r\n```python\r\n@property\r\n def is_realm_owner(self) -> bool:\r\n return self.role == UserProfile.ROLE_REALM_OWNER\r\n```\r\n@debalance can you try this once?\n@sahil839 You're right, now it's working!"},"created_at":{"kind":"timestamp","value":"2021-07-28T16:26:05","string":"2021-07-28T16:26:05"}}},{"rowIdx":686,"cells":{"repo":{"kind":"string","value":"zulip/zulip"},"pull_number":{"kind":"number","value":19454,"string":"19,454"},"instance_id":{"kind":"string","value":"zulip__zulip-19454"},"issue_numbers":{"kind":"list like","value":["19205"],"string":"[\n \"19205\"\n]"},"base_commit":{"kind":"string","value":"9968fb5081dbf21d6a904f9669f5c8a4a228b719"},"patch":{"kind":"string","value":"diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.py\n--- a/zerver/lib/markdown/__init__.py\n+++ b/zerver/lib/markdown/__init__.py\n@@ -1369,7 +1369,13 @@ def handleMatch(self, match: Match[str]) -> Optional[Element]:\n time_input_string = match.group(\"time\")\n timestamp = None\n try:\n- timestamp = dateutil.parser.parse(time_input_string, tzinfos=common_timezones)\n+ # Check if the time string is of the new more-readable format.\n+ if \"|UTC\" in time_input_string:\n+ # Remove and replace the non-standard characters with the ISO ones.\n+ standard_format_time = time_input_string.replace(\"|\", \"T\", 1).replace(\"|UTC\", \"\")\n+ timestamp = dateutil.parser.parse(standard_format_time, tzinfos=common_timezones)\n+ else:\n+ timestamp = dateutil.parser.parse(time_input_string, tzinfos=common_timezones)\n except ValueError:\n try:\n timestamp = datetime.datetime.fromtimestamp(float(time_input_string))\n"},"test_patch":{"kind":"string","value":"diff --git a/zerver/tests/fixtures/markdown_test_cases.json b/zerver/tests/fixtures/markdown_test_cases.json\n--- a/zerver/tests/fixtures/markdown_test_cases.json\n+++ b/zerver/tests/fixtures/markdown_test_cases.json\n@@ -790,6 +790,19 @@\n \"expected_output\": \"

Let's meet at .

\",\n \"text_content\": \"Let's meet at 1496701800.\"\n },\n+ {\n+ \"name\": \"timestamp_new_format\",\n+ \"input\": \"\",\n+ \"expected_output\": \"

\",\n+ \"text_content\": \"2021-08-02|14:03:00|UTC+05:30\"\n+ },\n+ {\n+ \"name\": \"timestamp_without_utc\",\n+ \"input\": \"\",\n+ \"expected_output\": \"

Invalid time format: 2021-08-02|14:03:00|+05:30

\",\n+ \"marked_expected_output\": \"

2021-08-02|14:03:00|+05:30

\",\n+ \"text_content\": \"Invalid time format: 2021-08-02|14:03:00|+05:30\"\n+ },\n {\n \"name\": \"tex_inline\",\n \"input\": \"$$1 \\\\oplus 0 = 1$$\",\n"},"problem_statement":{"kind":"string","value":"Improve formatting inserted by