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
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
| Input | Outcome |
|---|---|
| notes.md with no comments file and a comment is saved | notes.comments.json exists with version 1 and the document name notes.md |
| A comments file that names the document and a comment is saved | The file keeps its document name and gains the thread |
nominalChanges of one file run one after another
| Input | Outcome |
|---|---|
| Two create messages sent at the same moment | The file holds both threads |
| A create and a reply to another thread queued together | Both changes are in the file |
| A resolve or a delete queued with a create | The same per-file queue runs them, each on the latest file |
refusalA refused change does not stop the queue
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.
| Condition | Reason 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 thread | the 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
a failed write or rename removes the temporary file and leaves the comments file as it was
refusalA refusal also shows a warning
WHEN a comment is saved normally, THEN no warning is shown
boundaryThe change is written once the cause is gone
| Input | Outcome |
|---|---|
| The same comments file saved or closed in its editor, and a comment is saved | The comment is written |
| A comment that keeps the file below 2 MiB | The comment is written |
| A preview of a saved file, and a comment is created | The comment is written |
nominalValid create message
refusalInvalid create messages
| Input | Outcome |
|---|---|
| An anchor with line 0 | dropped without an answer and nothing is written |
| An anchor with endLine before line | dropped without an answer and nothing is written |
| A quote of 501 characters | dropped without an answer and nothing is written |
| A prefix or suffix of 33 characters | dropped without an answer and nothing is written |
| A body of 0 characters | dropped without an answer and nothing is written |
| A body of 10 001 characters | dropped without an answer and nothing is written |
boundaryAccepted limits of a create message
| Input | Outcome |
|---|---|
| A quote of 500 characters, a prefix and a suffix of 32 characters | accepted |
| A body of 1 character, a body of 10 000 characters | accepted |
Implemented in 5
Tested by 8
- test/core/comments/commentEditing.test.tsunit
- test/core/comments/reviewReq.requirements.test.tsunit
- test/core/comments/sha256.test.tsunit
- test/core/protocol/pageToHost.test.tsunit
- test/host-vscode/fileRename.test.tsunit
- test/integration/commentWrite.test.tsintegration
- test/node-services/nodeServices.test.tsunit
- test/session/reviewReqComments.requirements.test.tsunit