Markdown OKF-Schema Studio

How we test

Every behaviour of Markdown OKF-Schema Studio is written as a requirement. A test proves a requirement by naming it with a marker, a comment such as @tests_req <SwRS-ID>#S<n>.

okfreq, the requirements tool of the project, counts the markers. The CI jobs prove that the tests pass. This page follows one use case from its paths to the tests that prove them, and ends with what is not enforced yet.

Two levels of requirements

One example, from the trust-security area:

The levels at a glance

Test levels by lane: simulated levels on every pull request, real VS Code levels on a push to main and a heavy dispatch, and manual mutation, with the marker arrows from the levels to the StRS and SwRS requirements

Which test proves which requirement

Test level Where Command CI job, when Proves Marker
Unit test/build, test/core, test/host, test/host-memory, test/host-vscode, test/node-services, test/page, test/session, test/site just unit static, static-windows; every pull request SwRS scenario @tests_req <SwRS-ID>#S<n>
Contract sphinx/tests, test/core/render/*.contract.ts (no such file today) just contracts, just sphinx-check static, static-windows; every pull request SwRS scenario (no contract test carries a marker today) @tests_req <SwRS-ID>#S<n>
Security test/security just security, just audit static, static-windows; every pull request SwRS scenario; may accept a TRUST-014 path @tests_req <SwRS-ID>#S<n>; @accepts_req <StRS-ID>#S<n> allowed for TRUST-014
Release and tooling test/build/*.py just release-tests static, static-windows; every pull request SwRS scenario; may accept a CORE-007 path @tests_req <SwRS-ID>#S<n>; @accepts_req <StRS-ID>#S<n> allowed for CORE-007
Simulated bench test/visual, test/page/tableBreakout.test.ts, test/page/codeBlockBreakout.test.ts, test/site/requirementsViewer/*.browser.test.ts, test/site/galleryLinks.browser.test.ts just ci-visual, just ci-viewer-graph visual, visual-2, viewer-graph; every pull request SwRS scenario; StRS path tested @tests_req <SwRS-ID>#S<n>, @tests_req <StRS-ID>#S<n>
Real VS Code integration test/integration just ci-integration integration; push to main, heavy dispatch SwRS scenario; StRS path accepted (suites that walk one) @tests_req <SwRS-ID>#S<n>, @accepts_req <StRS-ID>#S<n>
Acceptance test/integration/acceptance just ci-acceptance [GROUP] acceptance (one shard per group with a file); push to main, heavy dispatch StRS path accepted @accepts_req <StRS-ID>#S<n>
Stress test/shared/stressPlan.ts just ci-stress [REPEAT] stress; push to main, heavy dispatch that a passing test passes every time none
Mutation src/core against test/core just mutation-core [SAMPLE] none; manual strength of the SwRS tests (score per SwRS) none

The jobs of every pull request also run on a push to main and on a manual dispatch.

The rules of the markers, which just check-markers holds:

The test levels

Unit tests

Node tests of the TypeScript code and of the repository’s own tooling, in test/build, test/core, test/host (a fake VS Code host harness, with *.requirements.test.ts files), test/host-memory, test/host-vscode, test/node-services, test/page, test/session and test/site.

A unit test that needs Chromium is skipped where none can start, as in these CI jobs.

Contract tests

The Python Sphinx source-mapping contract, with its tests and fixtures in sphinx/tests. A second command runs the files test/core/render/*.contract.ts; no such file exists today.

Security tests

The tests of test/security, and the online npm audit of the production dependencies. The folder test/release holds a lockfile audit script, audit-lockfile.mjs, that no just target, package.json script or workflow calls.

Release and tooling tests

The Python tests of test/build: the release, the CI workflows, the run selection, the plugin manifests, the visual checks (their two parts and the table bar layout), the unpacking of the built VSIX and other repository checks (guideline isolation, main paths, merge commits, changelog).

Simulated bench

No VS Code window opens. test/visual drives the preview page with Playwright Chromium against a mock host, and its screenshots feed the gallery. Some tests of test/page measure the real page in Chromium: the table and code block breakout widths, the aligned-float layout, the style cost of one comment and the selected text of a scroll. The use case map tests of test/site/requirementsViewer and the gallery link tests of test/site also run in Chromium.

Real VS Code integration

The suites of test/integration run in real VS Code windows (trusted, Restricted Mode, standalone file and others), with real keys and pointer input through test/integration/realInput.

Acceptance

The acceptance files are test/integration/acceptance/<group>[.<kind>].acceptance.ts, with one real VS Code launch per file. Each file declares its window: trusted, in Restricted Mode, or running the built VSIX. An acceptance test walks one path of a use case in such a window and carries the marker of that path. A human step is a simulated input: the test checks the gate, never a judgment.

Not every check of these files is an acceptance test. The checks of the built VSIX file of trust-security read the texts of the manifest with the label of the preview tab, and the icon of the installed package. They walk no path in full, so they carry no marker and accept no path.

Groups with acceptance files: trust-security. The other groups have no acceptance file yet.

Stress

The flake-prone real-window scenarios of test/shared/stressPlan.ts run again and again, REPEAT times, in a trusted window and then in a Restricted Mode window. Some scenarios of that file are not part of a default run: they run only when STUDIO_STRESS_SCENARIOS (the stress_scenarios input of a manual dispatch) names them.

Mutation

StrykerJS changes the code of src/core and checks that the test/core tests fail. A second phase runs what the first one missed against the tests of the other layers. The report, out/reports/mutation/summary.md, gives a score per source folder and per SwRS: it measures how well the SwRS tests catch a broken implementation. See CONTRIBUTING.

Repro tools and probes

The toc-loop job (just ci-toc-loop) repeats real-window steps to reproduce a flake. It runs only on a manual dispatch that asks for it, and never gates a merge. The perf-547 job (just ci-perf-547) measures comments on a large generated document in a real window (issue 547), the wait of a comment write for the Git user name, and, in plain Node, the time to index the comment threads. It sets no limit and fails only when the measure cannot be taken. It runs only on a manual dispatch with perf_547=true, and never gates a merge. The probes of test/probe measure performance and frames and take chart screenshots. None of these jobs and probes has a marker of its own.

The folders test/shared and test/fixtures hold shared code and data only.

The e2e groups

The groups of test/shared/e2eGroups.ts are the scopes of okfreq, the areas of the requirements viewer, the first part of the visual scenario ids, the folders of their captures, and the possible shards of the acceptance job. In order: rendering-core, code-blocks, gfm, myst, diagrams, frontmatter-schema, frontmatter-editing, layout-width, theme-zoom, toolbar-navigation, block-editing, palette-slash, table-editing, review-annotations, lifecycle-sync, trust-security.

From markers to coverage

just check-markers, part of just check, holds where a marker may sit: the fragment rules above, @accepts_req only where it is allowed, at most 3 requirement IDs per marker block, and a source marker on every in-force SwRS that is not exempt. It does not check whether a requirement is tested.

just requirements-update runs okfreq update-coverage, which writes implemented_in_files and tested_in_files into the SwRS files.

The StRS coverage mode is linked-swrs-and-validation-test.

In this mode, okfreq counts a StRS as covered when all of these hold:

Acceptance markers are counted and shown, but they do not change whether a StRS is covered.

just requirements-lint, part of just check, runs these commands:

Reports:

The requirements viewer of the published site, deployed with each release, shows the counts. Its home has the cards “StRS paths tested”, “StRS paths accepted”, “StRS covered” (it follows the coverage mode) and “SwRS scenarios tested”, and an area table with the columns “Paths tested” and “Paths accepted”. A use case page lists each path with the files that test and accept it. A behaviour page lists its scenarios with their tests.

What a count does not prove

okfreq counts markers. It never reads a test result. The proof that a marked test passes is the green CI job that runs it:

A green job does not prove that every marked test ran:

These jobs run no test level:

What is not enforced yet

Keeping this page current

The test test/site/howWeTest.test.ts compares this page with the repository. It fails when:

The test does not see everything. A folder, job, e2e group, marker verb or lint command that the repository has dropped can stay on this page without a failure, unless a link to it breaks. The test does not check the commands of the test levels, the options of a lint command, when a level runs, or what the diagram draws.

The CI guidelines make the author of a change that adds, removes or renames a CI job, a test folder, an e2e group or an acceptance group, or changes when a level runs, update this page in the same pull request. The requirements guidelines do the same for a change to a marker verb, the bench convention, the commands of just requirements-lint or the coverage mode.