<commit_before># @sustainer: <EMAIL>

@ui
@slack
@datamapper
@database
@integrations-slack
Feature: Slack Connector

  Background: Clean application state
    Given clean application state
    And reset content of "contact" table
    And log into the Syndesis
    And created connections
      | Slack | QE Slack | QE Slack | SyndesisQE Slack test |
    And navigate to the "Home" page


#
#  1. Check that slack message exists
#
  @deprecated
  @slack-check-message-body
  Scenario: Check message with logger

    When import extensions from syndesis-extensions folder
      | syndesis-extension-body |
    And navigate to the "Home" page
    And click on the "Create Integration" link to create a new integration.
    Then check visibility of visual integration editor
    And check that position of connection to fill is "Start"

    When select the "Timer" connection
    And select "Simple Timer" integration action
    And fill in values by element ID
      | period        | 200     |
      | select-period | Seconds |
    And click on the "Done" button
    Then check that position of connection to fill is "Finish"

    When select the "QE Slack" connection
    And select "Channel" integration action
    And fill in values
      | Channel | test |
    And click on the "Done" button
    Then add integration step on position "0"

    When select "Set Body" integration step
    And fill in values
      | Body | test message |
    And scroll "top" "right"
    And click on the "Done" button

    When click on the "Save" link
    And set integration name "Integration_with_slack"
    And publish integration
    Then Integration "Integration_with_slack" is present in integrations list
    And wait until integration "Integration_with_slack" gets into "Running" state
    And check that last slack message equals "test message" on channel "test"


#
#  2. Check that slack message exists, use data mapper
#
  @slack-check-message-data-mapper
  Scenario: Check that slack received a message from an integration

    When click on the "Create Integration" link to create a new integration.
    Then check visibility of visual integration editor
    And check that position of connection to fill is "Start"

    When select the "PostgresDB" connection
    And select "Periodic SQL Invocation" integration action
    Then check "Next" button is "Disabled"

    When fill in periodic query input with "SELECT company FROM CONTACT limit(1)" value
    And fill in period input with "200" value
    And select "Seconds" from sql dropdown
    And click on the "Next" button
    Then check that position of connection to fill is "Finish"

    When select the "QE Slack" connection
    And select "Channel" integration action
    And fill in values
      | Channel | test |
    And click on the "Done" button
    And add integration step on position "0"
    And select "Data Mapper" integration step
    Then check visibility of data mapper ui

    When open data mapper collection mappings
    And create data mapper mappings
      | company | message |
    And click on the "Done" button
    And click on the "Save" link
    And set integration name "Integration_with_slack"
    And publish integration
    Then Integration "Integration_with_slack" is present in integrations list
    And wait until integration "Integration_with_slack" gets into "Running" state
    And sleep for jenkins delay or "15" seconds
    And check that last slack message equals "Red Hat" on channel "test"

#
#  3. Check that slack message is saved to DB. The data mapper and basic filter are used.
#
  @slack-to-db
  Scenario: Check that slack message is saved into DB

    When click on the "Create Integration" link to create a new integration.
    Then check visibility of visual integration editor
    And check that position of connection to fill is "Start"

    When select the "QE Slack" connection
    And select "Read Messages" integration action
    And select "test" from "channel" dropdown
    And click on the "Done" button
    Then check visibility of page "Choose a Finish Connection"

    When select the "PostgresDB" connection
    And select "Invoke SQL" integration action
    And fill in invoke query input with "insert into CONTACT values (:#AUTOR , 'Dvere', :#COMPANY , 'some lead', '1999-01-01')" value
    And click on the "Done" button
    # Then check visibility of page "Add to Integration"

    When add integration step on position "0"
    And select "Data Mapper" integration step
    Then check visibility of data mapper ui

    When create data mapper mappings
      | username | AUTOR   |
      | text     | COMPANY |
    And click on the "Done" button
    And add integration step on position "0"
    And select "Basic Filter" integration step
    Then check visibility of "Basic Filter" step configuration page

    When fill in the configuration page for "Basic Filter" step with "ANY of the following, text, contains, Red Hat testSlack" parameter
    And click on the "Done" button
    And click on the "Save" link
    And set integration name "slack-to-db"
    And publish integration
    Then Integration "slack-to-db" is present in integrations list
    And wait until integration "slack-to-db" gets into "Running" state

    When send message "Red Hat testSlack" on channel "test"
    And send message "Red Hat test incorrect Slack" on channel "test"
    Then checks that query "select * from contact where company = 'Red Hat testSlack' AND first_name = 'syndesis-bot'" has some output
    And checks that query "select * from contact where company = 'Red Hat test incorrect Slack'" has no output

#
#  4. Check Maximum Messages to Retrieve and Delay function in SLACK consumer ( GH issue: #3761 )
#
  @slack-to-db-delay-and-maxmessage
  Scenario: Check Maximum Messages to Retrieve and Delay function in SLACK consumer
    # create integration
    Given click on the "Create Integration" link to create a new integration.
    Then check visibility of visual integration editor
    And check that position of connection to fill is "Start"

    # select slack connection as start integration
    When select the "QE Slack" connection
    Then select "Read Messages" integration action
    And select "random" from "channel" dropdown
    And fill in values by element ID
      | maxResults | 2  |
      | delay      | 60 |
    And select "Seconds" from "select-delay" dropdown
    And click on the "Done" button.

    # select postgresDB connection as finish integration
    Then check visibility of page "Choose a Finish Connection"
    When select the "PostgresDB" connection
    And select "Invoke SQL" integration action
    And fill in invoke query input with "insert into CONTACT values (:#AUTOR , 'Dvere', :#COMPANY , 'some lead', '1999-01-01')" value
    And click on the "Done" button

    # add data mapper step<commit_msg>fix slack tests<commit_after># @sustainer: <EMAIL>

