Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-REVIEW-044

A comment editor sends its text on Save or Cmd+Enter and keeps it until the host accepts it

When a reader writes a comment in the comment box or a reply in the reply box of a thread popover, the page SHALL send the typed text to the host only on Save or Reply, Cmd+Enter or Ctrl+Enter with a text that is not blank, and keep the box and its text until the host answers that the text is saved.

Step 3 of path 1 in StRS-MDOKFSTUDIO-REVIEW-003: from “The comment box is open” to “The comment is sent”.

Scenarios 16

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

nominalBox content

When the comment box opens, the page shows a dialog named New comment holding the quoted text, a text area labelled Comment with the placeholder Write a comment and a limit of 10 000 characters, and Save and Cancel buttons.

InputOutcome
A selection of the words "second paragraph" and the box opensThe dialog shows those words, an empty text area with the focus, Save and Cancel
A selection whose text looks like HTML and the box opensThe quote and the typed text are set as text, never as markup
nominalSave or Cmd/Ctrl+Enter sends the comment
Givena box holding the text "Why?"
Whenthe reader presses Save, or presses Cmd+Enter or Ctrl+Enter in the box
Thena create message with the anchor of the selection and the body Why? is sent, exactly one per save, and Save is disabled until the host answers
refusalEmpty or blank text is not sent
Givenan empty box, or a box holding only spaces
Whenthe reader presses Save, or presses Cmd+Enter
Thenno message is sent and the box stays open
nominalEscape or Cancel closes the box
InputOutcome
An open box with no text and the reader presses Escape, wherever the focus isThe box closes and nothing is sent
An open box with typed text and the reader presses EscapeThe box asks Discard or Keep editing and nothing is sent (SwRS-MDOKFSTUDIO-REVIEW-218)
An open box and the reader presses CancelThe box closes, nothing is sent, and the selection state is looked at again
boundaryKeys typed in the box stay in the box
InputOutcome
The reader types a letter that is also a shortcut in the open boxThe letter goes to the text area, each key event is stopped, and no other key handler of the page acts
A key is pressed outside the box and it is not the comment chordThe event is left alone
nominalA saved comment closes the box
InputOutcome
A box waiting for the host, and the host answers a create with ok trueThe box closes and the text selection is cleared
An answer of another kind arrivesThe answer is ignored and the box stays
An answer arrives with no save pendingThe answer is ignored and the box stays
refusalA refused comment keeps the box and its text
Givena box waiting for the host
Whenthe host answers a create with ok false and the reason "the comments file is full."
Thenthe box and the text stay, an alert shows the reason as text (cut at 500 characters) and Save is enabled again
InputOutcome
The answer ok false has no reasonThe alert reads "The comment was not saved."
refusalNo answer from the host after 15 seconds
Givena box waiting for the host
When15 seconds pass without an answer
Thenthe alert reads "No answer from the editor. Your text is kept: try Save again.", the box and the text stay and Save is enabled
WHEN the host answers ok true later, THEN the box closes
refusalThe host answers a blank or invalid comment as empty

When a create or reply message passes the protocol with a body that is blank or over 10 000 characters, the host answers ok false and writes nothing.

InputOutcome
A create message with the body of three spacesThe page is told "the comment is empty or too long." and no thread is written
A reply message with the body of three spacesThe page is told "the reply is empty or too long."
A create message whose anchor is not valid (lines, quote of at most 500 characters, prefix and suffix of at most 32 characters)The page is told "the comment is empty or too long."
nominalReply box: the popover of a preview ends with the reply box
Givena preview and a thread
Whenits popover opens
Thenthe popover ends with the text area (aria-label "Reply to this thread", placeholder Reply, maxlength 10000) and the Reply button
refusalReply box: none without a reply hook
Givena page whose host gave no reply hook (the runtime context carries commentsEnabled false, as in a test host)
Whenthe popover opens
Thenno reply box is shown
nominalReply box: Reply sends the thread id and the trimmed text
Givena reply box holding " Thanks "
a reply box that is empty or holds only blanks
Whenthe reader presses Reply, or presses Cmd+Enter or Ctrl+Enter in the box
the reader presses Reply, or presses Cmd+Enter or Ctrl+Enter in the box
Thenone reply message with the thread id and the text Thanks is sent to the host
nothing is sent (the body must not be empty)
nominalReply box: keys typed in the box stay in the box
Givenan open reply box
Whenthe reader types a letter that is also a shortcut of the page
Thenthe letter goes to the text area, the key event is stopped (stopImmediatePropagation) and no other key handler of the page acts
when the reader presses Cmd+Enter with text, the reply is sent and the event is stopped
boundaryReply box: length of the reply
InputOutcome
a reply of 10 000 charactersthe reply is sent
a text of 10 001 characters forced into the boxnothing is sent (the text area also carries maxlength 10000)
nominalReply box: a reply accepted by the host empties the box
Givena reply waiting for the host
Whenthe host answers ok true
Thenthe reply box is emptied of the text that was sent
when the reader typed other text in the box after the reply was sent, the box keeps that new text (the box is cleared only when it still equals the sent text)
refusalReply box: a reply the host does not accept keeps its text
InputOutcome
the host answers ok false with a reasonthe text stays, the reason is shown as text in an alert of at most 500 characters and Reply works again
the host answers ok false without a reasonthe text stays and the alert reads "The reply was not saved."
the host gives no answer within 15 secondsthe text stays, the message reads "No answer from the editor. Your text is kept: try Reply again." and Reply works again
the host answers ok true after that timeoutthe box is emptied

Implemented in 3

Tested by 3

Replaces

SwRS-MDOKFSTUDIO-REVIEW-081The thread popover of a preview sends a reply and keeps it until accepted superseded superseded by SwRS-MDOKFSTUDIO-REVIEW-044 Markdown file