Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-REVIEW-054

The host writes comment changes one after another within the file limits and drops a malformed create message

When the host receives a create message from a preview of a saved document, the extension SHALL append a thread with the anchor as sent, resolved false and one comment, with thread and comment ids and the time chosen by the host, in the review comments file next to the document, running the changes of one file one after another on its latest content and refusing with a reason and a warning, and writing nothing, a change that the file state or its limits do not allow, and writing through a temporary file renamed onto the comments file and never into a comments file that is a symbolic link; a create message is dropped without an answer unless its anchor has integer lines with 1 <= line <= endLine, a quote of at most 500 characters and a prefix and suffix of at most 32 characters, and its body has 1 to 10 000 characters.

Step 5 of path 1 in StRS-MDOKFSTUDIO-REVIEW-003: from “The comment has its anchor” to “The comment is in the review comments file”.

Scenarios 11

The situations the tests check; open one to read it.

nominalFirst comment on a text
Givena preview of notes.md and a create message with an anchor and the body "First remark"
Whenthe host handles it
Thenthe comments file holds one thread with the anchor as sent, resolved false, an id of the form t_ and 8 hex characters, a comment with an id of the form c_ and 8 hex characters, and an ISO creation time
the earlier threads of the file are unchanged
the answer of the store carries the written text and its hash
nominalThe first comment creates the review comments file
InputOutcome
notes.md with no comments file and a comment is savednotes.comments.json exists with version 1 and the document name notes.md
A comments file that names the document and a comment is savedThe file keeps its document name and gains the thread
nominalChanges of one file run one after another
InputOutcome
Two create messages sent at the same momentThe file holds both threads
A create and a reply to another thread queued togetherBoth changes are in the file
A resolve or a delete queued with a createThe same per-file queue runs them, each on the latest file
refusalA refused change does not stop the queue
Givena refused change followed by a valid one for the same file
Whenboth are handled
Thenthe valid change is written
refusalRefusal reasons

When the host refuses a comment change, it answers the page ok false with the reason below, writes nothing and leaves the file untouched.

ConditionReason answered to the page
The document is not a saved file (an untitled document, a uri that does not start with file:)"save the document first."
The comments file is open in an editor with unsaved changes"{name} has unsaved changes in an editor; save or close it first."
The change makes the serialized file larger than 2 MiB (the UTF-8 length above MAX_SIDECAR_BYTES)"the comments file would become too large."
The file already holds 1000 threads"the comments file is full."
A new thread repeats the id of another threadthe change is refused (the same reason, "the comments file is full.")
The existing comments file is not valid"the comments file is not valid ({first problem}) and is left untouched."
The comments file path is itself a symbolic link (a dangling one included)"the comments file is a symbolic link and is left untouched"
nominalA write replaces the file in one step
Givena valid change to a comments file that is not a symbolic link
Whenthe host writes it
Thenthe text is written to a temporary file in the same folder and renamed onto the comments file
a failed write or rename removes the temporary file and leaves the comments file as it was
refusalA refusal also shows a warning
Givena comments file with unsaved changes in an editor
Whena comment is saved
Thenthe warning "The comment was not saved: {reason}" names the reason and the page is told the same reason
WHEN a comment is saved normally, THEN no warning is shown
boundaryThe change is written once the cause is gone
InputOutcome
The same comments file saved or closed in its editor, and a comment is savedThe comment is written
A comment that keeps the file below 2 MiBThe comment is written
A preview of a saved file, and a comment is createdThe comment is written
nominalValid create message
Givena previewCommentCreate message with an anchor on lines 3 to 3 with a quote of 5 characters and a body of 1 character
Whenthe message is validated
Thenit is accepted
refusalInvalid create messages
InputOutcome
An anchor with line 0dropped without an answer and nothing is written
An anchor with endLine before linedropped without an answer and nothing is written
A quote of 501 charactersdropped without an answer and nothing is written
A prefix or suffix of 33 charactersdropped without an answer and nothing is written
A body of 0 charactersdropped without an answer and nothing is written
A body of 10 001 charactersdropped without an answer and nothing is written
boundaryAccepted limits of a create message
InputOutcome
A quote of 500 characters, a prefix and a suffix of 32 charactersaccepted
A body of 1 character, a body of 10 000 charactersaccepted

Implemented in 5

Tested by 8

Replaces

SwRS-MDOKFSTUDIO-REVIEW-069A comment create message needs a valid anchor and a bounded body superseded superseded by SwRS-MDOKFSTUDIO-REVIEW-054 Markdown file