@ui
@slack
@datamapper
@database
@integrations-slack
Feature: Slack Connector

  Background: Clean application state
    Given clean application state
    And reset content of "contact" table
    And log into the Syndesis
    And created connections
      | Slack | QE Slack | QE Slack | SyndesisQE Slack test |
    And navigate to the "Home" page
    
#
#  2. Check that slack message exists, use data mapper
#
  @slack-check-message-data-mapper
  Scenario: Check that slack received a message from an integration

    When click on the "Create Integration" link to create a new integration.
    Then check visibility of visual integration editor
    And check that position of connection to fill is "Start"

    When select the "PostgresDB" connection

    And select "Periodic SQL Invocation" integration action
    Then check "Next" button is "Disabled"

    When fill in periodic query input with "SELECT company FROM CONTACT limit(1)" value
    And fill in period input with "200" value
    And select "Seconds" from sql dropdown
    And click on the "Next" button
    Then check that position of connection to fill is "Finish"

    When select the "QE Slack" connection
    And select "Channel" integration action
    And fill in values by element data-testid
      | channel | test |
    And click on the "Done" button
    And add integration step on position "0"
    And select "Data Mapper" integration step
    Then check visibility of data mapper ui

    When open data mapper collection mappings
    And create data mapper mappings
      | company | message |
    And click on the "Done" button
    And click on the "Save" link
    And set integration name "Integration_with_slack"
    And publish integration
    Then Integration "Integration_with_slack" is present in integrations list
    And wait until integration "Integration_with_slack" gets into "Running" state
    And sleep for jenkins delay or "15" seconds
    And check that last slack message equals "Red Hat" on channel "test"

#
#  3. Check that slack message is saved to DB. The data mapper and basic filter are used.
#
  @slack-to-db
  Scenario: Check that slack message is saved into DB

    When click on the "Create Integration" link to create a new integration.
    Then check visibility of visual integration editor
    And check that position of connection to fill is "Start"

    When select the "QE Slack" connection
    And select "Read Messages" integration action
    And select "test" from "channel" dropdown
    And click on the "Done" button
    Then check visibility of page "Choose a Finish Connection"

    When select the "PostgresDB" connection
    And select "Invoke SQL" integration action
    And fill in invoke query input with "insert into CONTACT values (:#AUTOR , 'Dvere', :#COMPANY , 'some lead', '1999-01-01')" value
    And click on the "Done" button
    # Then check visibility of page "Add to Integration"

    When add integration step on position "0"
    And select "Data Mapper" integration step
    Then check visibility of data mapper ui

    When create data mapper mappings
      | username | AUTOR   |
      | text     | COMPANY |
    And click on the "Done" button
    And add integration step on position "0"
    And select "Basic Filter" integration step
    Then check visibility of "Basic Filter" step configuration page

    When fill in the configuration page for "Basic Filter" step with "ANY of the following, text, contains, Red Hat testSlack" parameter
    And click on the "Done" button
    And click on the "Save" link
    And set integration name "slack-to-db"
    And publish integration
    Then Integration "slack-to-db" is present in integrations list
    And wait until integration "slack-to-db" gets into "Running" state

    When send message "Red Hat testSlack" on channel "test"
    And send message "Red Hat test incorrect Slack" on channel "test"
    Then checks that query "select * from contact where company = 'Red Hat testSlack' AND first_name = 'syndesis-bot'" has some output
    And checks that query "select * from contact where company = 'Red Hat test incorrect Slack'" has no output

#
#  4. Check Maximum Messages to Retrieve and Delay function in SLACK consumer ( GH issue: #3761 )
#
  @slack-to-db-delay-and-maxmessage
  Scenario: Check Maximum Messages to Retrieve and Delay function in SLACK consumer
    # create integration
    Given click on the "Create Integration" link to create a new integration.
    Then check visibility of visual integration editor
    And check that position of connection to fill is "Start"

    # select slack connection as start integration
    When select the "QE Slack" connection
    Then select "Read Messages" integration action
    And select "random" from "channel" dropdown
    And fill in values by element ID
      | maxresults | 2     |
      | delay      | 60000 |
    And click on the "Done" button.

    # select postgresDB connection as finish integration
    Then check visibility of page "Choose a Finish Connection"
    When select the "PostgresDB" connection
    And select "Invoke SQL" integration action
    And fill in invoke query input with "insert into CONTACT values (:#AUTOR , 'Dvere', :#COMPANY , 'some lead', '1999-01-01')" value
    And click on the "Done" button

    # add data mapper step
{'fraction_non_alphanumeric': 0.05345448592010478, 'fraction_numerical': 0.0063850687622789785, 'mean_word_length': 3.2942003514938487, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6078774', 'n_tokens_mistral': 3274, 'n_tokens_neox': 3129, 'n_words': 1651}