Behaviour SwRS-MDOKFSTUDIO-REVIEW-012
The host posts the threads of the review comments file and follows its changes
When a document is shown or its review comments file is created, changed, deleted or written by the Studio, the extension SHALL post the current threads of the file to the page with their comments, anchors, resolved flags and orphaned verdicts, once for each distinct content, never from a read that a newer read overtook and never from a read that failed.
Step 1 of path 1 in StRS-MDOKFSTUDIO-REVIEW-001: from “A document with a review comments file is shown” to “The threads reach the page”.
Scenarios 11
The situations the tests check; open one to read it.
nominalValid file
Givena comments file with one thread quoting "second paragraph" whose comment body is `<b>Why?</b>`
Whenthe preview renders
Thenthe page receives that thread with the body as stored
nominalOrphan verdict
Givena thread whose quote the document no longer holds
Whenthe threads are posted
Thenthe thread is posted with orphaned true and its stored lines
boundaryDocument that is not a saved file
| Input | Outcome |
|---|
| A preview of an untitled document, or of another scheme than file | Nothing is posted, whatever files exist |
| A preview of a document saved as a file | The threads of its comments file are posted |
boundaryDocument without a comments file
| Input | Outcome |
|---|
| A document with no comments file and no threads shown before | No previewComments message is posted |
| A preview that showed threads and whose comments file was deleted | An empty list is posted so the page removes them |
nominalChange of the file outside the Studio
| Input | Outcome |
|---|
| A preview that shows two threads and a comments file rewritten with one thread, the file watcher fires | The page receives the one thread after a debounce of 150 ms |
| A comments file created next to a document that had none | The threads of the new file are posted |
refusalThe same threads are not posted twice
| Input | Outcome |
|---|
| A comment just written by the Studio, the file watcher reports the write | No second post is made |
| The same comments file text after the lines followed in memory were dropped (see SwRS-MDOKFSTUDIO-REVIEW-119) | The text is not skipped: the anchors are checked again, and a post is made only if the threads differ |
| A page that already shows the threads, the document renders again | The same threads are not posted again |
boundaryRead overtaken by a newer read
| Input | Outcome |
|---|
| Two changes of the comments file in quick succession, the first read ends after the second started | Only the result of the second read is posted |
| One change of the file, the read ends | Its result is posted |
| A post overtaken by a newer post while it checks the anchors against the document, both reading the same new text | The newer post shows the new threads; the overtaken one posts nothing and does not mark the text as shown |
refusalA read of the comments file that fails
| Input | Outcome |
|---|
| A preview that shows a resolved thread whose open popover the reader uses, the next read of the existing comments file fails (busy, denied, interrupted) | Nothing is posted: the page keeps its threads and the popover stays open; the next successful read is posted as usual |
| A preview that showed threads and a read that finds the file missing | An empty list is posted so the page removes the threads (see the boundary "Document without a comments file") |
boundaryThe watch of the comments file is released
| Input | Outcome |
|---|
| The preview shows another document, so another comments file | The watcher of the previous file and its three change, create and delete subscriptions are all disposed; the live count stays at one watcher and three subscriptions |
| The preview closes | The watcher and its three subscriptions are disposed; disposing twice is harmless |
nominalAfter a write by the host
| Input | Outcome |
|---|
| A comment just written, the write ends | The page receives the new list of threads |
| A refused change, the host answers | No new list is posted by the write |
refusalShape of the threads message the page accepts
| Input | Outcome |
|---|
| previewComments with a threads list of threads (id, anchor, resolved, createdAt, comments, optional boolean orphaned) and the render fields | The page shows the threads |
| previewComments whose threads is not a list | The page keeps no thread |
| A thread without a non-empty string id, with an anchor line that is not an integer of at least 1, or with comments that are not a list | The page drops that thread and keeps the others |
| More than 1000 threads, or more than 200 comments in a thread | The page keeps the first 1000 threads and the first 200 comments of a thread |
| A text that is not a string, or longer than 10 000 characters | The page uses an empty string, or the first 10 000 characters |
For an invalid file the host posts no thread and shows one warning, see SwRS-MDOKFSTUDIO-REVIEW-004. The page accepts the message only when it is addressed to its render, see SwRS-MDOKFSTUDIO-TRUST-059.