mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
markdown-tests: Allow ignoring certain fixtures while developing.
Usually, to debug a small change, you have to remove some tests from JSON because of lack of support for comments in JSON. This commit allows to ignore some tests by setting `"ignore" : true` in the bugdown fixtures. Also, since this is only for while developing, the complete test suite will throw an error if we leave an 'ignored' test in a commit.
This commit is contained in:
committed by
Tim Abbott
parent
c0ea4f2d5a
commit
115b633551
@@ -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:
|
||||
|
@@ -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);
|
||||
|
@@ -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')
|
||||
|
Reference in New Issue
Block a user