<commit_before>Feature: reaction/react
  Background:
    Given user "participant1" exists
    Given user "participant2" exists

  Scenario: React to message with success
    Given user "participant1" creates room "room" (v4)
      | roomType | 3 |
      | roomName | room |
    And user "participant1" adds user "participant2" to room "room" with 200 (v4)
    And user "participant1" sends message "Message 1" to room "room" with 201
    And user "participant2" react with "👍" on message "Message 1" to room "room" with 201
      | actorType | actorId      | actorDisplayName         | reaction |
      | users     | participant2 | participant2-displayname | 👍       |
    Then user "participant1" sees the following system messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | systemMessage |
      | room | users     | participant2 | participant2-displayname | reaction |
      | room | users     | participant1 | participant1-displayname | user_added |
      | room | users     | participant1 | participant1-displayname | conversation_created |
    Then user "participant1" sees the following messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | message   | messageParameters | reactions | reactionsSelf |
      | room | users     | participant1 | participant1-displayname | Message 1 | []                | {"👍":1}  |               |
    And user "participant1" react with "👍" on message "Message 1" to room "room" with 201
      | actorType | actorId      | actorDisplayName         | reaction |
      | users     | participant1 | participant1-displayname | 👍       |
      | users     | participant2 | participant2-displayname | 👍       |
    And user "participant1" react with "🚀" on message "Message 1" to room "room" with 201
    Then user "guest" joins room "room" with 200 (v4)
    And user "guest" react with "👤" on message "Message 1" to room "room" with 201
    Then user "participant1" sees the following messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | message   | messageParameters | reactions              | reactionsSelf |
      | room | users     | participant1 | participant1-displayname | Message 1 | []                | {"👍":2,"👤":1,"🚀":1} | ["👍","🚀"]   |
    Then user "participant1" sees the following system messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | systemMessage |
      | room | guests    | guest        |                          | reaction |
      | room | users     | participant1 | participant1-displayname | reaction |
      | room | users     | participant1 | participant1-displayname | reaction |
      | room | users     | participant2 | participant2-displayname | reaction |
      | room | users     | participant1 | participant1-displayname | user_added |
      | room | users     | participant1 | participant1-displayname | conversation_created |

  Scenario: React to message fails without chat permission
    Given user "participant1" creates room "room" (v4)
      | roomType | 3 |
      | roomName | room |
    And user "participant1" adds user "participant2" to room "room" with 200 (v4)
    And user "participant1" sends message "Message 1" to room "room" with 201
    And user "participant2" react with "👍" on message "Message 1" to room "room" with 201
      | actorType | actorId      | actorDisplayName         | reaction |
      | users     | participant2 | participant2-displayname | 👍       |
    Then user "participant1" sees the following system messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | systemMessage |
      | room | users     | participant2 | participant2-displayname | reaction |
      | room | users     | participant1 | participant1-displayname | user_added |
      | room | users     | participant1 | participant1-displayname | conversation_created |
    # Removing chat permission only
    Then user "participant1" sets permissions for "participant2" in room "room" to "CSJLAVP" with 200 (v4)
    When user "participant2" delete react with "👍" on message "Message 1" to room "room" with 403
    And user "participant2" react with "💙" on message "Message 1" to room "room" with 403
    And user "participant1" sees the following system messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | systemMessage |
      | room | users     | participant2 | participant2-displayname | reaction |
      | room | users     | participant1 | participant1-displayname | user_added |
      | room | users     | participant1 | participant1-displayname | conversation_created |

  Scenario: React two times to same message with the same reaction
    Given user "participant1" creates room "room" (v4)
      | roomType | 3 |
      | roomName | room |
    And user "participant1" adds user "participant2" to room "room" with 200 (v4)
    And user "participant1" sends message "Message 1" to room "room" with 201
    And user "participant2" react with "👍" on message "Message 1" to room "room" with 201
      | actorType | actorId      | actorDisplayName         | reaction |
      | users     | participant2 | participant2-displayname | 👍       |
    And user "participant2" react with "👍" on message "Message 1" to room "room" with 200
      | actorType | actorId      | actorDisplayName         | reaction |
      | users     | participant2 | participant2-displayname | 👍       |
    Then user "participant1" sees the following messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | message   | messageParameters | reactions |
      | room | users     | participant1 | participant1-displayname | Message 1 | []                | {"👍":1}  |
    Then user "participant1" sees the following system messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | systemMessage |
      | room | users     | participant2 | participant2-displayname | reaction |
      | room | users     | participant1 | participant1-displayname | user_added |
      | room | users     | participant1 | participant1-displayname | conversation_created |

  Scenario: Delete reaction to message with success
    Given user "participant1" creates room "room" (v4)
      | roomType | 3 |
      | roomName | room |
    And user "participant1" adds user "participant2" to room "room" with 200 (v4)
    And user "participant1" sends message "Message 1" to room "room" with 201
    And user "participant2" react with "👍" on message "Message 1" to room "room" with 201
      | actorType | actorId      | actorDisplayName         | reaction |
      | users     | participant2 | participant2-displayname | 👍       |
    Then user "guest" joins room "room" with 200 (v4)
    And user "guest" react with "👤" on message "Message 1" to room "room" with 201
    Then user "participant1" sees the following messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | message   | messageParameters | reactions |
      | room | users     | participant1 | participant1-displayname | Message 1 | []                | {"👤":1,"👍":1}  |
    And user "participant2" delete react with "👍" on message "Message 1" to room "room" with 200
      | actorType | actorId      | actorDisplayName         | reaction |
      | guests    | guest        |                          | 👤       |
    And user "guest" delete react with "👤" on message "Message 1" to room "room" with 200
      | actorType | actorId      | actorDisplayName         | reaction |
    Then user "participant1" sees the following messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | message   | messageParameters | reactions |
      | room | users     | participant1 | participant1-displayname | Message 1 | []                | []        |
    Then user "participant1" sees the following system messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | systemMessage |
      | room | guests    | guest        |                          | reaction_revoked |
      | room | users     | participant2 | participant2-displayname | reaction_revoked |
      | room | guests    | guest        |                          | reaction_deleted |
      | room | users     | participant2 | participant2-displayname | reaction_deleted |
      | room | users     | participant1 | participant1-displayname | user_added |
      | room | users     | participant1 | participant1-displayname | conversation_created |

  Scenario: Retrieve reactions of a message
    Given user "participant1" creates room "room" (v4)
      | roomType | 3 |
      | roomName | room |<commit_msg>ADjust reactions order after server merge<commit_after>Feature: reaction/react
  Background:
    Given user "participant1" exists
    Given user "participant2" exists

  Scenario: React to message with success
    Given user "participant1" creates room "room" (v4)
      | roomType | 3 |
      | roomName | room |
    And user "participant1" adds user "participant2" to room "room" with 200 (v4)
    And user "participant1" sends message "Message 1" to room "room" with 201
    And user "participant2" react with "👍" on message "Message 1" to room "room" with 201
      | actorType | actorId      | actorDisplayName         | reaction |
      | users     | participant2 | participant2-displayname | 👍       |
    Then user "participant1" sees the following system messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | systemMessage |
      | room | users     | participant2 | participant2-displayname | reaction |
      | room | users     | participant1 | participant1-displayname | user_added |
      | room | users     | participant1 | participant1-displayname | conversation_created |
    Then user "participant1" sees the following messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | message   | messageParameters | reactions | reactionsSelf |
      | room | users     | participant1 | participant1-displayname | Message 1 | []                | {"👍":1}  |               |
    And user "participant1" react with "👍" on message "Message 1" to room "room" with 201
      | actorType | actorId      | actorDisplayName         | reaction |
      | users     | participant1 | participant1-displayname | 👍       |
      | users     | participant2 | participant2-displayname | 👍       |
    And user "participant1" react with "🚀" on message "Message 1" to room "room" with 201
    Then user "guest" joins room "room" with 200 (v4)
    And user "guest" react with "👤" on message "Message 1" to room "room" with 201
    Then user "participant1" sees the following messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | message   | messageParameters | reactions              | reactionsSelf |
      | room | users     | participant1 | participant1-displayname | Message 1 | []                | {"👍":2,"👤":1,"🚀":1} | ["👍","🚀"]   |
    Then user "participant1" sees the following system messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | systemMessage |
      | room | guests    | guest        |                          | reaction |
      | room | users     | participant1 | participant1-displayname | reaction |
      | room | users     | participant1 | participant1-displayname | reaction |
      | room | users     | participant2 | participant2-displayname | reaction |
      | room | users     | participant1 | participant1-displayname | user_added |
      | room | users     | participant1 | participant1-displayname | conversation_created |

  Scenario: React to message fails without chat permission
    Given user "participant1" creates room "room" (v4)
      | roomType | 3 |
      | roomName | room |
    And user "participant1" adds user "participant2" to room "room" with 200 (v4)
    And user "participant1" sends message "Message 1" to room "room" with 201
    And user "participant2" react with "👍" on message "Message 1" to room "room" with 201
      | actorType | actorId      | actorDisplayName         | reaction |
      | users     | participant2 | participant2-displayname | 👍       |
    Then user "participant1" sees the following system messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | systemMessage |
      | room | users     | participant2 | participant2-displayname | reaction |
      | room | users     | participant1 | participant1-displayname | user_added |
      | room | users     | participant1 | participant1-displayname | conversation_created |
    # Removing chat permission only
    Then user "participant1" sets permissions for "participant2" in room "room" to "CSJLAVP" with 200 (v4)
    When user "participant2" delete react with "👍" on message "Message 1" to room "room" with 403
    And user "participant2" react with "💙" on message "Message 1" to room "room" with 403
    And user "participant1" sees the following system messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | systemMessage |
      | room | users     | participant2 | participant2-displayname | reaction |
      | room | users     | participant1 | participant1-displayname | user_added |
      | room | users     | participant1 | participant1-displayname | conversation_created |

  Scenario: React two times to same message with the same reaction
    Given user "participant1" creates room "room" (v4)
      | roomType | 3 |
      | roomName | room |
    And user "participant1" adds user "participant2" to room "room" with 200 (v4)
    And user "participant1" sends message "Message 1" to room "room" with 201
    And user "participant2" react with "👍" on message "Message 1" to room "room" with 201
      | actorType | actorId      | actorDisplayName         | reaction |
      | users     | participant2 | participant2-displayname | 👍       |
    And user "participant2" react with "👍" on message "Message 1" to room "room" with 200
      | actorType | actorId      | actorDisplayName         | reaction |
      | users     | participant2 | participant2-displayname | 👍       |
    Then user "participant1" sees the following messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | message   | messageParameters | reactions |
      | room | users     | participant1 | participant1-displayname | Message 1 | []                | {"👍":1}  |
    Then user "participant1" sees the following system messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | systemMessage |
      | room | users     | participant2 | participant2-displayname | reaction |
      | room | users     | participant1 | participant1-displayname | user_added |
      | room | users     | participant1 | participant1-displayname | conversation_created |

  Scenario: Delete reaction to message with success
    Given user "participant1" creates room "room" (v4)
      | roomType | 3 |
      | roomName | room |
    And user "participant1" adds user "participant2" to room "room" with 200 (v4)
    And user "participant1" sends message "Message 1" to room "room" with 201
    And user "participant2" react with "👍" on message "Message 1" to room "room" with 201
      | actorType | actorId      | actorDisplayName         | reaction |
      | users     | participant2 | participant2-displayname | 👍       |
    Then user "guest" joins room "room" with 200 (v4)
    And user "guest" react with "👤" on message "Message 1" to room "room" with 201
    Then user "participant1" sees the following messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | message   | messageParameters | reactions |
      | room | users     | participant1 | participant1-displayname | Message 1 | []                | {"👍":1,"👤":1}  |
    And user "participant2" delete react with "👍" on message "Message 1" to room "room" with 200
      | actorType | actorId      | actorDisplayName         | reaction |
      | guests    | guest        |                          | 👤       |
    And user "guest" delete react with "👤" on message "Message 1" to room "room" with 200
      | actorType | actorId      | actorDisplayName         | reaction |
    Then user "participant1" sees the following messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | message   | messageParameters | reactions |
      | room | users     | participant1 | participant1-displayname | Message 1 | []                | []        |
    Then user "participant1" sees the following system messages in room "room" with 200
      | room | actorType | actorId      | actorDisplayName         | systemMessage |
      | room | guests    | guest        |                          | reaction_revoked |
      | room | users     | participant2 | participant2-displayname | reaction_revoked |
      | room | guests    | guest        |                          | reaction_deleted |
      | room | users     | participant2 | participant2-displayname | reaction_deleted |
      | room | users     | participant1 | participant1-displayname | user_added |
      | room | users     | participant1 | participant1-displayname | conversation_created |

  Scenario: Retrieve reactions of a message
    Given user "participant1" creates room "room" (v4)
      | roomType | 3 |
      | roomName | room |
{'fraction_non_alphanumeric': 0.08578846370922226, 'fraction_numerical': 0.02923580539564285, 'mean_word_length': 2.4770408163265305, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3827316', 'n_tokens_mistral': 5029, 'n_tokens_neox': 4722, 'n_words': 1715}