WP Origin: round-trip contract tests and plugin hardening#239
Open
adamziel wants to merge 1 commit intoadamziel/wp-origin-gitfrom
Open
WP Origin: round-trip contract tests and plugin hardening#239adamziel wants to merge 1 commit intoadamziel/wp-origin-gitfrom
adamziel wants to merge 1 commit intoadamziel/wp-origin-gitfrom
Conversation
The round-trip tests lock in the byte-preservation promise: Markdown that enters WordPress and comes back out must be identical, and block markup that is exported to Markdown and pushed back must produce the same blocks. 29 test cases cover paragraphs, headings, lists, tables, blockquotes, images, links, gutenberg fences (opaque unsupported-block preservation), front matter, and mixed content. The plugin gains several stability improvements: the repository now lives in a per-request temp directory that is always cleaned up in a finally block, binary Git responses bypass WordPress REST JSON encoding via a rest_pre_serve_request hook, permission checks cover both editing existing posts and creating new ones, and metadata values are correctly wrapped in arrays as BlocksWithMetadata requires.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements Milestone 1 from the WP Origin PRD: byte-exact round-trip contract tests for the Markdown component, plus a batch of stability fixes to the plugin itself.
Round-trip tests — 29 cases covering both directions:
md -> wp -> md: Markdown goes through WordPress and must come back byte-for-byte. Covers paragraphs, headings, lists, tables, blockquotes, images, links, gutenberg fences (opaque unsupported-block preservation), front matter, and mixed content.wp -> md -> wp: Block markup is exported to Markdown and pushed back; the resulting blocks must match (modulo whitespace inside block comment delimiters, which WordPress normalises on save).blockfence language is still accepted on import but always exported asgutenberg.Plugin hardening:
finallyblock, removing the persistent uploads-dir repository that would cause state leaks between requests.rest_pre_serve_requesthook — without this, pack data gets double-encoded and breaksgit clone.assert_can_edit_postandassert_can_create_post_typehelpers.array('value')asBlocksWithMetadatarequires; the previous code passed scalars and would have thrown on every export.post/hello-world.mdwhose front matter saysslug: something-elseis rejected.