diff --git a/docs/subsystems/markdown.md b/docs/subsystems/markdown.md index d2022b5261..6178476078 100644 --- a/docs/subsystems/markdown.md +++ b/docs/subsystems/markdown.md @@ -73,6 +73,14 @@ This procedure prevents any server-side rendering. If you don't do this, backend will likely render the Markdown you're testing and swap it in before you can see the frontend's rendering. +If you are working on a feature that breaks multiple testcases, and want +to debug the testcases one by one, you can add `"ignore": true` to any +testcases in `markdown_test_cases.json` that you want to ignore. This +is a workaround due to lack of comments support in JSON. Revert your +"ignore" changes before committing. After this, you can run the frontend +tests with `tools/test-js-with-node markdown` and backend tests with +`tools/test-backend zerver.tests.test_bugdown.BugdownTest.test_bugdown_fixtures`. + ## Changing Zulip's markdown processor First, you will likely find these third-party resources helpful: diff --git a/frontend_tests/node_tests/markdown.js b/frontend_tests/node_tests/markdown.js index e7f870623a..cfde31bc3a 100644 --- a/frontend_tests/node_tests/markdown.js +++ b/frontend_tests/node_tests/markdown.js @@ -180,6 +180,12 @@ var bugdown_data = JSON.parse(fs.readFileSync(path.join(__dirname, '../../zerver var tests = bugdown_data.regular_tests; tests.forEach(function (test) { + + // Ignore tests if specified + if (test.ignore === true) { + return; + } + var message = {raw_content: test.input}; page_params.translate_emoticons = test.translate_emoticons || false; markdown.apply_markdown(message); diff --git a/zerver/tests/test_bugdown.py b/zerver/tests/test_bugdown.py index 70369e6970..a3af5d2554 100644 --- a/zerver/tests/test_bugdown.py +++ b/zerver/tests/test_bugdown.py @@ -242,18 +242,30 @@ class BugdownTest(ZulipTestCase): return test_fixtures, data['linkify_tests'] + def test_bugdown_no_ignores(self) -> None: + # We do not want any ignored tests to be committed and merged. + format_tests, linkify_tests = self.load_bugdown_tests() + for name, test in format_tests.items(): + message = 'Test "%s" shouldn\'t be ignored.' % (name,) + is_ignored = test.get('ignore', False) + self.assertFalse(is_ignored, message) + @slow("Aggregate of runs dozens of individual markdown tests") def test_bugdown_fixtures(self) -> None: format_tests, linkify_tests = self.load_bugdown_tests() valid_keys = set(["name", "input", "expected_output", "backend_only_rendering", "marked_expected_output", "text_content", - "translate_emoticons"]) + "translate_emoticons", "ignore"]) for name, test in format_tests.items(): # Check that there aren't any unexpected keys as those are often typos self.assertEqual(len(set(test.keys()) - valid_keys), 0) + # Ignore tests if specified + if test.get('ignore', False): + return # nocoverage + if test.get('translate_emoticons', False): # Create a userprofile and send message with it. user_profile = self.example_user('othello')