Skip to content

Set up markdown processing tests for the content editor

What does this MR do?

It creates a test that ensures the Content Editor knows how to process the HTML Output of the Markdown API and generate the exact original Markdown that the Markdown API received as input in the first place.

Context

Read the Rich Text Editor technical design document for more information about the Markdown import / export flow.

Documenting the examples

  • spec/frontend/fixtures/api_markdown.yml is an array of markdown examples, with a name (name of the type of mark) and markdown example (raw markdown for the example) for each.
  • spec/frontend/fixtures/api_markdown.rb generates frontend fixtures in tmp/tests/frontend/fixtures-ee/api/markdown/${name}.json for each example name (via rake frontend:fixtures OR bin/rake spec/frontend/fixtures/api_markdown.rb)
  • markdown_processing_spec.js reads the spec/frontend/fixtures/api_markdown.yml file, and for each name example, ensures that the editor can load the tmp/tests/frontend/fixtures-ee/api/markdown/${name}.json and generate the same original markdown.

Preventing regressions

We use the CI environment to make sure the Markdown API does not break the expectations of the Rich Text Editor markdown processing services:

graph TD
    A[`rake frontend:fixtures` OR `bin/rake spec/frontend/fixtures/api_markdown.rb`] -->|generates `tmp/tests/frontend/fixtures-ee/api/markdown/bold.json` fixture| B[jest:job]
    B --> |compares editor markdown output against original markdown|C{Matches?}
    C -->|No| D[Test fails!]
    C -->|Yes| E[Test passes!]

If the Markdown API output changes, the jest test will fail because the markdown doesn't match the markdown originally sent to the API.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Enrique Alcántara

Merge request reports